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 #include "wx/deprecated/setup.h"
19 #include "wx/deprecated/prop.h"
22 class WXDLLIMPEXP_DEPRECATED wxPropertyFormView
;
25 //// Property form classes: for using an existing dialog or panel
28 #define wxID_PROP_REVERT 3100
29 #define wxID_PROP_UPDATE 3101
31 // Mediates between a physical panel and the property sheet
32 class WXDLLIMPEXP_DEPRECATED wxPropertyFormView
: public wxPropertyView
34 DECLARE_DYNAMIC_CLASS(wxPropertyFormView
)
36 wxPropertyFormView(wxWindow
*propPanel
= NULL
, long flags
= 0);
37 ~wxPropertyFormView(void);
39 // Associates and shows the view
40 virtual void ShowView(wxPropertySheet
*propertySheet
, wxWindow
*panel
);
42 // Update this view of the viewed object, called e.g. by
44 virtual bool OnUpdateView(void);
46 // Transfer values from property sheet to dialog
47 virtual bool TransferToDialog(void);
49 // Transfer values from dialog to property sheet
50 virtual bool TransferToPropertySheet(void);
52 // Check that all the values are valid
53 virtual bool Check(void);
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);
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
);
67 virtual bool OnClose();
68 virtual void OnDoubleClick(wxControl
*item
);
70 // TODO: does OnCommand still get called...??? No,
71 // make ProcessEvent do it.
72 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
74 // Extend event processing to process OnCommand
75 virtual bool ProcessEvent(wxEvent
& event
);
77 inline virtual void AssociatePanel(wxWindow
*win
) { m_propertyWindow
= win
; }
78 inline virtual wxWindow
*GetPanel(void) const { return m_propertyWindow
; }
80 inline virtual void SetManagedWindow(wxWindow
*win
) { m_managedWindow
= win
; }
81 inline virtual wxWindow
*GetManagedWindow(void) const { return m_managedWindow
; }
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
; }
88 static bool sm_dialogCancelled
;
91 bool m_detailedEditing
; // E.g. using listbox for choices
93 wxWindow
* m_propertyWindow
; // Panel that the controls will appear on
94 wxWindow
* m_managedWindow
; // Frame or dialog
96 wxButton
* m_windowCloseButton
; // Or OK
97 wxButton
* m_windowCancelButton
;
98 wxButton
* m_windowHelpButton
;
100 DECLARE_EVENT_TABLE()
105 * The type of validator used for forms (wxForm style but using an existing panel
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.
119 class WXDLLIMPEXP_DEPRECATED wxPropertyFormValidator
: public wxPropertyValidator
121 DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator
)
124 wxPropertyFormValidator(long flags
= 0): wxPropertyValidator(flags
) { }
125 ~wxPropertyFormValidator(void) {}
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; }
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;
136 // Called by the view to transfer the property to the window.
137 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
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
) ) {}
148 // Virtual function hiding suppression
149 #if WXWIN_COMPATIBILITY_2
150 virtual void OnCommand(wxWindow
& win
,
151 wxCommandEvent
& event
)
152 { wxEvtHandler::OnCommand(win
, event
); }
157 * Some default validators
160 class WXDLLIMPEXP_DEPRECATED wxRealFormValidator
: public wxPropertyFormValidator
162 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
164 // 0.0, 0.0 means no range
165 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
167 m_realMin
= min
; m_realMax
= max
;
169 ~wxRealFormValidator(void) {}
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
);
181 class WXDLLIMPEXP_DEPRECATED wxIntegerFormValidator
: public wxPropertyFormValidator
183 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
185 // 0, 0 means no range
186 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
188 m_integerMin
= min
; m_integerMax
= max
;
190 ~wxIntegerFormValidator(void) {}
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
);
201 class WXDLLIMPEXP_DEPRECATED wxBoolFormValidator
: public wxPropertyFormValidator
203 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
206 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
209 ~wxBoolFormValidator(void) {}
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
);
216 class WXDLLIMPEXP_DEPRECATED wxStringFormValidator
: public wxPropertyFormValidator
218 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
220 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
222 ~wxStringFormValidator(void)
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
);
233 wxStringList
* m_strings
;
237 * A default dialog box class to use.
240 class WXDLLIMPEXP_DEPRECATED wxPropertyFormDialog
: public wxDialog
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"));
251 void OnCloseWindow(wxCloseEvent
& event
);
252 void OnDefaultAction(wxControl
*item
);
253 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
255 // Extend event processing to search the view's event table
256 virtual bool ProcessEvent(wxEvent
& event
);
259 wxPropertyFormView
* m_view
;
261 DECLARE_EVENT_TABLE()
262 DECLARE_CLASS(wxPropertyFormDialog
)
266 * A default panel class to use.
269 class WXDLLIMPEXP_DEPRECATED wxPropertyFormPanel
: public wxPanel
272 wxPropertyFormPanel(wxPropertyFormView
*v
= NULL
,
273 wxWindow
*parent
= NULL
,
274 const wxPoint
& pos
= wxDefaultPosition
,
275 const wxSize
& size
= wxDefaultSize
,
277 const wxString
& name
= _T("panel"))
278 : wxPanel(parent
, wxID_ANY
, pos
, size
, style
, name
)
282 void OnDefaultAction(wxControl
*item
);
283 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
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
; }
291 wxPropertyFormView
* m_view
;
293 DECLARE_CLASS(wxPropertyFormPanel
)
297 * A default frame class to use.
300 class WXDLLIMPEXP_DEPRECATED wxPropertyFormFrame
: public wxFrame
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
)
313 m_propertyPanel
= NULL
;
315 void OnCloseWindow(wxCloseEvent
& event
);
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
; }
323 wxPropertyFormView
* m_view
;
324 wxPanel
* m_propertyPanel
;
326 DECLARE_EVENT_TABLE()
327 DECLARE_CLASS(wxPropertyFormFrame
)