2013-03-16 20:25:38 +00:00
|
|
|
/*
|
2007-09-08 22:27:41 +00:00
|
|
|
* PROJECT: ReactOS International Control Panel
|
|
|
|
* FILE: dll/cpl/intl/sort.c
|
|
|
|
* PURPOSE: Sorting property page
|
|
|
|
* PROGRAMMER: Eric Kohl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "intl.h"
|
|
|
|
|
|
|
|
static BOOL bSortPage = FALSE;
|
|
|
|
static LCID userLcid;
|
|
|
|
|
|
|
|
static HWND hWndSortList = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
|
|
|
SortTestEnumProc(LPTSTR lpLocale)
|
|
|
|
{
|
|
|
|
LCID lcid;
|
|
|
|
|
|
|
|
lcid = _tcstoul(lpLocale, NULL, 16);
|
|
|
|
|
|
|
|
if ((LANGIDFROMLCID(lcid) == LANGIDFROMLCID(userLcid)) &&
|
|
|
|
(SORTIDFROMLCID(lcid) != SORTIDFROMLCID(userLcid)))
|
|
|
|
bSortPage = TRUE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
IsSortPageNeeded(LCID lcid)
|
|
|
|
{
|
|
|
|
/* Handle special case for Spanish (Spain) */
|
|
|
|
if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) ||
|
|
|
|
lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
userLcid = lcid;
|
|
|
|
bSortPage = FALSE;
|
|
|
|
|
|
|
|
EnumSystemLocales(SortTestEnumProc, LCID_ALTERNATE_SORTS);
|
|
|
|
|
|
|
|
return bSortPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL CALLBACK
|
|
|
|
SortEnumProc(LPTSTR lpLocale)
|
|
|
|
{
|
|
|
|
LCID lcid;
|
|
|
|
TCHAR lang[255];
|
|
|
|
INT index;
|
|
|
|
|
|
|
|
lcid = _tcstoul(lpLocale, NULL, 16);
|
|
|
|
|
|
|
|
if ((LANGIDFROMLCID(lcid) == LANGIDFROMLCID(userLcid)) &&
|
|
|
|
(SORTIDFROMLCID(lcid) != SORTIDFROMLCID(userLcid)))
|
|
|
|
{
|
2008-05-06 20:51:07 +00:00
|
|
|
GetLocaleInfo(lcid, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
index = SendMessage(hWndSortList,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lang);
|
|
|
|
|
|
|
|
SendMessage(hWndSortList,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
index,
|
|
|
|
(LPARAM)lcid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
CreateSortList(HWND hwnd, LCID lcid)
|
|
|
|
{
|
|
|
|
TCHAR lang[255];
|
|
|
|
INT index;
|
|
|
|
|
|
|
|
hWndSortList = hwnd;
|
|
|
|
|
|
|
|
/* Handle special case for Spainish (Spain) */
|
|
|
|
if (lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH), SORT_DEFAULT) ||
|
|
|
|
lcid == MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN), SORT_DEFAULT))
|
|
|
|
{
|
|
|
|
/* Add traditional sorting */
|
|
|
|
GetLocaleInfo(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH),
|
2008-05-06 20:51:07 +00:00
|
|
|
LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
index = SendMessage(hwnd,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lang);
|
|
|
|
|
|
|
|
SendMessage(hwnd,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
index,
|
|
|
|
(LPARAM)MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH));
|
|
|
|
|
|
|
|
/* Add modern sorting */
|
|
|
|
GetLocaleInfo(MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN),
|
2008-05-06 20:51:07 +00:00
|
|
|
LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
index = SendMessage(hwnd,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lang);
|
|
|
|
|
|
|
|
SendMessage(hwnd,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
index,
|
|
|
|
(LPARAM)MAKELANGID(LANG_SPANISH, SUBLANG_SPANISH_MODERN));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
userLcid = lcid;
|
|
|
|
|
2008-05-06 20:51:07 +00:00
|
|
|
GetLocaleInfo(lcid & 0xFFFF, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
index = SendMessage(hWndSortList,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lang);
|
|
|
|
|
|
|
|
SendMessage(hWndSortList,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
index,
|
|
|
|
(LPARAM)lcid & 0xFFFF);
|
|
|
|
|
|
|
|
EnumSystemLocales(SortEnumProc, LCID_ALTERNATE_SORTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Select current locale */
|
|
|
|
/* or should it be System and not user? */
|
2014-04-08 00:14:44 +00:00
|
|
|
GetLocaleInfo(lcid, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
SendMessage(hwnd,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
|
|
|
(LPARAM)lang);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Property page dialog callback */
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
SortPageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2007-09-10 20:46:27 +00:00
|
|
|
PGLOBALDATA pGlobalData;
|
|
|
|
|
|
|
|
pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
2007-09-08 22:27:41 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2007-09-10 20:46:27 +00:00
|
|
|
pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
2007-09-08 22:27:41 +00:00
|
|
|
|
2007-09-10 20:46:27 +00:00
|
|
|
CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO), pGlobalData->lcid);
|
2007-09-08 22:27:41 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDC_SORTLIST_COMBO:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
2007-09-10 20:46:27 +00:00
|
|
|
LCID NewLcid;
|
|
|
|
INT iCurSel;
|
|
|
|
|
|
|
|
iCurSel = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SORTLIST_COMBO,
|
|
|
|
CB_GETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
if (iCurSel == CB_ERR)
|
|
|
|
break;
|
|
|
|
|
|
|
|
NewLcid = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SORTLIST_COMBO,
|
|
|
|
CB_GETITEMDATA,
|
|
|
|
iCurSel,
|
|
|
|
0);
|
|
|
|
if (NewLcid == (LCID)CB_ERR)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Save the new LCID */
|
|
|
|
pGlobalData->lcid = NewLcid;
|
|
|
|
|
2007-09-08 22:27:41 +00:00
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
2007-09-10 20:46:27 +00:00
|
|
|
if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
|
2007-09-08 22:27:41 +00:00
|
|
|
{
|
2007-09-10 20:46:27 +00:00
|
|
|
/* FIXME: Set locale ID: pGlobalData->lcid */
|
2007-09-08 22:27:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|