]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/deprecated/prop.h
Deprecated library mods
[wxWidgets.git] / contrib / include / wx / deprecated / prop.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: prop.h
3 // Purpose: Property sheet classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PROP_H_
13 #define _WX_PROP_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "prop.h"
17 #endif
18
19 #include "wx/deprecated/setup.h"
20
21 #if wxUSE_PROPSHEET
22
23 #include "wx/defs.h"
24 #include "wx/string.h"
25 #include "wx/hash.h"
26 #include "wx/dialog.h"
27 #include "wx/frame.h"
28 #include "wx/button.h"
29 #include "wx/listbox.h"
30 #include "wx/textctrl.h"
31 #include "wx/gdicmn.h"
32 #include "wx/layout.h"
33 #include "wx/sizer.h"
34
35 class wxWindow;
36 class wxProperty;
37 class wxPropertyValue;
38 class wxPropertySheet;
39 class wxPropertyView;
40 class wxPropertyValidator;
41 class wxPropertyValidatorRegistry;
42
43 #define wxPROPERTY_VERSION 2.0
44
45 // A storable sheet of values
46 class WXDLLEXPORT wxPropertySheet: public wxObject
47 {
48 public:
49 wxPropertySheet(const wxString& name = wxT(""));
50 ~wxPropertySheet();
51
52 // Set the name of the sheet
53 inline virtual void SetName(const wxString& name) { m_name=name; }
54 inline virtual wxString GetName() const { return m_name; }
55
56 // Does this sheet contain a property with this name
57 virtual bool HasProperty(const wxString& name) const;
58
59 // Set property name to value
60 virtual bool SetProperty(const wxString& name, const wxPropertyValue& value);
61
62 // Remove property from sheet by name, deleting it
63 virtual void RemoveProperty(const wxString& name);
64
65 // Get the name of the sheet
66 // Add a property
67 virtual void AddProperty(wxProperty *property);
68
69 // Get property by name
70 virtual wxProperty *GetProperty(const wxString& name) const;
71
72 // Clear all properties
73 virtual void Clear();
74
75 virtual void UpdateAllViews(wxPropertyView *thisView = NULL);
76 inline virtual wxList& GetProperties() const { return (wxList&) m_properties; }
77
78 // Sets/clears the modified flag for each property value
79 virtual void SetAllModified(bool flag = TRUE);
80
81 protected:
82 wxObject* m_viewedObject;
83 wxList m_properties;
84 wxPropertyView* m_propertyView;
85 wxString m_name;
86
87 private:
88 DECLARE_DYNAMIC_CLASS(wxPropertySheet)
89 };
90
91
92 // Base class for property sheet views. There are currently two directly derived
93 // classes: wxPropertyListView, and wxPropertyFormView.
94 class WXDLLEXPORT wxPropertyView: public wxEvtHandler
95 {
96 public:
97 wxPropertyView(long flags = 0);
98 ~wxPropertyView();
99
100 // Associates and shows the view
101 virtual void ShowView(wxPropertySheet *WXUNUSED(propertySheet), wxWindow *WXUNUSED(panel)) {}
102
103 // Update this view of the viewed object, called e.g. by
104 // the object itself.
105 virtual bool OnUpdateView() {return FALSE;};
106
107 // Override this to do something as soon as the property changed,
108 // if the view and validators support it.
109 virtual void OnPropertyChanged(wxProperty *WXUNUSED(property)) {}
110
111 virtual void AddRegistry(wxPropertyValidatorRegistry *registry);
112 inline virtual wxList& GetRegistryList() const
113 { return (wxList&) m_validatorRegistryList; }
114
115 virtual wxPropertyValidator *FindPropertyValidator(wxProperty *property);
116 inline virtual void SetPropertySheet(wxPropertySheet *sheet) { m_propertySheet = sheet; }
117 inline virtual wxPropertySheet *GetPropertySheet() const { return m_propertySheet; }
118
119 inline virtual bool OnClose() { return FALSE; }
120 inline long GetFlags(void) { return m_buttonFlags; }
121
122 protected:
123 long m_buttonFlags;
124 wxPropertySheet* m_propertySheet;
125 wxProperty* m_currentProperty;
126 wxList m_validatorRegistryList;
127 wxPropertyValidator* m_currentValidator;
128
129 private:
130 DECLARE_DYNAMIC_CLASS(wxPropertyView)
131 };
132
133
134 class WXDLLEXPORT wxPropertyValidator: public wxEvtHandler
135 {
136 public:
137 wxPropertyValidator(long flags = 0);
138 ~wxPropertyValidator();
139
140 inline long GetFlags() const { return m_validatorFlags; }
141 inline void SetValidatorProperty(wxProperty *prop) { m_validatorProperty = prop; }
142 inline wxProperty *GetValidatorProperty(void) const { return m_validatorProperty; }
143
144 virtual bool StringToFloat (wxChar *s, float *number);
145 virtual bool StringToDouble (wxChar *s, double *number);
146 virtual bool StringToInt (wxChar *s, int *number);
147 virtual bool StringToLong (wxChar *s, long *number);
148 virtual wxChar *FloatToString (float number);
149 virtual wxChar *DoubleToString (double number);
150 virtual wxChar *IntToString (int number);
151 virtual wxChar *LongToString (long number);
152
153 protected:
154 long m_validatorFlags;
155 wxProperty* m_validatorProperty;
156
157 private:
158 DECLARE_DYNAMIC_CLASS(wxPropertyValidator)
159 };
160
161
162 // extern wxPropertyValidator *wxDefaultPropertyValidator;
163
164 class WXDLLEXPORT wxPropertyValidatorRegistry: public wxHashTable
165 {
166 public:
167 wxPropertyValidatorRegistry();
168 ~wxPropertyValidatorRegistry();
169
170 virtual void RegisterValidator(const wxString& roleName, wxPropertyValidator *validator);
171 virtual wxPropertyValidator *GetValidator(const wxString& roleName);
172 void ClearRegistry();
173
174 private:
175 DECLARE_DYNAMIC_CLASS(wxPropertyValidatorRegistry)
176 };
177
178 /*
179 * Property value class
180 */
181
182 typedef enum {
183 wxPropertyValueNull,
184 wxPropertyValueInteger,
185 wxPropertyValueReal,
186 wxPropertyValuebool,
187 wxPropertyValueString,
188 wxPropertyValueList,
189 wxPropertyValueIntegerPtr,
190 wxPropertyValueRealPtr,
191 wxPropertyValueboolPtr,
192 wxPropertyValueStringPtr
193 } wxPropertyValueType;
194
195 class WXDLLEXPORT wxPropertyValue: public wxObject
196 {
197 DECLARE_DYNAMIC_CLASS(wxPropertyValue)
198
199 wxPropertyValue(void); // Unknown type
200 wxPropertyValue(const wxPropertyValue& copyFrom); // Copy constructor
201 wxPropertyValue(const wxChar *val);
202 wxPropertyValue(const wxString& val);
203 wxPropertyValue(long val);
204 wxPropertyValue(bool val);
205 wxPropertyValue(float val);
206 wxPropertyValue(double the_real);
207 wxPropertyValue(wxList *val);
208 wxPropertyValue(wxStringList *val);
209 // Pointer versions
210 wxPropertyValue(wxChar **val);
211 wxPropertyValue(long *val);
212 wxPropertyValue(bool *val);
213 wxPropertyValue(float *val);
214
215 ~wxPropertyValue(void);
216
217 virtual inline wxPropertyValueType Type(void) const { return m_type; }
218 virtual inline void SetType(wxPropertyValueType typ) { m_type = typ; }
219 virtual long IntegerValue(void) const;
220 virtual float RealValue(void) const;
221 virtual bool BoolValue(void) const;
222 virtual wxChar *StringValue(void) const;
223 virtual long *IntegerValuePtr(void) const;
224 virtual float *RealValuePtr(void) const;
225 virtual bool *BoolValuePtr(void) const;
226 virtual wxChar **StringValuePtr(void) const;
227
228 // Get nth arg of clause (starting from 1)
229 virtual wxPropertyValue *Arg(wxPropertyValueType type, int arg) const;
230
231 // Return nth argument of a list expression (starting from zero)
232 virtual wxPropertyValue *Nth(int arg) const;
233 // Returns the number of elements in a list expression
234 virtual int Number(void) const;
235
236 virtual wxPropertyValue *NewCopy(void) const;
237 virtual void Copy(wxPropertyValue& copyFrom);
238
239 virtual void WritePropertyClause(wxString &stream); // Write this expression as a top-level clause
240 virtual void WritePropertyType(wxString &stream); // Write as any other subexpression
241
242 // Append an expression to a list
243 virtual void Append(wxPropertyValue *expr);
244 // Insert at beginning of list
245 virtual void Insert(wxPropertyValue *expr);
246
247 // Get first expr in list
248 virtual inline wxPropertyValue *GetFirst(void) const
249 { return ((m_type == wxPropertyValueList) ? m_value.first : (wxPropertyValue*)NULL); }
250
251 // Get next expr if this is a node in a list
252 virtual inline wxPropertyValue *GetNext(void) const
253 { return m_next; }
254
255 // Get last expr in list
256 virtual inline wxPropertyValue *GetLast(void) const
257 { return ((m_type == wxPropertyValueList) ? m_last : (wxPropertyValue*)NULL); }
258
259 // Delete this node from the list
260 virtual void Delete(wxPropertyValue *node);
261
262 // Clear list
263 virtual void ClearList(void);
264
265 virtual inline void SetClientData(wxObject *data) { m_clientData = data; }
266 virtual inline wxObject *GetClientData(void) { return m_clientData; }
267
268 virtual wxString GetStringRepresentation(void);
269
270 inline void SetModified(bool flag = TRUE) { m_modifiedFlag = flag; }
271 inline bool GetModified(void) { return m_modifiedFlag; }
272
273 // Operators
274 void operator=(const wxPropertyValue& val);
275 // void operator=(const char *val);
276 void operator=(const wxString& val);
277 void operator=(const long val);
278 void operator=(const bool val);
279 void operator=(const float val);
280 void operator=(const wxChar **val);
281 void operator=(const long *val);
282 void operator=(const bool *val);
283 void operator=(const float *val);
284
285 public:
286 wxObject* m_clientData;
287 wxPropertyValueType m_type;
288 bool m_modifiedFlag;
289
290 union {
291 long integer; // Also doubles as bool
292 wxChar *string;
293 float real;
294 long *integerPtr;
295 bool *boolPtr;
296 wxChar **stringPtr;
297 float *realPtr;
298 wxPropertyValue *first; // If is a list expr, points to the first node
299 } m_value;
300
301 wxPropertyValue* m_next; // If this is a node in a list, points to the next node
302 wxPropertyValue* m_last; // If is a list expr, points to the last node
303
304 };
305
306 /*
307 * Property class: contains a name and a value.
308 */
309
310 class WXDLLEXPORT wxProperty: public wxObject
311 {
312 DECLARE_DYNAMIC_CLASS(wxProperty)
313 protected:
314 bool m_enabled;
315 public:
316 wxPropertyValue m_value;
317 wxString m_name;
318 wxString m_propertyRole;
319 wxPropertyValidator* m_propertyValidator;
320 wxWindow* m_propertyWindow; // Usually a panel item, if anything
321
322 wxProperty(void);
323 wxProperty(wxProperty& copyFrom);
324 wxProperty(wxString name, wxString role, wxPropertyValidator *ed = NULL);
325 wxProperty(wxString name, const wxPropertyValue& val, wxString role, wxPropertyValidator *ed = NULL);
326 ~wxProperty(void);
327
328 virtual wxPropertyValue& GetValue(void) const;
329 virtual wxPropertyValidator *GetValidator(void) const;
330 virtual wxString& GetName(void) const;
331 virtual wxString& GetRole(void) const;
332 virtual void SetValue(const wxPropertyValue& val);
333 virtual void SetValidator(wxPropertyValidator *v);
334 virtual void SetName(wxString& nm);
335 virtual void SetRole(wxString& role);
336 void operator=(const wxPropertyValue& val);
337 virtual inline void SetWindow(wxWindow *win) { m_propertyWindow = win; }
338 virtual inline wxWindow *GetWindow(void) const { return m_propertyWindow; }
339
340 inline void Enable(bool en) { m_enabled = en; }
341 inline bool IsEnabled(void) const { return m_enabled; }
342 };
343
344 #endif
345 // wxUSE_PROPSHEET
346
347 #endif
348 // _WX_PROP_H_