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 // A kind of property list view that intercepts OnPropertyChanged
25 class wxResourcePropertyListView
: public wxPropertyListView
28 wxPropertyInfo
*propertyInfo
;
30 wxResourcePropertyListView(wxPropertyInfo
*info
, wxPanel
*propPanel
= NULL
, long flags
= wxPROP_BUTTON_DEFAULT
):
31 wxPropertyListView(propPanel
, flags
)
35 void OnPropertyChanged(wxProperty
*property
);
39 // Generic class for relating an object to a collection of properties.
40 // Instead of defining new functions like wxButton::GetProperty, wxButton::SetProperty,
41 // we take these functions out into of the wxWindows library and associate
42 // them with separate classes.
43 class wxPropertyInfo
: public wxObject
46 static wxWindow
*sm_propertyWindow
;
54 virtual wxProperty
*GetProperty(wxString
& propName
) = 0;
55 virtual bool SetProperty(wxString
& propName
, wxProperty
*property
) = 0;
56 virtual void GetPropertyNames(wxStringList
& names
) = 0;
57 virtual bool Edit(wxWindow
*parent
, char *title
);
61 class wxWindowPropertyInfo
: public wxPropertyInfo
64 wxWindow
*propertyWindow
;
65 wxItemResource
*propertyResource
;
67 wxWindowPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
);
68 ~wxWindowPropertyInfo(void);
69 wxProperty
*GetProperty(wxString
& name
);
70 bool SetProperty(wxString
& name
, wxProperty
*property
);
71 void GetPropertyNames(wxStringList
& names
);
73 inline void SetPropertyWindow(wxWindow
*win
) { propertyWindow
= win
; }
75 inline void SetResource(wxItemResource
*res
) { propertyResource
= res
; }
77 // Helper functions for font properties
79 wxProperty
*GetFontProperty(wxString
& name
, wxFont
*font
);
80 wxFont
*SetFontProperty(wxString
& name
, wxProperty
*property
, wxFont
*oldFont
);
82 // Fill in the wxItemResource members to mirror the current window settings
83 virtual bool InstantiateResource(wxItemResource
*resource
);
87 class wxItemPropertyInfo
: public wxWindowPropertyInfo
91 wxItemPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
92 wxWindowPropertyInfo(win
, res
) {}
93 ~wxItemPropertyInfo(void) {}
94 wxProperty
*GetProperty(wxString
& name
);
95 bool SetProperty(wxString
& name
, wxProperty
*property
);
96 void GetPropertyNames(wxStringList
& names
);
97 bool InstantiateResource(wxItemResource
*resource
);
101 class wxButtonPropertyInfo
: public wxItemPropertyInfo
106 wxButtonPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
, bool bmButton
= FALSE
):
107 wxItemPropertyInfo(win
, res
) { isBitmapButton
= bmButton
; }
108 ~wxButtonPropertyInfo(void) {}
109 wxProperty
*GetProperty(wxString
& name
);
110 bool SetProperty(wxString
& name
, wxProperty
*property
);
111 void GetPropertyNames(wxStringList
& names
);
112 bool InstantiateResource(wxItemResource
*resource
);
114 inline bool IsBitmapButton(void) { return isBitmapButton
; }
118 class wxStaticTextPropertyInfo
: public wxItemPropertyInfo
122 bool isBitmapMessage
;
123 wxStaticTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
, bool bmMessage
= FALSE
):
124 wxItemPropertyInfo(win
, res
) { isBitmapMessage
= bmMessage
; }
125 ~wxStaticTextPropertyInfo(void) {}
126 wxProperty
*GetProperty(wxString
& name
);
127 bool SetProperty(wxString
& name
, wxProperty
*property
);
128 void GetPropertyNames(wxStringList
& names
);
129 bool InstantiateResource(wxItemResource
*resource
);
131 inline bool IsBitmapMessage(void) { return isBitmapMessage
; }
134 // For text/multitext items
135 class wxTextPropertyInfo
: public wxItemPropertyInfo
139 wxTextPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
140 wxItemPropertyInfo(win
, res
) {}
141 ~wxTextPropertyInfo(void) {}
142 wxProperty
*GetProperty(wxString
& name
);
143 bool SetProperty(wxString
& name
, wxProperty
*property
);
144 void GetPropertyNames(wxStringList
& names
);
145 bool InstantiateResource(wxItemResource
*resource
);
149 class wxListBoxPropertyInfo
: public wxItemPropertyInfo
153 wxListBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
154 wxItemPropertyInfo(win
, res
) {}
155 ~wxListBoxPropertyInfo(void) {}
156 wxProperty
*GetProperty(wxString
& name
);
157 bool SetProperty(wxString
& name
, wxProperty
*property
);
158 void GetPropertyNames(wxStringList
& names
);
159 bool InstantiateResource(wxItemResource
*resource
);
163 class wxChoicePropertyInfo
: public wxItemPropertyInfo
167 wxChoicePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
168 wxItemPropertyInfo(win
, res
) {}
169 ~wxChoicePropertyInfo(void) {}
170 wxProperty
*GetProperty(wxString
& name
);
171 bool SetProperty(wxString
& name
, wxProperty
*property
);
172 void GetPropertyNames(wxStringList
& names
);
173 bool InstantiateResource(wxItemResource
*resource
);
176 // For radiobox items
177 class wxRadioBoxPropertyInfo
: public wxItemPropertyInfo
181 wxRadioBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
182 wxItemPropertyInfo(win
, res
) {}
183 ~wxRadioBoxPropertyInfo(void) {}
184 wxProperty
*GetProperty(wxString
& name
);
185 bool SetProperty(wxString
& name
, wxProperty
*property
);
186 void GetPropertyNames(wxStringList
& names
);
187 bool InstantiateResource(wxItemResource
*resource
);
190 // For groupbox items
191 class wxGroupBoxPropertyInfo
: public wxItemPropertyInfo
195 wxGroupBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
196 wxItemPropertyInfo(win
, res
) {}
197 ~wxGroupBoxPropertyInfo(void) {}
198 wxProperty
*GetProperty(wxString
& name
);
199 bool SetProperty(wxString
& name
, wxProperty
*property
);
200 void GetPropertyNames(wxStringList
& names
);
201 bool InstantiateResource(wxItemResource
*resource
);
204 // For checkbox items
205 class wxCheckBoxPropertyInfo
: public wxItemPropertyInfo
209 wxCheckBoxPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
210 wxItemPropertyInfo(win
, res
) {}
211 ~wxCheckBoxPropertyInfo(void) {}
212 wxProperty
*GetProperty(wxString
& name
);
213 bool SetProperty(wxString
& name
, wxProperty
*property
);
214 void GetPropertyNames(wxStringList
& names
);
215 bool InstantiateResource(wxItemResource
*resource
);
219 class wxGaugePropertyInfo
: public wxItemPropertyInfo
223 wxGaugePropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
224 wxItemPropertyInfo(win
, res
) {}
225 ~wxGaugePropertyInfo(void) {}
226 wxProperty
*GetProperty(wxString
& name
);
227 bool SetProperty(wxString
& name
, wxProperty
*property
);
228 void GetPropertyNames(wxStringList
& names
);
229 bool InstantiateResource(wxItemResource
*resource
);
232 // For scrollbar items
233 class wxScrollBarPropertyInfo
: public wxItemPropertyInfo
237 wxScrollBarPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
238 wxItemPropertyInfo(win
, res
) {}
239 ~wxScrollBarPropertyInfo(void) {}
240 wxProperty
*GetProperty(wxString
& name
);
241 bool SetProperty(wxString
& name
, wxProperty
*property
);
242 void GetPropertyNames(wxStringList
& names
);
243 bool InstantiateResource(wxItemResource
*resource
);
247 class wxSliderPropertyInfo
: public wxItemPropertyInfo
251 wxSliderPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
252 wxItemPropertyInfo(win
, res
) {}
253 ~wxSliderPropertyInfo(void) {}
254 wxProperty
*GetProperty(wxString
& name
);
255 bool SetProperty(wxString
& name
, wxProperty
*property
);
256 void GetPropertyNames(wxStringList
& names
);
257 bool InstantiateResource(wxItemResource
*resource
);
261 class wxPanelPropertyInfo
: public wxWindowPropertyInfo
265 wxPanelPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
266 wxWindowPropertyInfo(win
, res
) {}
267 ~wxPanelPropertyInfo(void) {}
268 wxProperty
*GetProperty(wxString
& name
);
269 bool SetProperty(wxString
& name
, wxProperty
*property
);
270 void GetPropertyNames(wxStringList
& names
);
271 bool InstantiateResource(wxItemResource
*resource
);
275 class wxDialogPropertyInfo
: public wxPanelPropertyInfo
279 wxDialogPropertyInfo(wxWindow
*win
, wxItemResource
*res
= NULL
):
280 wxPanelPropertyInfo(win
, res
) {}
281 ~wxDialogPropertyInfo(void) {}
282 wxProperty
*GetProperty(wxString
& name
);
283 bool SetProperty(wxString
& name
, wxProperty
*property
);
284 void GetPropertyNames(wxStringList
& names
);
285 bool InstantiateResource(wxItemResource
*resource
);
288 int wxStringToFontWeight(wxString
& val
);
289 int wxStringToFontStyle(wxString
& val
);
290 int wxStringToFontFamily(wxString
& val
);