ReactOS 0.4.15-dev-7953-g1f49173
settings_page.c File Reference
#include "input.h"
#include "layout_list.h"
#include "locale_list.h"
#include "input_list.h"
Include dependency graph for settings_page.c:

Go to the source code of this file.

Functions

static HICON CreateLayoutIcon (LANGID LangID)
 
static VOID InitDefaultLangComboBox (HWND hwndCombo)
 
static VOID SetControlsState (HWND hwndDlg)
 
static BOOL CALLBACK EnumResNameProc (HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
 
static HICON LoadIMEIcon (LPCTSTR pszImeFile)
 
static HTREEITEM FindLanguageInList (HWND hwndList, LPCTSTR pszLangName)
 
static VOID AddToInputListView (HWND hwndList, INPUT_LIST_NODE *pInputNode)
 
static VOID ExpandTreeItem (HWND hwndTree, HTREEITEM hItem)
 
static VOID UpdateInputListView (HWND hwndList)
 
static VOID OnInitSettingsPage (HWND hwndDlg)
 
static VOID OnDestroySettingsPage (HWND hwndDlg)
 
VOID OnCommandSettingsPage (HWND hwndDlg, WPARAM wParam)
 
BOOL EnableProcessPrivileges (LPCWSTR lpPrivilegeName, BOOL bEnable)
 
static INT_PTR OnNotifySettingsPage (HWND hwndDlg, LPARAM lParam)
 
INT_PTR CALLBACK SettingsPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static INT s_nAliveLeafCount = 0
 
static INT s_nRootCount = 0
 
static INT s_iKeyboardImage = -1
 
static INT s_iDotImage = -1
 

Function Documentation

◆ AddToInputListView()

static VOID AddToInputListView ( HWND  hwndList,
INPUT_LIST_NODE pInputNode 
)
static

Definition at line 215 of file settings_page.c.

216{
219 HIMAGELIST hImageList = TreeView_GetImageList(hwndList, TVSIL_NORMAL);
220 WCHAR szKeyboard[64];
222 BOOL bBold = !!(pInputNode->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT);
223
224 hItem = FindLanguageInList(hwndList, pInputNode->pLocale->pszName);
225 if (hItem == NULL)
226 {
227 // Language icon
228 INT LangImageIndex = -1;
229 HICON hLangIcon = CreateLayoutIcon(LOWORD(pInputNode->pLocale->dwId));
230 if (hLangIcon)
231 {
232 LangImageIndex = ImageList_AddIcon(hImageList, hLangIcon);
233 DestroyIcon(hLangIcon);
234 }
235
236 // Language
237 ZeroMemory(&item, sizeof(item));
239 item.pszText = pInputNode->pLocale->pszName;
240 item.iImage = LangImageIndex;
241 item.iSelectedImage = LangImageIndex;
242 item.lParam = LOWORD(pInputNode->pLocale->dwId); // HIWORD(item.lParam) == 0
243 if (bBold)
244 {
245 item.state = item.stateMask = TVIS_BOLD;
246 }
247 insert.hParent = TVI_ROOT;
248 insert.hInsertAfter = TVI_LAST;
249 insert.item = item;
250 hItem = TreeView_InsertItem(hwndList, &insert);
251
252 // The type of input method (currently keyboard only)
253 LoadStringW(hApplet, IDS_KEYBOARD, szKeyboard, _countof(szKeyboard));
254 ZeroMemory(&item, sizeof(item));
256 item.pszText = szKeyboard;
257 item.iImage = s_iKeyboardImage;
258 item.iSelectedImage = s_iKeyboardImage;
259 item.lParam = 0; // HIWORD(item.lParam) == 0
260 insert.hParent = hItem;
261 insert.hInsertAfter = TVI_LAST;
262 insert.item = item;
263 hItem = TreeView_InsertItem(hwndList, &insert);
264 }
265 else
266 {
267 // Language
268 ZeroMemory(&item, sizeof(item));
269 item.mask = TVIF_STATE | TVIF_HANDLE;
270 item.hItem = hItem;
271 item.stateMask = TVIS_BOLD;
272 if (TreeView_GetItem(hwndList, &item) && bBold && !(item.state & TVIS_BOLD))
273 {
274 // Make the item bold
275 item.mask = TVIF_STATE | TVIF_HANDLE;
276 item.hItem = hItem;
277 item.state = item.stateMask = TVIS_BOLD;
278 TreeView_SetItem(hwndList, &item);
279 }
280
281 // The type of input method (currently keyboard only)
282 hItem = TreeView_GetChild(hwndList, hItem);
283 }
284
285 // Input method
286 if (hItem)
287 {
288 INT ImeImageIndex = s_iDotImage;
289 if (IS_IME_HKL(pInputNode->hkl) && pInputNode->pLayout->pszImeFile) // IME?
290 {
291 HICON hImeIcon = LoadIMEIcon(pInputNode->pLayout->pszImeFile);
292 if (hImeIcon)
293 {
294 ImeImageIndex = ImageList_AddIcon(hImageList, hImeIcon);
295 DestroyIcon(hImeIcon);
296 }
297 }
298
299 ZeroMemory(&item, sizeof(item));
301 item.pszText = pInputNode->pLayout->pszName;
302 item.iImage = ImeImageIndex;
303 item.iSelectedImage = ImeImageIndex;
304 item.lParam = (LPARAM)pInputNode; // HIWORD(item.lParam) != 0
305 if (bBold)
306 {
307 item.state = item.stateMask = TVIS_BOLD; // Make the item bold
308 }
309 insert.hParent = hItem;
310 insert.hInsertAfter = TVI_LAST;
311 insert.item = item;
312 hItem = TreeView_InsertItem(hwndList, &insert);
313 }
314}
#define NULL
Definition: types.h:112
HINSTANCE hApplet
Definition: access.c:17
#define IDS_KEYBOARD
Definition: resource.h:47
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:20
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:30
static HICON
Definition: imagelist.c:84
static ATOM item
Definition: dde.c:856
#define LOWORD(l)
Definition: pedump.c:82
#define TVI_LAST
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3466
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define TVIS_BOLD
Definition: commctrl.h:3283
#define TreeView_GetImageList(hwnd, iImage)
Definition: commctrl.h:3441
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TV_INSERTSTRUCT
Definition: commctrl.h:3377
#define TVI_ROOT
Definition: commctrl.h:3368
#define TV_ITEM
Definition: commctrl.h:3300
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
#define TVIF_STATE
Definition: commctrl.h:3269
static HICON LoadIMEIcon(LPCTSTR pszImeFile)
static INT s_iDotImage
Definition: settings_page.c:17
static INT s_iKeyboardImage
Definition: settings_page.c:16
static HICON CreateLayoutIcon(LANGID LangID)
Definition: settings_page.c:20
static HTREEITEM FindLanguageInList(HWND hwndList, LPCTSTR pszLangName)
#define _countof(array)
Definition: sndvol32.h:68
LAYOUT_LIST_NODE * pLayout
Definition: input_list.h:37
LOCALE_LIST_NODE * pLocale
Definition: input_list.h:36
HTREEITEM hItem
Definition: treelist.h:37
int32_t INT
Definition: typedefs.h:58
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053
static int insert
Definition: xmllint.c:138
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UpdateInputListView().

◆ CreateLayoutIcon()

static HICON CreateLayoutIcon ( LANGID  LangID)
static

Definition at line 20 of file settings_page.c.

21{
22 WCHAR szBuf[4];
23 HDC hdcScreen, hdc;
24 HBITMAP hbmColor, hbmMono, hBmpOld;
25 HFONT hFont, hFontOld;
26 LOGFONTW lf;
27 RECT rect;
32
33 /* Getting "EN", "FR", etc. from English, French, ... */
36 szBuf,
37 ARRAYSIZE(szBuf)) == 0)
38 {
39 szBuf[0] = szBuf[1] = L'?';
40 }
41 szBuf[2] = UNICODE_NULL; /* Truncate the identifier to two characters: "ENG" --> "EN" etc. */
42
43 /* Create hdc, hbmColor and hbmMono */
44 hdcScreen = GetDC(NULL);
45 hdc = CreateCompatibleDC(hdcScreen);
46 hbmColor = CreateCompatibleBitmap(hdcScreen, cxIcon, cyIcon);
47 ReleaseDC(NULL, hdcScreen);
48 hbmMono = CreateBitmap(cxIcon, cyIcon, 1, 1, NULL);
49
50 /* Checking NULL */
51 if (!hdc || !hbmColor || !hbmMono)
52 {
53 if (hbmMono)
54 DeleteObject(hbmMono);
55 if (hbmColor)
56 DeleteObject(hbmColor);
57 if (hdc)
59 return NULL;
60 }
61
62 /* Create a font */
63 hFont = NULL;
64 if (SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0))
65 {
66 /* Override the current size with something manageable */
67 lf.lfHeight = -11;
68 lf.lfWidth = 0;
70 }
71 if (!hFont)
73
74 SetRect(&rect, 0, 0, cxIcon, cyIcon);
75
76 /* Draw hbmColor */
77 hBmpOld = SelectObject(hdc, hbmColor);
79 FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));
80 hFontOld = SelectObject(hdc, hFont);
84 SelectObject(hdc, hFontOld);
85
86 /* Fill hbmMono with black */
87 SelectObject(hdc, hbmMono);
88 PatBlt(hdc, 0, 0, cxIcon, cyIcon, BLACKNESS);
89 SelectObject(hdc, hBmpOld);
90
91 /* Create an icon from hbmColor and hbmMono */
94 IconInfo.hbmColor = hbmColor;
95 IconInfo.hbmMask = hbmMono;
97
98 /* Clean up */
100 DeleteObject(hbmMono);
101 DeleteObject(hbmColor);
102 DeleteDC(hdc);
103
104 return hIcon;
105}
HFONT hFont
Definition: main.c:53
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
pKey DeleteObject()
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2294
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HICON hIcon
Definition: msconfig.c:44
#define UNICODE_NULL
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define L(x)
Definition: ntvdm.h:50
& rect
Definition: startmenu.cpp:1413
LONG lfHeight
Definition: dimm.idl:59
LONG lfWidth
Definition: dimm.idl:60
DWORD yHotspot
Definition: winuser.h:3125
BOOL fIcon
Definition: winuser.h:3123
DWORD xHotspot
Definition: winuser.h:3124
HBITMAP hbmColor
Definition: winuser.h:3127
HBITMAP hbmMask
Definition: winuser.h:3126
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_writes_opt_ NumCharacters PUSHORT _Inout_ PUSHORT _In_ UCHAR _In_opt_ USHORT LangID
Definition: wdfusb.h:1083
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
#define BLACKNESS
Definition: wingdi.h:323
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI DeleteDC(_In_ HDC)
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
HICON WINAPI CreateIconIndirect(_In_ PICONINFO)
Definition: cursoricon.c:2581
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_HIGHLIGHT
Definition: winuser.h:926
#define DT_SINGLELINE
Definition: winuser.h:540
#define SM_CYSMICON
Definition: winuser.h:1013
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1380
#define SM_CXSMICON
Definition: winuser.h:1012
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:927
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define DT_VCENTER
Definition: winuser.h:543
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by AddToInputListView().

