]> git.saurik.com Git - wxWidgets.git/blame - utils/dialoged/src/winprop.h
reverted Julian's unintentional breakage of wxChoice
[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();
f6bcfd97 31
8caa4ed1 32 wxPropertyInfo* GetInfo() const { return m_propInfo; }
f6bcfd97 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{
f6bcfd97
BP
44public:
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
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;
f6bcfd97
BP
64protected:
65 static wxWindow *sm_propertyWindow;
66 wxPropertyInfo(void)
67 {
68 }
69 ~wxPropertyInfo(void)
70 {
71 }
72public:
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.
457814b5
JS
78};
79
80// For all windows
81class wxWindowPropertyInfo: public wxPropertyInfo
82{
f6bcfd97
BP
83public:
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
108protected:
109 wxWindow* m_propertyWindow;
110 wxItemResource* m_propertyResource;
457814b5
JS
111};
112
113// For panel items
114class wxItemPropertyInfo: public wxWindowPropertyInfo
115{
f6bcfd97
BP
116protected:
117public:
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);
457814b5
JS
125};
126
127// For buttons
128class wxButtonPropertyInfo: public wxItemPropertyInfo
129{
f6bcfd97
BP
130protected:
131public:
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);
ae8351fc 139};
457814b5 140
ae8351fc
JS
141// For bitmap buttons
142class wxBitmapButtonPropertyInfo: public wxButtonPropertyInfo
143{
f6bcfd97
BP
144protected:
145public:
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);
457814b5
JS
153};
154
ae8351fc 155// For static text controls
457814b5
JS
156class wxStaticTextPropertyInfo: public wxItemPropertyInfo
157{
f6bcfd97
BP
158protected:
159public:
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);
ae8351fc 167};
457814b5 168
ae8351fc
JS
169// For static bitmap controls
170class wxStaticBitmapPropertyInfo: public wxItemPropertyInfo
171{
f6bcfd97
BP
172protected:
173public:
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);
457814b5
JS
181};
182
183// For text/multitext items
184class wxTextPropertyInfo: public wxItemPropertyInfo
185{
f6bcfd97
BP
186protected:
187public:
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);
457814b5
JS
195};
196
197// For list boxes
198class wxListBoxPropertyInfo: public wxItemPropertyInfo
199{
f6bcfd97
BP
200protected:
201public:
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);
457814b5
JS
209};
210
211// For choice items
212class wxChoicePropertyInfo: public wxItemPropertyInfo
213{
f6bcfd97
BP
214protected:
215public:
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);
9c331ded
JS
223};
224
225// For choice items
226class wxComboBoxPropertyInfo: public wxChoicePropertyInfo
227{
f6bcfd97
BP
228protected:
229public:
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);
457814b5
JS
237};
238
239// For radiobox items
240class wxRadioBoxPropertyInfo: public wxItemPropertyInfo
241{
f6bcfd97
BP
242protected:
243public:
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);
457814b5
JS
251};
252
253// For groupbox items
254class wxGroupBoxPropertyInfo: public wxItemPropertyInfo
255{
f6bcfd97
BP
256protected:
257public:
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);
457814b5
JS
265};
266
267// For checkbox items
268class wxCheckBoxPropertyInfo: public wxItemPropertyInfo
269{
f6bcfd97
BP
270protected:
271public:
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);
457814b5
JS
279};
280
03f68f12
JS
281// For radiobutton items
282class wxRadioButtonPropertyInfo: public wxItemPropertyInfo
283{
f6bcfd97
BP
284protected:
285public:
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);
03f68f12
JS
293};
294
457814b5
JS
295// For gauge items
296class wxGaugePropertyInfo: public wxItemPropertyInfo
297{
f6bcfd97
BP
298protected:
299public:
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);
457814b5
JS
307};
308
309// For scrollbar items
310class wxScrollBarPropertyInfo: public wxItemPropertyInfo
311{
f6bcfd97
BP
312protected:
313public:
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);
457814b5
JS
321};
322
323// For slider items
324class wxSliderPropertyInfo: public wxItemPropertyInfo
325{
f6bcfd97
BP
326protected:
327public:
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);
457814b5
JS
335};
336
337// For panels
338class wxPanelPropertyInfo: public wxWindowPropertyInfo
339{
f6bcfd97
BP
340protected:
341public:
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);
457814b5
JS
352};
353
457814b5
JS
354int wxStringToFontWeight(wxString& val);
355int wxStringToFontStyle(wxString& val);
356int wxStringToFontFamily(wxString& val);
357
03f68f12 358/*
f6bcfd97
BP
359* A validator to allow editing symbol/id pairs
360*/
03f68f12
JS
361
362class wxResourceSymbolValidator: public wxPropertyListValidator
363{
f6bcfd97
BP
364 DECLARE_DYNAMIC_CLASS(wxResourceSymbolValidator)
365protected:
366public:
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);
03f68f12
JS
387};
388
389/*
f6bcfd97
BP
390* A dialog for editing symbol/id pairs
391*/
03f68f12
JS
392
393class wxResourceSymbolDialog: public wxDialog
394{
395public:
396 wxResourceSymbolDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
397 const wxPoint& pos = wxDefaultPosition,
5de76427 398 const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL);
f6bcfd97 399
03f68f12 400 void Init();
f6bcfd97 401
03f68f12
JS
402 inline void SetSymbol(const wxString& symbol) { m_symbolName = symbol; }
403 inline void SetId(long id) { m_symbolId = id; }
f6bcfd97 404
03f68f12
JS
405 inline wxString GetSymbol() const { return m_symbolName; }
406 inline long GetId() const { return m_symbolId; }
f6bcfd97 407
03f68f12
JS
408 bool CheckValues();
409 void OnOK(wxCommandEvent& event);
5de76427
JS
410 void OnComboBoxSelect(wxCommandEvent& event);
411 void OnSymbolNameUpdate(wxCommandEvent& event);
f6bcfd97 412
03f68f12
JS
413protected:
414 wxString m_symbolName;
415 long m_symbolId;
416 wxComboBox* m_nameCtrl;
417 wxTextCtrl* m_idCtrl;
f6bcfd97
BP
418
419 DECLARE_EVENT_TABLE()
03f68f12
JS
420};
421
422#define ID_SYMBOLNAME_COMBOBOX 100
423#define ID_SYMBOLID_TEXTCTRL 101
424
425#endif
f6bcfd97 426// _WINPROP_H_