Author: dchapyshev
Date: Sun Aug 7 23:28:50 2016
New Revision: 72154
URL:
http://svn.reactos.org/svn/reactos?rev=72154&view=rev
Log:
[INPUT]
- Implement list of keyboard layouts on Settings Page
Added:
trunk/reactos/dll/cpl/input_new/layout_list.c (with props)
trunk/reactos/dll/cpl/input_new/layout_list.h (with props)
trunk/reactos/dll/cpl/input_new/locale_list.c (with props)
trunk/reactos/dll/cpl/input_new/locale_list.h (with props)
trunk/reactos/dll/cpl/input_new/settings_page.c (with props)
Modified:
trunk/reactos/dll/cpl/input_new/CMakeLists.txt
trunk/reactos/dll/cpl/input_new/input.c
trunk/reactos/dll/cpl/input_new/input.h
Modified: trunk/reactos/dll/cpl/input_new/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/CMakeLis…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/CMakeLists.txt [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -3,7 +3,12 @@
list(APPEND SOURCE
input.c
- input.h)
+ input.h
+ layout_list.c
+ layout_list.h
+ locale_list.c
+ locale_list.h
+ settings_page.c)
add_rc_deps(input.rc ${CMAKE_CURRENT_SOURCE_DIR}/resources/keyboard-shortcuts.ico)
Modified: trunk/reactos/dll/cpl/input_new/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/input.c?…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/input.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/input.c [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -15,73 +15,66 @@
#define NUM_APPLETS (1)
LONG CALLBACK SystemApplet(VOID);
-HINSTANCE hApplet = 0;
-HANDLE hProcessHeap;
+HINSTANCE hApplet = NULL;
HWND hCPLWindow;
/* Applets */
-APPLET Applets[NUM_APPLETS] =
+static APPLET Applets[NUM_APPLETS] =
{
{IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
};
VOID
-InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
+InitPropSheetPage(PROPSHEETPAGE *page, WORD idDlg, DLGPROC DlgProc)
{
- ZeroMemory(psp, sizeof(PROPSHEETPAGE));
- psp->dwSize = sizeof(PROPSHEETPAGE);
- psp->dwFlags = PSP_DEFAULT;
- psp->hInstance = hApplet;
- psp->pszTemplate = MAKEINTRESOURCE(idDlg);
- psp->pfnDlgProc = DlgProc;
-}
+ memset(page, 0, sizeof(PROPSHEETPAGE));
-
-INT_PTR CALLBACK
-SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- return FALSE;
+ page->dwSize = sizeof(PROPSHEETPAGE);
+ page->dwFlags = PSP_DEFAULT;
+ page->hInstance = hApplet;
+ page->pszTemplate = MAKEINTRESOURCE(idDlg);
+ page->pfnDlgProc = DlgProc;
}
INT_PTR CALLBACK
AdvancedSettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- return FALSE;
+ return FALSE;
}
/* First Applet */
-
LONG CALLBACK
SystemApplet(VOID)
{
- PROPSHEETPAGE psp[2];
- PROPSHEETHEADER psh;
- TCHAR Caption[1024];
+ PROPSHEETPAGE page[2];
+ PROPSHEETHEADER header;
+ WCHAR szCaption[MAX_STR_LEN];
- LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
+ LoadString(hApplet, IDS_CPLSYSTEMNAME, szCaption, ARRAYSIZE(szCaption));
- ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
- psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_PROPSHEETPAGE;
- psh.hwndParent = hCPLWindow;
- psh.hInstance = hApplet;
- psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
- psh.pszCaption = Caption;
- psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
- psh.nStartPage = 0;
- psh.ppsp = psp;
- psh.pfnCallback = NULL;
+ memset(&header, 0, sizeof(PROPSHEETHEADER));
+
+ header.dwSize = sizeof(PROPSHEETHEADER);
+ header.dwFlags = PSH_PROPSHEETPAGE;
+ header.hwndParent = hCPLWindow;
+ header.hInstance = hApplet;
+ header.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
+ header.pszCaption = szCaption;
+ header.nPages = ARRAYSIZE(page);
+ header.nStartPage = 0;
+ header.ppsp = page;
+ header.pfnCallback = NULL;
/* Settings */
- InitPropSheetPage(&psp[0], IDD_PROPPAGESETTINGS, (DLGPROC)SettingsPageProc);
+ InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc);
/* Advanced Settings */
- InitPropSheetPage(&psp[1], IDD_PROPPAGEADVANCEDSETTINGS,
(DLGPROC)AdvancedSettingsPageProc);
+ InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS,
AdvancedSettingsPageProc);
- return (LONG)(PropertySheet(&psh) != -1);
+ return (LONG)(PropertySheet(&header) != -1);
}
@@ -93,6 +86,7 @@
DWORD i;
i = (DWORD)lParam1;
+
switch (uMsg)
{
case CPL_INIT:
@@ -129,7 +123,6 @@
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
hApplet = hinstDLL;
- hProcessHeap = GetProcessHeap();
break;
}
Modified: trunk/reactos/dll/cpl/input_new/input.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/input.h?…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/input.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input_new/input.h [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -9,8 +9,11 @@
#include <winnls.h>
#include <winreg.h>
#include <winuser.h>
+#include <wingdi.h>
#include <commctrl.h>
-#include <tchar.h>
+#include <wchar.h>
+#include <strsafe.h>
+#include <stdlib.h>
#include "resource.h"
@@ -25,7 +28,6 @@
} APPLET, *PAPPLET;
extern HINSTANCE hApplet;
-extern HANDLE hProcessHeap;
// Character Count of a layout ID like "00000409"
#define CCH_LAYOUT_ID 8
@@ -33,44 +35,33 @@
// Maximum Character Count of a ULONG in decimal
#define CCH_ULONG_DEC 10
+#define MAX_STR_LEN 256
+
/* input.c */
VOID
-InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc);
+InitPropSheetPage(PROPSHEETPAGE *page, WORD idDlg, DLGPROC DlgProc);
-/* settings.c */
+/* settings_dialog.c */
INT_PTR CALLBACK
-SettingsPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
-BOOL
-GetLayoutName(LPCTSTR szLCID, LPTSTR szName);
-VOID
-UpdateLayoutsList(VOID);
-BOOL
-IsLayoutExists(LPTSTR szLayoutID, LPTSTR szLangID);
-
-/* advsettings.c */
-INT_PTR CALLBACK
-AdvancedSettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-
-/* keysettings.c */
-INT_PTR CALLBACK
-KeySettingsDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
-VOID
-UpdateKeySettingsList(VOID);
-
-/* add.c */
-INT_PTR CALLBACK
-AddDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
-VOID
-CreateKeyboardLayoutList(HWND hItemsList);
-INT
-GetLayoutCount(LPTSTR szLang);
-
-/* changekeyseq.c */
-INT_PTR CALLBACK
-ChangeKeySeqDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
-BOOL
-GetHotkeys(LPTSTR szHotkey, LPTSTR szLangHotkey, LPTSTR szLayoutHotkey);
+SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void ShowLastWin32Error(HWND hWndOwner);
+static inline WCHAR*
+DublicateString(const WCHAR *pszString)
+{
+ WCHAR *pszDublicate;
+ size_t size;
+
+ size = (wcslen(pszString) + 1) * sizeof(WCHAR);
+
+ pszDublicate = (WCHAR*) malloc(size);
+ if (pszDublicate != NULL)
+ {
+ StringCbCopyW(pszDublicate, size, pszString);
+ }
+
+ return pszDublicate;
+}
+
#endif /* _INPUT_H */
Added: trunk/reactos/dll/cpl/input_new/layout_list.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/layout_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/layout_list.c (added)
+++ trunk/reactos/dll/cpl/input_new/layout_list.c [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -0,0 +1,221 @@
+/*
+ * PROJECT: input.dll
+ * FILE: dll/cpl/input/layout_list.c
+ * PURPOSE: input.dll
+ * PROGRAMMER: Dmitry Chapyshev (dmitry(a)reactos.org)
+ */
+
+#include "layout_list.h"
+
+
+static LAYOUT_LIST_NODE *_LayoutList = NULL;
+
+
+static LAYOUT_LIST_NODE*
+LayoutList_Append(DWORD dwId, DWORD dwSpecialId, const WCHAR *pszName, const WCHAR
*pszFile)
+{
+ LAYOUT_LIST_NODE *pCurrent;
+ LAYOUT_LIST_NODE *pNew;
+
+ if (pszName == NULL || pszFile == NULL)
+ return NULL;
+
+ pCurrent = _LayoutList;
+
+ pNew = (LAYOUT_LIST_NODE*)malloc(sizeof(LAYOUT_LIST_NODE));
+ if (pNew == NULL)
+ return NULL;
+
+ memset(pNew, 0, sizeof(LAYOUT_LIST_NODE));
+
+ pNew->pszName = DublicateString(pszName);
+ if (pNew->pszName == NULL)
+ {
+ free(pNew);
+ return NULL;
+ }
+
+ pNew->pszFile = DublicateString(pszFile);
+ if (pNew->pszFile == NULL)
+ {
+ free(pNew->pszName);
+ free(pNew);
+ return NULL;
+ }
+
+ pNew->dwId = dwId;
+ pNew->dwSpecialId = dwSpecialId;
+
+ if (pCurrent == NULL)
+ {
+ _LayoutList = pNew;
+ }
+ else
+ {
+ while (pCurrent->pNext != NULL)
+ {
+ pCurrent = pCurrent->pNext;
+ }
+
+ pNew->pPrev = pCurrent;
+ pCurrent->pNext = pNew;
+ }
+
+ return pNew;
+}
+
+
+VOID
+LayoutList_Destroy(VOID)
+{
+ LAYOUT_LIST_NODE *pCurrent;
+
+ if (_LayoutList == NULL)
+ return;
+
+ pCurrent = _LayoutList;
+
+ while (pCurrent != NULL)
+ {
+ LAYOUT_LIST_NODE *pNext = pCurrent->pNext;
+
+ free(pCurrent->pszName);
+ free(pCurrent->pszFile);
+ free(pCurrent);
+
+ pCurrent = pNext;
+ }
+
+ _LayoutList = NULL;
+}
+
+
+VOID
+LayoutList_Create(VOID)
+{
+ WCHAR szSystemDirectory[MAX_PATH];
+ WCHAR szLayoutId[MAX_PATH];
+ DWORD dwIndex = 0;
+ DWORD dwSize;
+ HKEY hKey;
+
+ GetSystemDirectoryW(szSystemDirectory, ARRAYSIZE(szSystemDirectory));
+
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts",
+ 0,
+ KEY_ENUMERATE_SUB_KEYS,
+ &hKey) != ERROR_SUCCESS)
+ {
+ return;
+ }
+
+ dwSize = sizeof(szLayoutId);
+
+ while (RegEnumKeyExW(hKey, dwIndex, szLayoutId, &dwSize,
+ NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+ {
+ HKEY hLayoutKey;
+
+ if (RegOpenKeyExW(hKey,
+ szLayoutId,
+ 0,
+ KEY_QUERY_VALUE,
+ &hLayoutKey) == ERROR_SUCCESS)
+ {
+ WCHAR szBuffer[MAX_PATH];
+
+ dwSize = sizeof(szBuffer);
+
+ if (RegQueryValueExW(hLayoutKey,
+ L"Layout File",
+ NULL, NULL,
+ (LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS)
+ {
+ WCHAR szFilePath[MAX_PATH];
+
+ StringCchPrintfW(szFilePath, ARRAYSIZE(szFilePath),
+ L"%s\\%s", szSystemDirectory, szBuffer);
+
+ if (GetFileAttributes(szFilePath) != INVALID_FILE_ATTRIBUTES)
+ {
+ DWORD dwSpecialId = 0;
+ WCHAR *pszEnd;
+
+ dwSize = sizeof(szBuffer);
+
+ if (RegQueryValueExW(hLayoutKey,
+ L"Layout Id",
+ NULL, NULL,
+ (LPBYTE)szBuffer, &dwSize) ==
ERROR_SUCCESS)
+ {
+ dwSpecialId = wcstoul(szBuffer, &pszEnd, 16);
+ }
+
+ dwSize = sizeof(szBuffer);
+
+ if (RegQueryValueExW(hLayoutKey,
+ L"Layout Text",
+ NULL, NULL,
+ (LPBYTE)szBuffer, &dwSize) ==
ERROR_SUCCESS)
+ {
+ DWORD dwLayoutId;
+
+ dwLayoutId = wcstoul(szLayoutId, &pszEnd, 16);
+
+ LayoutList_Append(dwLayoutId,
+ dwSpecialId,
+ szBuffer,
+ szFilePath);
+ }
+ }
+ }
+
+ RegCloseKey(hLayoutKey);
+ }
+
+ dwSize = sizeof(szLayoutId);
+ ++dwIndex;
+ }
+
+ RegCloseKey(hKey);
+}
+
+
+WCHAR*
+LayoutList_GetNameByHkl(HKL hkl)
+{
+ LAYOUT_LIST_NODE *pCurrent;
+
+ if ((HIWORD(hkl) & 0xF000) == 0xF000)
+ {
+ DWORD dwSpecialId = (HIWORD(hkl) & 0x0FFF);
+
+ for (pCurrent = _LayoutList; pCurrent != NULL; pCurrent = pCurrent->pNext)
+ {
+ if (dwSpecialId == pCurrent->dwSpecialId)
+ {
+ return pCurrent->pszName;
+ }
+ }
+ }
+ else
+ {
+ for (pCurrent = _LayoutList; pCurrent != NULL; pCurrent = pCurrent->pNext)
+ {
+ if (HIWORD(hkl) == LOWORD(pCurrent->dwId))
+ {
+ return pCurrent->pszName;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+LAYOUT_LIST_NODE*
+LayoutList_Get(VOID)
+{
+ return _LayoutList;
+}
Propchange: trunk/reactos/dll/cpl/input_new/layout_list.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/cpl/input_new/layout_list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/layout_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/layout_list.h (added)
+++ trunk/reactos/dll/cpl/input_new/layout_list.h [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "input.h"
+
+typedef struct _LAYOUT_LIST_NODE
+{
+ WCHAR *pszName;
+ WCHAR *pszFile;
+ DWORD dwId;
+ DWORD dwSpecialId;
+ struct _LAYOUT_LIST_NODE *pPrev;
+ struct _LAYOUT_LIST_NODE *pNext;
+} LAYOUT_LIST_NODE;
+
+VOID
+LayoutList_Create(VOID);
+
+VOID
+LayoutList_Destroy(VOID);
+
+WCHAR*
+LayoutList_GetNameByHkl(HKL hkl);
+
+LAYOUT_LIST_NODE*
+LayoutList_Get(VOID);
Propchange: trunk/reactos/dll/cpl/input_new/layout_list.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/cpl/input_new/locale_list.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/locale_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/locale_list.c (added)
+++ trunk/reactos/dll/cpl/input_new/locale_list.c [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -0,0 +1,154 @@
+/*
+ * PROJECT: input.dll
+ * FILE: dll/cpl/input/locale_list.c
+ * PURPOSE: input.dll
+ * PROGRAMMER: Dmitry Chapyshev (dmitry(a)reactos.org)
+ */
+
+#include "locale_list.h"
+
+
+static LOCALE_LIST_NODE *_LocaleList = NULL;
+
+
+static LOCALE_LIST_NODE*
+LocaleList_Append(DWORD dwId, WCHAR *pszName, WCHAR *pszIndicator)
+{
+ LOCALE_LIST_NODE *pCurrent;
+ LOCALE_LIST_NODE *pNew;
+
+ if (pszName == NULL || pszIndicator == NULL)
+ return NULL;
+
+ pCurrent = _LocaleList;
+
+ pNew = (LOCALE_LIST_NODE*) malloc(sizeof(LOCALE_LIST_NODE));
+ if (pNew == NULL)
+ return NULL;
+
+ memset(pNew, 0, sizeof(LOCALE_LIST_NODE));
+
+ pNew->pszName = DublicateString(pszName);
+ if (pNew->pszName == NULL)
+ {
+ free(pNew);
+ return NULL;
+ }
+
+ pNew->pszIndicator = DublicateString(pszIndicator);
+ if (pNew->pszIndicator == NULL)
+ {
+ free(pNew->pszName);
+ free(pNew);
+ return NULL;
+ }
+
+ pNew->dwId = dwId;
+
+ if (pCurrent == NULL)
+ {
+ _LocaleList = pNew;
+ }
+ else
+ {
+ while (pCurrent->pNext != NULL)
+ {
+ pCurrent = pCurrent->pNext;
+ }
+
+ pNew->pPrev = pCurrent;
+ pCurrent->pNext = pNew;
+ }
+
+ return pNew;
+}
+
+
+VOID
+LocaleList_Destroy(VOID)
+{
+ LOCALE_LIST_NODE *pCurrent;
+
+ if (_LocaleList == NULL)
+ return;
+
+ pCurrent = _LocaleList;
+
+ while (pCurrent != NULL)
+ {
+ LOCALE_LIST_NODE *pNext = pCurrent->pNext;
+
+ free(pCurrent->pszName);
+ free(pCurrent);
+
+ pCurrent = pNext;
+ }
+
+ _LocaleList = NULL;
+}
+
+
+LOCALE_LIST_NODE*
+LocaleList_Create(VOID)
+{
+ WCHAR szValue[MAX_PATH];
+ DWORD dwIndex;
+ DWORD dwSize;
+ HKEY hKey;
+
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\Control\\Nls\\Language",
+ 0,
+ KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE,
+ &hKey) != ERROR_SUCCESS)
+ {
+ return NULL;
+ }
+
+ dwSize = sizeof(szValue);
+ dwIndex = 0;
+
+ while (RegEnumValueW(hKey, dwIndex, szValue, &dwSize,
+ NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+ {
+ WCHAR szName[MAX_STR_LEN];
+ WCHAR *End;
+ DWORD dwId;
+
+ dwId = wcstoul(szValue, &End, 16);
+
+ if (GetLocaleInfoW(LOWORD(dwId),
+ LOCALE_SLANGUAGE,
+ szName, ARRAYSIZE(szName)))
+ {
+ WCHAR szIndicator[MAX_STR_LEN];
+
+ if (GetLocaleInfoW(LOWORD(dwId),
+ LOCALE_SABBREVLANGNAME | LOCALE_NOUSEROVERRIDE,
+ szIndicator,
+ ARRAYSIZE(szIndicator)))
+ {
+ size_t len = wcslen(szIndicator);
+
+ if (len > 0)
+ {
+ szIndicator[len - 1] = 0;
+ }
+ }
+
+ LocaleList_Append(dwId, szName, szIndicator);
+ }
+
+ dwSize = sizeof(szValue);
+ ++dwIndex;
+ }
+
+ return _LocaleList;
+}
+
+
+LOCALE_LIST_NODE*
+LocaleList_Get(VOID)
+{
+ return _LocaleList;
+}
Propchange: trunk/reactos/dll/cpl/input_new/locale_list.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/cpl/input_new/locale_list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/locale_l…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/locale_list.h (added)
+++ trunk/reactos/dll/cpl/input_new/locale_list.h [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "input.h"
+
+typedef struct _LOCALE_LIST_NODE
+{
+ WCHAR *pszName;
+ WCHAR *pszIndicator;
+ DWORD dwId;
+ struct _LOCALE_LIST_NODE *pPrev;
+ struct _LOCALE_LIST_NODE *pNext;
+} LOCALE_LIST_NODE;
+
+LOCALE_LIST_NODE*
+LocaleList_Create(VOID);
+
+VOID
+LocaleList_Destroy(VOID);
+
+LOCALE_LIST_NODE*
+LocaleList_Get(VOID);
Propchange: trunk/reactos/dll/cpl/input_new/locale_list.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/cpl/input_new/settings_page.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input_new/settings…
==============================================================================
--- trunk/reactos/dll/cpl/input_new/settings_page.c (added)
+++ trunk/reactos/dll/cpl/input_new/settings_page.c [iso-8859-1] Sun Aug 7 23:28:50 2016
@@ -0,0 +1,233 @@
+/*
+ * PROJECT: input.dll
+ * FILE: dll/cpl/input/settings_page.c
+ * PURPOSE: input.dll
+ * PROGRAMMER: Dmitry Chapyshev (dmitry(a)reactos.org)
+ */
+
+#include "input.h"
+#include "layout_list.h"
+#include "locale_list.h"
+
+
+static HICON
+CreateLayoutIcon(LPWSTR szLayout)
+{
+ HDC hdc, hdcsrc;
+ HBITMAP hBitmap, hBmpNew, hBmpOld;
+ RECT rect;
+ HFONT hFont = NULL;
+ ICONINFO IconInfo;
+ HICON hIcon = NULL;
+
+ hdcsrc = GetDC(NULL);
+ hdc = CreateCompatibleDC(hdcsrc);
+ hBitmap = CreateCompatibleBitmap(hdcsrc,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON));
+ ReleaseDC(NULL, hdcsrc);
+
+ if (hdc && hBitmap)
+ {
+ hBmpNew = CreateBitmap(GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ 1, 1, NULL);
+ if (hBmpNew)
+ {
+ hBmpOld = SelectObject(hdc, hBitmap);
+ rect.right = GetSystemMetrics(SM_CXSMICON);
+ rect.left = 0;
+ rect.bottom = GetSystemMetrics(SM_CYSMICON);
+ rect.top = 0;
+
+ SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
+ SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+
+ ExtTextOut(hdc, rect.left, rect.top, ETO_OPAQUE, &rect, L"", 0,
NULL);
+
+ hFont = CreateFont(-11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET,
+ OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY, FF_DONTCARE, L"Tahoma");
+
+ SelectObject(hdc, hFont);
+ DrawText(hdc, szLayout, 2, &rect, DT_SINGLELINE|DT_CENTER|DT_VCENTER);
+ SelectObject(hdc, hBmpNew);
+
+ PatBlt(hdc, 0, 0,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ BLACKNESS);
+
+ SelectObject(hdc, hBmpOld);
+
+ IconInfo.hbmColor = hBitmap;
+ IconInfo.hbmMask = hBmpNew;
+ IconInfo.fIcon = TRUE;
+
+ hIcon = CreateIconIndirect(&IconInfo);
+
+ DeleteObject(hBmpNew);
+ DeleteObject(hBmpOld);
+ DeleteObject(hFont);
+ }
+ }
+
+ DeleteDC(hdc);
+ DeleteObject(hBitmap);
+
+ return hIcon;
+}
+
+
+static VOID
+AddToLayoutListView(HWND hwndList,
+ WCHAR *pszLanguageName,
+ WCHAR *pszLayoutName,
+ WCHAR *pszIndicatorTitle)
+{
+ INT ItemIndex = -1;
+ INT ImageIndex = -1;
+ LV_ITEM item;
+ HIMAGELIST hImageList;
+
+ hImageList = ListView_GetImageList(hwndList, LVSIL_SMALL);
+ if (hImageList != NULL)
+ {
+ HICON hLayoutIcon;
+
+ hLayoutIcon = CreateLayoutIcon(pszIndicatorTitle);
+ if (hLayoutIcon != NULL)
+ {
+ ImageIndex = ImageList_AddIcon(hImageList, hLayoutIcon);
+ DestroyIcon(hLayoutIcon);
+ }
+ }
+
+ memset(&item, 0, sizeof(LV_ITEM));
+
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
+ item.pszText = pszLanguageName;
+ item.iItem = -1;
+ item.lParam = (LPARAM)NULL;
+ item.iImage = ImageIndex;
+
+ ItemIndex = ListView_InsertItem(hwndList, &item);
+
+ ListView_SetItemText(hwndList, ItemIndex, 1, pszLayoutName);
+}
+
+
+static VOID
+OnInitSettingsPage(HWND hwndDlg)
+{
+ WCHAR szBuffer[MAX_STR_LEN];
+ LV_COLUMN column;
+ HWND hLayoutList;
+ HIMAGELIST hLayoutImageList;
+ INT iLayoutCount;
+ HKL *pActiveLayoutList;
+
+ hLayoutList = GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST);
+
+ ListView_SetExtendedListViewStyle(hLayoutList, LVS_EX_FULLROWSELECT);
+
+ memset(&column, 0, sizeof(LV_COLUMN));
+
+ column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
+
+ LoadString(hApplet, IDS_LANGUAGE, szBuffer, ARRAYSIZE(szBuffer));
+ column.fmt = LVCFMT_LEFT;
+ column.iSubItem = 0;
+ column.pszText = szBuffer;
+ column.cx = 175;
+ ListView_InsertColumn(hLayoutList, 0, &column);
+
+ LoadString(hApplet, IDS_LAYOUT, szBuffer, ARRAYSIZE(szBuffer));
+ column.fmt = LVCFMT_RIGHT;
+ column.cx = 155;
+ column.iSubItem = 1;
+ column.pszText = szBuffer;
+ ListView_InsertColumn(hLayoutList, 1, &column);
+
+ hLayoutImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ ILC_COLOR8 | ILC_MASK, 0, 0);
+ if (hLayoutImageList != NULL)
+ {
+ ListView_SetImageList(hLayoutList, hLayoutImageList, LVSIL_SMALL);
+ }
+
+ LayoutList_Create();
+ LocaleList_Create();
+
+ iLayoutCount = GetKeyboardLayoutList(0, NULL);
+ pActiveLayoutList = (HKL*) malloc(iLayoutCount * sizeof(HKL));
+ if (pActiveLayoutList != NULL)
+ {
+ if (GetKeyboardLayoutList(iLayoutCount, pActiveLayoutList) > 0)
+ {
+ INT iIndex;
+
+ for (iIndex = 0; iIndex < iLayoutCount; iIndex++)
+ {
+ LOCALE_LIST_NODE *CurrentLocale;
+
+ for (CurrentLocale = LocaleList_Get();
+ CurrentLocale != NULL;
+ CurrentLocale = CurrentLocale->pNext)
+ {
+ if (LOWORD(CurrentLocale->dwId) ==
LOWORD(pActiveLayoutList[iIndex]))
+ {
+ AddToLayoutListView(hLayoutList,
+ CurrentLocale->pszName,
+
LayoutList_GetNameByHkl(pActiveLayoutList[iIndex]),
+ CurrentLocale->pszIndicator);
+ }
+ }
+ }
+ }
+
+ free(pActiveLayoutList);
+ }
+}
+
+
+static VOID
+OnDestroySettingsPage(HWND hwndDlg)
+{
+ HIMAGELIST hImageList;
+
+ LayoutList_Destroy();
+ LocaleList_Destroy();
+
+ hImageList = ListView_GetImageList(GetDlgItem(hwndDlg, IDC_KEYLAYOUT_LIST),
+ LVSIL_SMALL);
+ if (hImageList != NULL)
+ {
+ ImageList_Destroy(hImageList);
+ }
+}
+
+
+INT_PTR CALLBACK
+SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ OnInitSettingsPage(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ OnDestroySettingsPage(hwndDlg);
+ break;
+
+ case WM_COMMAND:
+ {
+
+ }
+ break;
+ }
+
+ return FALSE;
+}
Propchange: trunk/reactos/dll/cpl/input_new/settings_page.c
------------------------------------------------------------------------------
svn:eol-style = native