◆ EnableProcessPrivileges()

BOOL EnableProcessPrivileges ( LPCWSTR  lpPrivilegeName,
BOOL  bEnable 
)

Definition at line 548 of file settings_page.c.

549{
550 HANDLE hToken;
551 LUID luid;
552 TOKEN_PRIVILEGES tokenPrivileges;
553 BOOL Ret;
554
557 &hToken);
558 if (!Ret)
559 return Ret; // failure
560
561 Ret = LookupPrivilegeValueW(NULL, lpPrivilegeName, &luid);
562 if (Ret)
563 {
564 tokenPrivileges.PrivilegeCount = 1;
565 tokenPrivileges.Privileges[0].Luid = luid;
566 tokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
567
568 Ret = AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0, 0, 0);
569 }
570
571 CloseHandle(hToken);
572 return Ret;
573}
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
_In_ BOOL bEnable
Definition: winddi.h:3426
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

◆ EnumResNameProc()

static BOOL CALLBACK EnumResNameProc ( HMODULE  hModule,
LPCWSTR  lpszType,
LPWSTR  lpszName,
LONG_PTR  lParam 
)
static

Definition at line 158 of file settings_page.c.

159{
160 HICON* phIconSm = (HICON*)lParam;
161 if (*phIconSm)
162 return FALSE;
163
164 *phIconSm = (HICON)LoadImageW(hModule, lpszName, IMAGE_ICON,
167 0);
168 return TRUE;
169}
LPARAM lParam
Definition: combotst.c:139
HMODULE hModule
Definition: animate.c:44
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203

