ReactOS  0.4.12-dev-914-g71f84a3
sort.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS International Control Panel
3  * FILE: dll/cpl/intl/sort.c
4  * PURPOSE: Sorting property page
5  * PROGRAMMER: Eric Kohl
6  */
7 
8 #include "intl.h"
9 
10 static BOOL bSortPage = FALSE;
11 static LCID userLcid;
12 
14 
15 
16 static BOOL CALLBACK
18 {
19  LCID lcid;
20 
21  lcid = wcstoul(lpLocale, NULL, 16);
22 
23  if ((LANGIDFROMLCID(lcid) == LANGIDFROMLCID(userLcid)) &&
25  bSortPage = TRUE;
26 
27  return TRUE;
28 }
29 
30 
31 BOOL
33 {
34  /* Handle special case for Spanish (Spain) */
37  return TRUE;
38 
39  userLcid = lcid;
40  bSortPage = FALSE;
41 
43 
44  return bSortPage;
45 }
46 
47 
48 static BOOL CALLBACK
50 {
51  LCID lcid;
52  WCHAR lang[255];
53  INT index;
54 
55  lcid = wcstoul(lpLocale, NULL, 16);
56 
57  if ((LANGIDFROMLCID(lcid) == LANGIDFROMLCID(userLcid)) &&
59  {
60  GetLocaleInfoW(lcid, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(WCHAR));
61 
64  0,
65  (LPARAM)lang);
66 
69  index,
70  (LPARAM)lcid);
71  }
72 
73  return TRUE;
74 }
75 
76 static VOID
78 {
79  WCHAR lang[255];
80  INT index;
81 
83 
84  /* Handle special case for Spanish (Spain) */
87  {
88  /* Add traditional sorting */
90  LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
91 
94  0,
95  (LPARAM)lang);
96 
99  index,
101 
102  /* Add modern sorting */
104  LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
105 
107  CB_ADDSTRING,
108  0,
109  (LPARAM)lang);
110 
113  index,
115  }
116  else
117  {
118  userLcid = lcid;
119 
120  GetLocaleInfoW(lcid & 0xFFFF, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(WCHAR));
121 
123  CB_ADDSTRING,
124  0,
125  (LPARAM)lang);
126 
129  index,
130  (LPARAM)lcid & 0xFFFF);
131 
133  }
134 
135  /* Select current locale */
136  /* or should it be System and not user? */
137  GetLocaleInfoW(lcid, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(WCHAR));
138 
141  -1,
142  (LPARAM)lang);
143 }
144 
145 /* Property page dialog callback */
148  UINT uMsg,
149  WPARAM wParam,
150  LPARAM lParam)
151 {
152  PGLOBALDATA pGlobalData;
153 
154  pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
155 
156  switch (uMsg)
157  {
158  case WM_INITDIALOG:
159  pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
160  SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
161 
162  CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO), pGlobalData->UserLCID);
163  break;
164 
165  case WM_COMMAND:
166  switch (LOWORD(wParam))
167  {
168  case IDC_SORTLIST_COMBO:
169  if (HIWORD(wParam) == CBN_SELCHANGE)
170  {
171  PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
172  }
173  break;
174  }
175  break;
176 
177  case WM_NOTIFY:
178  if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
179  {
180  LCID NewLcid;
181  INT iCurSel;
182 
183  iCurSel = SendDlgItemMessage(hwndDlg,
185  CB_GETCURSEL,
186  0,
187  0);
188  if (iCurSel == CB_ERR)
189  break;
190 
191  NewLcid = SendDlgItemMessage(hwndDlg,
194  iCurSel,
195  0);
196  if (NewLcid == (LCID)CB_ERR)
197  break;
198 
199  /* Save the new LCID */
200  pGlobalData->UserLCID = NewLcid;
201  pGlobalData->bUserLocaleChanged = TRUE;
202  }
203  break;
204  }
205 
206  return FALSE;
207 }
208 
209 /* EOF */
#define CB_SETITEMDATA
Definition: winuser.h:1927
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
struct _GLOBALDATA * PGLOBALDATA
#define MAKELCID(lgid, srtid)
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:54
#define CB_GETITEMDATA
Definition: winuser.h:1911
#define CALLBACK
Definition: compat.h:27
#define SUBLANG_SPANISH_MODERN
Definition: nls.h:338
DWORD LCID
Definition: nls.h:13
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5708
#define PSN_APPLY
Definition: prsht.h:117
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
int32_t INT_PTR
Definition: typedefs.h:62
int32_t INT
Definition: typedefs.h:56
#define SetWindowLongPtr
Definition: treelist.c:70
#define CB_GETCURSEL
Definition: winuser.h:1904
WPARAM wParam
Definition: combotst.c:138
CHAR * LPTSTR
Definition: xmlstorage.h:192
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1095
static BOOL CALLBACK SortEnumProc(LPTSTR lpLocale)
Definition: sort.c:49
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CB_ADDSTRING
Definition: winuser.h:1897
#define LPPROPSHEETPAGE
Definition: prsht.h:372
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW lpfnLocaleEnum, DWORD dwFlags)
Definition: lang.c:1601
#define CB_ERR
Definition: winuser.h:2389
static const WCHAR lang[]
Definition: wbemdisp.c:287
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
#define SORT_DEFAULT
#define index(s, c)
Definition: various.h:29
BOOL IsSortPageNeeded(LCID lcid)
Definition: sort.c:32
#define DWLP_USER
Definition: winuser.h:866
#define CB_SELECTSTRING
Definition: winuser.h:1921
#define LANGIDFROMLCID(l)
Definition: nls.h:18
static HWND hWndSortList
Definition: sort.c:13
#define WM_COMMAND
Definition: winuser.h:1716
static BOOL bSortPage
Definition: sort.c:10
#define SUBLANG_SPANISH
Definition: nls.h:336
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SORTIDFROMLCID(lcid)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define IDC_SORTLIST_COMBO
Definition: resource.h:70
#define CBN_SELCHANGE
Definition: winuser.h:1940
#define HIWORD(l)
Definition: typedefs.h:246
#define MAKELANGID(p, s)
Definition: nls.h:15
static LCID userLcid
Definition: sort.c:11
#define GetWindowLongPtr
Definition: treelist.c:73
INT_PTR CALLBACK SortPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: sort.c:147
static VOID CreateSortList(HWND hwnd, LCID lcid)
Definition: sort.c:77
#define LANG_SPANISH
Definition: nls.h:123
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define LCID_ALTERNATE_SORTS
Definition: winnls.h:200
#define WM_NOTIFY
Definition: richedit.h:61
static BOOL CALLBACK SortTestEnumProc(PWSTR lpLocale)
Definition: sort.c:17