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();
33 wxPropertySheet
* m_propSheet
;
34 wxPropertyValidatorRegistry m_registry
;
35 wxPropertyInfo
* m_propInfo
;
38 // A kind of property list view that intercepts OnPropertyChanged
40 class wxResourcePropertyListView
: public wxPropertyListView
43 wxResourcePropertyListView(wxPropertyInfo
*info
, wxPanel
*propPanel
= NULL
, long flags
= wxPROP_BUTTON_DEFAULT
):
44 wxPropertyListView(propPanel
, flags
)
46 m_propertyInfo
= info
;
48 void OnPropertyChanged(wxProperty
*property
);
51 wxPropertyInfo
* m_propertyInfo
;
55 // Generic class for relating an object to a collection of properties.
56 // Instead of defining new functions like wxButton::GetProperty, wxButton::SetProperty,
57 // we take these functions out into of the wxWindows library and associate
58 // them with separate classes.
59 class wxPropertyInfo
: public wxObject
61 friend class wxDialogEditorPropertyListFrame
;
63 static wxWindow
*sm_propertyWindow
;
71 virtual wxProperty
*GetProperty(wxString
& propName
) = 0;
72 virtual bool SetProperty(wxString
& propName
, wxProperty
*property
) = 0;
73 virtual void GetPropertyNames(wxStringList
& names
) = 0;
74 virtual bool Edit(wxWindow
*parent
, const wxString
& title
);
78 class wxWindowPropertyInfo
: public wxPropertyInfo
81 wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
);
82 ~wxWindowPropertyInfo(void);
83 wxProperty
*GetProperty(wxString
& name
);
84 bool SetProperty(wxString
& name
, wxProperty
*property
);
85 void GetPropertyNames(wxStringList
& names
);
87 inline void SetPropertyWindow(wxWindow
*win
) { m_propertyWindow
= win
; }
89 inline void SetResource(wxItemResource
*res
) { m_propertyResource
= res
; }
91 // Helper functions for font properties
93 wxProperty
*GetFontProperty(wxString
& name
, wxFont
*font
);
94 wxFont
*SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*oldFont
);
96 // Fill in the wxItemResource members to mirror the current window settings
97 virtual bool InstantiateResource(wxItemResource
*resource
);
99 // Set the window style
100 void SetWindowStyle(wxWindow
* win
, long style
, bool set
);
103 wxWindow
* m_propertyWindow
;
104 wxItemResource
* m_propertyResource
;
108 class wxItemPropertyInfo
: public wxWindowPropertyInfo
112 wxItemPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
113 wxWindowPropertyInfo(win
, res
) {}
114 ~wxItemPropertyInfo(void) {}
115 wxProperty
*GetProperty(wxString
& name
);
116 bool SetProperty(wxString
& name
, wxProperty
*property
);
117 void GetPropertyNames(wxStringList
& names
);
118 bool InstantiateResource(wxItemResource
*resource
);
122 class wxButtonPropertyInfo
: public wxItemPropertyInfo
126 wxButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
127 wxItemPropertyInfo(win
, res
) { }
128 ~wxButtonPropertyInfo(void) {}
129 wxProperty
*GetProperty(wxString
& name
);
130 bool SetProperty(wxString
& name
, wxProperty
*property
);
131 void GetPropertyNames(wxStringList
& names
);
132 bool InstantiateResource(wxItemResource
*resource
);
135 // For bitmap buttons
136 class wxBitmapButtonPropertyInfo
: public wxButtonPropertyInfo
140 wxBitmapButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
141 wxButtonPropertyInfo(win
, res
) { }
142 ~wxBitmapButtonPropertyInfo(void) {}
143 wxProperty
*GetProperty(wxString
& name
);
144 bool SetProperty(wxString
& name
, wxProperty
*property
);
145 void GetPropertyNames(wxStringList
& names
);
146 bool InstantiateResource(wxItemResource
*resource
);
149 // For static text controls
150 class wxStaticTextPropertyInfo
: public wxItemPropertyInfo
154 wxStaticTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
155 wxItemPropertyInfo(win
, res
) { }
156 ~wxStaticTextPropertyInfo(void) {}
157 wxProperty
*GetProperty(wxString
& name
);
158 bool SetProperty(wxString
& name
, wxProperty
*property
);
159 void GetPropertyNames(wxStringList
& names
);
160 bool InstantiateResource(wxItemResource
*resource
);
163 // For static bitmap controls
164 class wxStaticBitmapPropertyInfo
: public wxItemPropertyInfo
168 wxStaticBitmapPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
169 wxItemPropertyInfo(win
, res
) { }
170 ~wxStaticBitmapPropertyInfo(void) {}
171 wxProperty
*GetProperty(wxString
& name
);
172 bool SetProperty(wxString
& name
, wxProperty
*property
);
173 void GetPropertyNames(wxStringList
& names
);
174 bool InstantiateResource(wxItemResource
*resource
);
177 // For text/multitext items
178 class wxTextPropertyInfo
: public wxItemPropertyInfo
182 wxTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
183 wxItemPropertyInfo(win
, res
) {}
184 ~wxTextPropertyInfo(void) {}
185 wxProperty
*GetProperty(wxString
& name
);
186 bool SetProperty(wxString
& name
, wxProperty
*property
);
187 void GetPropertyNames(wxStringList
& names
);
188 bool InstantiateResource(wxItemResource
*resource
);
192 class wxListBoxPropertyInfo
: public wxItemPropertyInfo
196 wxListBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
197 wxItemPropertyInfo(win
, res
) {}
198 ~wxListBoxPropertyInfo(void) {}
199 wxProperty
*GetProperty(wxString
& name
);
200 bool SetProperty(wxString
& name
, wxProperty
*property
);
201 void GetPropertyNames(wxStringList
& names
);
202 bool InstantiateResource(wxItemResource
*resource
);
206 class wxChoicePropertyInfo
: public wxItemPropertyInfo
210 wxChoicePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
211 wxItemPropertyInfo(win
, res
) {}
212 ~wxChoicePropertyInfo(void) {}
213 wxProperty
*GetProperty(wxString
& name
);
214 bool SetProperty(wxString
& name
, wxProperty
*property
);
215 void GetPropertyNames(wxStringList
& names
);
216 bool InstantiateResource(wxItemResource
*resource
);
220 class wxComboBoxPropertyInfo
: public wxChoicePropertyInfo
224 wxComboBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
225 wxChoicePropertyInfo(win
, res
) {}
226 ~wxComboBoxPropertyInfo(void) {}
227 wxProperty
*GetProperty(wxString
& name
);
228 bool SetProperty(wxString
& name
, wxProperty
*property
);
229 void GetPropertyNames(wxStringList
& names
);
230 bool InstantiateResource(wxItemResource
*resource
);
233 // For radiobox items
234 class wxRadioBoxPropertyInfo
: public wxItemPropertyInfo
238 wxRadioBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
239 wxItemPropertyInfo(win
, res
) {}
240 ~wxRadioBoxPropertyInfo(void) {}
241 wxProperty
*GetProperty(wxString
& name
);
242 bool SetProperty(wxString
& name
, wxProperty
*property
);
243 void GetPropertyNames(wxStringList
& names
);
244 bool InstantiateResource(wxItemResource
*resource
);
247 // For groupbox items
248 class wxGroupBoxPropertyInfo
: public wxItemPropertyInfo
252 wxGroupBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
253 wxItemPropertyInfo(win
, res
) {}
254 ~wxGroupBoxPropertyInfo(void) {}
255 wxProperty
*GetProperty(wxString
& name
);
256 bool SetProperty(wxString
& name
, wxProperty
*property
);
257 void GetPropertyNames(wxStringList
& names
);
258 bool InstantiateResource(wxItemResource
*resource
);
261 // For checkbox items
262 class wxCheckBoxPropertyInfo
: public wxItemPropertyInfo
266 wxCheckBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
267 wxItemPropertyInfo(win
, res
) {}
268 ~wxCheckBoxPropertyInfo(void) {}
269 wxProperty
*GetProperty(wxString
& name
);
270 bool SetProperty(wxString
& name
, wxProperty
*property
);
271 void GetPropertyNames(wxStringList
& names
);
272 bool InstantiateResource(wxItemResource
*resource
);
275 // For radiobutton items
276 class wxRadioButtonPropertyInfo
: public wxItemPropertyInfo
280 wxRadioButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
281 wxItemPropertyInfo(win
, res
) {}
282 ~wxRadioButtonPropertyInfo(void) {}
283 wxProperty
*GetProperty(wxString
& name
);
284 bool SetProperty(wxString
& name
, wxProperty
*property
);
285 void GetPropertyNames(wxStringList
& names
);
286 bool InstantiateResource(wxItemResource
*resource
);
290 class wxGaugePropertyInfo
: public wxItemPropertyInfo
294 wxGaugePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
295 wxItemPropertyInfo(win
, res
) {}
296 ~wxGaugePropertyInfo(void) {}
297 wxProperty
*GetProperty(wxString
& name
);
298 bool SetProperty(wxString
& name
, wxProperty
*property
);
299 void GetPropertyNames(wxStringList
& names
);
300 bool InstantiateResource(wxItemResource
*resource
);
303 // For scrollbar items
304 class wxScrollBarPropertyInfo
: public wxItemPropertyInfo
308 wxScrollBarPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
309 wxItemPropertyInfo(win
, res
) {}
310 ~wxScrollBarPropertyInfo(void) {}
311 wxProperty
*GetProperty(wxString
& name
);
312 bool SetProperty(wxString
& name
, wxProperty
*property
);
313 void GetPropertyNames(wxStringList
& names
);
314 bool InstantiateResource(wxItemResource
*resource
);
318 class wxSliderPropertyInfo
: public wxItemPropertyInfo
322 wxSliderPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
323 wxItemPropertyInfo(win
, res
) {}
324 ~wxSliderPropertyInfo(void) {}
325 wxProperty
*GetProperty(wxString
& name
);
326 bool SetProperty(wxString
& name
, wxProperty
*property
);
327 void GetPropertyNames(wxStringList
& names
);
328 bool InstantiateResource(wxItemResource
*resource
);
332 class wxPanelPropertyInfo
: public wxWindowPropertyInfo
336 wxPanelPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
337 wxWindowPropertyInfo(win
, res
) {}
338 ~wxPanelPropertyInfo(void) {}
339 wxProperty
*GetProperty(wxString
& name
);
340 bool SetProperty(wxString
& name
, wxProperty
*property
);
341 void GetPropertyNames(wxStringList
& names
);
342 bool InstantiateResource(wxItemResource
*resource
);
344 // Convert this dialog, and its children, to or from dialog units
345 void ConvertDialogUnits(bool toDialogUnits
);
348 int wxStringToFontWeight(wxString
& val
);
349 int wxStringToFontStyle(wxString
& val
);
350 int wxStringToFontFamily(wxString
& val
);
353 * A validator to allow editing symbol/id pairs
356 class wxResourceSymbolValidator
: public wxPropertyListValidator
358 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator
)
361 wxResourceSymbolValidator(long flags
= 0);
363 ~wxResourceSymbolValidator(void);
365 // Called when TICK is pressed or focus is lost.
366 // Return FALSE if value didn't check out; signal to restore old value.
367 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
369 // Called when TICK is pressed or focus is lost or view wants to update
370 // the property list.
371 // Does the transferance from the property editing area to the property itself
372 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
373 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
375 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
377 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
379 // Called when the edit (...) button is pressed.
380 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
384 * A dialog for editing symbol/id pairs
387 class wxResourceSymbolDialog
: public wxDialog
390 wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
391 const wxPoint
& pos
= wxDefaultPosition
,
392 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
);
396 inline void SetSymbol(const wxString
& symbol
) { m_symbolName
= symbol
; }
397 inline void SetId(long id
) { m_symbolId
= id
; }
399 inline wxString
GetSymbol() const { return m_symbolName
; }
400 inline long GetId() const { return m_symbolId
; }
403 void OnOK(wxCommandEvent
& event
);
404 void OnComboBoxSelect(wxCommandEvent
& event
);
405 void OnSymbolNameUpdate(wxCommandEvent
& event
);
408 wxString m_symbolName
;
410 wxComboBox
* m_nameCtrl
;
411 wxTextCtrl
* m_idCtrl
;
413 DECLARE_EVENT_TABLE()
416 #define ID_SYMBOLNAME_COMBOBOX 100
417 #define ID_SYMBOLID_TEXTCTRL 101