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 wxDialogEditorPropertyListDialog
: public wxPropertyListDialog
25 friend class wxPropertyInfo
;
27 wxDialogEditorPropertyListDialog(wxPropertyListView
*v
, wxWindow
*parent
, const wxString
& title
,
28 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
29 long style
= wxDEFAULT_DIALOG_STYLE
, const wxString
& name
= "dialogBox");
30 ~wxDialogEditorPropertyListDialog();
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 wxPropertyInfo
*propertyInfo
;
45 wxResourcePropertyListView(wxPropertyInfo
*info
, wxPanel
*propPanel
= NULL
, long flags
= wxPROP_BUTTON_DEFAULT
):
46 wxPropertyListView(propPanel
, flags
)
50 void OnPropertyChanged(wxProperty
*property
);
54 // Generic class for relating an object to a collection of properties.
55 // Instead of defining new functions like wxButton::GetProperty, wxButton::SetProperty,
56 // we take these functions out into of the wxWindows library and associate
57 // them with separate classes.
58 class wxPropertyInfo
: public wxObject
60 friend class wxDialogEditorPropertyListDialog
;
62 static wxWindow
*sm_propertyWindow
;
70 virtual wxProperty
*GetProperty(wxString
& propName
) = 0;
71 virtual bool SetProperty(wxString
& propName
, wxProperty
*property
) = 0;
72 virtual void GetPropertyNames(wxStringList
& names
) = 0;
73 virtual bool Edit(wxWindow
*parent
, const wxString
& title
);
77 class wxWindowPropertyInfo
: public wxPropertyInfo
80 wxWindow
*propertyWindow
;
81 wxItemResource
*propertyResource
;
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
) { propertyWindow
= win
; }
91 inline void SetResource(wxItemResource
*res
) { 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
);
103 class wxItemPropertyInfo
: public wxWindowPropertyInfo
107 wxItemPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
108 wxWindowPropertyInfo(win
, res
) {}
109 ~wxItemPropertyInfo(void) {}
110 wxProperty
*GetProperty(wxString
& name
);
111 bool SetProperty(wxString
& name
, wxProperty
*property
);
112 void GetPropertyNames(wxStringList
& names
);
113 bool InstantiateResource(wxItemResource
*resource
);
117 class wxButtonPropertyInfo
: public wxItemPropertyInfo
121 wxButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
122 wxItemPropertyInfo(win
, res
) { }
123 ~wxButtonPropertyInfo(void) {}
124 wxProperty
*GetProperty(wxString
& name
);
125 bool SetProperty(wxString
& name
, wxProperty
*property
);
126 void GetPropertyNames(wxStringList
& names
);
127 bool InstantiateResource(wxItemResource
*resource
);
130 // For bitmap buttons
131 class wxBitmapButtonPropertyInfo
: public wxButtonPropertyInfo
135 wxBitmapButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
136 wxButtonPropertyInfo(win
, res
) { }
137 ~wxBitmapButtonPropertyInfo(void) {}
138 wxProperty
*GetProperty(wxString
& name
);
139 bool SetProperty(wxString
& name
, wxProperty
*property
);
140 void GetPropertyNames(wxStringList
& names
);
141 bool InstantiateResource(wxItemResource
*resource
);
144 // For static text controls
145 class wxStaticTextPropertyInfo
: public wxItemPropertyInfo
149 wxStaticTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
150 wxItemPropertyInfo(win
, res
) { }
151 ~wxStaticTextPropertyInfo(void) {}
152 wxProperty
*GetProperty(wxString
& name
);
153 bool SetProperty(wxString
& name
, wxProperty
*property
);
154 void GetPropertyNames(wxStringList
& names
);
155 bool InstantiateResource(wxItemResource
*resource
);
158 // For static bitmap controls
159 class wxStaticBitmapPropertyInfo
: public wxItemPropertyInfo
163 wxStaticBitmapPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
164 wxItemPropertyInfo(win
, res
) { }
165 ~wxStaticBitmapPropertyInfo(void) {}
166 wxProperty
*GetProperty(wxString
& name
);
167 bool SetProperty(wxString
& name
, wxProperty
*property
);
168 void GetPropertyNames(wxStringList
& names
);
169 bool InstantiateResource(wxItemResource
*resource
);
172 // For text/multitext items
173 class wxTextPropertyInfo
: public wxItemPropertyInfo
177 wxTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
178 wxItemPropertyInfo(win
, res
) {}
179 ~wxTextPropertyInfo(void) {}
180 wxProperty
*GetProperty(wxString
& name
);
181 bool SetProperty(wxString
& name
, wxProperty
*property
);
182 void GetPropertyNames(wxStringList
& names
);
183 bool InstantiateResource(wxItemResource
*resource
);
187 class wxListBoxPropertyInfo
: public wxItemPropertyInfo
191 wxListBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
192 wxItemPropertyInfo(win
, res
) {}
193 ~wxListBoxPropertyInfo(void) {}
194 wxProperty
*GetProperty(wxString
& name
);
195 bool SetProperty(wxString
& name
, wxProperty
*property
);
196 void GetPropertyNames(wxStringList
& names
);
197 bool InstantiateResource(wxItemResource
*resource
);
201 class wxChoicePropertyInfo
: public wxItemPropertyInfo
205 wxChoicePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
206 wxItemPropertyInfo(win
, res
) {}
207 ~wxChoicePropertyInfo(void) {}
208 wxProperty
*GetProperty(wxString
& name
);
209 bool SetProperty(wxString
& name
, wxProperty
*property
);
210 void GetPropertyNames(wxStringList
& names
);
211 bool InstantiateResource(wxItemResource
*resource
);
214 // For radiobox items
215 class wxRadioBoxPropertyInfo
: public wxItemPropertyInfo
219 wxRadioBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
220 wxItemPropertyInfo(win
, res
) {}
221 ~wxRadioBoxPropertyInfo(void) {}
222 wxProperty
*GetProperty(wxString
& name
);
223 bool SetProperty(wxString
& name
, wxProperty
*property
);
224 void GetPropertyNames(wxStringList
& names
);
225 bool InstantiateResource(wxItemResource
*resource
);
228 // For groupbox items
229 class wxGroupBoxPropertyInfo
: public wxItemPropertyInfo
233 wxGroupBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
234 wxItemPropertyInfo(win
, res
) {}
235 ~wxGroupBoxPropertyInfo(void) {}
236 wxProperty
*GetProperty(wxString
& name
);
237 bool SetProperty(wxString
& name
, wxProperty
*property
);
238 void GetPropertyNames(wxStringList
& names
);
239 bool InstantiateResource(wxItemResource
*resource
);
242 // For checkbox items
243 class wxCheckBoxPropertyInfo
: public wxItemPropertyInfo
247 wxCheckBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
248 wxItemPropertyInfo(win
, res
) {}
249 ~wxCheckBoxPropertyInfo(void) {}
250 wxProperty
*GetProperty(wxString
& name
);
251 bool SetProperty(wxString
& name
, wxProperty
*property
);
252 void GetPropertyNames(wxStringList
& names
);
253 bool InstantiateResource(wxItemResource
*resource
);
256 // For radiobutton items
257 class wxRadioButtonPropertyInfo
: public wxItemPropertyInfo
261 wxRadioButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
262 wxItemPropertyInfo(win
, res
) {}
263 ~wxRadioButtonPropertyInfo(void) {}
264 wxProperty
*GetProperty(wxString
& name
);
265 bool SetProperty(wxString
& name
, wxProperty
*property
);
266 void GetPropertyNames(wxStringList
& names
);
267 bool InstantiateResource(wxItemResource
*resource
);
271 class wxGaugePropertyInfo
: public wxItemPropertyInfo
275 wxGaugePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
276 wxItemPropertyInfo(win
, res
) {}
277 ~wxGaugePropertyInfo(void) {}
278 wxProperty
*GetProperty(wxString
& name
);
279 bool SetProperty(wxString
& name
, wxProperty
*property
);
280 void GetPropertyNames(wxStringList
& names
);
281 bool InstantiateResource(wxItemResource
*resource
);
284 // For scrollbar items
285 class wxScrollBarPropertyInfo
: public wxItemPropertyInfo
289 wxScrollBarPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
290 wxItemPropertyInfo(win
, res
) {}
291 ~wxScrollBarPropertyInfo(void) {}
292 wxProperty
*GetProperty(wxString
& name
);
293 bool SetProperty(wxString
& name
, wxProperty
*property
);
294 void GetPropertyNames(wxStringList
& names
);
295 bool InstantiateResource(wxItemResource
*resource
);
299 class wxSliderPropertyInfo
: public wxItemPropertyInfo
303 wxSliderPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
304 wxItemPropertyInfo(win
, res
) {}
305 ~wxSliderPropertyInfo(void) {}
306 wxProperty
*GetProperty(wxString
& name
);
307 bool SetProperty(wxString
& name
, wxProperty
*property
);
308 void GetPropertyNames(wxStringList
& names
);
309 bool InstantiateResource(wxItemResource
*resource
);
313 class wxPanelPropertyInfo
: public wxWindowPropertyInfo
317 wxPanelPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
318 wxWindowPropertyInfo(win
, res
) {}
319 ~wxPanelPropertyInfo(void) {}
320 wxProperty
*GetProperty(wxString
& name
);
321 bool SetProperty(wxString
& name
, wxProperty
*property
);
322 void GetPropertyNames(wxStringList
& names
);
323 bool InstantiateResource(wxItemResource
*resource
);
326 int wxStringToFontWeight(wxString
& val
);
327 int wxStringToFontStyle(wxString
& val
);
328 int wxStringToFontFamily(wxString
& val
);
331 * A validator to allow editing symbol/id pairs
334 class wxResourceSymbolValidator
: public wxPropertyListValidator
336 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator
)
339 wxResourceSymbolValidator(long flags
= 0);
341 ~wxResourceSymbolValidator(void);
343 // Called when TICK is pressed or focus is lost.
344 // Return FALSE if value didn't check out; signal to restore old value.
345 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
347 // Called when TICK is pressed or focus is lost or view wants to update
348 // the property list.
349 // Does the transferance from the property editing area to the property itself
350 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
351 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
353 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
355 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
357 // Called when the edit (...) button is pressed.
358 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
362 * A dialog for editing symbol/id pairs
365 class wxResourceSymbolDialog
: public wxDialog
368 wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
369 const wxPoint
& pos
= wxDefaultPosition
,
370 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
);
374 inline void SetSymbol(const wxString
& symbol
) { m_symbolName
= symbol
; }
375 inline void SetId(long id
) { m_symbolId
= id
; }
377 inline wxString
GetSymbol() const { return m_symbolName
; }
378 inline long GetId() const { return m_symbolId
; }
381 void OnOK(wxCommandEvent
& event
);
384 wxString m_symbolName
;
386 wxComboBox
* m_nameCtrl
;
387 wxTextCtrl
* m_idCtrl
;
389 DECLARE_EVENT_TABLE()
392 #define ID_SYMBOLNAME_COMBOBOX 100
393 #define ID_SYMBOLID_TEXTCTRL 101