]>
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
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
121 wxWindow
*WXUNUSED(parentWindow
) ) { return TRUE
; }
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
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
131 wxWindow
*WXUNUSED(parentWindow
) ) { }
132 virtual void OnSetFocus( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
133 wxWindow
*WXUNUSED(parentWindow
) ) { }
134 virtual void OnKillFocus( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
135 wxWindow
*WXUNUSED(parentWindow
) ) { }
136 virtual void OnCommand( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
137 wxWindow
*WXUNUSED(parentWindow
), wxCommandEvent
& WXUNUSED(event
) ) {}
141 * Some default validators
144 class wxRealFormValidator
: public wxPropertyFormValidator
146 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
151 // 0.0, 0.0 means no range
152 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
154 realMin
= min
; realMax
= max
;
156 ~wxRealFormValidator(void) {}
158 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
159 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
160 // Called by the view to transfer the property to the window.
161 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
164 class wxIntegerFormValidator
: public wxPropertyFormValidator
166 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
171 // 0, 0 means no range
172 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
174 integerMin
= min
; integerMax
= max
;
176 ~wxIntegerFormValidator(void) {}
178 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
179 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
180 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
183 class wxBoolFormValidator
: public wxPropertyFormValidator
185 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
188 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
191 ~wxBoolFormValidator(void) {}
193 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
194 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
195 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
198 class wxStringFormValidator
: public wxPropertyFormValidator
200 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
202 wxStringList
*strings
;
204 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
206 ~wxStringFormValidator(void)
212 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
213 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
214 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
218 * A default dialog box class to use.
221 class wxPropertyFormDialog
: public wxDialog
223 DECLARE_CLASS(wxPropertyFormDialog
)
225 wxPropertyFormView
*view
;
227 wxPropertyFormDialog(wxPropertyFormView
*v
, wxWindow
*parent
, const wxString
& title
,
228 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
229 long style
= wxDEFAULT_DIALOG_STYLE
, const wxString
& name
= "dialogBox");
231 void OnDefaultAction(wxControl
*item
);
232 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
234 // Extend event processing to search the view's event table
235 virtual bool ProcessEvent(wxEvent
& event
);
239 * A default panel class to use.
242 class wxPropertyFormPanel
: public wxPanel
244 DECLARE_CLASS(wxPropertyFormPanel
)
246 wxPropertyFormView
*view
;
248 wxPropertyFormPanel(wxPropertyFormView
*v
, wxWindow
*parent
, const wxPoint
& pos
= wxDefaultPosition
,
249 const wxSize
& size
= wxDefaultSize
, long style
= 0, const wxString
& name
= "panel"):
250 wxPanel(parent
, -1, pos
, size
, style
, name
)
254 void OnDefaultAction(wxControl
*item
);
255 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
257 // Extend event processing to search the view's event table
258 virtual bool ProcessEvent(wxEvent
& event
);
262 * A default frame class to use.
265 class wxPropertyFormFrame
: public wxFrame
267 DECLARE_CLASS(wxPropertyFormFrame
)
269 wxPropertyFormView
*view
;
270 wxPanel
*propertyPanel
;
272 wxPropertyFormFrame(wxPropertyFormView
*v
, wxFrame
*parent
, const wxString
& title
,
273 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
274 long style
= wxDEFAULT_FRAME
, const wxString
& name
= "frame"):
275 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
278 propertyPanel
= NULL
;
282 // Must call this to create panel and associate view
283 virtual bool Initialize(void);
284 virtual wxPanel
*OnCreatePanel(wxFrame
*parent
, wxPropertyFormView
*v
);
285 inline virtual wxPanel
*GetPropertyPanel(void) { return propertyPanel
; }