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
) ) {}
151 * Some default validators
154 class WXDLLIMPEXP_DEPRECATED wxRealFormValidator
: public wxPropertyFormValidator
156 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
158 // 0.0, 0.0 means no range
159 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
161 m_realMin
= min
; m_realMax
= max
;
163 ~wxRealFormValidator(void) {}
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
);
175 class WXDLLIMPEXP_DEPRECATED wxIntegerFormValidator
: public wxPropertyFormValidator
177 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
179 // 0, 0 means no range
180 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
182 m_integerMin
= min
; m_integerMax
= max
;
184 ~wxIntegerFormValidator(void) {}
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
);
195 class WXDLLIMPEXP_DEPRECATED wxBoolFormValidator
: public wxPropertyFormValidator
197 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
200 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
203 ~wxBoolFormValidator(void) {}
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
);
210 class WXDLLIMPEXP_DEPRECATED wxStringFormValidator
: public wxPropertyFormValidator
212 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
214 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
216 ~wxStringFormValidator(void)
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
);
227 wxStringList
* m_strings
;
231 * A default dialog box class to use.
234 class WXDLLIMPEXP_DEPRECATED wxPropertyFormDialog
: public wxDialog
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"));
245 void OnCloseWindow(wxCloseEvent
& event
);
246 void OnDefaultAction(wxControl
*item
);
247 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
249 // Extend event processing to search the view's event table
250 virtual bool ProcessEvent(wxEvent
& event
);
253 wxPropertyFormView
* m_view
;
255 DECLARE_EVENT_TABLE()
256 DECLARE_CLASS(wxPropertyFormDialog
)
260 * A default panel class to use.
263 class WXDLLIMPEXP_DEPRECATED wxPropertyFormPanel
: public wxPanel
266 wxPropertyFormPanel(wxPropertyFormView
*v
= NULL
,
267 wxWindow
*parent
= NULL
,
268 const wxPoint
& pos
= wxDefaultPosition
,
269 const wxSize
& size
= wxDefaultSize
,
271 const wxString
& name
= _T("panel"))
272 : wxPanel(parent
, wxID_ANY
, pos
, size
, style
, name
)
276 void OnDefaultAction(wxControl
*item
);
277 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
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
; }
285 wxPropertyFormView
* m_view
;
287 DECLARE_CLASS(wxPropertyFormPanel
)
291 * A default frame class to use.
294 class WXDLLIMPEXP_DEPRECATED wxPropertyFormFrame
: public wxFrame
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
)
307 m_propertyPanel
= NULL
;
309 void OnCloseWindow(wxCloseEvent
& event
);
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
; }
317 wxPropertyFormView
* m_view
;
318 wxPanel
* m_propertyPanel
;
320 DECLARE_EVENT_TABLE()
321 DECLARE_CLASS(wxPropertyFormFrame
)