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