Referenced by LoadIMEIcon().

◆ ExpandTreeItem()

static VOID ExpandTreeItem ( HWND  hwndTree,
HTREEITEM  hItem 
)
static

Definition at line 316 of file settings_page.c.

317{
318 TreeView_Expand(hwndTree, hItem, TVE_EXPAND);
319 hItem = TreeView_GetChild(hwndTree, hItem);
320 while (hItem)
321 {
322 ExpandTreeItem(hwndTree, hItem);
324 }
325}
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3420
#define TVE_EXPAND
Definition: commctrl.h:3423
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3467
static VOID ExpandTreeItem(HWND hwndTree, HTREEITEM hItem)

Referenced by ExpandTreeItem(), and UpdateInputListView().

◆ FindLanguageInList()

static HTREEITEM FindLanguageInList ( HWND  hwndList,
LPCTSTR  pszLangName 
)
static

Definition at line 190 of file settings_page.c.

191{
193 TCHAR szText[128];
195
196 hItem = TreeView_GetRoot(hwndList);
197 while (hItem)
198 {
199 szText[0] = 0;
200 item.mask = TVIF_TEXT | TVIF_HANDLE;
201 item.pszText = szText;
202 item.cchTextMax = _countof(szText);
203 item.hItem = hItem;
204 TreeView_GetItem(hwndList, &item);
205 if (_wcsicmp(szText, pszLangName) == 0)
206 return hItem;
207
209 }
210
211 return NULL;
212}
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3475
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
char TCHAR
Definition: xmlstorage.h:189

