#include "Profile.h"\r
#include "MainFrm.h"\r
#include "DotXkeymacs.h"\r
-#include <Imm.h>\r
+#include "imelist.h"\r
#include <Shlwapi.h>\r
#include <TlHelp32.h>\r
-#include <vector>\r
\r
#ifdef _DEBUG\r
#undef THIS_FILE\r
TASK_LIST CProfile::m_TaskList[MAX_TASKS];\r
DWORD CProfile::m_dwTasks;\r
\r
-enum { INITIAL_SIZE = 51200 };\r
-enum { EXTEND_SIZE = 25600 };\r
-\r
-void CProfile::Item2AppName(CString *const sz)\r
-{\r
- if (IsTheString(*sz, IDS_DEFAULT_TITLE)) {\r
- sz->LoadString(IDS_DEFAULT);\r
- }\r
-\r
- if (IsTheString(*sz, IDS_DIALOG_TITLE)) {\r
- sz->LoadString(IDS_DIALOG);\r
- }\r
-\r
- int nStart, nEnd, nCount;\r
-\r
- nStart = sz->ReverseFind(_T('(')) + 1;\r
- nEnd = sz->Find(_T(')'), nStart) - 1;\r
- nCount = (nEnd + 1) - nStart;\r
- *sz = sz->Mid(nStart, nCount);\r
-}\r
-\r
-int CProfile::IsNotSameString(CComboBox *const pApplication, const CString szListItem)\r
-{\r
- CString szItem, szList;\r
- szList = szListItem;\r
- Item2AppName(&szList);\r
-\r
- for (int i = 0; i < pApplication->GetCount(); ++i) {\r
- pApplication->GetLBText(i, szItem);\r
- Item2AppName(&szItem);\r
- if (!_tcsicmp(szItem, szList)) {\r
- return 0;\r
- }\r
- }\r
-\r
- return 1;\r
-}\r
-\r
// This function returns the nth string in a window name separated by " - ".\r
// If there aren't a sufficient number of strings, it returns the last string\r
// appropriate for the title.\r
\r
BOOL CALLBACK CProfile::EnumWindowsProc(const HWND hWnd, const LPARAM lParam)\r
{\r
- CComboBox *pApplication = (CComboBox*)lParam;\r
- PTASK_LIST pTask = CProfile::m_TaskList;\r
+ CProperties *pProperties = reinterpret_cast<CProperties*>(lParam);\r
+ PTASK_LIST pTask = CProfile::m_TaskList;\r
\r
TCHAR szWindowName[WINDOW_TEXT_LENGTH];\r
TCHAR szClassName[CLASS_NAME_LENGTH];\r
}\r
}\r
\r
- \r
- if ((IsWindowVisible(hWnd)) // Is visible?\r
- && (GetWindow(hWnd, GW_OWNER) == NULL) // Is top level window?\r
- && (lstrlen(szWindowName) > 0) // Have caption?\r
- && (pApplication->FindString(-1, szClassName) == CB_ERR)) {// Is not same string?\r
- CString szListItem;\r
- szListItem.Format(IDS_APPLICATION_LIST_ITEM, appTitle, pTask[i].ProcessName);\r
- if (IsNotSameString(pApplication, szListItem)) {\r
- pApplication->AddString(szListItem);\r
- }\r
+ if (IsWindowVisible(hWnd) && // Is visible?\r
+ GetWindow(hWnd, GW_OWNER) == NULL && // Is top level window?\r
+ lstrlen(szWindowName) > 0) { // Have caption?\r
+ pProperties->AddItem(appTitle, pTask[i].ProcessName);\r
}\r
return TRUE;\r
}\r
_tcsncpy_s(m_Config.szWindowText[nAppID], AfxGetApp()->GetProfileString(appName, entry, _T("*")), _TRUNCATE);\r
\r
const CString regApp = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName;\r
- for (int nComID = 1; nComID < MAX_COMMAND; ++nComID) {\r
+ for (BYTE nComID = 1; nComID < MAX_COMMAND; ++nComID) {\r
entry = CCommands::GetCommandName(nComID);\r
HKEY hKey;\r
const CString regKey = regApp + _T("\\") + entry;\r
}\r
\r
entry.LoadString(IDS_REG_ENTRY_KILL_RING_MAX);\r
- m_Config.nKillRingMax[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
+ int n = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
+ m_Config.nKillRingMax[nAppID] = static_cast<BYTE>(n > 255 ? 255 : n);\r
entry.LoadString(IDS_REG_ENTRY_USE_DIALOG_SETTING);\r
- m_Config.bUseDialogSetting[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 1);\r
+ m_Config.bUseDialogSetting[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 1));\r
entry.LoadString(IDS_REG_ENTRY_DISABLE_XKEYMACS);\r
- m_Config.nSettingStyle[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC;\r
+ m_Config.nSettingStyle[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0) ? SETTING_DISABLE : SETTING_SPECIFIC);\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_META_CTRL);\r
- m_Config.bIgnoreUndefinedMetaCtrl[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.bIgnoreUndefinedMetaCtrl[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
entry.LoadString(IDC_REG_ENTRY_IGNORE_C_X);\r
- m_Config.bIgnoreUndefinedC_x[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.bIgnoreUndefinedC_x[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
entry.LoadString(IDC_REG_ENTRY_ENABLE_CUA);\r
- m_Config.bEnableCUA[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.bEnableCUA[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
entry.LoadString(IDS_REG_ENTRY_326_COMPATIBLE);\r
- m_Config.b326Compatible[nAppID] = AfxGetApp()->GetProfileInt(appName, entry, 0);\r
+ m_Config.b326Compatible[nAppID] = static_cast<BYTE>(AfxGetApp()->GetProfileInt(appName, entry, 0));\r
}\r
}\r
\r
for (int nKey = 0; nKey < MAX_KEY; ++nKey)\r
if ((nType & CONTROLX) && m_Config.nCommandID[nAppID][nType][nKey])\r
m_Config.nCommandID[nAppID][CONTROL]['X'] = 1; // C-x is available.\r
- for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
+ for (BYTE nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID)\r
for (int nKeyID = 0; nKeyID < CDotXkeymacs::GetKeyNumber(nFuncID, nAppID); ++nKeyID) {\r
int nType, nKey;\r
CDotXkeymacs::GetKey(nFuncID, nAppID, nKeyID, &nType, &nKey);\r
m_Config.nCommandID[nAppID][CONTROL]['X'] = 1; // C-x is available.\r
}\r
}\r
- m_Config.b106Keyboard = Is106Keyboard();\r
+ m_Config.b106Keyboard = static_cast<BYTE>(Is106Keyboard());\r
CXkeymacsDll::SetConfig(m_Config);\r
CXkeymacsApp *pApp = static_cast<CXkeymacsApp *>(AfxGetApp());\r
if (!pApp->IsWow64())\r
return nSavedSetting;\r
}\r
\r
-void CProfile::InitApplicationList(CComboBox *const cApplicationList)\r
+void CProfile::InitAppList(CProperties& cProperties)\r
{\r
- cApplicationList->ResetContent();\r
-\r
GetTaskList();\r
\r
- EnumWindows(EnumWindowsProc, (LPARAM)cApplicationList);\r
+ EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&cProperties));\r
\r
- CString szListItem;\r
for (int i = 0; i < MAX_APP; ++i) {\r
const LPCTSTR szAppName = m_Config.szSpecialApp[i];\r
const LPCTSTR szAppTitle = m_szAppTitle[i];\r
if (!szAppName[0] || !_tcscmp(szAppName, _T("IME")))\r
continue;\r
- szListItem.Format(IDS_APPLICATION_LIST_ITEM, szAppTitle, szAppName);\r
- if (IsNotSameString(cApplicationList, szListItem) &&\r
- !IsDefault(szAppName) && !IsDialog(szAppName))\r
- cApplicationList->AddString(szListItem);\r
+ if (CString(MAKEINTRESOURCE(IDS_DEFAULT)) == szAppName ||\r
+ CString(MAKEINTRESOURCE(IDS_DIALOG)) == szAppName)\r
+ continue;\r
+ cProperties.AddItem(szAppTitle, szAppName);\r
}\r
-\r
- AddIMEInfo(cApplicationList);\r
-\r
- // Add Dialog\r
- cApplicationList->InsertString(0, CString(MAKEINTRESOURCE(IDS_DIALOG_TITLE)));\r
-\r
- // Add Default\r
- cApplicationList->InsertString( 0, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
- cApplicationList->SelectString(-1, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE)));\r
+ AddIMEInfo(cProperties);\r
}\r
\r
-void CProfile::AddIMEInfo(CComboBox *cApplicationList)\r
+void CProfile::AddIMEInfo(CProperties& cProperties)\r
{\r
- const UINT n = GetKeyboardLayoutList(0, NULL);\r
- if (!n)\r
- return;\r
- std::vector<HKL> hkls(n);\r
- GetKeyboardLayoutList(n, &hkls[0]);\r
- TCHAR szFileName[MAX_PATH];\r
- TCHAR szDescription[WINDOW_TEXT_LENGTH];\r
- for (std::vector<HKL>::const_iterator p = hkls.begin(); p != hkls.end(); ++p)\r
- if (ImmGetDescription(*p, szDescription, WINDOW_TEXT_LENGTH) &&\r
- ImmGetIMEFileName(*p, szFileName, MAX_PATH)) {\r
- CString item;\r
- item.Format(IDS_APPLICATION_LIST_ITEM, szDescription, szFileName);\r
- if (IsNotSameString(cApplicationList, item))\r
- cApplicationList->AddString(item);\r
- }\r
+ IMEList imeList;\r
+ for (IMEListIterator p = imeList.begin(); p != imeList.end(); ++p)\r
+ cProperties.AddItem(p->szDescription, p->szFileName);\r
}\r
\r
void CProfile::GetTaskList()\r
{\r
if (nAppID == MAX_APP)\r
return;\r
- m_Config.nSettingStyle[nAppID] = nSettingStyle;\r
+ m_Config.nSettingStyle[nAppID] = static_cast<BYTE>(nSettingStyle);\r
}\r
\r
BOOL CProfile::Is106Keyboard()\r
return keyboard == JAPANESE_KEYBOARD;\r
}\r
\r
-BOOL CProfile::IsTheString(const CString sz, const UINT nID)\r
+void CProfile::SetAppTitle(const int nAppID, const CString& appTitle)\r
{\r
- return sz == CString(MAKEINTRESOURCE(nID));\r
-}\r
-\r
-// if sz is "Default", return TRUE\r
-BOOL CProfile::IsDefault(const CString sz)\r
-{\r
- return IsTheString(sz, IDS_DEFAULT);\r
-}\r
-\r
-// if sz is "Dialog", return TRUE\r
-BOOL CProfile::IsDialog(const CString sz)\r
-{\r
- return IsTheString(sz, IDS_DIALOG);\r
-}\r
-\r
-void CProfile::GetApplicationTitle(CComboBox *const cApplicationList, CString &rList, const int nIndex)\r
-{\r
- if (0 <= nIndex) {\r
- cApplicationList->GetLBText(nIndex, rList);\r
- } else {\r
- cApplicationList->GetWindowText(rList);\r
- }\r
-\r
- if (IsTheString(rList, IDS_DEFAULT_TITLE)) {\r
- rList.LoadString(IDS_DEFAULT);\r
- }\r
-\r
- if (IsTheString(rList, IDS_DIALOG_TITLE)) {\r
- rList.LoadString(IDS_DIALOG);\r
- }\r
-\r
- return;\r
-}\r
-\r
-void CProfile::UpdateApplicationTitle(CComboBox *const cApplicationList, const CString szCurrentApplication, const int nAppID, const BOOL bSaveAndValidate)\r
-{\r
- static CString szApplicationTitle;\r
- if (bSaveAndValidate) { // GetDialogData\r
- if (!CProfile::IsDefault(szCurrentApplication))\r
- _tcsncpy_s(m_szAppTitle[nAppID], szApplicationTitle, _TRUNCATE);\r
- szApplicationTitle.Empty();\r
- } else { // SetDialogData\r
- CString szListItem;\r
- CProfile::GetApplicationTitle(cApplicationList, szListItem);\r
- const int nEndTitle = szListItem.ReverseFind(_T('('));\r
- if (nEndTitle > 0)\r
- szApplicationTitle = szListItem.Left(nEndTitle);\r
- }\r
+ _tcsncpy_s(m_szAppTitle[nAppID], appTitle, _TRUNCATE);\r
}\r
\r
void CProfile::SetCommandID(const int nAppID, const int nType, const int nKey, int nComID)\r
for (nComID = 1; nComID < MAX_COMMAND; ++nComID)\r
if (Commands[nComID].fCommand == CCommands::C_Eisu)\r
break;\r
- m_Config.nCommandID[nAppID][nType][nKey] = nComID;\r
+ m_Config.nCommandID[nAppID][nType][nKey] = static_cast<BYTE>(nComID);\r
}\r
\r
int CProfile::GetCommandID(const int nAppID, const int nType, const int nKey)\r
\r
void CProfile::SetKillRingMax(const int nAppID, const int nKillRingMax)\r
{\r
- m_Config.nKillRingMax[nAppID] = nKillRingMax;\r
+ m_Config.nKillRingMax[nAppID] = static_cast<BYTE>(nKillRingMax > 255 ? 255 : nKillRingMax);\r
}\r
\r
int CProfile::GetKillRingMax(const int nAppID)\r
\r
void CProfile::SetUseDialogSetting(const int nAppID, const BOOL bUseDialogSetting)\r
{\r
- m_Config.bUseDialogSetting[nAppID] = bUseDialogSetting;\r
+ m_Config.bUseDialogSetting[nAppID] = static_cast<BYTE>(bUseDialogSetting);\r
}\r
\r
BOOL CProfile::GetUseDialogSetting(const int nAppID)\r
}\r
}\r
\r
-int CProfile::GetCurrentApplicationID(CComboBox *const cApplicationList, const CString szCurrentApplication)\r
-{\r
- int nCounter = cApplicationList->GetCount();\r
- CString szListItem;\r
- int nCurSel = cApplicationList->GetCurSel();\r
-\r
- for (int i = 0; i < nCounter; ++i) {\r
- cApplicationList->SetCurSel(i);\r
- CProfile::GetApplicationTitle(cApplicationList, szListItem);\r
- if (szListItem.Find(szCurrentApplication) != -1) {\r
- cApplicationList->SetCurSel(nCurSel);\r
- return i;\r
- }\r
- }\r
- return -1;\r
-}\r
-\r
void CProfile::CopyData(const CString szDstApp, const CString szSrcApp)\r
{\r
const int nDstApp = AssignAppID(szDstApp);\r
\r
void CProfile::SetEnableCUA(const int nAppID, const BOOL bEnableCUA)\r
{\r
- m_Config.bEnableCUA[nAppID] = bEnableCUA;\r
+ m_Config.bEnableCUA[nAppID] = static_cast<BYTE>(bEnableCUA);\r
}\r
\r
int CProfile::GetKeyboardSpeed()\r