Created button mode preferences dialogue on Win32
[dasher.git] / Src / Win32 / ButtonType.cpp
blob0689c6a016cba9376c76a203d25270f167737f4f
1 // ButtonType.cpp
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #include "WinCommon.h"
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;
19 using namespace std;
22 CButtonTypePage::CButtonTypePage(HWND Parent, CDasherInterface *DI, CAppSettings *pAppSettings)
23 :CPrefsPageBase(Parent, DI, pAppSettings) {
26 struct menuentry {
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
43 // in m_pDasher
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);
53 else
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.
62 return TRUE;
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.
74 return TRUE;
77 LRESULT CButtonTypePage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) {
79 double NewSpeed;
80 switch (message)
82 case WM_COMMAND:
83 switch (LOWORD(wParam))
85 case (IDC_DISPLAY):
86 break;
88 break;
93 // pass on to superclass:
94 return CPrefsPageBase::WndProc(Window, message, wParam, lParam);