]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/winprop.h
several fixes
[wxWidgets.git] / utils / dialoged / src / winprop.h
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
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
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 {
60 friend class wxDialogEditorPropertyListDialog;
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;
73 virtual bool Edit(wxWindow *parent, const wxString& title);
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:
121 wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
122 wxItemPropertyInfo(win, res) { }
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);
128 };
129
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);
142 };
143
144 // For static text controls
145 class wxStaticTextPropertyInfo: public wxItemPropertyInfo
146 {
147 protected:
148 public:
149 wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
150 wxItemPropertyInfo(win, res) { }
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);
156 };
157
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);
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 radiobutton items
257 class wxRadioButtonPropertyInfo: public wxItemPropertyInfo
258 {
259 protected:
260 public:
261 wxRadioButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
262 wxItemPropertyInfo(win, res) {}
263 ~wxRadioButtonPropertyInfo(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 gauge items
271 class wxGaugePropertyInfo: public wxItemPropertyInfo
272 {
273 protected:
274 public:
275 wxGaugePropertyInfo(wxWindow *win, wxItemResource *res = NULL):
276 wxItemPropertyInfo(win, res) {}
277 ~wxGaugePropertyInfo(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 scrollbar items
285 class wxScrollBarPropertyInfo: public wxItemPropertyInfo
286 {
287 protected:
288 public:
289 wxScrollBarPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
290 wxItemPropertyInfo(win, res) {}
291 ~wxScrollBarPropertyInfo(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 slider items
299 class wxSliderPropertyInfo: public wxItemPropertyInfo
300 {
301 protected:
302 public:
303 wxSliderPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
304 wxItemPropertyInfo(win, res) {}
305 ~wxSliderPropertyInfo(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
312 // For panels
313 class wxPanelPropertyInfo: public wxWindowPropertyInfo
314 {
315 protected:
316 public:
317 wxPanelPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
318 wxWindowPropertyInfo(win, res) {}
319 ~wxPanelPropertyInfo(void) {}
320 wxProperty *GetProperty(wxString& name);
321 bool SetProperty(wxString& name, wxProperty *property);
322 void GetPropertyNames(wxStringList& names);
323 bool InstantiateResource(wxItemResource *resource);
324 };
325
326 int wxStringToFontWeight(wxString& val);
327 int wxStringToFontStyle(wxString& val);
328 int wxStringToFontFamily(wxString& val);
329
330 /*
331 * A validator to allow editing symbol/id pairs
332 */
333
334 class wxResourceSymbolValidator: public wxPropertyListValidator
335 {
336 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator)
337 protected:
338 public:
339 wxResourceSymbolValidator(long flags = 0);
340
341 ~wxResourceSymbolValidator(void);
342
343 // Called when TICK is pressed or focus is lost.
344 // Return FALSE if value didn't check out; signal to restore old value.
345 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
346
347 // Called when TICK is pressed or focus is lost or view wants to update
348 // the property list.
349 // Does the transferance from the property editing area to the property itself
350 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
351 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
352
353 bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
354
355 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
356
357 // Called when the edit (...) button is pressed.
358 void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
359 };
360
361 /*
362 * A dialog for editing symbol/id pairs
363 */
364
365 class wxResourceSymbolDialog: public wxDialog
366 {
367 public:
368 wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
369 const wxPoint& pos = wxDefaultPosition,
370 const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE);
371
372 void Init();
373
374 inline void SetSymbol(const wxString& symbol) { m_symbolName = symbol; }
375 inline void SetId(long id) { m_symbolId = id; }
376
377 inline wxString GetSymbol() const { return m_symbolName; }
378 inline long GetId() const { return m_symbolId; }
379
380 bool CheckValues();
381 void OnOK(wxCommandEvent& event);
382
383 protected:
384 wxString m_symbolName;
385 long m_symbolId;
386 wxComboBox* m_nameCtrl;
387 wxTextCtrl* m_idCtrl;
388
389 DECLARE_EVENT_TABLE()
390 };
391
392 #define ID_SYMBOLNAME_COMBOBOX 100
393 #define ID_SYMBOLID_TEXTCTRL 101
394
395 #endif
396 // _WINPROP_H_