]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/deprecated/propform.h
wxUSE_EXTENDED_RTTI as name
[wxWidgets.git] / contrib / include / wx / deprecated / propform.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: propform.h
3 // Purpose: Property form 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_PROPFORM_H_
13 #define _WX_PROPFORM_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "propform.h"
17 #endif
18
19 #include "wx/deprecated/setup.h"
20
21 #if wxUSE_PROPSHEET
22
23 #include "wx/deprecated/prop.h"
24 #include "wx/panel.h"
25
26 class WXDLLEXPORT wxPropertyFormView;
27
28 ////
29 //// Property form classes: for using an existing dialog or panel
30 ////
31
32 #define wxID_PROP_REVERT 3100
33 #define wxID_PROP_UPDATE 3101
34
35 // Mediates between a physical panel and the property sheet
36 class WXDLLEXPORT wxPropertyFormView: public wxPropertyView
37 {
38 DECLARE_DYNAMIC_CLASS(wxPropertyFormView)
39 public:
40 wxPropertyFormView(wxWindow *propPanel = NULL, long flags = 0);
41 ~wxPropertyFormView(void);
42
43 // Associates and shows the view
44 virtual void ShowView(wxPropertySheet *propertySheet, wxWindow *panel);
45
46 // Update this view of the viewed object, called e.g. by
47 // the object itself.
48 virtual bool OnUpdateView(void);
49
50 // Transfer values from property sheet to dialog
51 virtual bool TransferToDialog(void);
52
53 // Transfer values from dialog to property sheet
54 virtual bool TransferToPropertySheet(void);
55
56 // Check that all the values are valid
57 virtual bool Check(void);
58
59 // Give each property in the sheet a panel item, by matching
60 // the name of the property to the name of the panel item.
61 // The user doesn't always want to call this; sometimes, it
62 // will have been done explicitly (e.g., no matching names).
63 virtual bool AssociateNames(void);
64
65 void OnOk(wxCommandEvent& event);
66 void OnCancel(wxCommandEvent& event);
67 void OnHelp(wxCommandEvent& event);
68 void OnUpdate(wxCommandEvent& event);
69 void OnRevert(wxCommandEvent& event);
70
71 virtual bool OnClose();
72 virtual void OnDoubleClick(wxControl *item);
73
74 // TODO: does OnCommand still get called...??? No,
75 // make ProcessEvent do it.
76 virtual void OnCommand(wxWindow& win, wxCommandEvent& event);
77
78 // Extend event processing to process OnCommand
79 virtual bool ProcessEvent(wxEvent& event);
80
81 inline virtual void AssociatePanel(wxWindow *win) { m_propertyWindow = win; }
82 inline virtual wxWindow *GetPanel(void) const { return m_propertyWindow; }
83
84 inline virtual void SetManagedWindow(wxWindow *win) { m_managedWindow = win; }
85 inline virtual wxWindow *GetManagedWindow(void) const { return m_managedWindow; }
86
87 inline virtual wxButton *GetWindowCloseButton() const { return m_windowCloseButton; }
88 inline virtual wxButton *GetWindowCancelButton() const { return m_windowCancelButton; }
89 inline virtual wxButton *GetHelpButton() const { return m_windowHelpButton; }
90
91 public:
92 static bool sm_dialogCancelled;
93
94 protected:
95 bool m_detailedEditing; // E.g. using listbox for choices
96
97 wxWindow* m_propertyWindow; // Panel that the controls will appear on
98 wxWindow* m_managedWindow; // Frame or dialog
99
100 wxButton* m_windowCloseButton; // Or OK
101 wxButton* m_windowCancelButton;
102 wxButton* m_windowHelpButton;
103
104 DECLARE_EVENT_TABLE()
105
106 };
107
108 /*
109 * The type of validator used for forms (wxForm style but using an existing panel
110 * or dialog box).
111 * Classes derived from this know how to map from whatever widget they
112 * find themselves paired with, to the wxProperty and vice versa.
113 * Should the widget pointer be stored with the validator, or
114 * the wxProperty? If with the property, we don't have to supply
115 * a validator for every property. Otherwise, there ALWAYS needs
116 * to be a validator. On the other hand, not storing a wxWindow pointer
117 * in the wxProperty is more elegant. Perhaps.
118 * I think on balance, should put wxWindow pointer into wxProperty.
119 * After all, wxProperty will often be used to represent the data
120 * assocated with a window. It's that kinda thing.
121 */
122
123 class WXDLLEXPORT wxPropertyFormValidator: public wxPropertyValidator
124 {
125 DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator)
126 protected:
127 public:
128 wxPropertyFormValidator(long flags = 0): wxPropertyValidator(flags) { }
129 ~wxPropertyFormValidator(void) {}
130
131 // Called to check value is OK (e.g. when OK is pressed)
132 // Return FALSE if value didn't check out; signal to restore old value.
133 virtual bool OnCheckValue( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view),
134 wxWindow *WXUNUSED(parentWindow) ) { return TRUE; }
135
136 // Does the transferance from the property editing area to the property itself.
137 // Called by the view, e.g. when closing the window.
138 virtual bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow) = 0;
139
140 // Called by the view to transfer the property to the window.
141 virtual bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow) = 0;
142
143 virtual void OnDoubleClick( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view),
144 wxWindow *WXUNUSED(parentWindow) ) { }
145 virtual void OnSetFocus( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view),
146 wxWindow *WXUNUSED(parentWindow) ) { }
147 virtual void OnKillFocus( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view),
148 wxWindow *WXUNUSED(parentWindow) ) { }
149 virtual void OnCommand( wxProperty *WXUNUSED(property), wxPropertyFormView *WXUNUSED(view),
150 wxWindow *WXUNUSED(parentWindow), wxCommandEvent& WXUNUSED(event) ) {}
151 private:
152 // Virtual function hiding suppression
153 #if WXWIN_COMPATIBILITY_2
154 virtual void OnCommand(wxWindow& win,
155 wxCommandEvent& event)
156 { wxEvtHandler::OnCommand(win, event); }
157 #endif
158 };
159
160 /*
161 * Some default validators
162 */
163
164 class WXDLLEXPORT wxRealFormValidator: public wxPropertyFormValidator
165 {
166 DECLARE_DYNAMIC_CLASS(wxRealFormValidator)
167 public:
168 // 0.0, 0.0 means no range
169 wxRealFormValidator(float min = 0.0, float max = 0.0, long flags = 0):wxPropertyFormValidator(flags)
170 {
171 m_realMin = min; m_realMax = max;
172 }
173 ~wxRealFormValidator(void) {}
174
175 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
176 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
177 // Called by the view to transfer the property to the window.
178 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
179
180 protected:
181 float m_realMin;
182 float m_realMax;
183 };
184
185 class WXDLLEXPORT wxIntegerFormValidator: public wxPropertyFormValidator
186 {
187 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator)
188 public:
189 // 0, 0 means no range
190 wxIntegerFormValidator(long min = 0, long max = 0, long flags = 0):wxPropertyFormValidator(flags)
191 {
192 m_integerMin = min; m_integerMax = max;
193 }
194 ~wxIntegerFormValidator(void) {}
195
196 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
197 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
198 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
199
200 protected:
201 long m_integerMin;
202 long m_integerMax;
203 };
204
205 class WXDLLEXPORT wxBoolFormValidator: public wxPropertyFormValidator
206 {
207 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator)
208 protected:
209 public:
210 wxBoolFormValidator(long flags = 0):wxPropertyFormValidator(flags)
211 {
212 }
213 ~wxBoolFormValidator(void) {}
214
215 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
216 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
217 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
218 };
219
220 class WXDLLEXPORT wxStringFormValidator: public wxPropertyFormValidator
221 {
222 DECLARE_DYNAMIC_CLASS(wxStringFormValidator)
223 public:
224 wxStringFormValidator(wxStringList *list = NULL, long flags = 0);
225
226 ~wxStringFormValidator(void)
227 {
228 if (m_strings)
229 delete m_strings;
230 }
231
232 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
233 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
234 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
235
236 protected:
237 wxStringList* m_strings;
238 };
239
240 /*
241 * A default dialog box class to use.
242 */
243
244 class WXDLLEXPORT wxPropertyFormDialog: public wxDialog
245 {
246 public:
247 wxPropertyFormDialog(wxPropertyFormView *v = NULL,
248 wxWindow *parent = NULL,
249 const wxString& title = wxEmptyString,
250 const wxPoint& pos = wxDefaultPosition,
251 const wxSize& size = wxDefaultSize,
252 long style = wxDEFAULT_DIALOG_STYLE,
253 const wxString& name = _T("dialogBox"));
254
255 void OnCloseWindow(wxCloseEvent& event);
256 void OnDefaultAction(wxControl *item);
257 void OnCommand(wxWindow& win, wxCommandEvent& event);
258
259 // Extend event processing to search the view's event table
260 virtual bool ProcessEvent(wxEvent& event);
261
262 private:
263 wxPropertyFormView* m_view;
264
265 DECLARE_EVENT_TABLE()
266 DECLARE_CLASS(wxPropertyFormDialog)
267 };
268
269 /*
270 * A default panel class to use.
271 */
272
273 class WXDLLEXPORT wxPropertyFormPanel: public wxPanel
274 {
275 public:
276 wxPropertyFormPanel(wxPropertyFormView *v = NULL,
277 wxWindow *parent = NULL,
278 const wxPoint& pos = wxDefaultPosition,
279 const wxSize& size = wxDefaultSize,
280 long style = 0,
281 const wxString& name = _T("panel"))
282 : wxPanel(parent, -1, pos, size, style, name)
283 {
284 m_view = v;
285 }
286 void OnDefaultAction(wxControl *item);
287 void OnCommand(wxWindow& win, wxCommandEvent& event);
288
289 // Extend event processing to search the view's event table
290 virtual bool ProcessEvent(wxEvent& event);
291 void SetView(wxPropertyFormView* view) { m_view = view; }
292 wxPropertyFormView* GetView() const { return m_view; }
293
294 private:
295 wxPropertyFormView* m_view;
296
297 DECLARE_CLASS(wxPropertyFormPanel)
298 };
299
300 /*
301 * A default frame class to use.
302 */
303
304 class WXDLLEXPORT wxPropertyFormFrame: public wxFrame
305 {
306 public:
307 wxPropertyFormFrame(wxPropertyFormView *v = NULL,
308 wxFrame *parent = NULL,
309 const wxString& title = wxEmptyString,
310 const wxPoint& pos = wxDefaultPosition,
311 const wxSize& size = wxDefaultSize,
312 long style = wxDEFAULT_FRAME_STYLE,
313 const wxString& name = _T("frame"))
314 : wxFrame(parent, -1, title, pos, size, style, name)
315 {
316 m_view = v;
317 m_propertyPanel = NULL;
318 }
319 void OnCloseWindow(wxCloseEvent& event);
320
321 // Must call this to create panel and associate view
322 virtual bool Initialize(void);
323 virtual wxPanel *OnCreatePanel(wxFrame *parent, wxPropertyFormView *v);
324 inline virtual wxPanel *GetPropertyPanel(void) const { return m_propertyPanel; }
325
326 private:
327 wxPropertyFormView* m_view;
328 wxPanel* m_propertyPanel;
329
330 DECLARE_EVENT_TABLE()
331 DECLARE_CLASS(wxPropertyFormFrame)
332 };
333
334 #endif
335 // wxUSE_PROPSHEET
336
337 #endif
338 // _WX_PROPFORM_H_