OSDN Git Service

Ignore inactive IMEs.
[xkeymacs/xkeymacs.git] / xkeymacs / propertiesbasic.cpp
index 9e1c9f6..db8b994 100644 (file)
@@ -146,84 +146,23 @@ void CPropertiesBasic::SetAllDialogData(UINT nCheck, BOOL bChanged)
 \r
 void CPropertiesBasic::SetDialogData()\r
 {\r
-       UpdateDialogData(FALSE);\r
-}\r
-\r
-void CPropertiesBasic::UpdateDialogData(BOOL bSaveAndValidate)\r
-{\r
-       if (bSaveAndValidate) { // GetDialogData\r
-               UpdateData();\r
-       }\r
-\r
-       if (m_pProperties->GetApplicationID() == MAX_APP) {\r
-               if (!bSaveAndValidate) {\r
-                       SetAllDialogData(1, FALSE);     // FIXME\r
-               }\r
+       SetAllDialogData(1, FALSE);\r
+       CheckDlgButton(IDC_CO2, BST_CHECKED);\r
+       const int nAppID = m_pProperties->GetApplicationID();\r
+       if (nAppID == MAX_APP)\r
                return;\r
-       }\r
-\r
-       // on/off\r
-       if (!bSaveAndValidate) {        // SetDialogData\r
-               SetAllDialogData(1, FALSE);\r
-               CheckDlgButton(IDC_CO2, BST_CHECKED);\r
-       }\r
        for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) {\r
-               CString szCommandName = CCommands::GetCommandName(nComID);\r
-               if (szCommandName.IsEmpty()) {\r
-                       break;\r
-               }\r
-\r
-               for (int i = 0; ; ++i) {\r
-                       int nType = CCommands::GetDefaultCommandType(nComID, i);\r
-                       int nKey = CCommands::GetDefaultCommandKey(nComID, i);\r
-                       int nControlID = CCommands::GetDefaultControlID(nComID, i);\r
-                       if (nKey == 0) {\r
-                               break;\r
-                       }\r
-                       if (bSaveAndValidate) { // GetDialogData\r
-                               if (nControlID == IDC_CO2) {\r
-                                       continue;\r
-                               }\r
-                               if (!m_bChanged[nComID]) {\r
-                                       continue;\r
-                               }\r
-                               if (IsDlgButtonChecked(nControlID)) {\r
-                                       CProfile::SetCommandID(m_pProperties->GetApplicationID(), nType, nKey, nComID);\r
-                                       CDotXkeymacs::RemoveKey(m_pProperties->GetApplicationID(), nType, nKey);\r
-                               } else {\r
-                                       CProfile::SetCommandID(m_pProperties->GetApplicationID(), nType, nKey, 0);\r
-                               }\r
-                       } else {                                // SetDialogData\r
-                               if (nComID != CProfile::GetCommandID(m_pProperties->GetApplicationID(), nType, nKey)) {\r
-                                       CheckDlgButton(nControlID, BST_UNCHECKED);\r
-                               }\r
-                       }\r
+               const LPCSTR szComName = CCommands::GetCommandName(nComID);\r
+               if (!szComName[0])\r
+                       return;\r
+               for (int i = 0; const int nKey = CCommands::GetDefaultCommandKey(nComID, i); ++i) {\r
+                       const int nType = CCommands::GetDefaultCommandType(nComID, i);\r
+                       const int nControlID = CCommands::GetDefaultControlID(nComID, i);\r
+                       if (nComID != CProfile::GetCommandID(nAppID, nType, nKey))\r
+                               CheckDlgButton(nControlID, BST_UNCHECKED);\r
                }\r
        }\r
-       // only for Toggle Imput Method Editor C-o: Canna mode\r
-       if (bSaveAndValidate) { // GetDialogData\r
-               int nType = CONTROL;\r
-               int nKey = 'O';\r
-               if (CProfile::GetCommandID(m_pProperties->GetApplicationID(), nType, nKey) == 0) {\r
-                       if (IsDlgButtonChecked(IDC_CO2)) {\r
-                               for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) {\r
-                                       CString szCommandName = CCommands::GetCommandName(nComID);\r
-                                       if (szCommandName.IsEmpty()) {\r
-                                               break;\r
-                                       }\r
-                                       if (!szCommandName.CompareNoCase(_T("toggle-input-method"))) {\r
-                                               CProfile::SetCommandID(m_pProperties->GetApplicationID(), nType, nKey, nComID);\r
-                                               CProfile::SetCommandID(m_pProperties->GetApplicationID(), CONTROL+SHIFT, nKey, nComID);\r
-                                               break;\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       if (!bSaveAndValidate) {        // SetDialogData\r
-               UpdateData(FALSE);\r
-       }\r
+       UpdateData(FALSE);\r
 }\r
 \r
 void CPropertiesBasic::InitChanged(BOOL bChanged)\r
@@ -247,7 +186,26 @@ int CPropertiesBasic::OnCreate(LPCREATESTRUCT lpCreateStruct)
 \r
 void CPropertiesBasic::GetDialogData()\r
 {\r
-       UpdateDialogData(TRUE);\r
+       UpdateData();\r
+       const int nAppID = m_pProperties->GetApplicationID();\r
+       if (nAppID == MAX_APP)\r
+               return;\r
+       for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) {\r
+               const LPCSTR szComName = CCommands::GetCommandName(nComID);\r
+               if (!szComName[0])\r
+                       return;\r
+               for (int i = 0; const int nKey = CCommands::GetDefaultCommandKey(nComID, i); ++i) {\r
+                       const int nType = CCommands::GetDefaultCommandType(nComID, i);\r
+                       const int nControlID = CCommands::GetDefaultControlID(nComID, i);\r
+                       if (!m_bChanged[nComID])\r
+                               continue;\r
+                       if (IsDlgButtonChecked(nControlID)) {\r
+                               CProfile::SetCommandID(nAppID, nType, nKey, nComID);\r
+                               CDotXkeymacs::RemoveKey(nAppID, nType, nKey);\r
+                       } else if (nControlID != IDC_CO2)\r
+                               CProfile::SetCommandID(nAppID, nType, nKey, 0);\r
+               }\r
+       }\r
 }\r
 \r
 void CPropertiesBasic::OnAlt() \r