1 // PropertiesBasic.cpp : implementation file
\r
5 #include "xkeymacs.h"
\r
6 #include "DotXkeymacs.h"
\r
8 #include "Properties.h"
\r
9 #include "PropertiesBasic.h"
\r
12 #define new DEBUG_NEW
\r
14 static char THIS_FILE[] = __FILE__;
\r
17 /////////////////////////////////////////////////////////////////////////////
\r
18 // CPropertiesBasic property page
\r
20 IMPLEMENT_DYNCREATE(CPropertiesBasic, CPropertyPage)
\r
22 CPropertiesBasic::CPropertiesBasic() : CPropertyPage(CPropertiesBasic::IDD)
\r
24 //{{AFX_DATA_INIT(CPropertiesBasic)
\r
28 CPropertiesBasic::~CPropertiesBasic()
\r
32 void CPropertiesBasic::DoDataExchange(CDataExchange* pDX)
\r
34 CPropertyPage::DoDataExchange(pDX);
\r
35 //{{AFX_DATA_MAP(CPropertiesBasic)
\r
40 BEGIN_MESSAGE_MAP(CPropertiesBasic, CPropertyPage)
\r
41 //{{AFX_MSG_MAP(CPropertiesBasic)
\r
43 ON_BN_CLICKED(IDC_ALT, OnAlt)
\r
44 ON_BN_CLICKED(IDC_C_, OnC_)
\r
45 ON_BN_CLICKED(IDC_CA, OnCa)
\r
46 ON_BN_CLICKED(IDC_CB, OnCb)
\r
47 ON_BN_CLICKED(IDC_CBACKSLASH, OnCbackslash)
\r
48 ON_BN_CLICKED(IDC_CBACKSLASH_106, OnCbackslash106)
\r
49 ON_BN_CLICKED(IDC_CD, OnCd)
\r
50 ON_BN_CLICKED(IDC_CDIGIT, OnCdigit)
\r
51 ON_BN_CLICKED(IDC_CE, OnCe)
\r
52 ON_BN_CLICKED(IDC_CF, OnCf)
\r
53 ON_BN_CLICKED(IDC_CG, OnCg)
\r
54 ON_BN_CLICKED(IDC_CH, OnCh)
\r
55 ON_BN_CLICKED(IDC_CI, OnCi)
\r
56 ON_BN_CLICKED(IDC_CK, OnCk)
\r
57 ON_BN_CLICKED(IDC_CL, OnCl)
\r
58 ON_BN_CLICKED(IDC_CM, OnCm)
\r
59 ON_BN_CLICKED(IDC_CMS5, OnCms5)
\r
60 ON_BN_CLICKED(IDC_CN, OnCn)
\r
61 ON_BN_CLICKED(IDC_CO, OnCo)
\r
62 ON_BN_CLICKED(IDC_CO2, OnCo2)
\r
63 ON_BN_CLICKED(IDC_CP, OnCp)
\r
64 ON_BN_CLICKED(IDC_CQ, OnCq)
\r
65 ON_BN_CLICKED(IDC_CR, OnCr)
\r
66 ON_BN_CLICKED(IDC_CS, OnCs)
\r
67 ON_BN_CLICKED(IDC_CSLASH, OnCslash)
\r
68 ON_BN_CLICKED(IDC_CSPACE, OnCspace)
\r
69 ON_BN_CLICKED(IDC_CT, OnCt)
\r
70 ON_BN_CLICKED(IDC_CU, OnCu)
\r
71 ON_BN_CLICKED(IDC_CV, OnCv)
\r
72 ON_BN_CLICKED(IDC_CW, OnCw)
\r
73 ON_BN_CLICKED(IDC_CXB, OnCxb)
\r
74 ON_BN_CLICKED(IDC_CXCC, OnCxcc)
\r
75 ON_BN_CLICKED(IDC_CXCF, OnCxcf)
\r
76 ON_BN_CLICKED(IDC_CXCJ, OnCxcj)
\r
77 ON_BN_CLICKED(IDC_CXCP, OnCxcp)
\r
78 ON_BN_CLICKED(IDC_CXCS, OnCxcs)
\r
79 ON_BN_CLICKED(IDC_CXCT, OnCxct)
\r
80 ON_BN_CLICKED(IDC_CXCW, OnCxcw)
\r
81 ON_BN_CLICKED(IDC_CXE, OnCxe)
\r
82 ON_BN_CLICKED(IDC_CXH, OnCxh)
\r
83 ON_BN_CLICKED(IDC_CXK, OnCxk)
\r
84 ON_BN_CLICKED(IDC_CXS0, OnCxs0)
\r
85 ON_BN_CLICKED(IDC_CXS9, OnCxs9)
\r
86 ON_BN_CLICKED(IDC_CXU, OnCxu)
\r
87 ON_BN_CLICKED(IDC_CY, OnCy)
\r
88 ON_BN_CLICKED(IDC_CZ, OnCz)
\r
89 ON_BN_CLICKED(IDC_LEFT_ALT, OnLeftAlt)
\r
90 ON_BN_CLICKED(IDC_MB, OnMb)
\r
91 ON_BN_CLICKED(IDC_MD, OnMd)
\r
92 ON_BN_CLICKED(IDC_MF, OnMf)
\r
93 ON_BN_CLICKED(IDC_MI, OnMi)
\r
94 ON_BN_CLICKED(IDC_MS1, OnMs1)
\r
95 ON_BN_CLICKED(IDC_MS5, OnMs5)
\r
96 ON_BN_CLICKED(IDC_MSCOMMA, OnMscomma)
\r
97 ON_BN_CLICKED(IDC_MSPERIOD, OnMsperiod)
\r
98 ON_BN_CLICKED(IDC_MV, OnMv)
\r
99 ON_BN_CLICKED(IDC_MW, OnMw)
\r
100 ON_BN_CLICKED(IDC_MY, OnMy)
\r
101 ON_BN_CLICKED(IDC_RIGHT_ALT, OnRightAlt)
\r
102 ON_BN_CLICKED(IDC_ESCAPE, OnEscape)
\r
103 ON_BN_CLICKED(IDC_SQUARE_BRA, OnSquareBra)
\r
104 ON_BN_CLICKED(IDC_MDEL, OnMdel)
\r
105 ON_BN_CLICKED(IDC_MF12, OnMf12)
\r
106 ON_BN_CLICKED(IDC_MT, OnMt)
\r
107 ON_BN_CLICKED(IDC_MC, OnMc)
\r
108 ON_BN_CLICKED(IDC_ML, OnMl)
\r
109 ON_BN_CLICKED(IDC_MU, OnMu)
\r
110 ON_BN_CLICKED(IDC_MX, OnMx)
\r
114 /////////////////////////////////////////////////////////////////////////////
\r
115 // CPropertiesBasic message handlers
\r
117 BOOL CPropertiesBasic::OnSetActive()
\r
119 m_pProperties->EnableControl(BASIC_TAB);
\r
120 SetDialogData(m_pProperties->GetCurrentApplication());
\r
122 return CPropertyPage::OnSetActive();
\r
125 void CPropertiesBasic::SetAllDialogData(UINT nCheck, BOOL bChanged)
\r
127 for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {
\r
128 CString szCommandName = CCommands::GetCommandName(nCommandID);
\r
129 if (szCommandName.IsEmpty()) {
\r
133 for (int i = 0; ; ++i) {
\r
134 int nKey = CCommands::GetDefaultCommandKey(nCommandID, i);
\r
135 int nControlID = CCommands::GetDefaultControlID(nCommandID, i);
\r
139 CheckDlgButton(nControlID, nCheck);
\r
142 CheckDlgButton(IDC_CO2, BST_UNCHECKED);
\r
144 InitChanged(bChanged);
\r
147 void CPropertiesBasic::SetDialogData(CString szApplicationName)
\r
149 UpdateDialogData(szApplicationName, FALSE);
\r
152 void CPropertiesBasic::UpdateDialogData(CString szApplicationName, BOOL bSaveAndValidate)
\r
154 if (bSaveAndValidate) { // GetDialogData
\r
158 if (m_pProperties->GetApplicationID() == MAX_APP) {
\r
159 if (!bSaveAndValidate) {
\r
160 SetAllDialogData(1, FALSE); // FIXME
\r
166 if (!bSaveAndValidate) { // SetDialogData
\r
167 SetAllDialogData(1, FALSE);
\r
168 CheckDlgButton(IDC_CO2, BST_CHECKED);
\r
170 for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {
\r
171 CString szCommandName = CCommands::GetCommandName(nCommandID);
\r
172 if (szCommandName.IsEmpty()) {
\r
176 for (int i = 0; ; ++i) {
\r
177 int nCommandType = CCommands::GetDefaultCommandType(nCommandID, i);
\r
178 int nKey = CCommands::GetDefaultCommandKey(nCommandID, i);
\r
179 int nControlID = CCommands::GetDefaultControlID(nCommandID, i);
\r
183 if (bSaveAndValidate) { // GetDialogData
\r
184 if (nControlID == IDC_CO2) {
\r
187 if (!m_bChanged[nCommandID]) {
\r
190 if (IsDlgButtonChecked(nControlID)) {
\r
191 CProfile::SetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey, nCommandID);
\r
192 CDotXkeymacs::RemoveKey(m_pProperties->GetApplicationID(), nCommandType, nKey);
\r
194 CProfile::SetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey, 0);
\r
196 } else { // SetDialogData
\r
197 if (nCommandID != CProfile::GetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey)) {
\r
198 CheckDlgButton(nControlID, BST_UNCHECKED);
\r
203 // only for Toggle Imput Method Editor C-o: Canna mode
\r
204 if (bSaveAndValidate) { // GetDialogData
\r
205 int nCommandType = CONTROL;
\r
207 if (CProfile::GetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey) == 0) {
\r
208 if (IsDlgButtonChecked(IDC_CO2)) {
\r
209 for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {
\r
210 CString szCommandName = CCommands::GetCommandName(nCommandID);
\r
211 if (szCommandName.IsEmpty()) {
\r
214 if (!szCommandName.CompareNoCase(_T("toggle-input-method"))) {
\r
215 CProfile::SetCommandID(m_pProperties->GetApplicationID(), nCommandType, nKey, nCommandID);
\r
216 CProfile::SetCommandID(m_pProperties->GetApplicationID(), CONTROL+SHIFT, nKey, nCommandID);
\r
224 if (!bSaveAndValidate) { // SetDialogData
\r
229 void CPropertiesBasic::InitChanged(BOOL bChanged)
\r
231 for (int i = 0; i < MAX_COMMAND; ++i) {
\r
232 if (CCommands::GetDefaultControlID(i, 0) || !bChanged) {
\r
233 m_bChanged[i] = bChanged;
\r
238 int CPropertiesBasic::OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
240 if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
\r
243 m_pProperties = (CProperties *)GetParent()->GetParent();
\r
248 void CPropertiesBasic::GetDialogData()
\r
250 UpdateDialogData(m_pProperties->GetCurrentApplication(), TRUE);
\r
253 void CPropertiesBasic::OnAlt()
\r
258 void CPropertiesBasic::OnC_()
\r
263 void CPropertiesBasic::OnCa()
\r
268 void CPropertiesBasic::OnCb()
\r
273 void CPropertiesBasic::OnCbackslash()
\r
275 Changed(IDC_CBACKSLASH);
\r
278 void CPropertiesBasic::OnCbackslash106()
\r
280 Changed(IDC_CBACKSLASH_106);
\r
283 void CPropertiesBasic::OnCd()
\r
288 void CPropertiesBasic::OnCdigit()
\r
290 Changed(IDC_CDIGIT);
\r
293 void CPropertiesBasic::OnCe()
\r
298 void CPropertiesBasic::OnCf()
\r
303 void CPropertiesBasic::OnCg()
\r
308 void CPropertiesBasic::OnCh()
\r
313 void CPropertiesBasic::OnCi()
\r
318 void CPropertiesBasic::OnCk()
\r
323 void CPropertiesBasic::OnCl()
\r
328 void CPropertiesBasic::OnCm()
\r
333 void CPropertiesBasic::OnCms5()
\r
338 void CPropertiesBasic::OnCn()
\r
343 void CPropertiesBasic::OnCo()
\r
346 if (IsDlgButtonChecked(IDC_CO) == BST_CHECKED) {
\r
347 CheckDlgButton(IDC_CO2, BST_UNCHECKED);
\r
352 void CPropertiesBasic::OnCo2()
\r
355 if (IsDlgButtonChecked(IDC_CO2) == BST_CHECKED) {
\r
356 CheckDlgButton(IDC_CO, BST_UNCHECKED);
\r
361 void CPropertiesBasic::OnCp()
\r
366 void CPropertiesBasic::OnCq()
\r
371 void CPropertiesBasic::OnCr()
\r
376 void CPropertiesBasic::OnCs()
\r
381 void CPropertiesBasic::OnCslash()
\r
383 Changed(IDC_CSLASH);
\r
386 void CPropertiesBasic::OnCspace()
\r
388 Changed(IDC_CSPACE);
\r
391 void CPropertiesBasic::OnCt()
\r
396 void CPropertiesBasic::OnCu()
\r
401 void CPropertiesBasic::OnCv()
\r
406 void CPropertiesBasic::OnCw()
\r
411 void CPropertiesBasic::OnCxb()
\r
416 void CPropertiesBasic::OnCxcc()
\r
421 void CPropertiesBasic::OnCxcf()
\r
426 void CPropertiesBasic::OnCxcj()
\r
431 void CPropertiesBasic::OnCxcp()
\r
436 void CPropertiesBasic::OnCxcs()
\r
441 void CPropertiesBasic::OnCxct()
\r
446 void CPropertiesBasic::OnCxcw()
\r
451 void CPropertiesBasic::OnCxe()
\r
456 void CPropertiesBasic::OnCxh()
\r
461 void CPropertiesBasic::OnCxk()
\r
466 void CPropertiesBasic::OnCxs0()
\r
471 void CPropertiesBasic::OnCxs9()
\r
476 void CPropertiesBasic::OnCxu()
\r
481 void CPropertiesBasic::OnCy()
\r
486 void CPropertiesBasic::OnCz()
\r
491 void CPropertiesBasic::OnEscape()
\r
493 Changed(IDC_ESCAPE);
\r
496 void CPropertiesBasic::OnLeftAlt()
\r
498 Changed(IDC_LEFT_ALT);
\r
501 void CPropertiesBasic::OnMb()
\r
506 void CPropertiesBasic::OnMd()
\r
511 void CPropertiesBasic::OnMf()
\r
516 void CPropertiesBasic::OnMi()
\r
521 void CPropertiesBasic::OnMs1()
\r
526 void CPropertiesBasic::OnMs5()
\r
531 void CPropertiesBasic::OnMscomma()
\r
533 Changed(IDC_MSCOMMA);
\r
536 void CPropertiesBasic::OnMsperiod()
\r
538 Changed(IDC_MSPERIOD);
\r
541 void CPropertiesBasic::OnMv()
\r
546 void CPropertiesBasic::OnMw()
\r
551 void CPropertiesBasic::OnMy()
\r
556 void CPropertiesBasic::OnRightAlt()
\r
558 Changed(IDC_RIGHT_ALT);
\r
561 void CPropertiesBasic::OnSquareBra()
\r
563 Changed(IDC_SQUARE_BRA);
\r
566 void CPropertiesBasic::Changed(int nObjectID)
\r
568 for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {
\r
569 CString szCommandName = CCommands::GetCommandName(nCommandID);
\r
570 if (szCommandName.IsEmpty()) {
\r
574 for (int i = 0; ; ++i) {
\r
575 if (CCommands::GetDefaultCommandKey(nCommandID, i) == 0) {
\r
579 int nControlID = CCommands::GetDefaultControlID(nCommandID, i);
\r
580 if ((nControlID == nObjectID)
\r
581 || ((nObjectID == IDC_CO) && (nControlID == IDC_CO2))
\r
582 || ((nObjectID == IDC_CO2) && (nControlID == IDC_CO))) {
\r
583 m_bChanged[nCommandID] = TRUE;
\r
589 BOOL CPropertiesBasic::OnKillActive()
\r
593 return CPropertyPage::OnKillActive();
\r
596 void CPropertiesBasic::EnableControl()
\r
598 BOOL bEnable = m_pProperties->IsEnableControl();
\r
600 for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {
\r
601 CString szCommandName = CCommands::GetCommandName(nCommandID);
\r
602 if (szCommandName.IsEmpty()) {
\r
606 for (int i = 0; ; ++i) {
\r
607 int nKey = CCommands::GetDefaultCommandKey(nCommandID, i);
\r
608 int nControlID = CCommands::GetDefaultControlID(nCommandID, i);
\r
612 if (GetDlgItem(nControlID)) {
\r
613 GetDlgItem(nControlID)->EnableWindow(bEnable);
\r
619 BOOL CPropertiesBasic::PreTranslateMessage(MSG* pMsg)
\r
621 m_ToolTip.RelayEvent(pMsg);
\r
623 return CPropertyPage::PreTranslateMessage(pMsg);
\r
626 BOOL CPropertiesBasic::OnInitDialog()
\r
628 CPropertyPage::OnInitDialog();
\r
630 if (m_ToolTip.Create(this)) {
\r
631 for (int nCommandID = 0; nCommandID < MAX_COMMAND; ++nCommandID) {
\r
632 CString szCommandName = CCommands::GetCommandName(nCommandID);
\r
633 if (szCommandName.IsEmpty()) {
\r
637 for (int i = 0; ; ++i) {
\r
638 int nKey = CCommands::GetDefaultCommandKey(nCommandID, i);
\r
639 int nControlID = CCommands::GetDefaultControlID(nCommandID, i);
\r
643 if (GetDlgItem(nControlID)) {
\r
644 m_ToolTip.AddTool(GetDlgItem(nControlID), CString(MAKEINTRESOURCE(CCommands::GetToolTipID(nCommandID))));
\r
650 return TRUE; // return TRUE unless you set the focus to a control
\r
651 // EXCEPTION: OCX Property Pages should return FALSE
\r
654 void CPropertiesBasic::OnMdel()
\r
659 void CPropertiesBasic::OnMf12()
\r
664 void CPropertiesBasic::OnMt()
\r
669 void CPropertiesBasic::OnMc()
\r
674 void CPropertiesBasic::OnMl()
\r
679 void CPropertiesBasic::OnMu()
\r
684 void CPropertiesBasic::OnMx()
\r