1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Window properties
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "winprop.h"
23 class wxDialogEditorPropertyListFrame
: public wxPropertyListFrame
25 friend class wxPropertyInfo
;
27 wxDialogEditorPropertyListFrame(wxPropertyListView
*v
, wxFrame
*parent
, const wxString
& title
,
28 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
29 long style
= wxDEFAULT_FRAME_STYLE
, const wxString
& name
= "frame");
30 ~wxDialogEditorPropertyListFrame();
32 wxPropertyInfo
* GetInfo() const { return m_propInfo
; }
35 wxPropertySheet
* m_propSheet
;
36 wxPropertyValidatorRegistry m_registry
;
37 wxPropertyInfo
* m_propInfo
;
40 // A kind of property list view that intercepts OnPropertyChanged
42 class wxResourcePropertyListView
: public wxPropertyListView
45 wxResourcePropertyListView(wxPropertyInfo
*info
, wxPanel
*propPanel
= NULL
, long flags
= wxPROP_BUTTON_DEFAULT
):
46 wxPropertyListView(propPanel
, flags
)
48 m_propertyInfo
= info
;
50 void OnPropertyChanged(wxProperty
*property
);
53 wxPropertyInfo
* m_propertyInfo
;
57 // Generic class for relating an object to a collection of properties.
58 // Instead of defining new functions like wxButton::GetProperty, wxButton::SetProperty,
59 // we take these functions out into of the wxWindows library and associate
60 // them with separate classes.
61 class wxPropertyInfo
: public wxObject
63 friend class wxDialogEditorPropertyListFrame
;
65 static wxWindow
*sm_propertyWindow
;
73 virtual wxProperty
*GetProperty(wxString
& propName
) = 0;
74 virtual bool SetProperty(wxString
& propName
, wxProperty
*property
) = 0;
75 virtual void GetPropertyNames(wxStringList
& names
) = 0;
76 virtual bool Edit(wxWindow
*parent
, const wxString
& title
);
80 class wxWindowPropertyInfo
: public wxPropertyInfo
83 wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
);
84 ~wxWindowPropertyInfo(void);
85 wxProperty
*GetProperty(wxString
& name
);
86 bool SetProperty(wxString
& name
, wxProperty
*property
);
87 void GetPropertyNames(wxStringList
& names
);
89 inline void SetPropertyWindow(wxWindow
*win
) { m_propertyWindow
= win
; }
91 inline void SetResource(wxItemResource
*res
) { m_propertyResource
= res
; }
93 // Helper functions for font properties
95 wxProperty
*GetFontProperty(wxString
& name
, wxFont
*font
);
96 wxFont
*SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*oldFont
);
98 // Fill in the wxItemResource members to mirror the current window settings
99 virtual bool InstantiateResource(wxItemResource
*resource
);
101 // Set the window style
102 void SetWindowStyle(wxWindow
* win
, long style
, bool set
);
104 wxWindow
* GetWindow() const { return m_propertyWindow
; }
105 wxItemResource
* GetResource() const { return m_propertyResource
; }
108 wxWindow
* m_propertyWindow
;
109 wxItemResource
* m_propertyResource
;
113 class wxItemPropertyInfo
: public wxWindowPropertyInfo
117 wxItemPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
118 wxWindowPropertyInfo(win
, res
) {}
119 ~wxItemPropertyInfo(void) {}
120 wxProperty
*GetProperty(wxString
& name
);
121 bool SetProperty(wxString
& name
, wxProperty
*property
);
122 void GetPropertyNames(wxStringList
& names
);
123 bool InstantiateResource(wxItemResource
*resource
);
127 class wxButtonPropertyInfo
: public wxItemPropertyInfo
131 wxButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
132 wxItemPropertyInfo(win
, res
) { }
133 ~wxButtonPropertyInfo(void) {}
134 wxProperty
*GetProperty(wxString
& name
);
135 bool SetProperty(wxString
& name
, wxProperty
*property
);
136 void GetPropertyNames(wxStringList
& names
);
137 bool InstantiateResource(wxItemResource
*resource
);
140 // For bitmap buttons
141 class wxBitmapButtonPropertyInfo
: public wxButtonPropertyInfo
145 wxBitmapButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
146 wxButtonPropertyInfo(win
, res
) { }
147 ~wxBitmapButtonPropertyInfo(void) {}
148 wxProperty
*GetProperty(wxString
& name
);
149 bool SetProperty(wxString
& name
, wxProperty
*property
);
150 void GetPropertyNames(wxStringList
& names
);
151 bool InstantiateResource(wxItemResource
*resource
);
154 // For static text controls
155 class wxStaticTextPropertyInfo
: public wxItemPropertyInfo
159 wxStaticTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
160 wxItemPropertyInfo(win
, res
) { }
161 ~wxStaticTextPropertyInfo(void) {}
162 wxProperty
*GetProperty(wxString
& name
);
163 bool SetProperty(wxString
& name
, wxProperty
*property
);
164 void GetPropertyNames(wxStringList
& names
);
165 bool InstantiateResource(wxItemResource
*resource
);
168 // For static bitmap controls
169 class wxStaticBitmapPropertyInfo
: public wxItemPropertyInfo
173 wxStaticBitmapPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
174 wxItemPropertyInfo(win
, res
) { }
175 ~wxStaticBitmapPropertyInfo(void) {}
176 wxProperty
*GetProperty(wxString
& name
);
177 bool SetProperty(wxString
& name
, wxProperty
*property
);
178 void GetPropertyNames(wxStringList
& names
);
179 bool InstantiateResource(wxItemResource
*resource
);
182 // For text/multitext items
183 class wxTextPropertyInfo
: public wxItemPropertyInfo
187 wxTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
188 wxItemPropertyInfo(win
, res
) {}
189 ~wxTextPropertyInfo(void) {}
190 wxProperty
*GetProperty(wxString
& name
);
191 bool SetProperty(wxString
& name
, wxProperty
*property
);
192 void GetPropertyNames(wxStringList
& names
);
193 bool InstantiateResource(wxItemResource
*resource
);
197 class wxListBoxPropertyInfo
: public wxItemPropertyInfo
201 wxListBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
202 wxItemPropertyInfo(win
, res
) {}
203 ~wxListBoxPropertyInfo(void) {}
204 wxProperty
*GetProperty(wxString
& name
);
205 bool SetProperty(wxString
& name
, wxProperty
*property
);
206 void GetPropertyNames(wxStringList
& names
);
207 bool InstantiateResource(wxItemResource
*resource
);
211 class wxChoicePropertyInfo
: public wxItemPropertyInfo
215 wxChoicePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
216 wxItemPropertyInfo(win
, res
) {}
217 ~wxChoicePropertyInfo(void) {}
218 wxProperty
*GetProperty(wxString
& name
);
219 bool SetProperty(wxString
& name
, wxProperty
*property
);
220 void GetPropertyNames(wxStringList
& names
);
221 bool InstantiateResource(wxItemResource
*resource
);
225 class wxComboBoxPropertyInfo
: public wxChoicePropertyInfo
229 wxComboBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
230 wxChoicePropertyInfo(win
, res
) {}
231 ~wxComboBoxPropertyInfo(void) {}
232 wxProperty
*GetProperty(wxString
& name
);
233 bool SetProperty(wxString
& name
, wxProperty
*property
);
234 void GetPropertyNames(wxStringList
& names
);
235 bool InstantiateResource(wxItemResource
*resource
);
238 // For radiobox items
239 class wxRadioBoxPropertyInfo
: public wxItemPropertyInfo
243 wxRadioBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
244 wxItemPropertyInfo(win
, res
) {}
245 ~wxRadioBoxPropertyInfo(void) {}
246 wxProperty
*GetProperty(wxString
& name
);
247 bool SetProperty(wxString
& name
, wxProperty
*property
);
248 void GetPropertyNames(wxStringList
& names
);
249 bool InstantiateResource(wxItemResource
*resource
);
252 // For groupbox items
253 class wxGroupBoxPropertyInfo
: public wxItemPropertyInfo
257 wxGroupBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
258 wxItemPropertyInfo(win
, res
) {}
259 ~wxGroupBoxPropertyInfo(void) {}
260 wxProperty
*GetProperty(wxString
& name
);
261 bool SetProperty(wxString
& name
, wxProperty
*property
);
262 void GetPropertyNames(wxStringList
& names
);
263 bool InstantiateResource(wxItemResource
*resource
);
266 // For checkbox items
267 class wxCheckBoxPropertyInfo
: public wxItemPropertyInfo
271 wxCheckBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
272 wxItemPropertyInfo(win
, res
) {}
273 ~wxCheckBoxPropertyInfo(void) {}
274 wxProperty
*GetProperty(wxString
& name
);
275 bool SetProperty(wxString
& name
, wxProperty
*property
);
276 void GetPropertyNames(wxStringList
& names
);
277 bool InstantiateResource(wxItemResource
*resource
);
280 // For radiobutton items
281 class wxRadioButtonPropertyInfo
: public wxItemPropertyInfo
285 wxRadioButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
286 wxItemPropertyInfo(win
, res
) {}
287 ~wxRadioButtonPropertyInfo(void) {}
288 wxProperty
*GetProperty(wxString
& name
);
289 bool SetProperty(wxString
& name
, wxProperty
*property
);
290 void GetPropertyNames(wxStringList
& names
);
291 bool InstantiateResource(wxItemResource
*resource
);
295 class wxGaugePropertyInfo
: public wxItemPropertyInfo
299 wxGaugePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
300 wxItemPropertyInfo(win
, res
) {}
301 ~wxGaugePropertyInfo(void) {}
302 wxProperty
*GetProperty(wxString
& name
);
303 bool SetProperty(wxString
& name
, wxProperty
*property
);
304 void GetPropertyNames(wxStringList
& names
);
305 bool InstantiateResource(wxItemResource
*resource
);
308 // For scrollbar items
309 class wxScrollBarPropertyInfo
: public wxItemPropertyInfo
313 wxScrollBarPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
314 wxItemPropertyInfo(win
, res
) {}
315 ~wxScrollBarPropertyInfo(void) {}
316 wxProperty
*GetProperty(wxString
& name
);
317 bool SetProperty(wxString
& name
, wxProperty
*property
);
318 void GetPropertyNames(wxStringList
& names
);
319 bool InstantiateResource(wxItemResource
*resource
);
323 class wxSliderPropertyInfo
: public wxItemPropertyInfo
327 wxSliderPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
328 wxItemPropertyInfo(win
, res
) {}
329 ~wxSliderPropertyInfo(void) {}
330 wxProperty
*GetProperty(wxString
& name
);
331 bool SetProperty(wxString
& name
, wxProperty
*property
);
332 void GetPropertyNames(wxStringList
& names
);
333 bool InstantiateResource(wxItemResource
*resource
);
337 class wxPanelPropertyInfo
: public wxWindowPropertyInfo
341 wxPanelPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
342 wxWindowPropertyInfo(win
, res
) {}
343 ~wxPanelPropertyInfo(void) {}
344 wxProperty
*GetProperty(wxString
& name
);
345 bool SetProperty(wxString
& name
, wxProperty
*property
);
346 void GetPropertyNames(wxStringList
& names
);
347 bool InstantiateResource(wxItemResource
*resource
);
349 // Convert this dialog, and its children, to or from dialog units
350 void ConvertDialogUnits(bool toDialogUnits
);
353 int wxStringToFontWeight(wxString
& val
);
354 int wxStringToFontStyle(wxString
& val
);
355 int wxStringToFontFamily(wxString
& val
);
358 * A validator to allow editing symbol/id pairs
361 class wxResourceSymbolValidator
: public wxPropertyListValidator
363 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator
)
366 wxResourceSymbolValidator(long flags
= 0);
368 ~wxResourceSymbolValidator(void);
370 // Called when TICK is pressed or focus is lost.
371 // Return FALSE if value didn't check out; signal to restore old value.
372 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
374 // Called when TICK is pressed or focus is lost or view wants to update
375 // the property list.
376 // Does the transferance from the property editing area to the property itself
377 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
378 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
380 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
382 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
384 // Called when the edit (...) button is pressed.
385 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
389 * A dialog for editing symbol/id pairs
392 class wxResourceSymbolDialog
: public wxDialog
395 wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
396 const wxPoint
& pos
= wxDefaultPosition
,
397 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
);
401 inline void SetSymbol(const wxString
& symbol
) { m_symbolName
= symbol
; }
402 inline void SetId(long id
) { m_symbolId
= id
; }
404 inline wxString
GetSymbol() const { return m_symbolName
; }
405 inline long GetId() const { return m_symbolId
; }
408 void OnOK(wxCommandEvent
& event
);
409 void OnComboBoxSelect(wxCommandEvent
& event
);
410 void OnSymbolNameUpdate(wxCommandEvent
& event
);
413 wxString m_symbolName
;
415 wxComboBox
* m_nameCtrl
;
416 wxTextCtrl
* m_idCtrl
;
418 DECLARE_EVENT_TABLE()
421 #define ID_SYMBOLNAME_COMBOBOX 100
422 #define ID_SYMBOLID_TEXTCTRL 101