Referenced by AddToInputListView().

◆ InitDefaultLangComboBox()

static VOID InitDefaultLangComboBox ( HWND  hwndCombo)
static

Definition at line 107 of file settings_page.c.

108{
109 WCHAR szText[256];
110 INPUT_LIST_NODE *pNode;
111 INT iIndex, nCount, iDefault = (INT)SendMessageW(hwndCombo, CB_GETCURSEL, 0, 0);
112
113 SendMessageW(hwndCombo, CB_RESETCONTENT, 0, 0);
114
115 for (pNode = InputList_GetFirst(); pNode != NULL; pNode = pNode->pNext)
116 {
118 continue;
119
120 StringCchPrintfW(szText, _countof(szText), L"%s - %s",
121 pNode->pLocale->pszName, pNode->pLayout->pszName);
122 iIndex = (INT)SendMessageW(hwndCombo, CB_ADDSTRING, 0, (LPARAM)szText);
123 SendMessageW(hwndCombo, CB_SETITEMDATA, iIndex, (LPARAM)pNode);
124
126 iDefault = iIndex;
127 }
128
129 nCount = (INT)SendMessageW(hwndCombo, CB_GETCOUNT, 0, 0);
130 if (iDefault >= nCount)
131 SendMessageW(hwndCombo, CB_SETCURSEL, nCount - 1, 0);
132 else
133 SendMessageW(hwndCombo, CB_SETCURSEL, iDefault, 0);
134}
INPUT_LIST_NODE * InputList_GetFirst(VOID)
Definition: input_list.c:800
#define INPUT_LIST_NODE_FLAG_DELETED
Definition: input_list.h:24
#define INT
Definition: polytest.cpp:20
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:44
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define CB_GETCOUNT
Definition: winuser.h:1942
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_GETCURSEL
Definition: winuser.h:1943
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by SetControlsState().

◆ LoadIMEIcon()

static HICON LoadIMEIcon ( LPCTSTR  pszImeFile)
static

Definition at line 171 of file settings_page.c.

172{
173 WCHAR szSysDir[MAX_PATH], szPath[MAX_PATH];
174 HINSTANCE hImeInst;
176
177 GetSystemDirectoryW(szSysDir, _countof(szSysDir));
178 StringCchPrintfW(szPath, _countof(szPath), L"%s\\%s", szSysDir, pszImeFile);
179
181 if (hImeInst == NULL)
182 return NULL;
183
185 FreeLibrary(hImeInst);
186
187 return hIconSm;
188}
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
BOOL WINAPI EnumResourceNamesW(HMODULE hmod, LPCWSTR type, ENUMRESNAMEPROCW lpfun, LONG_PTR lparam)
Definition: res.c:358
LPCWSTR szPath
Definition: env.c:37
HICON hIconSm
Definition: msconfig.c:44
#define RT_GROUP_ICON
Definition: pedump.c:375
static BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCWSTR lpszType, LPWSTR lpszName, LONG_PTR lParam)
#define DONT_RESOLVE_DLL_REFERENCES
Definition: winbase.h:341

