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