]>
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 | ||
bbcdf8bc | 23 | class wxDialogEditorPropertyListFrame: public wxPropertyListFrame |
ae8351fc JS |
24 | { |
25 | friend class wxPropertyInfo; | |
26 | public: | |
bbcdf8bc | 27 | wxDialogEditorPropertyListFrame(wxPropertyListView *v, wxFrame *parent, const wxString& title, |
ae8351fc | 28 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, |
bbcdf8bc JS |
29 | long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); |
30 | ~wxDialogEditorPropertyListFrame(); | |
ae8351fc JS |
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 | { | |
bbcdf8bc | 60 | friend class wxDialogEditorPropertyListFrame; |
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); | |
bbcdf8bc JS |
100 | |
101 | // Set the window style | |
102 | void SetWindowStyle(wxWindow* win, long style, bool set); | |
457814b5 JS |
103 | }; |
104 | ||
105 | // For panel items | |
106 | class wxItemPropertyInfo: public wxWindowPropertyInfo | |
107 | { | |
108 | protected: | |
109 | public: | |
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); | |
117 | }; | |
118 | ||
119 | // For buttons | |
120 | class wxButtonPropertyInfo: public wxItemPropertyInfo | |
121 | { | |
122 | protected: | |
123 | public: | |
ae8351fc JS |
124 | wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL): |
125 | wxItemPropertyInfo(win, res) { } | |
457814b5 JS |
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); | |
ae8351fc | 131 | }; |
457814b5 | 132 | |
ae8351fc JS |
133 | // For bitmap buttons |
134 | class wxBitmapButtonPropertyInfo: public wxButtonPropertyInfo | |
135 | { | |
136 | protected: | |
137 | public: | |
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); | |
457814b5 JS |
145 | }; |
146 | ||
ae8351fc | 147 | // For static text controls |
457814b5 JS |
148 | class wxStaticTextPropertyInfo: public wxItemPropertyInfo |
149 | { | |
150 | protected: | |
151 | public: | |
ae8351fc JS |
152 | wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL): |
153 | wxItemPropertyInfo(win, res) { } | |
457814b5 JS |
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); | |
ae8351fc | 159 | }; |
457814b5 | 160 | |
ae8351fc JS |
161 | // For static bitmap controls |
162 | class wxStaticBitmapPropertyInfo: public wxItemPropertyInfo | |
163 | { | |
164 | protected: | |
165 | public: | |
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); | |
457814b5 JS |
173 | }; |
174 | ||
175 | // For text/multitext items | |
176 | class wxTextPropertyInfo: public wxItemPropertyInfo | |
177 | { | |
178 | protected: | |
179 | public: | |
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); | |
187 | }; | |
188 | ||
189 | // For list boxes | |
190 | class wxListBoxPropertyInfo: public wxItemPropertyInfo | |
191 | { | |
192 | protected: | |
193 | public: | |
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); | |
201 | }; | |
202 | ||
203 | // For choice items | |
204 | class wxChoicePropertyInfo: public wxItemPropertyInfo | |
205 | { | |
206 | protected: | |
207 | public: | |
208 | wxChoicePropertyInfo(wxWindow *win, wxItemResource *res = NULL): | |
209 | wxItemPropertyInfo(win, res) {} | |
210 | ~wxChoicePropertyInfo(void) {} | |
9c331ded JS |
211 | wxProperty *GetProperty(wxString& name); |
212 | bool SetProperty(wxString& name, wxProperty *property); | |
213 | void GetPropertyNames(wxStringList& names); | |
214 | bool InstantiateResource(wxItemResource *resource); | |
215 | }; | |
216 | ||
217 | // For choice items | |
218 | class wxComboBoxPropertyInfo: public wxChoicePropertyInfo | |
219 | { | |
220 | protected: | |
221 | public: | |
222 | wxComboBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL): | |
223 | wxChoicePropertyInfo(win, res) {} | |
224 | ~wxComboBoxPropertyInfo(void) {} | |
457814b5 JS |
225 | wxProperty *GetProperty(wxString& name); |
226 | bool SetProperty(wxString& name, wxProperty *property); | |
227 | void GetPropertyNames(wxStringList& names); | |
228 | bool InstantiateResource(wxItemResource *resource); | |
229 | }; | |
230 | ||
231 | // For radiobox items | |
232 | class wxRadioBoxPropertyInfo: public wxItemPropertyInfo | |
233 | { | |
234 | protected: | |
235 | public: | |
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); | |
243 | }; | |
244 | ||
245 | // For groupbox items | |
246 | class wxGroupBoxPropertyInfo: public wxItemPropertyInfo | |
247 | { | |
248 | protected: | |
249 | public: | |
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); | |
257 | }; | |
258 | ||
259 | // For checkbox items | |
260 | class wxCheckBoxPropertyInfo: public wxItemPropertyInfo | |
261 | { | |
262 | protected: | |
263 | public: | |
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); | |
271 | }; | |
272 | ||
03f68f12 JS |
273 | // For radiobutton items |
274 | class wxRadioButtonPropertyInfo: public wxItemPropertyInfo | |
275 | { | |
276 | protected: | |
277 | public: | |
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); | |
285 | }; | |
286 | ||
457814b5 JS |
287 | // For gauge items |
288 | class wxGaugePropertyInfo: public wxItemPropertyInfo | |
289 | { | |
290 | protected: | |
291 | public: | |
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); | |
299 | }; | |
300 | ||
301 | // For scrollbar items | |
302 | class wxScrollBarPropertyInfo: public wxItemPropertyInfo | |
303 | { | |
304 | protected: | |
305 | public: | |
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); | |
313 | }; | |
314 | ||
315 | // For slider items | |
316 | class wxSliderPropertyInfo: public wxItemPropertyInfo | |
317 | { | |
318 | protected: | |
319 | public: | |
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); | |
327 | }; | |
328 | ||
329 | // For panels | |
330 | class wxPanelPropertyInfo: public wxWindowPropertyInfo | |
331 | { | |
332 | protected: | |
333 | public: | |
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); | |
341 | }; | |
342 | ||
457814b5 JS |
343 | int wxStringToFontWeight(wxString& val); |
344 | int wxStringToFontStyle(wxString& val); | |
345 | int wxStringToFontFamily(wxString& val); | |
346 | ||
03f68f12 JS |
347 | /* |
348 | * A validator to allow editing symbol/id pairs | |
349 | */ | |
350 | ||
351 | class wxResourceSymbolValidator: public wxPropertyListValidator | |
352 | { | |
353 | DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator) | |
354 | protected: | |
355 | public: | |
356 | wxResourceSymbolValidator(long flags = 0); | |
357 | ||
358 | ~wxResourceSymbolValidator(void); | |
359 | ||
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); | |
363 | ||
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); | |
457814b5 | 369 | |
03f68f12 JS |
370 | bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); |
371 | ||
372 | bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); | |
373 | ||
374 | // Called when the edit (...) button is pressed. | |
375 | void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow); | |
376 | }; | |
377 | ||
378 | /* | |
379 | * A dialog for editing symbol/id pairs | |
380 | */ | |
381 | ||
382 | class wxResourceSymbolDialog: public wxDialog | |
383 | { | |
384 | public: | |
385 | wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title, | |
386 | const wxPoint& pos = wxDefaultPosition, | |
5de76427 | 387 | const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); |
03f68f12 JS |
388 | |
389 | void Init(); | |
390 | ||
391 | inline void SetSymbol(const wxString& symbol) { m_symbolName = symbol; } | |
392 | inline void SetId(long id) { m_symbolId = id; } | |
393 | ||
394 | inline wxString GetSymbol() const { return m_symbolName; } | |
395 | inline long GetId() const { return m_symbolId; } | |
396 | ||
397 | bool CheckValues(); | |
398 | void OnOK(wxCommandEvent& event); | |
5de76427 JS |
399 | void OnComboBoxSelect(wxCommandEvent& event); |
400 | void OnSymbolNameUpdate(wxCommandEvent& event); | |
03f68f12 JS |
401 | |
402 | protected: | |
403 | wxString m_symbolName; | |
404 | long m_symbolId; | |
405 | wxComboBox* m_nameCtrl; | |
406 | wxTextCtrl* m_idCtrl; | |
407 | ||
408 | DECLARE_EVENT_TABLE() | |
409 | }; | |
410 | ||
411 | #define ID_SYMBOLNAME_COMBOBOX 100 | |
412 | #define ID_SYMBOLID_TEXTCTRL 101 | |
413 | ||
414 | #endif | |
415 | // _WINPROP_H_ |