Referenced by AddToInputListView().

◆ OnCommandSettingsPage()

VOID OnCommandSettingsPage ( HWND  hwndDlg,
WPARAM  wParam 
)

Definition at line 424 of file settings_page.c.

425{
426 switch (LOWORD(wParam))
427 {
428 case IDC_ADD_BUTTON:
429 {
432 hwndDlg,
434 {
436 SetControlsState(hwndDlg);
437 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
438 }
439 }
440 break;
441
443 {
444 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
445 if (hwndList)
446 {
449 item.hItem = hItem;
450
451 if (hItem && TreeView_GetItem(hwndList, &item))
452 {
453 if (item.lParam == 0) // Branch? (currently branch is keyboard only)
454 {
455 // Get root of branch
456 item.hItem = TreeView_GetParent(hwndList, hItem);
457 TreeView_GetItem(hwndList, &item);
458 }
459
460 if (HIWORD(item.lParam)) // Leaf?
461 {
464 }
465 else // Root?
466 {
469 }
470
471 UpdateInputListView(hwndList);
472 SetControlsState(hwndDlg);
473 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
474 }
475 }
476 }
477 break;
478
479 case IDC_PROP_BUTTON:
480 {
481 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
482 if (hwndList)
483 {
486 item.hItem = hItem;
487
488 if (hItem && TreeView_GetItem(hwndList, &item) && HIWORD(item.lParam))
489 {
492 hwndDlg,
494 item.lParam) == IDOK)
495 {
496 UpdateInputListView(hwndList);
497 SetControlsState(hwndDlg);
498 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
499 }
500 }
501 }
502 }
503 break;
504
505 case IDC_KEY_SET_BTN:
506 {
509 hwndDlg,
511 }
512 break;
513
514 case IDC_LANGUAGE_BAR:
515 {
516 // FIXME
517 break;
518 }
519
521 {
522 if (HIWORD(wParam) == CBN_SELENDOK)
523 {
524 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
525 HWND hwndCombo = GetDlgItem(hwndDlg, IDC_DEFAULT_LANGUAGE);
526 INT iSelected = (INT)SendMessageW(hwndCombo, CB_GETCURSEL, 0, 0);
527 if (iSelected != CB_ERR)
528 {
529 LPARAM lParam = SendMessageW(hwndCombo, CB_GETITEMDATA, iSelected, 0);
530 if (lParam)
531 {
533 if (!(pNode->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT))
534 {
537 UpdateInputListView(hwndList);
538 SetControlsState(hwndDlg);
539 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
540 }
541 }
542 }
543 }
544 }
545 }
546}
INT_PTR CALLBACK AddDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: add_dialog.c:177
WPARAM wParam
Definition: combotst.c:138
BOOL g_bRebootNeeded
Definition: input.c:18
INT_PTR CALLBACK KeySettingsDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define IDC_REMOVE_BUTTON
Definition: resource.h:24
#define IDD_ADD
Definition: resource.h:17
#define IDC_KEY_SET_BTN
Definition: resource.h:26
#define IDC_KEYLAYOUT_LIST
Definition: resource.h:21
#define IDC_PROP_BUTTON
Definition: resource.h:25
#define IDC_LANGUAGE_BAR
Definition: resource.h:42
#define IDD_INPUT_LANG_PROP
Definition: resource.h:15
#define IDC_ADD_BUTTON
Definition: resource.h:23
#define IDD_KEYSETTINGS
Definition: resource.h:18
#define IDC_DEFAULT_LANGUAGE
Definition: resource.h:22
INT_PTR CALLBACK EditDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: edit_dialog.c:14
VOID InputList_SetDefault(INPUT_LIST_NODE *pNode)
Definition: input_list.c:547
BOOL InputList_RemoveByLang(LANGID wLangId)
Definition: input_list.c:636
BOOL InputList_Remove(INPUT_LIST_NODE *pNode)
Definition: input_list.c:596
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
static VOID UpdateInputListView(HWND hwndList)
static VOID SetControlsState(HWND hwndDlg)
#define HIWORD(l)
Definition: typedefs.h:247
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399
#define CB_ERR
Definition: winuser.h:2435
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define CB_GETITEMDATA
Definition: winuser.h:1950
HWND WINAPI GetParent(_In_ HWND)
#define CBN_SELENDOK
Definition: winuser.h:1981
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by SettingsPageProc().

