]>
Commit | Line | Data |
---|---|---|
457814b5 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: winprop.h | |
3 | // Purpose: Window properties | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WINPROP_H_ | |
13 | #define _WINPROP_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "winprop.h" | |
17 | #endif | |
18 | ||
19 | #include "reseditr.h" | |
20 | ||
21 | class wxPropertyInfo; | |
22 | ||
ae8351fc JS |
23 | class wxDialogEditorPropertyListDialog: public wxPropertyListDialog |
24 | { | |
25 | friend class wxPropertyInfo; | |
26 | public: | |
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(); | |
31 | ||
32 | private: | |
33 | wxPropertySheet* m_propSheet; | |
34 | wxPropertyValidatorRegistry m_registry; | |
35 | wxPropertyInfo* m_propInfo; | |
36 | }; | |
37 | ||
457814b5 JS |
38 | // A kind of property list view that intercepts OnPropertyChanged |
39 | // feedback. | |
40 | class wxResourcePropertyListView: public wxPropertyListView | |
41 | { | |
42 | public: | |
43 | wxPropertyInfo *propertyInfo; | |
44 | ||
45 | wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT): | |
46 | wxPropertyListView(propPanel, flags) | |
47 | { | |
48 | propertyInfo = info; | |
49 | } | |
50 | void OnPropertyChanged(wxProperty *property); | |
51 | bool OnClose(void); | |
52 | }; | |
53 | ||
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 | |
59 | { | |
ae8351fc | 60 | friend class wxDialogEditorPropertyListDialog; |
457814b5 JS |
61 | protected: |
62 | static wxWindow *sm_propertyWindow; | |
63 | wxPropertyInfo(void) | |
64 | { | |
65 | } | |
66 | ~wxPropertyInfo(void) | |
67 | { | |
68 | } | |
69 | public: | |
70 | virtual wxProperty *GetProperty(wxString& propName) = 0; | |
71 | virtual bool SetProperty(wxString& propName, wxProperty *property) = 0; | |
72 | virtual void GetPropertyNames(wxStringList& names) = 0; | |
ae8351fc | 73 | virtual bool Edit(wxWindow *parent, const wxString& title); |
457814b5 JS |
74 | }; |
75 | ||
76 | // For all windows | |
77 | class wxWindowPropertyInfo: public wxPropertyInfo | |
78 | { | |
79 | protected: | |
80 | wxWindow *propertyWindow; | |
81 | wxItemResource *propertyResource; | |
82 | public: | |
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); | |
88 | ||
89 | inline void SetPropertyWindow(wxWindow *win) { propertyWindow = win; } | |
90 | ||
91 | inline void SetResource(wxItemResource *res) { propertyResource = res; } | |
92 | ||
93 | // Helper functions for font properties | |
94 | ||
95 | wxProperty *GetFontProperty(wxString& name, wxFont *font); | |
96 | wxFont *SetFontProperty(wxString& name, wxProperty *property, wxFont *oldFont); | |
97 | ||
98 | // Fill in the wxItemResource members to mirror the current window settings | |
99 | virtual bool InstantiateResource(wxItemResource *resource); | |
100 | }; | |
101 | ||
102 | // For panel items | |
103 | class wxItemPropertyInfo: public wxWindowPropertyInfo | |
104 | { | |
105 | protected: | |
106 | public: | |
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); | |
114 | }; | |
115 | ||
116 | // For buttons | |
117 | class wxButtonPropertyInfo: public wxItemPropertyInfo | |
118 | { | |
119 | protected: | |
120 | public: | |
ae8351fc JS |
121 | wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): |
122 | wxItemPropertyInfo(win, res) { } | |
457814b5 JS |
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); | |
ae8351fc | 128 | }; |
457814b5 | 129 | |
ae8351fc JS |
130 | // For bitmap buttons |
131 | class wxBitmapButtonPropertyInfo: public wxButtonPropertyInfo | |
132 | { | |
133 | protected: | |
134 | public: | |
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); | |
457814b5 JS |
142 | }; |
143 | ||
ae8351fc | 144 | // For static text controls |
457814b5 JS |
145 | class wxStaticTextPropertyInfo: public wxItemPropertyInfo |
146 | { | |
147 | protected: | |
148 | public: | |
ae8351fc JS |
149 | wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL): |
150 | wxItemPropertyInfo(win, res) { } | |
457814b5 JS |
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); | |
ae8351fc | 156 | }; |
457814b5 | 157 | |
ae8351fc JS |
158 | // For static bitmap controls |
159 | class wxStaticBitmapPropertyInfo: public wxItemPropertyInfo | |
160 | { | |
161 | protected: | |
162 | public: | |
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); | |
457814b5 JS |
170 | }; |
171 | ||
172 | // For text/multitext items | |
173 | class wxTextPropertyInfo: public wxItemPropertyInfo | |
174 | { | |
175 | protected: | |
176 | public: | |
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); | |
184 | }; | |
185 | ||
186 | // For list boxes | |
187 | class wxListBoxPropertyInfo: public wxItemPropertyInfo | |
188 | { | |
189 | protected: | |
190 | public: | |
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); | |
198 | }; | |
199 | ||
200 | // For choice items | |
201 | class wxChoicePropertyInfo: public wxItemPropertyInfo | |
202 | { | |
203 | protected: | |
204 | public: | |
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); | |
212 | }; | |
213 | ||
214 | // For radiobox items | |
215 | class wxRadioBoxPropertyInfo: public wxItemPropertyInfo | |
216 | { | |
217 | protected: | |
218 | public: | |
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); | |
226 | }; | |
227 | ||
228 | // For groupbox items | |
229 | class wxGroupBoxPropertyInfo: public wxItemPropertyInfo | |
230 | { | |
231 | protected: | |
232 | public: | |
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); | |
240 | }; | |
241 | ||
242 | // For checkbox items | |
243 | class wxCheckBoxPropertyInfo: public wxItemPropertyInfo | |
244 | { | |
245 | protected: | |
246 | public: | |
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); | |
254 | }; | |
255 | ||
256 | // For gauge items | |
257 | class wxGaugePropertyInfo: public wxItemPropertyInfo | |
258 | { | |
259 | protected: | |
260 | public: | |
261 | wxGaugePropertyInfo(wxWindow *win, wxItemResource *res = NULL): | |
262 | wxItemPropertyInfo(win, res) {} | |
263 | ~wxGaugePropertyInfo(void) {} | |
264 | wxProperty *GetProperty(wxString& name); | |
265 | bool SetProperty(wxString& name, wxProperty *property); | |
266 | void GetPropertyNames(wxStringList& names); | |
267 | bool InstantiateResource(wxItemResource *resource); | |
268 | }; | |
269 | ||
270 | // For scrollbar items | |
271 | class wxScrollBarPropertyInfo: public wxItemPropertyInfo | |
272 | { | |
273 | protected: | |
274 | public: | |
275 | wxScrollBarPropertyInfo(wxWindow *win, wxItemResource *res = NULL): | |
276 | wxItemPropertyInfo(win, res) {} | |
277 | ~wxScrollBarPropertyInfo(void) {} | |
278 | wxProperty *GetProperty(wxString& name); | |
279 | bool SetProperty(wxString& name, wxProperty *property); | |
280 | void GetPropertyNames(wxStringList& names); | |
281 | bool InstantiateResource(wxItemResource *resource); | |
282 | }; | |
283 | ||
284 | // For slider items | |
285 | class wxSliderPropertyInfo: public wxItemPropertyInfo | |
286 | { | |
287 | protected: | |
288 | public: | |
289 | wxSliderPropertyInfo(wxWindow *win, wxItemResource *res = NULL): | |
290 | wxItemPropertyInfo(win, res) {} | |
291 | ~wxSliderPropertyInfo(void) {} | |
292 | wxProperty *GetProperty(wxString& name); | |
293 | bool SetProperty(wxString& name, wxProperty *property); | |
294 | void GetPropertyNames(wxStringList& names); | |
295 | bool InstantiateResource(wxItemResource *resource); | |
296 | }; | |
297 | ||
298 | // For panels | |
299 | class wxPanelPropertyInfo: public wxWindowPropertyInfo | |
300 | { | |
301 | protected: | |
302 | public: | |
303 | wxPanelPropertyInfo(wxWindow *win, wxItemResource *res = NULL): | |
304 | wxWindowPropertyInfo(win, res) {} | |
305 | ~wxPanelPropertyInfo(void) {} | |
306 | wxProperty *GetProperty(wxString& name); | |
307 | bool SetProperty(wxString& name, wxProperty *property); | |
308 | void GetPropertyNames(wxStringList& names); | |
309 | bool InstantiateResource(wxItemResource *resource); | |
310 | }; | |
311 | ||
457814b5 JS |
312 | int wxStringToFontWeight(wxString& val); |
313 | int wxStringToFontStyle(wxString& val); | |
314 | int wxStringToFontFamily(wxString& val); | |
315 | ||
316 | #endif | |
317 |