1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Property form classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPFORM_H_
13 #define _WX_PROPFORM_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "propform.h"
19 #include "wx/deprecated/setup.h"
23 #include "wx/deprecated/prop.h"
26 class WXDLLIMPEXP_DEPRECATED wxPropertyFormView
;
29 //// Property form classes: for using an existing dialog or panel
32 #define wxID_PROP_REVERT 3100
33 #define wxID_PROP_UPDATE 3101
35 // Mediates between a physical panel and the property sheet
36 class WXDLLIMPEXP_DEPRECATED wxPropertyFormView
: public wxPropertyView
38 DECLARE_DYNAMIC_CLASS(wxPropertyFormView
)
40 wxPropertyFormView(wxWindow
*propPanel
= NULL
, long flags
= 0);
41 ~wxPropertyFormView(void);
43 // Associates and shows the view
44 virtual void ShowView(wxPropertySheet
*propertySheet
, wxWindow
*panel
);
46 // Update this view of the viewed object, called e.g. by
48 virtual bool OnUpdateView(void);
50 // Transfer values from property sheet to dialog
51 virtual bool TransferToDialog(void);
53 // Transfer values from dialog to property sheet
54 virtual bool TransferToPropertySheet(void);
56 // Check that all the values are valid
57 virtual bool Check(void);
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);
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
);
71 virtual bool OnClose();
72 virtual void OnDoubleClick(wxControl
*item
);
74 // TODO: does OnCommand still get called...??? No,
75 // make ProcessEvent do it.
76 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
78 // Extend event processing to process OnCommand
79 virtual bool ProcessEvent(wxEvent
& event
);
81 inline virtual void AssociatePanel(wxWindow
*win
) { m_propertyWindow
= win
; }
82 inline virtual wxWindow
*GetPanel(void) const { return m_propertyWindow
; }
84 inline virtual void SetManagedWindow(wxWindow
*win
) { m_managedWindow
= win
; }
85 inline virtual wxWindow
*GetManagedWindow(void) const { return m_managedWindow
; }
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
; }
92 static bool sm_dialogCancelled
;
95 bool m_detailedEditing
; // E.g. using listbox for choices
97 wxWindow
* m_propertyWindow
; // Panel that the controls will appear on
98 wxWindow
* m_managedWindow
; // Frame or dialog
100 wxButton
* m_windowCloseButton
; // Or OK
101 wxButton
* m_windowCancelButton
;
102 wxButton
* m_windowHelpButton
;
104 DECLARE_EVENT_TABLE()
109 * The type of validator used for forms (wxForm style but using an existing panel
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.
123 class WXDLLIMPEXP_DEPRECATED wxPropertyFormValidator
: public wxPropertyValidator
125 DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator
)
128 wxPropertyFormValidator(long flags
= 0): wxPropertyValidator(flags
) { }
129 ~wxPropertyFormValidator(void) {}
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; }
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;
140 // Called by the view to transfer the property to the window.
141 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
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
) ) {}
152 // Virtual function hiding suppression
153 #if WXWIN_COMPATIBILITY_2
154 virtual void OnCommand(wxWindow
& win
,
155 wxCommandEvent
& event
)
156 { wxEvtHandler::OnCommand(win
, event
); }
161 * Some default validators
164 class WXDLLIMPEXP_DEPRECATED wxRealFormValidator
: public wxPropertyFormValidator
166 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
168 // 0.0, 0.0 means no range
169 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
171 m_realMin
= min
; m_realMax
= max
;
173 ~wxRealFormValidator(void) {}
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
);
185 class WXDLLIMPEXP_DEPRECATED wxIntegerFormValidator
: public wxPropertyFormValidator
187 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
189 // 0, 0 means no range
190 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
192 m_integerMin
= min
; m_integerMax
= max
;
194 ~wxIntegerFormValidator(void) {}
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
);
205 class WXDLLIMPEXP_DEPRECATED wxBoolFormValidator
: public wxPropertyFormValidator
207 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
210 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
213 ~wxBoolFormValidator(void) {}
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
);
220 class WXDLLIMPEXP_DEPRECATED wxStringFormValidator
: public wxPropertyFormValidator
222 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
224 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
226 ~wxStringFormValidator(void)
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
);
237 wxStringList
* m_strings
;
241 * A default dialog box class to use.
244 class WXDLLIMPEXP_DEPRECATED wxPropertyFormDialog
: public wxDialog
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"));
255 void OnCloseWindow(wxCloseEvent
& event
);
256 void OnDefaultAction(wxControl
*item
);
257 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
259 // Extend event processing to search the view's event table
260 virtual bool ProcessEvent(wxEvent
& event
);
263 wxPropertyFormView
* m_view
;
265 DECLARE_EVENT_TABLE()
266 DECLARE_CLASS(wxPropertyFormDialog
)
270 * A default panel class to use.
273 class WXDLLIMPEXP_DEPRECATED wxPropertyFormPanel
: public wxPanel
276 wxPropertyFormPanel(wxPropertyFormView
*v
= NULL
,
277 wxWindow
*parent
= NULL
,
278 const wxPoint
& pos
= wxDefaultPosition
,
279 const wxSize
& size
= wxDefaultSize
,
281 const wxString
& name
= _T("panel"))
282 : wxPanel(parent
, wxID_ANY
, pos
, size
, style
, name
)
286 void OnDefaultAction(wxControl
*item
);
287 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
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
; }
295 wxPropertyFormView
* m_view
;
297 DECLARE_CLASS(wxPropertyFormPanel
)
301 * A default frame class to use.
304 class WXDLLIMPEXP_DEPRECATED wxPropertyFormFrame
: public wxFrame
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
, wxID_ANY
, title
, pos
, size
, style
, name
)
317 m_propertyPanel
= NULL
;
319 void OnCloseWindow(wxCloseEvent
& event
);
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
; }
327 wxPropertyFormView
* m_view
;
328 wxPanel
* m_propertyPanel
;
330 DECLARE_EVENT_TABLE()
331 DECLARE_CLASS(wxPropertyFormFrame
)