/
PreferenceItems.h
177 lines (152 loc) · 3.49 KB
/
PreferenceItems.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#pragma once
#include "ipreferencesystem.h"
#include "PreferenceItemBase.h"
/**
* greebo: This file contains a couple of classes describing
* the Preference Items visible in the Preference Dialog.
*
* Client code registers their configurable options with the
* GlobalPreferenceSystem during module initialisation, these
* classes here store this information for later retrieval
* (when the Preference Dialog is constructed, more specifically).
*
* All these are derived from a single base, as most of them
* want to save their stuff in the Registry.
*/
namespace settings
{
class PreferenceLabel :
public PreferenceItemBase,
public virtual IPreferenceLabel
{
public:
PreferenceLabel(const std::string& label) :
PreferenceItemBase(label)
{}
};
class PreferenceEntry :
public PreferenceItemBase,
public virtual IPreferenceLabel
{
public:
PreferenceEntry(const std::string& label, const std::string& registryKey) :
PreferenceItemBase(label, registryKey)
{}
};
class PreferenceCheckbox :
public PreferenceItemBase,
public virtual IPreferenceCheckbox
{
public:
PreferenceCheckbox(const std::string& label, const std::string& registryKey) :
PreferenceItemBase(label, registryKey)
{}
};
class PreferenceCombobox :
public PreferenceItemBase,
public virtual IPreferenceCombobox
{
private:
ComboBoxValueList _values;
bool _storeValueNotIndex;
public:
PreferenceCombobox(const std::string& label, const std::string& registryKey,
const ComboBoxValueList& values, bool storeValueNotIndex) :
PreferenceItemBase(label, registryKey),
_values(values),
_storeValueNotIndex(storeValueNotIndex)
{}
const ComboBoxValueList& getValues() const override
{
return _values;
}
bool storeValueNotIndex() const override
{
return _storeValueNotIndex;
}
};
class PreferencePathEntry :
public PreferenceItemBase,
public virtual IPreferencePathEntry
{
private:
bool _browseDirectories;
public:
PreferencePathEntry(const std::string& label, const std::string& registryKey, bool browseDirectories) :
PreferenceItemBase(label, registryKey),
_browseDirectories(browseDirectories)
{}
bool browseDirectories() const override
{
return _browseDirectories;
}
};
class PreferenceSpinner :
public PreferenceItemBase,
public virtual IPreferenceSpinner
{
private:
double _lower;
double _upper;
int _fraction;
public:
PreferenceSpinner(const std::string& label, const std::string& registryKey, double lower, double upper, int fraction) :
PreferenceItemBase(label, registryKey),
_lower(lower),
_upper(upper),
_fraction(fraction)
{}
double getLower() override
{
return _lower;
}
double getUpper() override
{
return _upper;
}
int getFraction() override
{
return _fraction;
}
};
class PreferenceSlider :
public PreferenceItemBase,
public virtual IPreferenceSlider
{
private:
double _lower;
double _upper;
double _stepIncrement;
double _pageIncrement;
int _factor;
public:
PreferenceSlider(const std::string& label, const std::string& registryKey, double lower, double upper, double stepIncrement, double pageIncrement) :
PreferenceItemBase(label, registryKey),
_lower(lower),
_upper(upper),
_stepIncrement(stepIncrement),
_pageIncrement(pageIncrement),
_factor(1)
{}
double getLower() override
{
return _lower;
}
double getUpper() override
{
return _upper;
}
double getStepIncrement() override
{
return _stepIncrement;
}
double getPageIncrement() override
{
return _pageIncrement;
}
int getFactor() override
{
return _factor;
}
};
} // namespace