]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/deprecated/propform.h
added support for colour cursors in wxGTK (patch 1655576)
[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 };
149
150 /*
151 * Some default validators
152 */
153
154 class WXDLLIMPEXP_DEPRECATED wxRealFormValidator: public wxPropertyFormValidator
155 {
156 DECLARE_DYNAMIC_CLASS(wxRealFormValidator)
157 public:
158 // 0.0, 0.0 means no range
159 wxRealFormValidator(float min = 0.0, float max = 0.0, long flags = 0):wxPropertyFormValidator(flags)
160 {
161 m_realMin = min; m_realMax = max;
162 }
163 ~wxRealFormValidator(void) {}
164
165 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
166 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
167 // Called by the view to transfer the property to the window.
168 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
169
170 protected:
171 float m_realMin;
172 float m_realMax;
173 };
174
175 class WXDLLIMPEXP_DEPRECATED wxIntegerFormValidator: public wxPropertyFormValidator
176 {
177 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator)
178 public:
179 // 0, 0 means no range
180 wxIntegerFormValidator(long min = 0, long max = 0, long flags = 0):wxPropertyFormValidator(flags)
181 {
182 m_integerMin = min; m_integerMax = max;
183 }
184 ~wxIntegerFormValidator(void) {}
185
186 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
187 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
188 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
189
190 protected:
191 long m_integerMin;
192 long m_integerMax;
193 };
194
195 class WXDLLIMPEXP_DEPRECATED wxBoolFormValidator: public wxPropertyFormValidator
196 {
197 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator)
198 protected:
199 public:
200 wxBoolFormValidator(long flags = 0):wxPropertyFormValidator(flags)
201 {
202 }
203 ~wxBoolFormValidator(void) {}
204
205 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
206 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
207 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
208 };
209
210 class WXDLLIMPEXP_DEPRECATED wxStringFormValidator: public wxPropertyFormValidator
211 {
212 DECLARE_DYNAMIC_CLASS(wxStringFormValidator)
213 public:
214 wxStringFormValidator(wxStringList *list = NULL, long flags = 0);
215
216 ~wxStringFormValidator(void)
217 {
218 if (m_strings)
219 delete m_strings;
220 }
221
222 bool OnCheckValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
223 bool OnRetrieveValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
224 bool OnDisplayValue(wxProperty *property, wxPropertyFormView *view, wxWindow *parentWindow);
225
226 protected:
227 wxStringList* m_strings;
228 };
229
230 /*
231 * A default dialog box class to use.
232 */
233
234 class WXDLLIMPEXP_DEPRECATED wxPropertyFormDialog: public wxDialog
235 {
236 public:
237 wxPropertyFormDialog(wxPropertyFormView *v = NULL,
238 wxWindow *parent = NULL,
239 const wxString& title = wxEmptyString,
240 const wxPoint& pos = wxDefaultPosition,
241 const wxSize& size = wxDefaultSize,
242 long style = wxDEFAULT_DIALOG_STYLE,
243 const wxString& name = _T("dialogBox"));
244
245 void OnCloseWindow(wxCloseEvent& event);
246 void OnDefaultAction(wxControl *item);
247 void OnCommand(wxWindow& win, wxCommandEvent& event);
248
249 // Extend event processing to search the view's event table
250 virtual bool ProcessEvent(wxEvent& event);
251
252 private:
253 wxPropertyFormView* m_view;
254
255 DECLARE_EVENT_TABLE()
256 DECLARE_CLASS(wxPropertyFormDialog)
257 };
258
259 /*
260 * A default panel class to use.
261 */
262
263 class WXDLLIMPEXP_DEPRECATED wxPropertyFormPanel: public wxPanel
264 {
265 public:
266 wxPropertyFormPanel(wxPropertyFormView *v = NULL,
267 wxWindow *parent = NULL,
268 const wxPoint& pos = wxDefaultPosition,
269 const wxSize& size = wxDefaultSize,
270 long style = 0,
271 const wxString& name = _T("panel"))
272 : wxPanel(parent, wxID_ANY, pos, size, style, name)
273 {
274 m_view = v;
275 }
276 void OnDefaultAction(wxControl *item);
277 void OnCommand(wxWindow& win, wxCommandEvent& event);
278
279 // Extend event processing to search the view's event table
280 virtual bool ProcessEvent(wxEvent& event);
281 void SetView(wxPropertyFormView* view) { m_view = view; }
282 wxPropertyFormView* GetView() const { return m_view; }
283
284 private:
285 wxPropertyFormView* m_view;
286
287 DECLARE_CLASS(wxPropertyFormPanel)
288 };
289
290 /*
291 * A default frame class to use.
292 */
293
294 class WXDLLIMPEXP_DEPRECATED wxPropertyFormFrame: public wxFrame
295 {
296 public:
297 wxPropertyFormFrame(wxPropertyFormView *v = NULL,
298 wxFrame *parent = NULL,
299 const wxString& title = wxEmptyString,
300 const wxPoint& pos = wxDefaultPosition,
301 const wxSize& size = wxDefaultSize,
302 long style = wxDEFAULT_FRAME_STYLE,
303 const wxString& name = _T("frame"))
304 : wxFrame(parent, wxID_ANY, title, pos, size, style, name)
305 {
306 m_view = v;
307 m_propertyPanel = NULL;
308 }
309 void OnCloseWindow(wxCloseEvent& event);
310
311 // Must call this to create panel and associate view
312 virtual bool Initialize(void);
313 virtual wxPanel *OnCreatePanel(wxFrame *parent, wxPropertyFormView *v);
314 inline virtual wxPanel *GetPropertyPanel(void) const { return m_propertyPanel; }
315
316 private:
317 wxPropertyFormView* m_view;
318 wxPanel* m_propertyPanel;
319
320 DECLARE_EVENT_TABLE()
321 DECLARE_CLASS(wxPropertyFormFrame)
322 };
323
324 #endif
325 // wxUSE_PROPSHEET
326
327 #endif
328 // _WX_PROPFORM_H_