2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011-2013, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
12 #include <ObjectList.h>
13 #include <Referenceable.h>
27 class Setting
: public BReferenceable
{
31 virtual setting_type
Type() const = 0;
32 virtual const char* ID() const = 0;
33 virtual const char* Name() const = 0;
35 virtual BVariant
DefaultValue() const = 0;
39 class BoolSetting
: public virtual Setting
{
41 virtual setting_type
Type() const;
43 virtual BVariant
DefaultValue() const;
45 virtual bool DefaultBoolValue() const = 0;
49 class FloatSetting
: public virtual Setting
{
51 virtual setting_type
Type() const;
53 virtual BVariant
DefaultValue() const;
55 virtual float DefaultFloatValue() const = 0;
59 class SettingsOption
: public BReferenceable
{
61 virtual ~SettingsOption();
63 virtual const char* ID() const = 0;
64 virtual const char* Name() const = 0;
68 class OptionsSetting
: public virtual Setting
{
70 virtual setting_type
Type() const;
72 virtual BVariant
DefaultValue() const;
74 virtual int32
CountOptions() const = 0;
75 virtual SettingsOption
* OptionAt(int32 index
) const = 0;
76 virtual SettingsOption
* OptionByID(const char* id
) const = 0;
78 virtual SettingsOption
* DefaultOption() const = 0;
82 class BoundedSetting
: public virtual Setting
{
84 virtual setting_type
Type() const;
86 virtual BVariant
LowerBound() const = 0;
87 virtual BVariant
UpperBound() const = 0;
91 class RangeSetting
: public virtual BoundedSetting
{
92 virtual setting_type
Type() const;
94 virtual BVariant
LowerValue() const = 0;
95 virtual BVariant
UpperValue() const = 0;
99 class RectSetting
: public virtual Setting
{
101 virtual setting_type
Type() const;
103 virtual BVariant
DefaultValue() const;
105 virtual BRect
DefaultRectValue() const = 0;
109 class AbstractSetting
: public virtual Setting
{
111 AbstractSetting(const BString
& id
,
112 const BString
& name
);
114 virtual const char* ID() const;
115 virtual const char* Name() const;
123 class BoolSettingImpl
: public AbstractSetting
, public BoolSetting
{
125 BoolSettingImpl(const BString
& id
,
126 const BString
& name
, bool defaultValue
);
128 virtual bool DefaultBoolValue() const;
135 class FloatSettingImpl
: public AbstractSetting
, public FloatSetting
{
137 FloatSettingImpl(const BString
& id
,
138 const BString
& name
, float defaultValue
);
140 virtual float DefaultFloatValue() const;
147 class OptionsSettingImpl
: public AbstractSetting
, public OptionsSetting
{
149 OptionsSettingImpl(const BString
& id
,
150 const BString
& name
);
151 virtual ~OptionsSettingImpl();
153 virtual SettingsOption
* DefaultOption() const;
155 virtual int32
CountOptions() const;
156 virtual SettingsOption
* OptionAt(int32 index
) const;
157 virtual SettingsOption
* OptionByID(const char* id
) const;
159 bool AddOption(SettingsOption
* option
);
160 bool AddOption(const BString
& id
,
161 const BString
& name
);
163 void SetDefaultOption(SettingsOption
* option
);
168 typedef BObjectList
<SettingsOption
> OptionList
;
172 SettingsOption
* fDefaultOption
;
176 class BoundedSettingImpl
: public AbstractSetting
, public BoundedSetting
{
178 BoundedSettingImpl(const BString
& id
,
180 const BVariant
& lowerBound
,
181 const BVariant
& upperBound
,
182 const BVariant
& defaultValue
);
184 virtual BVariant
DefaultValue() const;
186 virtual BVariant
LowerBound() const;
187 virtual BVariant
UpperBound() const;
190 BVariant fLowerBound
;
191 BVariant fUpperBound
;
192 BVariant fDefaultValue
;
196 class RangeSettingImpl
: public AbstractSetting
, public RangeSetting
{
198 RangeSettingImpl(const BString
& id
,
200 const BVariant
& lowerBound
,
201 const BVariant
& upperBound
,
202 const BVariant
& lowerValue
,
203 const BVariant
& upperValue
);
205 virtual BVariant
DefaultValue() const;
207 virtual BVariant
LowerBound() const;
208 virtual BVariant
UpperBound() const;
209 virtual BVariant
LowerValue() const;
210 virtual BVariant
UpperValue() const;
213 BVariant fLowerBound
;
214 BVariant fUpperBound
;
215 BVariant fLowerValue
;
216 BVariant fUpperValue
;
220 class RectSettingImpl
: public AbstractSetting
, public RectSetting
{
222 RectSettingImpl(const BString
& id
,
224 const BRect
& defaultValue
);
226 virtual BRect
DefaultRectValue() const;