]> git.saurik.com Git - wxWidgets.git/blame - utils/dialoged/src/winprop.h
new 'dynamic' SetColDefs fix
[wxWidgets.git] / utils / dialoged / src / winprop.h
CommitLineData
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
21class wxPropertyInfo;
22
bbcdf8bc 23class wxDialogEditorPropertyListFrame: public wxPropertyListFrame
ae8351fc
JS
24{
25 friend class wxPropertyInfo;
26public:
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 31
8caa4ed1
JS
32 wxPropertyInfo* GetInfo() const { return m_propInfo; }
33
ae8351fc
JS
34private:
35 wxPropertySheet* m_propSheet;
36 wxPropertyValidatorRegistry m_registry;
37 wxPropertyInfo* m_propInfo;
38};
39
457814b5
JS
40// A kind of property list view that intercepts OnPropertyChanged
41// feedback.
42class wxResourcePropertyListView: public wxPropertyListView
43{
44 public:
457814b5
JS
45 wxResourcePropertyListView(wxPropertyInfo *info, wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT):
46 wxPropertyListView(propPanel, flags)
47 {
fd71308f 48 m_propertyInfo = info;
457814b5
JS
49 }
50 void OnPropertyChanged(wxProperty *property);
51 bool OnClose(void);
fd71308f
JS
52
53 wxPropertyInfo* m_propertyInfo;
54
457814b5
JS
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.
61class wxPropertyInfo: public wxObject
62{
bbcdf8bc 63 friend class wxDialogEditorPropertyListFrame;
457814b5
JS
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;
ae8351fc 76 virtual bool Edit(wxWindow *parent, const wxString& title);
457814b5
JS
77};
78
79// For all windows
80class wxWindowPropertyInfo: public wxPropertyInfo
81{
457814b5
JS
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
fd71308f 89 inline void SetPropertyWindow(wxWindow *win) { m_propertyWindow = win; }
457814b5 90
fd71308f 91 inline void SetResource(wxItemResource *res) { m_propertyResource = res; }
457814b5
JS
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);
fd71308f 103
8caa4ed1
JS
104 wxWindow* GetWindow() const { return m_propertyWindow; }
105 wxItemResource* GetResource() const { return m_propertyResource; }
106
fd71308f
JS
107 protected:
108 wxWindow* m_propertyWindow;
109 wxItemResource* m_propertyResource;
457814b5
JS
110};
111
112// For panel items
113class 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
127class wxButtonPropertyInfo: public wxItemPropertyInfo
128{
129 protected:
130 public:
ae8351fc
JS
131 wxButtonPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
132 wxItemPropertyInfo(win, res) { }
457814b5
JS
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);
ae8351fc 138};
457814b5 139
ae8351fc
JS
140// For bitmap buttons
141class 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);
457814b5
JS
152};
153
ae8351fc 154// For static text controls
457814b5
JS
155class wxStaticTextPropertyInfo: public wxItemPropertyInfo
156{
157 protected:
158 public:
ae8351fc
JS
159 wxStaticTextPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
160 wxItemPropertyInfo(win, res) { }
457814b5
JS
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);
ae8351fc 166};
457814b5 167
ae8351fc
JS
168// For static bitmap controls
169class 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);
457814b5
JS
180};
181
182// For text/multitext items
183class 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
197class 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
211class wxChoicePropertyInfo: public wxItemPropertyInfo
212{
213 protected:
214 public:
215 wxChoicePropertyInfo(wxWindow *win, wxItemResource *res = NULL):
216 wxItemPropertyInfo(win, res) {}
217 ~wxChoicePropertyInfo(void) {}
9c331ded
JS
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
225class wxComboBoxPropertyInfo: public wxChoicePropertyInfo
226{
227 protected:
228 public:
229 wxComboBoxPropertyInfo(wxWindow *win, wxItemResource *res = NULL):
230 wxChoicePropertyInfo(win, res) {}
231 ~wxComboBoxPropertyInfo(void) {}
457814b5
JS
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
239class 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
253class 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
267class 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
03f68f12
JS
280// For radiobutton items
281class 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
457814b5
JS
294// For gauge items
295class 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
309class 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
323class 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
337class 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);
fd71308f
JS
348
349 // Convert this dialog, and its children, to or from dialog units
350 void ConvertDialogUnits(bool toDialogUnits);
457814b5
JS
351};
352
457814b5
JS
353int wxStringToFontWeight(wxString& val);
354int wxStringToFontStyle(wxString& val);
355int wxStringToFontFamily(wxString& val);
356
03f68f12
JS
357/*
358 * A validator to allow editing symbol/id pairs
359 */
360
361class 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);
457814b5 379
03f68f12
JS
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
392class wxResourceSymbolDialog: public wxDialog
393{
394public:
395 wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
396 const wxPoint& pos = wxDefaultPosition,
5de76427 397 const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL);
03f68f12
JS
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);
5de76427
JS
409 void OnComboBoxSelect(wxCommandEvent& event);
410 void OnSymbolNameUpdate(wxCommandEvent& event);
03f68f12
JS
411
412protected:
413 wxString m_symbolName;
414 long m_symbolId;
415 wxComboBox* m_nameCtrl;
416 wxTextCtrl* m_idCtrl;
417
418DECLARE_EVENT_TABLE()
419};
420
421#define ID_SYMBOLNAME_COMBOBOX 100
422#define ID_SYMBOLID_TEXTCTRL 101
423
424#endif
425 // _WINPROP_H_