]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/propform.h
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 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(void);
65 virtual void OnDoubleClick(wxControl
*item
);
67 // TODO: does OnCommand still get called...???
68 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
70 inline virtual void AssociatePanel(wxWindow
*win
) { m_propertyWindow
= win
; }
71 inline virtual wxWindow
*GetPanel(void) const { return m_propertyWindow
; }
73 inline virtual void SetManagedWindow(wxWindow
*win
) { m_managedWindow
= win
; }
74 inline virtual wxWindow
*GetManagedWindow(void) const { return m_managedWindow
; }
76 inline virtual wxButton
*GetWindowCloseButton() const { return m_windowCloseButton
; }
77 inline virtual wxButton
*GetWindowCancelButton() const { return m_windowCancelButton
; }
78 inline virtual wxButton
*GetHelpButton() const { return m_windowHelpButton
; }
81 static bool sm_dialogCancelled
;
84 bool m_detailedEditing
; // E.g. using listbox for choices
86 wxWindow
* m_propertyWindow
; // Panel that the controls will appear on
87 wxWindow
* m_managedWindow
; // Frame or dialog
89 wxButton
* m_windowCloseButton
; // Or OK
90 wxButton
* m_windowCancelButton
;
91 wxButton
* m_windowHelpButton
;
98 * The type of validator used for forms (wxForm style but using an existing panel
100 * Classes derived from this know how to map from whatever widget they
101 * find themselves paired with, to the wxProperty and vice versa.
102 * Should the widget pointer be stored with the validator, or
103 * the wxProperty? If with the property, we don't have to supply
104 * a validator for every property. Otherwise, there ALWAYS needs
105 * to be a validator. On the other hand, not storing a wxWindow pointer
106 * in the wxProperty is more elegant. Perhaps.
107 * I think on balance, should put wxWindow pointer into wxProperty.
108 * After all, wxProperty will often be used to represent the data
109 * assocated with a window. It's that kinda thing.
112 class wxPropertyFormValidator
: public wxPropertyValidator
114 DECLARE_DYNAMIC_CLASS(wxPropertyFormValidator
)
117 wxPropertyFormValidator(long flags
= 0): wxPropertyValidator(flags
) { }
118 ~wxPropertyFormValidator(void) {}
120 // Called to check value is OK (e.g. when OK is pressed)
121 // Return FALSE if value didn't check out; signal to restore old value.
122 virtual bool OnCheckValue( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
123 wxWindow
*WXUNUSED(parentWindow
) ) { return TRUE
; }
125 // Does the transferance from the property editing area to the property itself.
126 // Called by the view, e.g. when closing the window.
127 virtual bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
129 // Called by the view to transfer the property to the window.
130 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
) = 0;
132 virtual void OnDoubleClick( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
133 wxWindow
*WXUNUSED(parentWindow
) ) { }
134 virtual void OnSetFocus( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
135 wxWindow
*WXUNUSED(parentWindow
) ) { }
136 virtual void OnKillFocus( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
137 wxWindow
*WXUNUSED(parentWindow
) ) { }
138 virtual void OnCommand( wxProperty
*WXUNUSED(property
), wxPropertyFormView
*WXUNUSED(view
),
139 wxWindow
*WXUNUSED(parentWindow
), wxCommandEvent
& WXUNUSED(event
) ) {}
143 * Some default validators
146 class wxRealFormValidator
: public wxPropertyFormValidator
148 DECLARE_DYNAMIC_CLASS(wxRealFormValidator
)
150 // 0.0, 0.0 means no range
151 wxRealFormValidator(float min
= 0.0, float max
= 0.0, long flags
= 0):wxPropertyFormValidator(flags
)
153 m_realMin
= min
; m_realMax
= max
;
155 ~wxRealFormValidator(void) {}
157 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
158 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
159 // Called by the view to transfer the property to the window.
160 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
167 class wxIntegerFormValidator
: public wxPropertyFormValidator
169 DECLARE_DYNAMIC_CLASS(wxIntegerFormValidator
)
171 // 0, 0 means no range
172 wxIntegerFormValidator(long min
= 0, long max
= 0, long flags
= 0):wxPropertyFormValidator(flags
)
174 m_integerMin
= min
; m_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
);
187 class wxBoolFormValidator
: public wxPropertyFormValidator
189 DECLARE_DYNAMIC_CLASS(wxBoolFormValidator
)
192 wxBoolFormValidator(long flags
= 0):wxPropertyFormValidator(flags
)
195 ~wxBoolFormValidator(void) {}
197 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
198 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
199 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
202 class wxStringFormValidator
: public wxPropertyFormValidator
204 DECLARE_DYNAMIC_CLASS(wxStringFormValidator
)
206 wxStringFormValidator(wxStringList
*list
= NULL
, long flags
= 0);
208 ~wxStringFormValidator(void)
214 bool OnCheckValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
215 bool OnRetrieveValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
216 bool OnDisplayValue(wxProperty
*property
, wxPropertyFormView
*view
, wxWindow
*parentWindow
);
219 wxStringList
* m_strings
;
223 * A default dialog box class to use.
226 class wxPropertyFormDialog
: public wxDialog
228 DECLARE_CLASS(wxPropertyFormDialog
)
230 wxPropertyFormDialog(wxPropertyFormView
*v
, wxWindow
*parent
, const wxString
& title
,
231 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
232 long style
= wxDEFAULT_DIALOG_STYLE
, const wxString
& name
= "dialogBox");
234 void OnDefaultAction(wxControl
*item
);
235 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
237 // Extend event processing to search the view's event table
238 virtual bool ProcessEvent(wxEvent
& event
);
241 wxPropertyFormView
* m_view
;
245 * A default panel class to use.
248 class wxPropertyFormPanel
: public wxPanel
250 DECLARE_CLASS(wxPropertyFormPanel
)
252 wxPropertyFormPanel(wxPropertyFormView
*v
, wxWindow
*parent
, const wxPoint
& pos
= wxDefaultPosition
,
253 const wxSize
& size
= wxDefaultSize
, long style
= 0, const wxString
& name
= "panel"):
254 wxPanel(parent
, -1, pos
, size
, style
, name
)
258 void OnDefaultAction(wxControl
*item
);
259 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
261 // Extend event processing to search the view's event table
262 virtual bool ProcessEvent(wxEvent
& event
);
265 wxPropertyFormView
* m_view
;
269 * A default frame class to use.
272 class wxPropertyFormFrame
: public wxFrame
274 DECLARE_CLASS(wxPropertyFormFrame
)
276 wxPropertyFormFrame(wxPropertyFormView
*v
, wxFrame
*parent
, const wxString
& title
,
277 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
278 long style
= wxDEFAULT_FRAME
, const wxString
& name
= "frame"):
279 wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
282 m_propertyPanel
= NULL
;
286 // Must call this to create panel and associate view
287 virtual bool Initialize(void);
288 virtual wxPanel
*OnCreatePanel(wxFrame
*parent
, wxPropertyFormView
*v
);
289 inline virtual wxPanel
*GetPropertyPanel(void) const { return m_propertyPanel
; }
292 wxPropertyFormView
* m_view
;
293 wxPanel
* m_propertyPanel
;