tagging release
[dasher.git] / Src / Win32 / AppSettings.h
blob8abd6f76cf276426e509284e1599210515a184ba
1 #pragma once
3 #include <string>
4 #include "../Common/AppSettingsHeader.h"
6 #include <windows.h>
8 //#include "WinCommon.h"
9 #include "WinUTF8.h"
11 // Define first int value of the first element of each type.
12 // Useful for offsetting into specific arrays,
13 // since each setting is a unique int, but all 3 arrays start at 0
14 #define FIRST_APP_BP END_OF_SPS
15 #define FIRST_APP_LP END_OF_APP_BPS
16 #define FIRST_APP_SP END_OF_APP_LPS
18 #define NUM_OF_APP_BPS (END_OF_APP_BPS - END_OF_SPS)
19 #define NUM_OF_APP_LPS (END_OF_APP_LPS - END_OF_APP_BPS)
20 #define NUM_OF_APP_SPS (END_OF_APP_SPS - END_OF_APP_LPS)
22 namespace Dasher {
23 class CDasher;
26 class CAppSettings
28 public:
30 CAppSettings(Dasher::CDasher *pDasher, HWND hWnd);
31 ~CAppSettings(void);
33 ///
34 /// Get a boolean parameter
36 bool GetBoolParameter(int iParameter);
38 ///
39 /// Set a boolean parameter
41 void SetBoolParameter(int iParameter, bool bValue);
43 ///
44 /// Get a long integer parameter
46 long GetLongParameter(int iParameter);
48 ///
49 /// Set a long integer parameter
51 void SetLongParameter(int iParameter, long iValue);
53 ///
54 /// Get a string parameter
56 std::string GetStringParameter(int iParameter);
58 ///
59 /// Set a string parameter
61 void SetStringParameter(int iParameter, const std::string &strValue);
63 ///
64 /// Reset a parameter to its default value
66 void ResetParamater(int iParameter);
68 #ifndef DASHER_WINCE
69 bool LoadSetting(const std::string & Key, LPWINDOWPLACEMENT pwp);
70 void SaveSetting(const std::string & Key, const LPWINDOWPLACEMENT pwp);
71 #endif
73 void SetHwnd(HWND hWnd) {
74 m_hWnd = hWnd;
77 void SetDasher(Dasher::CDasher *pDasher) {
78 m_pDasher = pDasher;
81 private:
82 struct bp_info {
83 int key;
84 std::string regName;
85 bool persistent;
86 bool value;
87 bool defaultVal;
88 std::string humanReadable;
90 struct lp_info {
91 int key;
92 std::string regName;
93 bool persistent;
94 long value;
95 long defaultVal;
96 std::string humanReadable;
98 struct sp_info {
99 int key;
100 std::string regName;
101 bool persistent;
102 std::string value;
103 std::string defaultVal;
104 std::string humanReadable;
107 bp_info *m_pBoolTable;
108 lp_info *m_pLongTable;
109 sp_info *m_pStringTable;
111 Dasher::CDasher *m_pDasher;
112 HWND m_hWnd;
114 bool LoadSetting(const std::string & Key, bool * Value);
115 bool LoadSetting(const std::string & Key, long *Value);
116 bool LoadSetting(const std::string & Key, std::string * Value);
117 bool LoadSettingT(const std::string & Key, Tstring * Value);
119 void SaveSetting(const std::string & Key, bool Value);
120 void SaveSetting(const std::string & Key, long Value);
121 void SaveSetting(const std::string & Key, const std::string & Value);
123 void SaveSettingT(const std::string & Key, const Tstring & TValue);
125 // Platform Specific helpers
126 HKEY ProductKey;
127 int GetOrCreate(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired, HKEY * lpNewKey);
128 // CARE! Users of GetlpByte must call delete[] on *Data after use.
129 bool GetlpByte(const Tstring & key, BYTE ** Data) const;