ReactOS  0.4.13-dev-259-g5ca9c9c
add_dialog.c File Reference
#include "input.h"
#include "locale_list.h"
#include "layout_list.h"
#include "input_list.h"
Include dependency graph for add_dialog.c:

Go to the source code of this file.

Functions

static DWORD GetDefaultLayoutForLocale (DWORD dwLocaleId)
 
static VOID OnInitAddDialog (HWND hwndDlg)
 
static VOID OnCommandAddDialog (HWND hwndDlg, WPARAM wParam)
 
INT_PTR CALLBACK AddDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ AddDialogProc()

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

Definition at line 177 of file add_dialog.c.

178 {
179  switch (uMsg)
180  {
181  case WM_INITDIALOG:
182  OnInitAddDialog(hwndDlg);
183  break;
184 
185  case WM_COMMAND:
186  OnCommandAddDialog(hwndDlg, wParam);
187  break;
188 
189  case WM_DESTROY:
190  break;
191  }
192 
193  return FALSE;
194 }
WPARAM wParam
Definition: combotst.c:138
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_COMMAND
Definition: winuser.h:1716
static VOID OnCommandAddDialog(HWND hwndDlg, WPARAM wParam)
Definition: add_dialog.c:108
static VOID OnInitAddDialog(HWND hwndDlg)
Definition: add_dialog.c:62
#define WM_INITDIALOG
Definition: winuser.h:1715

Referenced by OnCommandSettingsPage().

◆ GetDefaultLayoutForLocale()

static DWORD GetDefaultLayoutForLocale ( DWORD  dwLocaleId)
static

Definition at line 15 of file add_dialog.c.

16 {
17  DWORD dwResult = 0;
18  HINF hIntlInf;
19 
20  hIntlInf = SetupOpenInfFileW(L"intl.inf", NULL, INF_STYLE_WIN4, NULL);
21  if (hIntlInf != INVALID_HANDLE_VALUE)
22  {
23  WCHAR szLangID[MAX_STR_LEN];
24  INFCONTEXT InfContext;
25 
26  StringCchPrintfW(szLangID, ARRAYSIZE(szLangID), L"%08X", dwLocaleId);
27 
28  if (SetupFindFirstLineW(hIntlInf, L"Locales", szLangID, &InfContext))
29  {
30  if (SetupGetFieldCount(&InfContext) >= 5)
31  {
32  WCHAR szField[MAX_STR_LEN];
33 
34  if (SetupGetStringFieldW(&InfContext, 5, szField, ARRAYSIZE(szField), NULL))
35  {
36  if (wcslen(szField) == 13) // like 0409:00000409 (13 chars)
37  {
38  WCHAR *pszSeparator = L":";
39  WCHAR *pszToken;
40 
41  pszToken = wcstok(szField, pszSeparator);
42  if (pszToken != NULL)
43  pszToken = wcstok(NULL, pszSeparator);
44 
45  if (pszToken != NULL)
46  {
47  dwResult = DWORDfromString(pszToken);
48  }
49  }
50  }
51  }
52  }
53 
54  SetupCloseInfFile(hIntlInf);
55  }
56 
57  return dwResult;
58 }
BOOL WINAPI SetupFindFirstLineW(IN HINF InfHandle, IN PCWSTR Section, IN PCWSTR Key, IN OUT PINFCONTEXT Context)
Definition: infsupp.c:54
#define INF_STYLE_WIN4
Definition: infsupp.h:41
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG WINAPI SetupGetFieldCount(IN PINFCONTEXT Context)
Definition: infsupp.c:91
static const WCHAR L[]
Definition: oid.c:1250
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
#define MAX_STR_LEN
Definition: defines.h:33
static DWORD DWORDfromString(const WCHAR *pszString)
Definition: input.h:78
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI SetupGetStringFieldW(IN PINFCONTEXT Context, IN ULONG FieldIndex, OUT PWSTR ReturnBuffer, IN ULONG ReturnBufferSize, OUT PULONG RequiredSize)
Definition: infsupp.c:184

Referenced by OnCommandAddDialog(), and OnInitAddDialog().

◆ OnCommandAddDialog()

static VOID OnCommandAddDialog ( HWND  hwndDlg,
WPARAM  wParam 
)
static

Definition at line 108 of file add_dialog.c.

