]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/winprop.h
Further fixes to Dialog Editor; additions to .dsp files
[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 wxDialogEditorPropertyListFrame: public wxPropertyListFrame
24 {
25 friend class wxPropertyInfo;
26 public:
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();
31
32 wxPropertyInfo* GetInfo() const { return m_propInfo; }
33
34 private:
35 wxPropertySheet* m_propSheet;
36 wxPropertyValidatorRegistry m_registry;
37 wxPropertyInfo* m_propInfo;
38 };
39
40 // A kind of property list view that intercepts OnPropertyChanged
41 // feedback.
42 class wxResourcePropertyListView: public wxPropertyListView
43 {
44 public:
45 wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT):
46 wxPropertyListView(propPanel, flags)
47 {
48 m_propertyInfo = info;
49 }
50 void OnPropertyChanged(wxProperty *property);
51 bool OnClose(void);
52
53 wxPropertyInfo* m_propertyInfo;
54
55 };
56
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
62 {
63 friend class wxDialogEditorPropertyListFrame;
64 protected:
65 static wxWindow *sm_propertyWindow;
66 wxPropertyInfo(void)
67 {
68 }
69 ~wxPropertyInfo(void)
70 {
71 }
72 public:
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 };
78
79 // For all windows
80 class wxWindowPropertyInfo: public wxPropertyInfo
81 {
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) { m_propertyWindow = win; }
90
91 inline void SetResource(wxItemResource *res) { m_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 // Set the window style
102 void SetWindowStyle(wxWindow* win, long style, bool set);
103
104 wxWindow* GetWindow() const { return m_propertyWindow; }
105 wxItemResource* GetResource() const { return m_propertyResource; }
106
107 protected:
108 wxWindow* m_propertyWindow;
109 wxItemResource* m_propertyResource;
110 };
111
112 // For panel items
113 class wxItemPropertyInfo: public wxWindowPropertyInfo
114 {
115 protected:
116 public:
117 wxItemPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
118 wxWindowPropertyInfo(win, res) {}
119 ~wxItemPropertyInfo(void) {}
120 wxProperty *GetProperty(wxString& name);
121 bool SetProperty(wxString& name, wxProperty *property);
122 void GetPropertyNames(wxStringList& names);
123 bool InstantiateResource(wxItemResource *resource);
124 };
125
126 // For buttons
127 class wxButtonPropertyInfo: public wxItemPropertyInfo
128 {
129 protected:
130 public:
131 wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
132 wxItemPropertyInfo(win, res) { }
133 ~wxButtonPropertyInfo(void) {}
134 wxProperty *GetProperty(wxString& name);
135 bool SetProperty(wxString& name, wxProperty *property);
136 void GetPropertyNames(wxStringList& names);
137 bool InstantiateResource(wxItemResource *resource);
138 };
139
140 // For bitmap buttons
141 class wxBitmapButtonPropertyInfo: public wxButtonPropertyInfo
142 {
143 protected:
144 public:
145 wxBitmapButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
146 wxButtonPropertyInfo(win, res) { }
147 ~wxBitmapButtonPropertyInfo(void) {}
148 wxProperty *GetProperty(wxString& name);
149 bool SetProperty(wxString& name, wxProperty *property);
150 void GetPropertyNames(wxStringList& names);
151 bool InstantiateResource(wxItemResource *resource);
152 };
153
154 // For static text controls
155 class wxStaticTextPropertyInfo: public wxItemPropertyInfo
156 {
157 protected:
158 public:
159 wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
160 wxItemPropertyInfo(win, res) { }
161 ~wxStaticTextPropertyInfo(void) {}
162 wxProperty *GetProperty(wxString& name);
163 bool SetProperty(wxString& name, wxProperty *property);
164 void GetPropertyNames(wxStringList& names);
165 bool InstantiateResource(wxItemResource *resource);
166 };
167
168 // For static bitmap controls
169 class wxStaticBitmapPropertyInfo: public wxItemPropertyInfo
170 {
171 protected:
172 public:
173 wxStaticBitmapPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
174 wxItemPropertyInfo(win, res) { }
175 ~wxStaticBitmapPropertyInfo(void) {}
176 wxProperty *GetProperty(wxString& name);
177 bool SetProperty(wxString& name, wxProperty *property);
178 void GetPropertyNames(wxStringList& names);
179 bool InstantiateResource(wxItemResource *resource);
180 };
181
182 // For text/multitext items
183 class wxTextPropertyInfo: public wxItemPropertyInfo
184 {
185 protected:
186 public:
187 wxTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
188 wxItemPropertyInfo(win, res) {}
189 ~wxTextPropertyInfo(void) {}
190 wxProperty *GetProperty(wxString& name);
191 bool SetProperty(wxString& name, wxProperty *property);
192 void GetPropertyNames(wxStringList& names);
193 bool InstantiateResource(wxItemResource *resource);
194 };
195
196 // For list boxes
197 class wxListBoxPropertyInfo: public wxItemPropertyInfo
198 {
199 protected:
200 public:
201 wxListBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
202 wxItemPropertyInfo(win, res) {}
203 ~wxListBoxPropertyInfo(void) {}
204 wxProperty *GetProperty(wxString& name);
205 bool SetProperty(wxString& name, wxProperty *property);
206 void GetPropertyNames(wxStringList& names);
207 bool InstantiateResource(wxItemResource *resource);
208 };
209
210 // For choice items
211 class wxChoicePropertyInfo: public wxItemPropertyInfo
212 {
213 protected:
214 public:
215 wxChoicePropertyInfo(wxWindow *win, wxItemResource *res = NULL):
216 wxItemPropertyInfo(win, res) {}
217 ~wxChoicePropertyInfo(void) {}
218 wxProperty *GetProperty(wxString& name);
219 bool SetProperty(wxString& name, wxProperty *property);
220 void GetPropertyNames(wxStringList& names);
221 bool InstantiateResource(wxItemResource *resource);
222 };
223
224 // For choice items
225 class wxComboBoxPropertyInfo: public wxChoicePropertyInfo
226 {
227 protected:
228 public:
229 wxComboBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
230 wxChoicePropertyInfo(win, res) {}
231 ~wxComboBoxPropertyInfo(void) {}
232 wxProperty *GetProperty(wxString& name);
233 bool SetProperty(wxString& name, wxProperty *property);
234 void GetPropertyNames(wxStringList& names);
235 bool InstantiateResource(wxItemResource *resource);
236 };
237
238 // For radiobox items
239 class wxRadioBoxPropertyInfo: public wxItemPropertyInfo
240 {
241 protected:
242 public:
243 wxRadioBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
244 wxItemPropertyInfo(win, res) {}
245 ~wxRadioBoxPropertyInfo(void) {}
246 wxProperty *GetProperty(wxString& name);
247 bool SetProperty(wxString& name, wxProperty *property);
248 void GetPropertyNames(wxStringList& names);
249 bool InstantiateResource(wxItemResource *resource);
250 };
251
252 // For groupbox items
253 class wxGroupBoxPropertyInfo: public wxItemPropertyInfo
254 {
255 protected:
256 public:
257 wxGroupBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
258 wxItemPropertyInfo(win, res) {}
259 ~wxGroupBoxPropertyInfo(void) {}
260 wxProperty *GetProperty(wxString& name);
261 bool SetProperty(wxString& name, wxProperty *property);
262 void GetPropertyNames(wxStringList& names);
263 bool InstantiateResource(wxItemResource *resource);
264 };
265
266 // For checkbox items
267 class wxCheckBoxPropertyInfo: public wxItemPropertyInfo
268 {
269 protected:
270 public:
271 wxCheckBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
272 wxItemPropertyInfo(win, res) {}
273 ~wxCheckBoxPropertyInfo(void) {}
274 wxProperty *GetProperty(wxString& name);
275 bool SetProperty(wxString& name, wxProperty *property);
276 void GetPropertyNames(wxStringList& names);
277 bool InstantiateResource(wxItemResource *resource);
278 };
279
280 // For radiobutton items
281 class wxRadioButtonPropertyInfo: public wxItemPropertyInfo
282 {
283 protected:
284 public:
285 wxRadioButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
286 wxItemPropertyInfo(win, res) {}
287 ~wxRadioButtonPropertyInfo(void) {}
288 wxProperty *GetProperty(wxString& name);
289 bool SetProperty(wxString& name, wxProperty *property);
290 void GetPropertyNames(wxStringList& names);
291 bool InstantiateResource(wxItemResource *resource);
292 };
293
294 // For gauge items
295 class wxGaugePropertyInfo: public wxItemPropertyInfo
296 {
297 protected:
298 public:
299 wxGaugePropertyInfo(wxWindow *win, wxItemResource *res = NULL):
300 wxItemPropertyInfo(win, res) {}
301 ~wxGaugePropertyInfo(void) {}
302 wxProperty *GetProperty(wxString& name);
303 bool SetProperty(wxString& name, wxProperty *property);
304 void GetPropertyNames(wxStringList& names);
305 bool InstantiateResource(wxItemResource *resource);
306 };
307
308 // For scrollbar items
309 class wxScrollBarPropertyInfo: public wxItemPropertyInfo
310 {
311 protected:
312 public:
313 wxScrollBarPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
314 wxItemPropertyInfo(win, res) {}
315 ~wxScrollBarPropertyInfo(void) {}
316 wxProperty *GetProperty(wxString& name);
317 bool SetProperty(wxString& name, wxProperty *property);
318 void GetPropertyNames(wxStringList& names);
319 bool InstantiateResource(wxItemResource *resource);
320 };
321
322 // For slider items
323 class wxSliderPropertyInfo: public wxItemPropertyInfo
324 {
325 protected:
326 public:
327 wxSliderPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
328 wxItemPropertyInfo(win, res) {}
329 ~wxSliderPropertyInfo(void) {}
330 wxProperty *GetProperty(wxString& name);
331 bool SetProperty(wxString& name, wxProperty *property);
332 void GetPropertyNames(wxStringList& names);
333 bool InstantiateResource(wxItemResource *resource);
334 };
335
336 // For panels
337 class wxPanelPropertyInfo: public wxWindowPropertyInfo
338 {
339 protected:
340 public:
341 wxPanelPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
342 wxWindowPropertyInfo(win, res) {}
343 ~wxPanelPropertyInfo(void) {}
344 wxProperty *GetProperty(wxString& name);
345 bool SetProperty(wxString& name, wxProperty *property);
346 void GetPropertyNames(wxStringList& names);
347 bool InstantiateResource(wxItemResource *resource);
348
349 // Convert this dialog, and its children, to or from dialog units
350 void ConvertDialogUnits(bool toDialogUnits);
351 };
352
353 int wxStringToFontWeight(wxString& val);
354 int wxStringToFontStyle(wxString& val);
355 int wxStringToFontFamily(wxString& val);
356
357 /*
358 * A validator to allow editing symbol/id pairs
359 */
360
361 class wxResourceSymbolValidator: public wxPropertyListValidator
362 {
363 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator)
364 protected:
365 public:
366 wxResourceSymbolValidator(long flags = 0);
367
368 ~wxResourceSymbolValidator(void);
369
370 // Called when TICK is pressed or focus is lost.
371 // Return FALSE if value didn't check out; signal to restore old value.
372 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
373
374 // Called when TICK is pressed or focus is lost or view wants to update
375 // the property list.
376 // Does the transferance from the property editing area to the property itself
377 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
378 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
379
380 bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
381
382 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
383
384 // Called when the edit (...) button is pressed.
385 void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
386 };
387
388 /*
389 * A dialog for editing symbol/id pairs
390 */
391
392 class wxResourceSymbolDialog: public wxDialog
393 {
394 public:
395 wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
396 const wxPoint& pos = wxDefaultPosition,
397 const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL);
398
399 void Init();
400
401 inline void SetSymbol(const wxString& symbol) { m_symbolName = symbol; }
402 inline void SetId(long id) { m_symbolId = id; }
403
404 inline wxString GetSymbol() const { return m_symbolName; }
405 inline long GetId() const { return m_symbolId; }
406
407 bool CheckValues();
408 void OnOK(wxCommandEvent& event);
409 void OnComboBoxSelect(wxCommandEvent& event);
410 void OnSymbolNameUpdate(wxCommandEvent& event);
411
412 protected:
413 wxString m_symbolName;
414 long m_symbolId;
415 wxComboBox* m_nameCtrl;
416 wxTextCtrl* m_idCtrl;
417
418 DECLARE_EVENT_TABLE()
419 };
420
421 #define ID_SYMBOLNAME_COMBOBOX 100
422 #define ID_SYMBOLID_TEXTCTRL 101
423
424 #endif
425 // _WINPROP_H_