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
);
77 static void CloseWindow(); // Close the current window if open.
81 class wxWindowPropertyInfo
: public wxPropertyInfo
84 wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
);
85 ~wxWindowPropertyInfo(void);
86 wxProperty
*GetProperty(wxString
& name
);
87 bool SetProperty(wxString
& name
, wxProperty
*property
);
88 void GetPropertyNames(wxStringList
& names
);
90 inline void SetPropertyWindow(wxWindow
*win
) { m_propertyWindow
= win
; }
92 inline void SetResource(wxItemResource
*res
) { m_propertyResource
= res
; }
94 // Helper functions for font properties
96 wxProperty
*GetFontProperty(wxString
& name
, wxFont
*font
);
97 wxFont
*SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*oldFont
);
99 // Fill in the wxItemResource members to mirror the current window settings
100 virtual bool InstantiateResource(wxItemResource
*resource
);
102 // Set the window style
103 void SetWindowStyle(wxWindow
* win
, long style
, bool set
);
105 wxWindow
* GetWindow() const { return m_propertyWindow
; }
106 wxItemResource
* GetResource() const { return m_propertyResource
; }
109 wxWindow
* m_propertyWindow
;
110 wxItemResource
* m_propertyResource
;
114 class wxItemPropertyInfo
: public wxWindowPropertyInfo
118 wxItemPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
119 wxWindowPropertyInfo(win
, res
) {}
120 ~wxItemPropertyInfo(void) {}
121 wxProperty
*GetProperty(wxString
& name
);
122 bool SetProperty(wxString
& name
, wxProperty
*property
);
123 void GetPropertyNames(wxStringList
& names
);
124 bool InstantiateResource(wxItemResource
*resource
);
128 class wxButtonPropertyInfo
: public wxItemPropertyInfo
132 wxButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
133 wxItemPropertyInfo(win
, res
) { }
134 ~wxButtonPropertyInfo(void) {}
135 wxProperty
*GetProperty(wxString
& name
);
136 bool SetProperty(wxString
& name
, wxProperty
*property
);
137 void GetPropertyNames(wxStringList
& names
);
138 bool InstantiateResource(wxItemResource
*resource
);
141 // For bitmap buttons
142 class wxBitmapButtonPropertyInfo
: public wxButtonPropertyInfo
146 wxBitmapButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
147 wxButtonPropertyInfo(win
, res
) { }
148 ~wxBitmapButtonPropertyInfo(void) {}
149 wxProperty
*GetProperty(wxString
& name
);
150 bool SetProperty(wxString
& name
, wxProperty
*property
);
151 void GetPropertyNames(wxStringList
& names
);
152 bool InstantiateResource(wxItemResource
*resource
);
155 // For static text controls
156 class wxStaticTextPropertyInfo
: public wxItemPropertyInfo
160 wxStaticTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
161 wxItemPropertyInfo(win
, res
) { }
162 ~wxStaticTextPropertyInfo(void) {}
163 wxProperty
*GetProperty(wxString
& name
);
164 bool SetProperty(wxString
& name
, wxProperty
*property
);
165 void GetPropertyNames(wxStringList
& names
);
166 bool InstantiateResource(wxItemResource
*resource
);
169 // For static bitmap controls
170 class wxStaticBitmapPropertyInfo
: public wxItemPropertyInfo
174 wxStaticBitmapPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
175 wxItemPropertyInfo(win
, res
) { }
176 ~wxStaticBitmapPropertyInfo(void) {}
177 wxProperty
*GetProperty(wxString
& name
);
178 bool SetProperty(wxString
& name
, wxProperty
*property
);
179 void GetPropertyNames(wxStringList
& names
);
180 bool InstantiateResource(wxItemResource
*resource
);
183 // For text/multitext items
184 class wxTextPropertyInfo
: public wxItemPropertyInfo
188 wxTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
189 wxItemPropertyInfo(win
, res
) {}
190 ~wxTextPropertyInfo(void) {}
191 wxProperty
*GetProperty(wxString
& name
);
192 bool SetProperty(wxString
& name
, wxProperty
*property
);
193 void GetPropertyNames(wxStringList
& names
);
194 bool InstantiateResource(wxItemResource
*resource
);
198 class wxListBoxPropertyInfo
: public wxItemPropertyInfo
202 wxListBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
203 wxItemPropertyInfo(win
, res
) {}
204 ~wxListBoxPropertyInfo(void) {}
205 wxProperty
*GetProperty(wxString
& name
);
206 bool SetProperty(wxString
& name
, wxProperty
*property
);
207 void GetPropertyNames(wxStringList
& names
);
208 bool InstantiateResource(wxItemResource
*resource
);
212 class wxChoicePropertyInfo
: public wxItemPropertyInfo
216 wxChoicePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
217 wxItemPropertyInfo(win
, res
) {}
218 ~wxChoicePropertyInfo(void) {}
219 wxProperty
*GetProperty(wxString
& name
);
220 bool SetProperty(wxString
& name
, wxProperty
*property
);
221 void GetPropertyNames(wxStringList
& names
);
222 bool InstantiateResource(wxItemResource
*resource
);
226 class wxComboBoxPropertyInfo
: public wxChoicePropertyInfo
230 wxComboBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
231 wxChoicePropertyInfo(win
, res
) {}
232 ~wxComboBoxPropertyInfo(void) {}
233 wxProperty
*GetProperty(wxString
& name
);
234 bool SetProperty(wxString
& name
, wxProperty
*property
);
235 void GetPropertyNames(wxStringList
& names
);
236 bool InstantiateResource(wxItemResource
*resource
);
239 // For radiobox items
240 class wxRadioBoxPropertyInfo
: public wxItemPropertyInfo
244 wxRadioBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
245 wxItemPropertyInfo(win
, res
) {}
246 ~wxRadioBoxPropertyInfo(void) {}
247 wxProperty
*GetProperty(wxString
& name
);
248 bool SetProperty(wxString
& name
, wxProperty
*property
);
249 void GetPropertyNames(wxStringList
& names
);
250 bool InstantiateResource(wxItemResource
*resource
);
253 // For groupbox items
254 class wxGroupBoxPropertyInfo
: public wxItemPropertyInfo
258 wxGroupBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
259 wxItemPropertyInfo(win
, res
) {}
260 ~wxGroupBoxPropertyInfo(void) {}
261 wxProperty
*GetProperty(wxString
& name
);
262 bool SetProperty(wxString
& name
, wxProperty
*property
);
263 void GetPropertyNames(wxStringList
& names
);
264 bool InstantiateResource(wxItemResource
*resource
);
267 // For checkbox items
268 class wxCheckBoxPropertyInfo
: public wxItemPropertyInfo
272 wxCheckBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
273 wxItemPropertyInfo(win
, res
) {}
274 ~wxCheckBoxPropertyInfo(void) {}
275 wxProperty
*GetProperty(wxString
& name
);
276 bool SetProperty(wxString
& name
, wxProperty
*property
);
277 void GetPropertyNames(wxStringList
& names
);
278 bool InstantiateResource(wxItemResource
*resource
);
281 // For radiobutton items
282 class wxRadioButtonPropertyInfo
: public wxItemPropertyInfo
286 wxRadioButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
287 wxItemPropertyInfo(win
, res
) {}
288 ~wxRadioButtonPropertyInfo(void) {}
289 wxProperty
*GetProperty(wxString
& name
);
290 bool SetProperty(wxString
& name
, wxProperty
*property
);
291 void GetPropertyNames(wxStringList
& names
);
292 bool InstantiateResource(wxItemResource
*resource
);
296 class wxGaugePropertyInfo
: public wxItemPropertyInfo
300 wxGaugePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
301 wxItemPropertyInfo(win
, res
) {}
302 ~wxGaugePropertyInfo(void) {}
303 wxProperty
*GetProperty(wxString
& name
);
304 bool SetProperty(wxString
& name
, wxProperty
*property
);
305 void GetPropertyNames(wxStringList
& names
);
306 bool InstantiateResource(wxItemResource
*resource
);
309 // For scrollbar items
310 class wxScrollBarPropertyInfo
: public wxItemPropertyInfo
314 wxScrollBarPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
315 wxItemPropertyInfo(win
, res
) {}
316 ~wxScrollBarPropertyInfo(void) {}
317 wxProperty
*GetProperty(wxString
& name
);
318 bool SetProperty(wxString
& name
, wxProperty
*property
);
319 void GetPropertyNames(wxStringList
& names
);
320 bool InstantiateResource(wxItemResource
*resource
);
324 class wxSliderPropertyInfo
: public wxItemPropertyInfo
328 wxSliderPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
329 wxItemPropertyInfo(win
, res
) {}
330 ~wxSliderPropertyInfo(void) {}
331 wxProperty
*GetProperty(wxString
& name
);
332 bool SetProperty(wxString
& name
, wxProperty
*property
);
333 void GetPropertyNames(wxStringList
& names
);
334 bool InstantiateResource(wxItemResource
*resource
);
338 class wxPanelPropertyInfo
: public wxWindowPropertyInfo
342 wxPanelPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
343 wxWindowPropertyInfo(win
, res
) {}
344 ~wxPanelPropertyInfo(void) {}
345 wxProperty
*GetProperty(wxString
& name
);
346 bool SetProperty(wxString
& name
, wxProperty
*property
);
347 void GetPropertyNames(wxStringList
& names
);
348 bool InstantiateResource(wxItemResource
*resource
);
350 // Convert this dialog, and its children, to or from dialog units
351 void ConvertDialogUnits(bool toDialogUnits
);
354 int wxStringToFontWeight(wxString
& val
);
355 int wxStringToFontStyle(wxString
& val
);
356 int wxStringToFontFamily(wxString
& val
);
359 * A validator to allow editing symbol/id pairs
362 class wxResourceSymbolValidator
: public wxPropertyListValidator
364 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator
)
367 wxResourceSymbolValidator(long flags
= 0);
369 ~wxResourceSymbolValidator(void);
371 // Called when TICK is pressed or focus is lost.
372 // Return FALSE if value didn't check out; signal to restore old value.
373 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
375 // Called when TICK is pressed or focus is lost or view wants to update
376 // the property list.
377 // Does the transferance from the property editing area to the property itself
378 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
379 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
381 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
383 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
385 // Called when the edit (...) button is pressed.
386 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
390 * A dialog for editing symbol/id pairs
393 class wxResourceSymbolDialog
: public wxDialog
396 wxResourceSymbolDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
397 const wxPoint
& pos
= wxDefaultPosition
,
398 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
);
402 inline void SetSymbol(const wxString
& symbol
) { m_symbolName
= symbol
; }
403 inline void SetId(long id
) { m_symbolId
= id
; }
405 inline wxString
GetSymbol() const { return m_symbolName
; }
406 inline long GetId() const { return m_symbolId
; }
409 void OnOK(wxCommandEvent
& event
);
410 void OnComboBoxSelect(wxCommandEvent
& event
);
411 void OnSymbolNameUpdate(wxCommandEvent
& event
);
414 wxString m_symbolName
;
416 wxComboBox
* m_nameCtrl
;
417 wxTextCtrl
* m_idCtrl
;
419 DECLARE_EVENT_TABLE()
422 #define ID_SYMBOLNAME_COMBOBOX 100
423 #define ID_SYMBOLID_TEXTCTRL 101