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 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 wxDialogEditorPropertyListFrame
;
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
);
101 // Set the window style
102 void SetWindowStyle(wxWindow
* win
, long style
, bool set
);
106 class wxItemPropertyInfo
: public wxWindowPropertyInfo
110 wxItemPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
111 wxWindowPropertyInfo(win
, res
) {}
112 ~wxItemPropertyInfo(void) {}
113 wxProperty
*GetProperty(wxString
& name
);
114 bool SetProperty(wxString
& name
, wxProperty
*property
);
115 void GetPropertyNames(wxStringList
& names
);
116 bool InstantiateResource(wxItemResource
*resource
);
120 class wxButtonPropertyInfo
: public wxItemPropertyInfo
124 wxButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
125 wxItemPropertyInfo(win
, res
) { }
126 ~wxButtonPropertyInfo(void) {}
127 wxProperty
*GetProperty(wxString
& name
);
128 bool SetProperty(wxString
& name
, wxProperty
*property
);
129 void GetPropertyNames(wxStringList
& names
);
130 bool InstantiateResource(wxItemResource
*resource
);
133 // For bitmap buttons
134 class wxBitmapButtonPropertyInfo
: public wxButtonPropertyInfo
138 wxBitmapButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
139 wxButtonPropertyInfo(win
, res
) { }
140 ~wxBitmapButtonPropertyInfo(void) {}
141 wxProperty
*GetProperty(wxString
& name
);
142 bool SetProperty(wxString
& name
, wxProperty
*property
);
143 void GetPropertyNames(wxStringList
& names
);
144 bool InstantiateResource(wxItemResource
*resource
);
147 // For static text controls
148 class wxStaticTextPropertyInfo
: public wxItemPropertyInfo
152 wxStaticTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
153 wxItemPropertyInfo(win
, res
) { }
154 ~wxStaticTextPropertyInfo(void) {}
155 wxProperty
*GetProperty(wxString
& name
);
156 bool SetProperty(wxString
& name
, wxProperty
*property
);
157 void GetPropertyNames(wxStringList
& names
);
158 bool InstantiateResource(wxItemResource
*resource
);
161 // For static bitmap controls
162 class wxStaticBitmapPropertyInfo
: public wxItemPropertyInfo
166 wxStaticBitmapPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
167 wxItemPropertyInfo(win
, res
) { }
168 ~wxStaticBitmapPropertyInfo(void) {}
169 wxProperty
*GetProperty(wxString
& name
);
170 bool SetProperty(wxString
& name
, wxProperty
*property
);
171 void GetPropertyNames(wxStringList
& names
);
172 bool InstantiateResource(wxItemResource
*resource
);
175 // For text/multitext items
176 class wxTextPropertyInfo
: public wxItemPropertyInfo
180 wxTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
181 wxItemPropertyInfo(win
, res
) {}
182 ~wxTextPropertyInfo(void) {}
183 wxProperty
*GetProperty(wxString
& name
);
184 bool SetProperty(wxString
& name
, wxProperty
*property
);
185 void GetPropertyNames(wxStringList
& names
);
186 bool InstantiateResource(wxItemResource
*resource
);
190 class wxListBoxPropertyInfo
: public wxItemPropertyInfo
194 wxListBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
195 wxItemPropertyInfo(win
, res
) {}
196 ~wxListBoxPropertyInfo(void) {}
197 wxProperty
*GetProperty(wxString
& name
);
198 bool SetProperty(wxString
& name
, wxProperty
*property
);
199 void GetPropertyNames(wxStringList
& names
);
200 bool InstantiateResource(wxItemResource
*resource
);
204 class wxChoicePropertyInfo
: public wxItemPropertyInfo
208 wxChoicePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
209 wxItemPropertyInfo(win
, res
) {}
210 ~wxChoicePropertyInfo(void) {}
211 wxProperty
*GetProperty(wxString
& name
);
212 bool SetProperty(wxString
& name
, wxProperty
*property
);
213 void GetPropertyNames(wxStringList
& names
);
214 bool InstantiateResource(wxItemResource
*resource
);
218 class wxComboBoxPropertyInfo
: public wxChoicePropertyInfo
222 wxComboBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
223 wxChoicePropertyInfo(win
, res
) {}
224 ~wxComboBoxPropertyInfo(void) {}
225 wxProperty
*GetProperty(wxString
& name
);
226 bool SetProperty(wxString
& name
, wxProperty
*property
);
227 void GetPropertyNames(wxStringList
& names
);
228 bool InstantiateResource(wxItemResource
*resource
);
231 // For radiobox items
232 class wxRadioBoxPropertyInfo
: public wxItemPropertyInfo
236 wxRadioBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
237 wxItemPropertyInfo(win
, res
) {}
238 ~wxRadioBoxPropertyInfo(void) {}
239 wxProperty
*GetProperty(wxString
& name
);
240 bool SetProperty(wxString
& name
, wxProperty
*property
);
241 void GetPropertyNames(wxStringList
& names
);
242 bool InstantiateResource(wxItemResource
*resource
);
245 // For groupbox items
246 class wxGroupBoxPropertyInfo
: public wxItemPropertyInfo
250 wxGroupBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
251 wxItemPropertyInfo(win
, res
) {}
252 ~wxGroupBoxPropertyInfo(void) {}
253 wxProperty
*GetProperty(wxString
& name
);
254 bool SetProperty(wxString
& name
, wxProperty
*property
);
255 void GetPropertyNames(wxStringList
& names
);
256 bool InstantiateResource(wxItemResource
*resource
);
259 // For checkbox items
260 class wxCheckBoxPropertyInfo
: public wxItemPropertyInfo
264 wxCheckBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
265 wxItemPropertyInfo(win
, res
) {}
266 ~wxCheckBoxPropertyInfo(void) {}
267 wxProperty
*GetProperty(wxString
& name
);
268 bool SetProperty(wxString
& name
, wxProperty
*property
);
269 void GetPropertyNames(wxStringList
& names
);
270 bool InstantiateResource(wxItemResource
*resource
);
273 // For radiobutton items
274 class wxRadioButtonPropertyInfo
: public wxItemPropertyInfo
278 wxRadioButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
279 wxItemPropertyInfo(win
, res
) {}
280 ~wxRadioButtonPropertyInfo(void) {}
281 wxProperty
*GetProperty(wxString
& name
);
282 bool SetProperty(wxString
& name
, wxProperty
*property
);
283 void GetPropertyNames(wxStringList
& names
);
284 bool InstantiateResource(wxItemResource
*resource
);
288 class wxGaugePropertyInfo
: public wxItemPropertyInfo
292 wxGaugePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
293 wxItemPropertyInfo(win
, res
) {}
294 ~wxGaugePropertyInfo(void) {}
295 wxProperty
*GetProperty(wxString
& name
);
296 bool SetProperty(wxString
& name
, wxProperty
*property
);
297 void GetPropertyNames(wxStringList
& names
);
298 bool InstantiateResource(wxItemResource
*resource
);
301 // For scrollbar items
302 class wxScrollBarPropertyInfo
: public wxItemPropertyInfo
306 wxScrollBarPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
307 wxItemPropertyInfo(win
, res
) {}
308 ~wxScrollBarPropertyInfo(void) {}
309 wxProperty
*GetProperty(wxString
& name
);
310 bool SetProperty(wxString
& name
, wxProperty
*property
);
311 void GetPropertyNames(wxStringList
& names
);
312 bool InstantiateResource(wxItemResource
*resource
);
316 class wxSliderPropertyInfo
: public wxItemPropertyInfo
320 wxSliderPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
321 wxItemPropertyInfo(win
, res
) {}
322 ~wxSliderPropertyInfo(void) {}
323 wxProperty
*GetProperty(wxString
& name
);
324 bool SetProperty(wxString
& name
, wxProperty
*property
);
325 void GetPropertyNames(wxStringList
& names
);
326 bool InstantiateResource(wxItemResource
*resource
);
330 class wxPanelPropertyInfo
: public wxWindowPropertyInfo
334 wxPanelPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
335 wxWindowPropertyInfo(win
, res
) {}
336 ~wxPanelPropertyInfo(void) {}
337 wxProperty
*GetProperty(wxString
& name
);
338 bool SetProperty(wxString
& name
, wxProperty
*property
);
339 void GetPropertyNames(wxStringList
& names
);
340 bool InstantiateResource(wxItemResource
*resource
);
343 int wxStringToFontWeight(wxString
& val
);
344 int wxStringToFontStyle(wxString
& val
);
345 int wxStringToFontFamily(wxString
& val
);
348 * A validator to allow editing symbol/id pairs
351 class wxResourceSymbolValidator
: public wxPropertyListValidator
353 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator
)
356 wxResourceSymbolValidator(long flags
= 0);
358 ~wxResourceSymbolValidator(void);
360 // Called when TICK is pressed or focus is lost.
361 // Return FALSE if value didn't check out; signal to restore old value.
362 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
364 // Called when TICK is pressed or focus is lost or view wants to update
365 // the property list.
366 // Does the transferance from the property editing area to the property itself
367 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
368 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
370 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
372 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
374 // Called when the edit (...) button is pressed.
375 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
379 * A dialog for editing symbol/id pairs
382 class wxResourceSymbolDialog
: public wxDialog
385 wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
386 const wxPoint
& pos
= wxDefaultPosition
,
387 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
);
391 inline void SetSymbol(const wxString
& symbol
) { m_symbolName
= symbol
; }
392 inline void SetId(long id
) { m_symbolId
= id
; }
394 inline wxString
GetSymbol() const { return m_symbolName
; }
395 inline long GetId() const { return m_symbolId
; }
398 void OnOK(wxCommandEvent
& event
);
399 void OnComboBoxSelect(wxCommandEvent
& event
);
400 void OnSymbolNameUpdate(wxCommandEvent
& event
);
403 wxString m_symbolName
;
405 wxComboBox
* m_nameCtrl
;
406 wxTextCtrl
* m_idCtrl
;
408 DECLARE_EVENT_TABLE()
411 #define ID_SYMBOLNAME_COMBOBOX 100
412 #define ID_SYMBOLID_TEXTCTRL 101