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