ReactOS 0.4.15-dev-7842-g558ab78
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
12
14
15
16static BOOL CALLBACK
18{
19 LCID lcid;
20
21 lcid = wcstoul(lpLocale, NULL, 16);
22
23 if ((LANGIDFROMLCID(lcid) == LANGIDFROMLCID(userLcid)) &&
26
27 return TRUE;
28}
29
30
31BOOL
33{
34 /* Handle special case for Spanish (Spain) */
37 return TRUE;
38
39 userLcid = lcid;
41
43
44 return bSortPage;
45}
46
47
48static 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
76static 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
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
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,
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 {
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,
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 index(s, c)
Definition: various.h:29
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_SORTLIST_COMBO
Definition: resource.h:70
BOOL IsSortPageNeeded(LCID lcid)
Definition: sort.c:32
static LCID userLcid
Definition: sort.c:11
static BOOL CALLBACK SortEnumProc(LPTSTR lpLocale)
Definition: sort.c:49
static BOOL CALLBACK SortTestEnumProc(PWSTR lpLocale)
Definition: sort.c:17
static HWND hWndSortList
Definition: sort.c:13
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
static BOOL bSortPage
Definition: sort.c:10
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint index
Definition: glext.h:6031
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
struct _GLOBALDATA * PGLOBALDATA
BOOL WINAPI EnumSystemLocalesW(LOCALE_ENUMPROCW lpfnLocaleEnum, DWORD dwFlags)
Definition: lang.c:1614
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define SORTIDFROMLCID(lcid)
#define SORT_DEFAULT
#define MAKELCID(lgid, srtid)
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define WM_NOTIFY
Definition: richedit.h:61
#define SUBLANG_SPANISH
Definition: nls.h:336
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_SPANISH
Definition: nls.h:123
#define LANGIDFROMLCID(l)
Definition: nls.h:18
DWORD LCID
Definition: nls.h:13
#define SUBLANG_SPANISH_MODERN
Definition: nls.h:338
Definition: inflate.c:139
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
static const WCHAR lang[]
Definition: wbemdisp.c:287
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define LCID_ALTERNATE_SORTS
Definition: winnls.h:203
#define CB_SELECTSTRING
Definition: winuser.h:1960
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define DWLP_USER
Definition: winuser.h:872
#define WM_COMMAND
Definition: winuser.h:1740
#define CB_ERR
Definition: winuser.h:2435
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CBN_SELCHANGE
Definition: winuser.h:1979
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_GETITEMDATA
Definition: winuser.h:1950
HWND WINAPI GetParent(_In_ HWND)
#define CB_GETCURSEL
Definition: winuser.h:1943
#define SendDlgItemMessage
Definition: winuser.h:5842
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * LPTSTR
Definition: xmlstorage.h:192