BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / icon-o-matic / generic / property / Property.h
blobe25d84341372831ab714d2f054f7c86936f4f9c0
1 /*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
9 #ifndef PROPERTY_H
10 #define PROPERTY_H
12 #include <limits.h>
14 #include <Archivable.h>
15 #include <String.h>
16 #include <TypeConstants.h>
18 class PropertyAnimator;
20 // Property
21 class Property : public BArchivable {
22 public:
23 Property(uint32 identifier);
24 Property(const Property& other);
25 Property(BMessage* archive);
26 virtual ~Property();
28 // BArchivable interface
29 virtual status_t Archive(BMessage* archive,
30 bool deep = true) const;
32 // Property
33 virtual Property* Clone() const = 0;
35 virtual type_code Type() const = 0;
37 virtual bool SetValue(const char* value) = 0;
38 virtual bool SetValue(const Property* other) = 0;
39 virtual void GetValue(BString& string) = 0;
41 // animation
42 virtual bool InterpolateTo(const Property* other,
43 float scale);
45 inline uint32 Identifier() const
46 { return fIdentifier; }
48 void SetEditable(bool editable);
49 inline bool IsEditable() const
50 { return fEditable; }
52 private:
53 uint32 fIdentifier;
54 bool fEditable;
57 // IntProperty
58 class IntProperty : public Property {
59 public:
60 IntProperty(uint32 identifier,
61 int32 value = 0,
62 int32 min = INT32_MIN,
63 int32 max = INT32_MAX);
64 IntProperty(const IntProperty& other);
65 IntProperty(BMessage* archive);
66 virtual ~IntProperty();
68 virtual status_t Archive(BMessage* archive,
69 bool deep = true) const;
70 static BArchivable* Instantiate(BMessage* archive);
72 virtual Property* Clone() const;
74 virtual type_code Type() const
75 { return B_INT32_TYPE; }
77 virtual bool SetValue(const char* value);
78 virtual bool SetValue(const Property* other);
79 virtual void GetValue(BString& string);
81 virtual bool InterpolateTo(const Property* other,
82 float scale);
84 // IntProperty
85 bool SetValue(int32 value);
87 inline int32 Value() const
88 { return fValue; }
89 inline int32 Min() const
90 { return fMin; }
91 inline int32 Max() const
92 { return fMax; }
94 private:
95 int32 fValue;
96 int32 fMin;
97 int32 fMax;
100 // FloatProperty
101 class FloatProperty : public Property {
102 public:
103 FloatProperty(uint32 identifier,
104 float value = 0.0,
105 float min = -1000000.0,
106 float max = 1000000.0);
107 FloatProperty(const FloatProperty& other);
108 FloatProperty(BMessage* archive);
109 virtual ~FloatProperty();
111 virtual status_t Archive(BMessage* archive,
112 bool deep = true) const;
113 static BArchivable* Instantiate(BMessage* archive);
115 virtual Property* Clone() const;
117 virtual type_code Type() const
118 { return B_FLOAT_TYPE; }
120 virtual bool SetValue(const char* value);
121 virtual bool SetValue(const Property* other);
122 virtual void GetValue(BString& string);
124 virtual bool InterpolateTo(const Property* other,
125 float scale);
127 // FloatProperty
128 bool SetValue(float value);
130 inline float Value() const
131 { return fValue; }
132 inline float Min() const
133 { return fMin; }
134 inline float Max() const
135 { return fMax; }
137 private:
138 float fValue;
139 float fMin;
140 float fMax;
143 // UInt8Property
144 class UInt8Property : public Property {
145 public:
146 UInt8Property(uint32 identifier,
147 uint8 value = 255);
148 UInt8Property(const UInt8Property& other);
149 UInt8Property(BMessage* archive);
150 virtual ~UInt8Property();
152 virtual status_t Archive(BMessage* archive,
153 bool deep = true) const;
154 static BArchivable* Instantiate(BMessage* archive);
156 virtual Property* Clone() const;
158 virtual type_code Type() const
159 { return B_INT8_TYPE; }
161 virtual bool SetValue(const char* value);
162 virtual bool SetValue(const Property* other);
163 virtual void GetValue(BString& string);
165 virtual bool InterpolateTo(const Property* other,
166 float scale);
168 // UInt8Property
169 bool SetValue(uint8 value);
171 inline uint8 Value() const
172 { return fValue; }
174 private:
175 uint8 fValue;
178 // BoolProperty
179 class BoolProperty : public Property {
180 public:
181 BoolProperty(uint32 identifier,
182 bool value = false);
183 BoolProperty(const BoolProperty& other);
184 BoolProperty(BMessage* archive);
185 virtual ~BoolProperty();
187 virtual status_t Archive(BMessage* archive,
188 bool deep = true) const;
189 static BArchivable* Instantiate(BMessage* archive);
191 virtual Property* Clone() const;
193 virtual type_code Type() const
194 { return B_BOOL_TYPE; }
196 virtual bool SetValue(const char* value);
197 virtual bool SetValue(const Property* other);
198 virtual void GetValue(BString& string);
200 virtual bool InterpolateTo(const Property* other,
201 float scale);
203 // BoolProperty
204 bool SetValue(bool value);
206 inline bool Value() const
207 { return fValue; }
209 private:
210 bool fValue;
213 // StringProperty
214 class StringProperty : public Property {
215 public:
216 StringProperty(uint32 identifier,
217 const char* string);
218 StringProperty(const StringProperty& other);
219 StringProperty(BMessage* archive);
220 virtual ~StringProperty();
222 virtual status_t Archive(BMessage* archive,
223 bool deep = true) const;
224 static BArchivable* Instantiate(BMessage* archive);
226 virtual Property* Clone() const;
228 virtual type_code Type() const
229 { return B_STRING_TYPE; }
231 virtual bool SetValue(const char* value);
232 virtual bool SetValue(const Property* other);
233 virtual void GetValue(BString& string);
235 // StringProperty
236 inline const char* Value() const
237 { return fValue.String(); }
239 private:
240 BString fValue;
243 #endif // PROPERTY_H