repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / codycam / Settings.h
blobcde0f821ba05124533143e9199d37967a7c29317
1 #ifndef SETTINGS_H
2 #define SETTINGS_H
4 #include "SettingsHandler.h"
6 void SetUpSettings(char* filename);
7 void QuitSettings();
9 class StringValueSetting : public SettingsArgvDispatcher {
10 // simple string setting
11 public:
12 StringValueSetting(const char* name,
13 const char* defaultValue,
14 const char* valueExpectedErrorString,
15 const char* wrongValueErrorString = "");
17 virtual ~StringValueSetting();
19 void ValueChanged(const char* newValue);
20 const char* Value() const;
21 virtual const char* Handle(const char *const *argv);
23 protected:
24 virtual void SaveSettingValue(Settings*);
25 virtual bool NeedsSaving() const;
27 const char* fDefaultValue;
28 const char* fValueExpectedErrorString;
29 const char* fWrongValueErrorString;
30 char* fValue;
34 // string setting, values that do not match string enumeration
35 // are rejected
36 class EnumeratedStringValueSetting : public StringValueSetting {
37 public:
38 // A pointer to a function returning a string for an index, or NULL
39 // if the index is out of bounds.
40 typedef const char* (*StringEnumerator)(int32);
42 EnumeratedStringValueSetting(const char* name,
43 const char* defaultValue,
44 StringEnumerator enumerator,
45 const char* valueExpectedErrorString,
46 const char* wrongValueErrorString);
48 void ValueChanged(const char* newValue);
49 virtual const char* Handle(const char *const *argv);
51 private:
52 bool _ValidateString(const char* string);
53 StringEnumerator fEnumerator;
57 // simple int32 setting
58 class ScalarValueSetting : public SettingsArgvDispatcher {
59 public:
60 ScalarValueSetting(const char* name,
61 int32 defaultValue,
62 const char* valueExpectedErrorString,
63 const char* wrongValueErrorString,
64 int32 min = INT32_MIN, int32 max = INT32_MAX);
65 virtual ~ScalarValueSetting();
67 void ValueChanged(int32 newValue);
68 int32 Value() const;
69 void GetValueAsString(char*) const;
70 virtual const char* Handle(const char *const *argv);
72 protected:
73 virtual void SaveSettingValue(Settings*);
74 virtual bool NeedsSaving() const;
76 int32 fDefaultValue;
77 int32 fValue;
78 int32 fMax;
79 int32 fMin;
80 const char* fValueExpectedErrorString;
81 const char* fWrongValueErrorString;
85 class BooleanValueSetting : public ScalarValueSetting {
86 public:
87 BooleanValueSetting(const char* name,
88 bool defaultValue);
89 virtual ~BooleanValueSetting();
91 bool Value() const;
92 virtual const char* Handle(const char *const *argv);
94 protected:
95 virtual void SaveSettingValue(Settings *);
98 #endif // SETTINGS_H