◆ OnDestroySettingsPage()

static VOID OnDestroySettingsPage ( HWND  hwndDlg)
static

Definition at line 415 of file settings_page.c.

416{
420}
VOID InputList_Destroy(VOID)
Definition: input_list.c:197
VOID LayoutList_Destroy(VOID)
Definition: layout_list.c:67
VOID LocaleList_Destroy(VOID)
Definition: locale_list.c:60

Referenced by SettingsPageProc().

◆ OnInitSettingsPage()

static VOID OnInitSettingsPage ( HWND  hwndDlg)
static

Definition at line 388 of file settings_page.c.

389{
390 HWND hwndInputList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
391 HIMAGELIST hLayoutImageList, hOldImageList;
392
396
398
401 ILC_COLOR8 | ILC_MASK, 0, 0);
402 if (hLayoutImageList != NULL)
403 {
404 hOldImageList = TreeView_SetImageList(hwndInputList, hLayoutImageList, TVSIL_NORMAL);
405 ImageList_Destroy(hOldImageList);
406 }
407
408 UpdateInputListView(hwndInputList);
409
410 SetControlsState(hwndDlg);
411}
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
VOID InputList_Create(VOID)
Definition: input_list.c:659
VOID LayoutList_Create(VOID)
Definition: layout_list.c:171
LOCALE_LIST_NODE * LocaleList_Create(VOID)
Definition: locale_list.c:84
#define ILC_COLOR8
Definition: commctrl.h:355
#define ILC_MASK
Definition: commctrl.h:351
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by SettingsPageProc().

◆ OnNotifySettingsPage()

static INT_PTR OnNotifySettingsPage ( HWND  hwndDlg,
LPARAM  lParam 
)
static

Definition at line 576 of file settings_page.c.

577{
579
580 switch (header->code)
581 {
582 case TVN_SELCHANGED:
583 {
584 SetControlsState(hwndDlg);
585 break;
586 }
587
589 {
590 // FIXME: Prevent collapse (COMCTL32 is buggy)
591 // https://bugs.winehq.org/show_bug.cgi?id=53727
592 NM_TREEVIEW* pTreeView = (NM_TREEVIEW*)lParam;
593 if ((pTreeView->action & TVE_TOGGLE) == TVE_COLLAPSE)
594 {
596 return TRUE;
597 }
598 break;
599 }
600
601 case PSN_APPLY:
602 {
603 /* Write Input Methods list to registry */
605 break;
606 }
607 }
608
609 return 0;
610}
BOOL InputList_Process(VOID)
Definition: input_list.c:382
#define PSN_APPLY
Definition: prsht.h:117
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define NM_TREEVIEW
Definition: commctrl.h:3624
#define TVE_TOGGLE
Definition: commctrl.h:3424
#define TVE_COLLAPSE
Definition: commctrl.h:3422
#define TVN_ITEMEXPANDING
Definition: commctrl.h:3738
struct tagNMHDR * LPNMHDR
#define DWLP_MSGRESULT
Definition: winuser.h:870
#define SetWindowLongPtrW
Definition: winuser.h:5346

Referenced by SettingsPageProc().

◆ SetControlsState()

static VOID SetControlsState ( HWND  hwndDlg)
static

Definition at line 137 of file settings_page.c.

138{
139 HWND hwndList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
140 HWND hwndCombo = GetDlgItem(hwndDlg, IDC_DEFAULT_LANGUAGE);
141 BOOL bIsLeaf, bCanRemove, bCanProp;
142 HTREEITEM hSelected = TreeView_GetSelection(hwndList);
144 item.hItem = hSelected;
145
146 bIsLeaf = (hSelected && TreeView_GetItem(hwndList, &item) && HIWORD(item.lParam));
147
148 bCanRemove = (bIsLeaf && (s_nAliveLeafCount > 1)) || (s_nRootCount > 1);
149 bCanProp = bIsLeaf;
150
151 EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE_BUTTON), bCanRemove);
152 EnableWindow(GetDlgItem(hwndDlg, IDC_PROP_BUTTON), bCanProp);
153
154 InitDefaultLangComboBox(hwndCombo);
155}
static VOID InitDefaultLangComboBox(HWND hwndCombo)
static INT s_nAliveLeafCount
Definition: settings_page.c:14
static INT s_nRootCount
Definition: settings_page.c:15

