]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxprop/src/propform.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Property form classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
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 wxPropertyFormView
: public wxPropertyView
31 DECLARE_DYNAMIC_CLASS(wxPropertyFormView
)
33 bool detailedEditing
; // E.g. using listbox for choices
35 wxWindow
*propertyWindow
; // Panel that the controls will appear on
36 wxWindow
*managedWindow
; // Frame or dialog
38 wxButton
*windowCloseButton
; // Or OK
39 wxButton
*windowCancelButton
;
40 wxButton
*windowHelpButton
;
42 static bool dialogCancelled
;
44 wxPropertyFormView(wxWindow
*propPanel
= NULL
, long flags
= 0);
45 ~wxPropertyFormView(void);
47 // Associates and shows the view
48 virtual void ShowView(wxPropertySheet
*propertySheet
, wxWindow
*panel
);
50 // Update this view of the viewed object, called e.g. by
52 virtual bool OnUpdateView(void);
54 // Transfer values from property sheet to dialog
55 virtual bool TransferToDialog(void);
57 // Transfer values from dialog to property sheet
58 virtual bool TransferToPropertySheet(void);
60 // Check that all the values are valid
61 virtual bool Check(void);
63 // Give each property in the sheet a panel item, by matching
64 // the name of the property to the name of the panel item.
65 // The user doesn't always want to call this; sometimes, it
66 // will have been done explicitly (e.g., no matching names).
67 virtual bool AssociateNames(void);
69 void OnOk(wxCommandEvent
& event
);
70 void OnCancel(wxCommandEvent
& event
);
71 void OnHelp(wxCommandEvent
& event
);
72 void OnUpdate(wxCommandEvent
& event
);
73 void OnRevert(wxCommandEvent
& event
);
75 virtual bool OnClose(void);
76 virtual void OnDoubleClick(wxControl
*item
);
78 // TODO: does OnCommand still get called...???
79 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
81 inline virtual void AssociatePanel(wxWindow
*win
) { propertyWindow
= win
; }
82 inline virtual wxWindow
*GetPanel(void) { return propertyWindow
; }
84 inline virtual void SetManagedWindow(wxWindow
*win
) { managedWindow
= win
; }
85 inline virtual wxWindow
*GetManagedWindow(void) { return managedWindow
; }
87 inline virtual wxButton
*GetWindowCloseButton() { return windowCloseButton
; }
88 inline virtual wxButton
*GetWindowCancelButton() { return windowCancelButton
; }
89 inline virtual wxButton
*GetHelpButton() { return windowHelpButton
; }
96 * The type of validator used for forms (wxForm style but using an existing panel
98 * Classes derived from this know how to map from whatever widget they
99 * find themselves paired with, to the wxProperty and vice versa.
100 * Should the widget pointer be stored with the validator, or
101 * the wxProperty? If with the property, we don't have to supply
102 * a validator for every property. Otherwise, there ALWAYS needs
103 * to be a validator. On the other hand, not storing a wxWindow pointer
104 * in the wxProperty is more elegant. Perhaps.
105 * I think on balance, should put wxWindow pointer into wxProperty.
106 * After all, wxProperty will often be used to represent the data
107 * assocated with a window. It's that kinda thing.
110 class wxPropertyFormValidator
: public wxPropertyValidator
112 DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator
)
115 wxPropertyFormValidator(long flags
= 0): wxPropertyValidator(flags
) { }
116 ~wxPropertyFormValidator(void) {}
118 // Called to check value is OK (e.g. when OK is pressed)
119 // Return FALSE if value didn't check out; signal to restore old value.
120 virtual bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
)
123 // Does the transferance from the property editing area to the property itself.
124 // Called by the view, e.g. when closing the window.
125 virtual bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
127 // Called by the view to transfer the property to the window.
128 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
130 virtual void OnDoubleClick(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) {};
131 virtual void OnSetFocus(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) {};
132 virtual void OnKillFocus(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) {};
133 virtual void OnCommand(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
, wxCommandEvent
& event
) {};
138 * Some default validators
141 class wxRealFormValidator
: public wxPropertyFormValidator
143 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
148 // 0.0, 0.0 means no range
149 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
151 realMin
= min
; realMax
= max
;
153 ~wxRealFormValidator(void) {}
155 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
156 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
157 // Called by the view to transfer the property to the window.
158 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
161 class wxIntegerFormValidator
: public wxPropertyFormValidator
163 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
168 // 0, 0 means no range
169 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
171 integerMin
= min
; integerMax
= max
;
173 ~wxIntegerFormValidator(void) {}
175 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
176 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
177 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
180 class wxBoolFormValidator
: public wxPropertyFormValidator
182 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
185 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
188 ~wxBoolFormValidator(void) {}
190 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
191 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
192 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
195 class wxStringFormValidator
: public wxPropertyFormValidator
197 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
199 wxStringList
*strings
;
201 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
203 ~wxStringFormValidator(void)
209 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
210 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
211 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
215 * A default dialog box class to use.
218 class wxPropertyFormDialog
: public wxDialog
220 DECLARE_CLASS(wxPropertyFormDialog
)
222 wxPropertyFormView
*view
;
224 wxPropertyFormDialog(wxPropertyFormView
*v
, wxWindow
*parent
, const wxString
& title
,
225 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
226 long style
= wxDEFAULT_DIALOG_STYLE
, const wxString
& name
= "dialogBox");
228 void OnDefaultAction(wxControl
*item
);
229 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
231 // Extend event processing to search the view's event table
232 virtual bool ProcessEvent(wxEvent
& event
);
236 * A default panel class to use.
239 class wxPropertyFormPanel
: public wxPanel
241 DECLARE_CLASS(wxPropertyFormPanel
)
243 wxPropertyFormView
*view
;
245 wxPropertyFormPanel(wxPropertyFormView
*v
, wxWindow
*parent
, const wxPoint
& pos
= wxDefaultPosition
,
246 const wxSize
& size
= wxDefaultSize
, long style
= 0, const wxString
& name
= "panel"):
247 wxPanel(parent
, -1, pos
, size
, style
, name
)
251 void OnDefaultAction(wxControl
*item
);
252 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
254 // Extend event processing to search the view's event table
255 virtual bool ProcessEvent(wxEvent
& event
);
259 * A default frame class to use.
262 class wxPropertyFormFrame
: public wxFrame
264 DECLARE_CLASS(wxPropertyFormFrame
)
266 wxPropertyFormView
*view
;
267 wxPanel
*propertyPanel
;
269 wxPropertyFormFrame(wxPropertyFormView
*v
, wxFrame
*parent
, const wxString
& title
,
270 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
271 long style
= wxDEFAULT_FRAME
, const wxString
& name
= "frame"):
272 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
275 propertyPanel
= NULL
;
279 // Must call this to create panel and associate view
280 virtual bool Initialize(void);
281 virtual wxPanel
*OnCreatePanel(wxFrame
*parent
, wxPropertyFormView
*v
);
282 inline virtual wxPanel
*GetPropertyPanel(void) { return propertyPanel
; }