3 /////////////////////////////////////////////////////////////////////////////
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
7 /////////////////////////////////////////////////////////////////////////////
11 #include "ButtonType.h"
12 #include "../resource.h"
13 #include "../Common/StringUtils.h"
14 #include "../AppSettings.h"
16 #include <utility> // for std::pair
18 using namespace Dasher
;
22 CButtonTypePage::CButtonTypePage(HWND Parent
, CDasherInterface
*DI
, CAppSettings
*pAppSettings
)
23 :CPrefsPageBase(Parent
, DI
, pAppSettings
) {
27 int paramNum
; // enum value in Parameters.h for setting store
28 int idcNum
; // #define value in resource.h for dasher.rc
31 // List of menu items that will be displayed in the General Preferences
32 static menuentry menutable
[] = {
33 {BP_BUTTONONEDYNAMIC
, IDC_ONE_DYNAMIC
},
34 {BP_BUTTONMENU
, IDC_MENU
},
35 {BP_BUTTONDIRECT
, IDC_THREE_DIRECT
},
36 {BP_BUTTONFOURDIRECT
, IDC_FOUR_DIRECT
},
37 {BP_BUTTONALTERNATINGDIRECT
, IDC_ALTERNATING_DIRECT
},
38 {BP_COMPASSMODE
, IDC_COMPASS
}
41 void CButtonTypePage::PopulateList() {
42 // Populate the controls in the dialogue box based on the relevent parameters
46 // all the button checkboxes
47 for(int ii
= 0; ii
<sizeof(menutable
)/sizeof(menuentry
); ii
++)
49 if(m_pAppSettings
->GetBoolParameter(menutable
[ii
].paramNum
))
51 SendMessage(GetDlgItem(m_hwnd
, menutable
[ii
].idcNum
), BM_SETCHECK
, BST_CHECKED
, 0);
55 SendMessage(GetDlgItem(m_hwnd
, menutable
[ii
].idcNum
), BM_SETCHECK
, BST_UNCHECKED
, 0);
60 bool CButtonTypePage::Validate() {
61 // Return false if something is wrong to prevent user from clicking to a different page. Please also pop up a dialogue informing the user at this point.
65 bool CButtonTypePage::Apply()
67 for(int ii
= 0; ii
<sizeof(menutable
)/sizeof(menuentry
); ii
++)
69 m_pAppSettings
->SetBoolParameter(menutable
[ii
].paramNum
,
70 SendMessage(GetDlgItem(m_hwnd
, menutable
[ii
].idcNum
), BM_GETCHECK
, 0, 0) == BST_CHECKED
);
73 // Return false (and notify the user) if something is wrong.
77 LRESULT
CButtonTypePage::WndProc(HWND Window
, UINT message
, WPARAM wParam
, LPARAM lParam
) {
83 switch (LOWORD(wParam
))
93 // pass on to superclass:
94 return CPrefsPageBase::WndProc(Window
, message
, wParam
, lParam
);