109 {
110  switch (LOWORD(wParam))
111  {
112  case IDOK:
113  {
114  HWND hwndLocaleCombo = GetDlgItem(hwndDlg, IDC_INPUT_LANG_COMBO);
115  HWND hwndLayoutCombo = GetDlgItem(hwndDlg, IDC_KEYBOARD_LO_COMBO);
116  LOCALE_LIST_NODE *pCurrentLocale;
117  LAYOUT_LIST_NODE *pCurrentLayout;
118 
119  pCurrentLocale = (LOCALE_LIST_NODE*)ComboBox_GetItemData(hwndLocaleCombo,
120  ComboBox_GetCurSel(hwndLocaleCombo));
121  pCurrentLayout = (LAYOUT_LIST_NODE*)ComboBox_GetItemData(hwndLayoutCombo,
122  ComboBox_GetCurSel(hwndLayoutCombo));
123 
124  InputList_Add(pCurrentLocale, pCurrentLayout);
125 
126  EndDialog(hwndDlg, LOWORD(wParam));
127  }
128  break;
129 
130  case IDCANCEL:
131  {
132  EndDialog(hwndDlg, LOWORD(wParam));
133  }
134  break;
135 
137  {
138  if (HIWORD(wParam) == CBN_SELCHANGE)
139  {
140  HWND hwndLocaleCombo = GetDlgItem(hwndDlg, IDC_INPUT_LANG_COMBO);
141  HWND hwndLayoutCombo = GetDlgItem(hwndDlg, IDC_KEYBOARD_LO_COMBO);
142  LOCALE_LIST_NODE *pCurrentLocale;
143 
144  pCurrentLocale = (LOCALE_LIST_NODE*)ComboBox_GetItemData(hwndLocaleCombo,
145  ComboBox_GetCurSel(hwndLocaleCombo));
146  if (pCurrentLocale != NULL)
147  {
148  DWORD dwLayoutId;
149  INT iIndex;
150  INT iCount;
151 
152  dwLayoutId = GetDefaultLayoutForLocale(pCurrentLocale->dwId);
153 
154  iCount = ComboBox_GetCount(hwndLayoutCombo);
155 
156  for (iIndex = 0; iIndex < iCount; iIndex++)
157  {
158  LAYOUT_LIST_NODE *pCurrentLayout;
159 
160  pCurrentLayout = (LAYOUT_LIST_NODE*)ComboBox_GetItemData(hwndLayoutCombo, iIndex);
161 
162  if (pCurrentLayout != NULL && pCurrentLayout->dwId == dwLayoutId)
163  {
164  ComboBox_SetCurSel(hwndLayoutCombo, iIndex);
165  break;
166  }
167  }
168  }
169  }
170  }
171  break;
172  }
173 }
#define IDOK
Definition: winuser.h:824
#define IDC_KEYBOARD_LO_COMBO
Definition: resource.h:31
#define ComboBox_GetCurSel(hwndCtl)
Definition: windowsx.h:24
static DWORD GetDefaultLayoutForLocale(DWORD dwLocaleId)
Definition: add_dialog.c:15
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:23
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define ComboBox_GetItemData(hwndCtl, index)
Definition: windowsx.h:29
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL InputList_Add(LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout)
Definition: input_list.c:408
#define IDC_INPUT_LANG_COMBO
Definition: resource.h:30
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:41
#define CBN_SELCHANGE
Definition: winuser.h:1940
#define HIWORD(l)
Definition: typedefs.h:246
#define IDCANCEL
Definition: winuser.h:825
#define LOWORD(l)
Definition: pedump.c:82

Referenced by AddDialogProc().

◆ OnInitAddDialog()

static VOID OnInitAddDialog ( HWND  hwndDlg)
static

Definition at line 62 of file add_dialog.c.

63 {
64  HWND hwndLocaleCombo = GetDlgItem(hwndDlg, IDC_INPUT_LANG_COMBO);
65  HWND hwndLayoutCombo = GetDlgItem(hwndDlg, IDC_KEYBOARD_LO_COMBO);
66  LOCALE_LIST_NODE *pCurrentLocale;
67  LAYOUT_LIST_NODE *pCurrentLayout;
68  DWORD dwDefaultLocaleId;
69  DWORD dwDefaultLayoutId;
70  INT iItemIndex;
71 
72  dwDefaultLocaleId = GetSystemDefaultLCID();
73 
74  for (pCurrentLocale = LocaleList_GetFirst();
75  pCurrentLocale != NULL;
76  pCurrentLocale = pCurrentLocale->pNext)
77  {
78  iItemIndex = ComboBox_AddString(hwndLocaleCombo, pCurrentLocale->pszName);
79  ComboBox_SetItemData(hwndLocaleCombo, iItemIndex, pCurrentLocale);
80 
81  if (pCurrentLocale->dwId == dwDefaultLocaleId)
82  {
83  ComboBox_SetCurSel(hwndLocaleCombo, iItemIndex);
84  }
85  }
86 
87  dwDefaultLayoutId = GetDefaultLayoutForLocale(dwDefaultLocaleId);
88 
89  for (pCurrentLayout = LayoutList_GetFirst();
90  pCurrentLayout != NULL;
91  pCurrentLayout = pCurrentLayout->pNext)
92  {
93  iItemIndex = ComboBox_AddString(hwndLayoutCombo, pCurrentLayout->pszName);
94  ComboBox_SetItemData(hwndLayoutCombo, iItemIndex, pCurrentLayout);
95 
96  if (pCurrentLayout->dwId == dwDefaultLayoutId)
97  {
98  ComboBox_SetCurSel(hwndLayoutCombo, iItemIndex);
99  }
100  }
101 
102  if (dwDefaultLayoutId == 0)
103  ComboBox_SetCurSel(hwndLayoutCombo, 0);
104 }
#define IDC_KEYBOARD_LO_COMBO
Definition: resource.h:31
#define ComboBox_AddString(hwndCtl, lpsz)
Definition: windowsx.h:16
LAYOUT_LIST_NODE * LayoutList_GetFirst(VOID)
Definition: layout_list.c:274
static DWORD GetDefaultLayoutForLocale(DWORD dwLocaleId)
Definition: add_dialog.c:15
int32_t INT
Definition: typedefs.h:56
LOCALE_LIST_NODE * LocaleList_GetFirst(VOID)
Definition: locale_list.c:146
struct _LOCALE_LIST_NODE * pNext
Definition: locale_list.h:12
smooth NULL
Definition: ftsmooth.c:416
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:787
struct _LAYOUT_LIST_NODE * pNext
Definition: layout_list.h:13
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_INPUT_LANG_COMBO
Definition: resource.h:30
#define ComboBox_SetCurSel(hwndCtl, index)
Definition: windowsx.h:41
#define ComboBox_SetItemData(hwndCtl, index, data)
Definition: windowsx.h:44

Referenced by AddDialogProc().