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