Referenced by OnCommandSettingsPage(), OnInitSettingsPage(), and OnNotifySettingsPage().

◆ SettingsPageProc()

INT_PTR CALLBACK SettingsPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 613 of file settings_page.c.

614{
615 switch (uMsg)
616 {
617 case WM_INITDIALOG:
618 OnInitSettingsPage(hwndDlg);
619 return TRUE;
620
621 case WM_DESTROY:
622 OnDestroySettingsPage(hwndDlg);
623 break;
624
625 case WM_COMMAND:
627 break;
628
629 case WM_NOTIFY:
630 return OnNotifySettingsPage(hwndDlg, lParam);
631 }
632
633 return FALSE;
634}
#define WM_NOTIFY
Definition: richedit.h:61
static INT_PTR OnNotifySettingsPage(HWND hwndDlg, LPARAM lParam)
static VOID OnInitSettingsPage(HWND hwndDlg)
static VOID OnDestroySettingsPage(HWND hwndDlg)
VOID OnCommandSettingsPage(HWND hwndDlg, WPARAM wParam)
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_DESTROY
Definition: winuser.h:1609

Referenced by SystemApplet().

◆ UpdateInputListView()

static VOID UpdateInputListView ( HWND  hwndList)
static

Definition at line 328 of file settings_page.c.

329{
330 INPUT_LIST_NODE *pNode;
331 HIMAGELIST hImageList = TreeView_GetImageList(hwndList, TVSIL_NORMAL);
333 HICON hKeyboardIcon, hDotIcon;
334
335 ImageList_RemoveAll(hImageList);
336 TreeView_DeleteAllItems(hwndList);
337
338 // Add keyboard icon
339 s_iKeyboardImage = -1;
342 0);
343 if (hKeyboardIcon)
344 {
345 s_iKeyboardImage = ImageList_AddIcon(hImageList, hKeyboardIcon);
346 DestroyIcon(hKeyboardIcon);
347 }
348
349 // Add dot icon
350 s_iDotImage = -1;
353 0);
354 if (hDotIcon)
355 {
356 s_iDotImage = ImageList_AddIcon(hImageList, hDotIcon);
357 DestroyIcon(hDotIcon);
358 }
359
361
363
364 // Add items to the list
365 for (pNode = InputList_GetFirst(); pNode; pNode = pNode->pNext)
366 {
368 continue;
369
370 AddToInputListView(hwndList, pNode);
371 }
372
373 // Expand all (with counting s_nRootCount)
374 s_nRootCount = 0;
375 hItem = TreeView_GetRoot(hwndList);
376 while (hItem)
377 {
378 ++s_nRootCount;
379 ExpandTreeItem(hwndList, hItem);
381 }
382
383 // Redraw
384 InvalidateRect(hwndList, NULL, TRUE);
385}
#define IDI_DOT
Definition: resource.h:10
#define IDI_KEYBOARD
Definition: resource.h:9
INT InputList_GetAliveCount(VOID)
Definition: input_list.c:783
VOID InputList_Sort(VOID)
Definition: input_list.c:724
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
#define ImageList_RemoveAll(himl)
Definition: commctrl.h:556
static VOID AddToInputListView(HWND hwndList, INPUT_LIST_NODE *pInputNode)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by OnCommandSettingsPage(), and OnInitSettingsPage().

Variable Documentation

◆ s_iDotImage

INT s_iDotImage = -1
static

Definition at line 17 of file settings_page.c.

Referenced by AddToInputListView(), and UpdateInputListView().

◆ s_iKeyboardImage

INT s_iKeyboardImage = -1
static

Definition at line 16 of file settings_page.c.

Referenced by AddToInputListView(), and UpdateInputListView().

◆ s_nAliveLeafCount

INT s_nAliveLeafCount = 0
static

Definition at line 14 of file settings_page.c.

Referenced by SetControlsState(), and UpdateInputListView().

◆ s_nRootCount

INT s_nRootCount = 0
static

Definition at line 15 of file settings_page.c.

Referenced by SetControlsState(), and UpdateInputListView().