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