1 // Properties.cpp : implementation file
\r
5 #include "xkeymacs.h"
\r
7 #include "Properties.h"
\r
10 #define new DEBUG_NEW
\r
12 static char THIS_FILE[] = __FILE__;
\r
15 /////////////////////////////////////////////////////////////////////////////
\r
16 // CProperties dialog
\r
19 CProperties::CProperties(CWnd* pParent /*=NULL*/)
\r
20 : CDialog(CProperties::IDD, pParent)
\r
22 m_nApplicationID = 0;
\r
23 //{{AFX_DATA_INIT(CProperties)
\r
24 m_nSettingStyle = -1;
\r
30 void CProperties::DoDataExchange(CDataExchange* pDX)
\r
32 CDialog::DoDataExchange(pDX);
\r
33 //{{AFX_DATA_MAP(CProperties)
\r
34 DDX_Control(pDX, IDC_WINDOW_TEXT, m_cWindowText);
\r
35 DDX_Control(pDX, IDC_KILL_RING_MAX, m_cKillRingMax);
\r
36 DDX_Control(pDX, IDC_USE_DIALOG_SETTING, m_cUseDialogSetting);
\r
37 DDX_Control(pDX, IDC_SELECT_ALL, m_cSelectAll);
\r
38 DDX_Control(pDX, IDC_CLEAR_ALL, m_cClearAll);
\r
39 DDX_Control(pDX, IDC_LOAD_DEFAULT, m_cLoadDefault);
\r
40 DDX_Control(pDX, IDC_APPLICATION, m_cApplication);
\r
41 DDX_Radio(pDX, IDC_SETTING_DEFAULT, m_nSettingStyle);
\r
42 DDX_Text(pDX, IDC_KILL_RING_MAX, m_nKillRingMax);
\r
43 DDV_MinMaxInt(pDX, m_nKillRingMax, 0, 2147483647);
\r
48 BEGIN_MESSAGE_MAP(CProperties, CDialog)
\r
49 //{{AFX_MSG_MAP(CProperties)
\r
50 ON_CBN_DROPDOWN(IDC_APPLICATION, OnDropdownApplication)
\r
51 ON_CBN_SELCHANGE(IDC_APPLICATION, OnSelchangeApplication)
\r
52 ON_BN_CLICKED(IDC_APPLY, OnApply)
\r
53 ON_BN_CLICKED(IDC_LOAD_DEFAULT, OnLoadDefault)
\r
54 ON_BN_CLICKED(IDC_SELECT_ALL, OnSelectAll)
\r
55 ON_BN_CLICKED(IDC_CLEAR_ALL, OnClearAll)
\r
56 ON_BN_CLICKED(IDC_SETTING_DEFAULT, OnSettingDefault)
\r
57 ON_BN_CLICKED(IDC_SETTING_DISABLE, OnSettingDisable)
\r
58 ON_BN_CLICKED(IDC_SETTING_SPECIFIC, OnSettingSpecific)
\r
62 /////////////////////////////////////////////////////////////////////////////
\r
63 // CProperties message handlers
\r
65 BOOL CProperties::OnInitDialog()
\r
67 CDialog::OnInitDialog();
\r
69 while (m_sheet.GetPageCount()) {
\r
70 m_sheet.RemovePage(0);
\r
73 m_sheet.AddPage(&m_basic);
\r
74 m_sheet.AddPage(&m_advanced);
\r
75 m_sheet.AddPage(&m_list);
\r
77 m_sheet.Create(this, WS_CHILD | WS_VISIBLE, 0);
\r
78 m_sheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);
\r
79 m_sheet.ModifyStyle( 0, WS_TABSTOP );
\r
82 GetDlgItem(IDC_TAB)->GetWindowRect(&rcSheet);
\r
83 ScreenToClient(&rcSheet);
\r
84 m_sheet.SetWindowPos(NULL, rcSheet.left - 11, rcSheet.top - 8, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
\r
87 SetForegroundWindow();
\r
89 InitApplicationList();
\r
91 CProfile::LoadData();
\r
92 m_szCurrentApplication.LoadString(IDS_DEFAULT);
\r
94 EnableUseDefaultButton(FALSE);
\r
95 EnableLoadDefaultButton(FALSE);
\r
97 EnableControl(BASIC_TAB);
\r
99 return TRUE; // return TRUE unless you set the focus to a control
\r
100 // EXCEPTION: OCX Property Pages should return FALSE
\r
103 void CProperties::OnDropdownApplication()
\r
105 InitApplicationList();
\r
107 int nID = GetCurrentApplicationID();
\r
108 if (nID != CB_ERR) {
\r
109 m_cApplication.SetCurSel(nID);
\r
112 m_szCurrentApplication.LoadString(IDS_DEFAULT_TITLE);
\r
113 m_cApplication.SelectString(-1, m_szCurrentApplication);
\r
118 void CProperties::OnSelchangeApplication()
\r
122 CProfile::GetApplicationTitle(&m_cApplication, m_szCurrentApplication, m_cApplication.GetCurSel());
\r
124 if ((nStart = m_szCurrentApplication.ReverseFind(_T('('))) != -1) {
\r
126 m_szCurrentApplication =
\r
127 m_szCurrentApplication.Mid(nStart, m_szCurrentApplication.GetLength() - nStart - 1);
\r
131 EnableControl(ACTIVE_TAB);
\r
134 void CProperties::InitApplicationList()
\r
136 CProfile::InitApplicationList(&m_cApplication);
\r
139 int CProperties::GetCurrentApplicationID()
\r
141 return CProfile::GetCurrentApplicationID(&m_cApplication, m_szCurrentApplication);
\r
144 void CProperties::GetDialogData()
\r
147 if (m_nSettingStyle == SETTING_DEFAULT) {
\r
148 CProfile::ClearData(m_szCurrentApplication);
\r
151 m_nApplicationID = CProfile::GetApplicationIndex(m_szCurrentApplication, TRUE, &m_nSettingStyle);
\r
152 CProfile::UpdateApplicationTitle(&m_cApplication, m_szCurrentApplication, m_nApplicationID, TRUE);
\r
153 CProfile::SetKillRingMax(m_nApplicationID, m_nKillRingMax);
\r
154 CProfile::SetUseDialogSetting(m_nApplicationID, m_cUseDialogSetting.GetCheck() == BST_CHECKED);
\r
155 CString szWindowText;
\r
156 m_cWindowText.GetWindowText(szWindowText);
\r
157 CProfile::SetWindowText(m_nApplicationID, szWindowText);
\r
159 if (m_sheet.GetActivePage() == &m_basic) // FIXME
\r
160 m_basic.GetDialogData();
\r
161 else if (m_sheet.GetActivePage() == &m_advanced)
\r
162 m_advanced.GetDialogData();
\r
163 else if (m_sheet.GetActivePage() == &m_list)
\r
164 m_list.GetDialogData();
\r
167 void CProperties::SetDialogData()
\r
169 m_nApplicationID = CProfile::GetApplicationIndex(m_szCurrentApplication, FALSE, &m_nSettingStyle);
\r
170 EnableUseDefaultButton(!CProfile::IsDefault(m_szCurrentApplication) && !CProfile::IsDialog(m_szCurrentApplication));
\r
171 CProfile::UpdateApplicationTitle(&m_cApplication, m_szCurrentApplication, m_nApplicationID, FALSE);
\r
172 m_nKillRingMax = CProfile::GetKillRingMax(m_nApplicationID);
\r
173 m_cUseDialogSetting.SetCheck(CProfile::GetUseDialogSetting(m_nApplicationID) ? BST_CHECKED : BST_UNCHECKED);
\r
174 m_cWindowText.SetWindowText(CProfile::GetWindowText(m_nApplicationID));
\r
177 if (m_sheet.GetActivePage() == &m_basic) // FIXME
\r
178 m_basic.SetDialogData();
\r
179 else if (m_sheet.GetActivePage() == &m_advanced)
\r
180 m_advanced.SetDialogData();
\r
181 else if (m_sheet.GetActivePage() == &m_list)
\r
182 m_list.SetDialogData();
\r
185 void CProperties::EnableControl(TAB_NAME tab)
\r
187 if (tab & ACTIVE_TAB) {
\r
188 if (m_sheet.GetActivePage() == &m_basic) { // FIXME
\r
190 } else if (m_sheet.GetActivePage() == &m_advanced) {
\r
191 tab = ADVANCED_TAB;
\r
192 } else if (m_sheet.GetActivePage() == &m_list) {
\r
197 BOOL bEnable = (m_nSettingStyle == SETTING_SPECIFIC);
\r
199 m_cKillRingMax.EnableWindow(bEnable);
\r
200 EnableLoadDefaultButton(bEnable);
\r
202 m_cSelectAll.EnableWindow(bEnable && tab & BASIC_TAB);
\r
203 m_cClearAll.EnableWindow(bEnable && tab & BASIC_TAB);
\r
205 EnableUseDialogSettingButton(bEnable);
\r
207 m_cWindowText.EnableWindow(bEnable);
\r
209 if (tab & BASIC_TAB) {
\r
210 m_basic.EnableControl();
\r
212 if (tab & ADVANCED_TAB) {
\r
213 m_advanced.EnableControl();
\r
215 if (tab & LIST_TAB) {
\r
216 m_list.EnableControl();
\r
220 void CProperties::EnableUseDialogSettingButton(BOOL bEnable)
\r
222 m_cUseDialogSetting.EnableWindow(bEnable);
\r
223 if (CProfile::IsDialog(m_szCurrentApplication)) {
\r
224 m_cUseDialogSetting.EnableWindow(FALSE);
\r
228 void CProperties::EnableLoadDefaultButton(BOOL bEnable)
\r
230 m_cLoadDefault.EnableWindow(bEnable);
\r
231 if (CProfile::IsDefault(m_szCurrentApplication)) {
\r
232 m_cLoadDefault.EnableWindow(FALSE);
\r
236 void CProperties::EnableUseDefaultButton(BOOL bEnable)
\r
238 if (GetDlgItem(IDC_SETTING_DEFAULT)) {
\r
239 GetDlgItem(IDC_SETTING_DEFAULT)->EnableWindow(bEnable);
\r
243 void CProperties::OnOK()
\r
250 void CProperties::OnCancel()
\r
252 CProfile::LoadData();
\r
254 CDialog::OnCancel();
\r
257 void CProperties::OnApply()
\r
260 CProfile::SaveData();
\r
263 void CProperties::OnLoadDefault()
\r
265 CProfile::CopyData(m_szCurrentApplication, CString(MAKEINTRESOURCE(IDS_DEFAULT)));
\r
269 void CProperties::OnSelectAll()
\r
271 m_basic.SetAllDialogData(1, TRUE);
\r
274 void CProperties::OnClearAll()
\r
276 m_basic.SetAllDialogData(0, TRUE);
\r
279 int CProperties::GetApplicationID()
\r
281 return m_nApplicationID;
\r
284 CString CProperties::GetCurrentApplication()
\r
286 return m_szCurrentApplication;
\r
289 void CProperties::OnSettingDefault()
\r
291 UpdateData(); // get data
\r
292 EnableControl(ACTIVE_TAB);
\r
295 void CProperties::OnSettingDisable()
\r
298 EnableControl(ACTIVE_TAB);
\r
301 void CProperties::OnSettingSpecific()
\r
304 EnableControl(ACTIVE_TAB);
\r
306 if (CProfile::GetAppID(m_szCurrentApplication) == MAX_APP) {
\r
307 CProfile::CopyData(m_szCurrentApplication, CString(MAKEINTRESOURCE(IDS_DEFAULT)));
\r
312 BOOL CProperties::IsEnableControl()
\r
314 return m_nSettingStyle == SETTING_SPECIFIC;
\r