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_
16 #pragma interface "propform.h"
22 //// Property form classes: for using an existing dialog or panel
25 #define wxID_PROP_REVERT 3100
26 #define wxID_PROP_UPDATE 3101
28 // Mediates between a physical panel and the property sheet
29 class WXDLLEXPORT wxPropertyFormView
: public wxPropertyView
31 DECLARE_DYNAMIC_CLASS(wxPropertyFormView
)
33 wxPropertyFormView(wxWindow
*propPanel
= NULL
, long flags
= 0);
34 ~wxPropertyFormView(void);
36 // Associates and shows the view
37 virtual void ShowView(wxPropertySheet
*propertySheet
, wxWindow
*panel
);
39 // Update this view of the viewed object, called e.g. by
41 virtual bool OnUpdateView(void);
43 // Transfer values from property sheet to dialog
44 virtual bool TransferToDialog(void);
46 // Transfer values from dialog to property sheet
47 virtual bool TransferToPropertySheet(void);
49 // Check that all the values are valid
50 virtual bool Check(void);
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);
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
);
64 virtual bool OnClose();
65 virtual void OnDoubleClick(wxControl
*item
);
67 // TODO: does OnCommand still get called...??? No,
68 // make ProcessEvent do it.
69 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
71 // Extend event processing to process OnCommand
72 virtual bool ProcessEvent(wxEvent
& event
);
74 inline virtual void AssociatePanel(wxWindow
*win
) { m_propertyWindow
= win
; }
75 inline virtual wxWindow
*GetPanel(void) const { return m_propertyWindow
; }
77 inline virtual void SetManagedWindow(wxWindow
*win
) { m_managedWindow
= win
; }
78 inline virtual wxWindow
*GetManagedWindow(void) const { return m_managedWindow
; }
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
; }
85 static bool sm_dialogCancelled
;
88 bool m_detailedEditing
; // E.g. using listbox for choices
90 wxWindow
* m_propertyWindow
; // Panel that the controls will appear on
91 wxWindow
* m_managedWindow
; // Frame or dialog
93 wxButton
* m_windowCloseButton
; // Or OK
94 wxButton
* m_windowCancelButton
;
95 wxButton
* m_windowHelpButton
;
102 * The type of validator used for forms (wxForm style but using an existing panel
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.
116 class WXDLLEXPORT wxPropertyFormValidator
: public wxPropertyValidator
118 DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator
)
121 wxPropertyFormValidator(long flags
= 0): wxPropertyValidator(flags
) { }
122 ~wxPropertyFormValidator(void) {}
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.
126 virtual bool OnCheckValue( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
127 wxWindow
*WXUNUSED(parentWindow
) ) { return TRUE
; }
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;
133 // Called by the view to transfer the property to the window.
134 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
136 virtual void OnDoubleClick( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
137 wxWindow
*WXUNUSED(parentWindow
) ) { }
138 virtual void OnSetFocus( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
139 wxWindow
*WXUNUSED(parentWindow
) ) { }
140 virtual void OnKillFocus( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
141 wxWindow
*WXUNUSED(parentWindow
) ) { }
142 virtual void OnCommand( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
143 wxWindow
*WXUNUSED(parentWindow
), wxCommandEvent
& WXUNUSED(event
) ) {}
147 * Some default validators
150 class WXDLLEXPORT wxRealFormValidator
: public wxPropertyFormValidator
152 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
154 // 0.0, 0.0 means no range
155 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
157 m_realMin
= min
; m_realMax
= max
;
159 ~wxRealFormValidator(void) {}
161 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
162 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
163 // Called by the view to transfer the property to the window.
164 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
171 class WXDLLEXPORT wxIntegerFormValidator
: public wxPropertyFormValidator
173 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
175 // 0, 0 means no range
176 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
178 m_integerMin
= min
; m_integerMax
= max
;
180 ~wxIntegerFormValidator(void) {}
182 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
183 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
184 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
191 class WXDLLEXPORT wxBoolFormValidator
: public wxPropertyFormValidator
193 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
196 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
199 ~wxBoolFormValidator(void) {}
201 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
202 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
203 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
206 class WXDLLEXPORT wxStringFormValidator
: public wxPropertyFormValidator
208 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
210 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
212 ~wxStringFormValidator(void)
218 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
219 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
220 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
223 wxStringList
* m_strings
;
227 * A default dialog box class to use.
230 class WXDLLEXPORT wxPropertyFormDialog
: public wxDialog
232 DECLARE_CLASS(wxPropertyFormDialog
)
234 wxPropertyFormDialog(wxPropertyFormView
*v
, wxWindow
*parent
, const wxString
& title
,
235 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
236 long style
= wxDEFAULT_DIALOG_STYLE
, const wxString
& name
= "dialogBox");
238 void OnCloseWindow(wxCloseEvent
& event
);
239 void OnDefaultAction(wxControl
*item
);
240 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
242 // Extend event processing to search the view's event table
243 virtual bool ProcessEvent(wxEvent
& event
);
246 wxPropertyFormView
* m_view
;
248 DECLARE_EVENT_TABLE()
252 * A default panel class to use.
255 class WXDLLEXPORT wxPropertyFormPanel
: public wxPanel
257 DECLARE_CLASS(wxPropertyFormPanel
)
259 wxPropertyFormPanel(wxPropertyFormView
*v
, wxWindow
*parent
, const wxPoint
& pos
= wxDefaultPosition
,
260 const wxSize
& size
= wxDefaultSize
, long style
= 0, const wxString
& name
= "panel"):
261 wxPanel(parent
, -1, pos
, size
, style
, name
)
265 void OnDefaultAction(wxControl
*item
);
266 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
268 // Extend event processing to search the view's event table
269 virtual bool ProcessEvent(wxEvent
& event
);
272 wxPropertyFormView
* m_view
;
276 * A default frame class to use.
279 class WXDLLEXPORT wxPropertyFormFrame
: public wxFrame
281 DECLARE_CLASS(wxPropertyFormFrame
)
283 wxPropertyFormFrame(wxPropertyFormView
*v
, wxFrame
*parent
, const wxString
& title
,
284 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
285 long style
= wxDEFAULT_FRAME_STYLE
, const wxString
& name
= "frame"):
286 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
289 m_propertyPanel
= NULL
;
291 void OnCloseWindow(wxCloseEvent
& event
);
293 // Must call this to create panel and associate view
294 virtual bool Initialize(void);
295 virtual wxPanel
*OnCreatePanel(wxFrame
*parent
, wxPropertyFormView
*v
);
296 inline virtual wxPanel
*GetPropertyPanel(void) const { return m_propertyPanel
; }
299 wxPropertyFormView
* m_view
;
300 wxPanel
* m_propertyPanel
;
302 DECLARE_EVENT_TABLE()