X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=xkeymacs%2Fpropertiesbasic.cpp;h=db8b994ccddc148c12dbdb0452515b7b5c86dc8c;hb=1c05e004f9ffe69ef9f63aa9138b3904b5a5e3fc;hp=46cc8ad78120ba6249035810f3e732cbab9ca0ce;hpb=41f31d955009c1a7d2906092d17171d1344e5449;p=xkeymacs%2Fxkeymacs.git diff --git a/xkeymacs/propertiesbasic.cpp b/xkeymacs/propertiesbasic.cpp index 46cc8ad..db8b994 100644 --- a/xkeymacs/propertiesbasic.cpp +++ b/xkeymacs/propertiesbasic.cpp @@ -117,22 +117,22 @@ END_MESSAGE_MAP() BOOL CPropertiesBasic::OnSetActive() { m_pProperties->EnableControl(BASIC_TAB); - SetDialogData(m_pProperties->GetCurrentApplication()); + SetDialogData(); return CPropertyPage::OnSetActive(); } void CPropertiesBasic::SetAllDialogData(UINT nCheck, BOOL bChanged) { - for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) { - CString szCommandName = CCommands::GetCommandName(nCommandID); + for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) { + CString szCommandName = CCommands::GetCommandName(nComID); if (szCommandName.IsEmpty()) { break; } for (int i = 0; ; ++i) { - int nKey = CCommands::GetDefaultCommandKey(nCommandID, i); - int nControlID = CCommands::GetDefaultControlID(nCommandID, i); + int nKey = CCommands::GetDefaultCommandKey(nComID, i); + int nControlID = CCommands::GetDefaultControlID(nComID, i); if (nKey == 0) { break; } @@ -144,86 +144,25 @@ void CPropertiesBasic::SetAllDialogData(UINT nCheck, BOOL bChanged) InitChanged(bChanged); } -void CPropertiesBasic::SetDialogData(CString szApplicationName) +void CPropertiesBasic::SetDialogData() { - UpdateDialogData(szApplicationName, FALSE); -} - -void CPropertiesBasic::UpdateDialogData(CString szApplicationName, BOOL bSaveAndValidate) -{ - if (bSaveAndValidate) { // GetDialogData - UpdateData(); - } - - if (m_pProperties->GetApplicationID() == MAX_APP) { - if (!bSaveAndValidate) { - SetAllDialogData(1, FALSE); // FIXME - } + SetAllDialogData(1, FALSE); + CheckDlgButton(IDC_CO2, BST_CHECKED); + const int nAppID = m_pProperties->GetApplicationID(); + if (nAppID == MAX_APP) return; - } - - // on/off - if (!bSaveAndValidate) { // SetDialogData - SetAllDialogData(1, FALSE); - CheckDlgButton(IDC_CO2, BST_CHECKED); - } - for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) { - CString szCommandName = CCommands::GetCommandName(nCommandID); - if (szCommandName.IsEmpty()) { - break; - } - - for (int i = 0; ; ++i) { - int nCommandType = CCommands::GetDefaultCommandType(nCommandID, i); - int nKey = CCommands::GetDefaultCommandKey(nCommandID, i); - int nControlID = CCommands::GetDefaultControlID(nCommandID, i); - if (nKey == 0) { - break; - } - if (bSaveAndValidate) { // GetDialogData - if (nControlID == IDC_CO2) { - continue; - } - if (!m_bChanged[nCommandID]) { - continue; - } - if (IsDlgButtonChecked(nControlID)) { - CProfile::SetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey, nCommandID); - CDotXkeymacs::RemoveKey(m_pProperties->GetApplicationID(), nCommandType, nKey); - } else { - CProfile::SetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey, 0); - } - } else { // SetDialogData - if (nCommandID != CProfile::GetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey)) { - CheckDlgButton(nControlID, BST_UNCHECKED); - } - } + for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) { + const LPCSTR szComName = CCommands::GetCommandName(nComID); + if (!szComName[0]) + return; + for (int i = 0; const int nKey = CCommands::GetDefaultCommandKey(nComID, i); ++i) { + const int nType = CCommands::GetDefaultCommandType(nComID, i); + const int nControlID = CCommands::GetDefaultControlID(nComID, i); + if (nComID != CProfile::GetCommandID(nAppID, nType, nKey)) + CheckDlgButton(nControlID, BST_UNCHECKED); } } - // only for Toggle Imput Method Editor C-o: Canna mode - if (bSaveAndValidate) { // GetDialogData - int nCommandType = CONTROL; - int nKey = 'O'; - if (CProfile::GetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey) == 0) { - if (IsDlgButtonChecked(IDC_CO2)) { - for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) { - CString szCommandName = CCommands::GetCommandName(nCommandID); - if (szCommandName.IsEmpty()) { - break; - } - if (!szCommandName.CompareNoCase(_T("toggle-input-method"))) { - CProfile::SetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey, nCommandID); - CProfile::SetCommandID(m_pProperties->GetApplicationID(), CONTROL+SHIFT, nKey, nCommandID); - break; - } - } - } - } - } - - if (!bSaveAndValidate) { // SetDialogData - UpdateData(FALSE); - } + UpdateData(FALSE); } void CPropertiesBasic::InitChanged(BOOL bChanged) @@ -247,7 +186,26 @@ int CPropertiesBasic::OnCreate(LPCREATESTRUCT lpCreateStruct) void CPropertiesBasic::GetDialogData() { - UpdateDialogData(m_pProperties->GetCurrentApplication(), TRUE); + UpdateData(); + const int nAppID = m_pProperties->GetApplicationID(); + if (nAppID == MAX_APP) + return; + for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) { + const LPCSTR szComName = CCommands::GetCommandName(nComID); + if (!szComName[0]) + return; + for (int i = 0; const int nKey = CCommands::GetDefaultCommandKey(nComID, i); ++i) { + const int nType = CCommands::GetDefaultCommandType(nComID, i); + const int nControlID = CCommands::GetDefaultControlID(nComID, i); + if (!m_bChanged[nComID]) + continue; + if (IsDlgButtonChecked(nControlID)) { + CProfile::SetCommandID(nAppID, nType, nKey, nComID); + CDotXkeymacs::RemoveKey(nAppID, nType, nKey); + } else if (nControlID != IDC_CO2) + CProfile::SetCommandID(nAppID, nType, nKey, 0); + } + } } void CPropertiesBasic::OnAlt() @@ -565,22 +523,22 @@ void CPropertiesBasic::OnSquareBra() void CPropertiesBasic::Changed(int nObjectID) { - for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) { - CString szCommandName = CCommands::GetCommandName(nCommandID); + for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) { + CString szCommandName = CCommands::GetCommandName(nComID); if (szCommandName.IsEmpty()) { break; } for (int i = 0; ; ++i) { - if (CCommands::GetDefaultCommandKey(nCommandID, i) == 0) { + if (CCommands::GetDefaultCommandKey(nComID, i) == 0) { break; } - int nControlID = CCommands::GetDefaultControlID(nCommandID, i); + int nControlID = CCommands::GetDefaultControlID(nComID, i); if ((nControlID == nObjectID) || ((nObjectID == IDC_CO) && (nControlID == IDC_CO2)) || ((nObjectID == IDC_CO2) && (nControlID == IDC_CO))) { - m_bChanged[nCommandID] = TRUE; + m_bChanged[nComID] = TRUE; } } } @@ -597,15 +555,15 @@ void CPropertiesBasic::EnableControl() { BOOL bEnable = m_pProperties->IsEnableControl(); - for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) { - CString szCommandName = CCommands::GetCommandName(nCommandID); + for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) { + CString szCommandName = CCommands::GetCommandName(nComID); if (szCommandName.IsEmpty()) { break; } for (int i = 0; ; ++i) { - int nKey = CCommands::GetDefaultCommandKey(nCommandID, i); - int nControlID = CCommands::GetDefaultControlID(nCommandID, i); + int nKey = CCommands::GetDefaultCommandKey(nComID, i); + int nControlID = CCommands::GetDefaultControlID(nComID, i); if (nKey == 0) { break; } @@ -628,20 +586,20 @@ BOOL CPropertiesBasic::OnInitDialog() CPropertyPage::OnInitDialog(); if (m_ToolTip.Create(this)) { - for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) { - CString szCommandName = CCommands::GetCommandName(nCommandID); + for (int nComID = 0; nComID < MAX_COMMAND; ++nComID) { + CString szCommandName = CCommands::GetCommandName(nComID); if (szCommandName.IsEmpty()) { break; } for (int i = 0; ; ++i) { - int nKey = CCommands::GetDefaultCommandKey(nCommandID, i); - int nControlID = CCommands::GetDefaultControlID(nCommandID, i); + int nKey = CCommands::GetDefaultCommandKey(nComID, i); + int nControlID = CCommands::GetDefaultControlID(nComID, i); if (nKey == 0) { break; } if (GetDlgItem(nControlID)) { - m_ToolTip.AddTool(GetDlgItem(nControlID), CString(MAKEINTRESOURCE(CCommands::GetToolTipID(nCommandID)))); + m_ToolTip.AddTool(GetDlgItem(nControlID), CString(MAKEINTRESOURCE(CCommands::GetToolTipID(nComID)))); } } }