]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/proplist.h
added missing wxSTDs
[wxWidgets.git] / include / wx / proplist.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: proplist.h
3// Purpose: Property list classes
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12 /*
13
14 TO DO:
15
16 (1) Optional popup-help for each item, and an optional Help button
17 for dialog.
18
19 (2) Align Ok, Cancel, Help buttons properly.
20
21 (3) Consider retrieving the rectangle on the panel that can be
22 drawn into (where the value listbox is) and giving an example
23 of editing graphically. May be too fancy.
24
25 (4) Deriveable types for wxPropertyValue => may need to reorganise
26 wxPropertyValue to use inheritance rather than present all-types-in-one
27 scheme.
28
29 (5) Optional popup panel for value list, perhaps.
30
31 (6) Floating point checking routine still crashes with Floating
32 point error for zany input.
33
34 (7) Property sheet with choice (or listbox) to select alternative
35 sheets... multiple views per panel, only one active. For this
36 we really need a wxChoice that can be dynamically set: XView
37 may be a problem; Motif?
38
39 (8) More example validators, e.g. colour selector.
40 */
41
42#ifndef _WX_PROPLIST_H_
43#define _WX_PROPLIST_H_
44
45#ifdef __GNUG__
46#pragma interface "proplist.h"
47#endif
48
49#if wxUSE_PROPSHEET
50
51#include "wx/prop.h"
52
53#define wxPROP_BUTTON_CLOSE 1
54#define wxPROP_BUTTON_OK 2
55#define wxPROP_BUTTON_CANCEL 4
56#define wxPROP_BUTTON_CHECK_CROSS 8
57#define wxPROP_BUTTON_HELP 16
58#define wxPROP_DYNAMIC_VALUE_FIELD 32
59#define wxPROP_PULLDOWN 64
60#define wxPROP_SHOWVALUES 128
61
62// Show OK/Cancel buttons on X-based systems where window management is
63// more awkward
64#if defined(__WXMOTIF__) || defined(__WXGTK__)
65#define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN
66#else
67#define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN | wxPROP_SHOWVALUES
68#endif
69
70#define wxID_PROP_CROSS 3000
71#define wxID_PROP_CHECK 3001
72#define wxID_PROP_EDIT 3002
73#define wxID_PROP_TEXT 3003
74#define wxID_PROP_SELECT 3004
75#define wxID_PROP_VALUE_SELECT 3005
76
77// Mediates between a physical panel and the property sheet
78class WXDLLEXPORT wxPropertyListView: public wxPropertyView
79{
80 DECLARE_DYNAMIC_CLASS(wxPropertyListView)
81 public:
82 wxPropertyListView(wxPanel *propPanel = NULL, long flags = wxPROP_BUTTON_DEFAULT);
83 ~wxPropertyListView(void);
84
85 // Associates and shows the view
86 virtual void ShowView(wxPropertySheet *propertySheet, wxPanel *panel);
87
88 // Update this view of the viewed object, called e.g. by
89 // the object itself.
90 virtual bool OnUpdateView(void);
91
92 wxString MakeNameValueString(wxString name, wxString value);
93
94 // Update a single line in the list of properties
95 virtual bool UpdatePropertyDisplayInList(wxProperty *property);
96
97 // Update the whole list
98 virtual bool UpdatePropertyList(bool clearEditArea = TRUE);
99
100 // Find the wxListBox index corresponding to this property
101 virtual int FindListIndexForProperty(wxProperty *property);
102
103 // Select and show string representation in editor the given
104 // property. NULL resets to show no property.
105 virtual bool ShowProperty(wxProperty *property, bool select = TRUE);
106 virtual bool EditProperty(wxProperty *property);
107
108 // Update the display from the property
109 virtual bool DisplayProperty(wxProperty *property);
110 // Update the property from the display
111 virtual bool RetrieveProperty(wxProperty *property);
112
113 // Find appropriate validator and load property into value controls
114 virtual bool BeginShowingProperty(wxProperty *property);
115 // Find appropriate validator and unload property from value controls
116 virtual bool EndShowingProperty(wxProperty *property);
117
118 // Begin detailed editing (e.g. using value listbox)
119 virtual void BeginDetailedEditing(void);
120
121 // End detailed editing (e.g. using value listbox)
122 virtual void EndDetailedEditing(void);
123
124 // Called by the property listbox
125 void OnPropertySelect(wxCommandEvent& event);
126
127 // Called by the value listbox
128 void OnValueListSelect(wxCommandEvent& event);
129
130 virtual bool CreateControls(void);
131 virtual void ShowTextControl(bool show);
132 virtual void ShowListBoxControl(bool show);
133 virtual void EnableCheck(bool show);
134 virtual void EnableCross(bool show);
135
136 void OnOk(wxCommandEvent& event);
137 void OnCancel(wxCommandEvent& event);
138 void OnHelp(wxCommandEvent& event);
139 void OnPropertyDoubleClick(wxCommandEvent& event);
140// virtual void OnDoubleClick(void);
141
142 void OnCheck(wxCommandEvent& event);
143 void OnCross(wxCommandEvent& event);
144 void OnEdit(wxCommandEvent& event);
145 void OnText(wxCommandEvent& event);
146
147 inline virtual wxListBox *GetPropertyScrollingList() const { return m_propertyScrollingList; }
148 inline virtual wxListBox *GetValueList() const { return m_valueList; }
149 inline virtual wxTextCtrl *GetValueText() const { return m_valueText; }
150 inline virtual wxButton *GetConfirmButton() const { return m_confirmButton; }
151 inline virtual wxButton *GetCancelButton() const { return m_cancelButton; }
152 inline virtual wxButton *GetEditButton() const { return m_editButton; }
153 inline virtual bool GetDetailedEditing(void) const { return m_detailedEditing; }
154
155 inline virtual void AssociatePanel(wxPanel *win) { m_propertyWindow = win; }
156 inline virtual wxPanel *GetPanel(void) const { return m_propertyWindow; }
157
158 inline virtual void SetManagedWindow(wxWindow *win) { m_managedWindow = win; }
159 inline virtual wxWindow *GetManagedWindow(void) const { return m_managedWindow; }
160
161 inline virtual wxButton *GetWindowCloseButton() const { return m_windowCloseButton; }
162 inline virtual wxButton *GetWindowCancelButton() const { return m_windowCancelButton; }
163 inline virtual wxButton *GetHelpButton() const { return m_windowHelpButton; }
164
165 bool OnClose(void);
166
167public:
168 static bool sm_dialogCancelled;
169
170 protected:
171 wxListBox* m_propertyScrollingList;
172 wxListBox* m_valueList; // Should really be a combobox, but we don't have one.
173 wxTextCtrl* m_valueText;
174 wxButton* m_confirmButton; // A tick, as in VB
175 wxButton* m_cancelButton; // A cross, as in VB
176 wxButton* m_editButton; // Invokes the custom validator, if any
177 wxSizer* m_middleSizer;
178
179 bool m_detailedEditing; // E.g. using listbox for choices
180
181 wxPanel* m_propertyWindow; // Panel that the controls will appear on
182 wxWindow* m_managedWindow; // Frame or dialog
183
184 wxButton* m_windowCloseButton; // Or OK
185 wxButton* m_windowCancelButton;
186 wxButton* m_windowHelpButton;
187
188DECLARE_EVENT_TABLE()
189private:
190 virtual void ShowView(wxPropertySheet *propertySheet, wxWindow *window)
191 { wxPropertyView::ShowView(propertySheet, window); };
192};
193
194class WXDLLEXPORT wxPropertyTextEdit: public wxTextCtrl
195{
196public:
197 wxPropertyTextEdit(wxPropertyListView *v = NULL,
198 wxWindow *parent = NULL,
199 const wxWindowID id = -1,
200 const wxString& value = wxEmptyString,
201 const wxPoint& pos = wxDefaultPosition,
202 const wxSize& size = wxDefaultSize,
203 long style = 0,
204 const wxString& name = _T("text"));
205
206 void OnSetFocus();
207 void OnKillFocus();
208
209 wxPropertyListView* m_view;
210
211 DECLARE_CLASS(wxPropertyTextEdit)
212};
213
214#define wxPROP_ALLOW_TEXT_EDITING 1
215
216/*
217 * The type of validator used for property lists (Visual Basic style)
218 */
219
220class WXDLLEXPORT wxPropertyListValidator: public wxPropertyValidator
221{
222 DECLARE_DYNAMIC_CLASS(wxPropertyListValidator)
223 protected:
224 public:
225 wxPropertyListValidator(long flags = wxPROP_ALLOW_TEXT_EDITING): wxPropertyValidator(flags) { }
226 ~wxPropertyListValidator(void) {}
227
228 // Called when the property is selected or deselected: typically displays the value
229 // in the edit control (having chosen a suitable control to display: (non)editable text or listbox)
230 virtual bool OnSelect(bool select, wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
231
232 // Called when the property is double clicked. Extra functionality can be provided, such as
233 // cycling through possible values.
234 inline virtual bool OnDoubleClick(
235 wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) )
236 { return TRUE; }
237
238 // Called when the value listbox is selected. Default behaviour is to copy
239 // string to text control, and retrieve the value into the property.
240 virtual bool OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
241
242 // Called when the property value is edited using standard text control
243 inline virtual bool OnPrepareControls(
244 wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) )
245 { return TRUE; }
246
247 virtual bool OnClearControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
248
249 // Called when the property is edited in detail
250 inline virtual bool OnPrepareDetailControls(
251 wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) )
252 { return TRUE; }
253
254 // Called if focus lost, IF we're in a modeless property editing situation.
255 inline virtual bool OnClearDetailControls(
256 wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) )
257 { return TRUE; }
258
259 // Called when the edit (...) button is pressed. The default implementation
260 // calls view->BeginDetailedEditing; the filename validator (for example) overrides
261 // this function to show the file selector.
262 virtual void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
263
264 // Called when TICK is pressed or focus is lost.
265 // Return FALSE if value didn't check out; signal to restore old value.
266 inline virtual bool OnCheckValue(
267 wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) )
268 { return TRUE; }
269
270 // Called when TICK is pressed or focus is lost or view wants to update
271 // the property list.
272 // Does the transferance from the property editing area to the property itself
273 virtual bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
274
275 virtual bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
276};
277
278/*
279 * A default dialog box class to use.
280 */
281
282class WXDLLEXPORT wxPropertyListDialog: public wxDialog
283{
284public:
285 wxPropertyListDialog(wxPropertyListView *v = NULL,
286 wxWindow *parent = NULL,
287 const wxString& title = wxEmptyString,
288 const wxPoint& pos = wxDefaultPosition,
289 const wxSize& size = wxDefaultSize,
290 long style = wxDEFAULT_DIALOG_STYLE,
291 const wxString& name = _T("dialogBox"));
292
293 void OnCloseWindow(wxCloseEvent& event);
294 void OnDefaultAction(wxControl *item);
295 void OnCancel(wxCommandEvent& event);
296
297 // Extend event processing to search the view's event table
298 virtual bool ProcessEvent(wxEvent& event);
299
300private:
301 wxPropertyListView* m_view;
302
303 DECLARE_CLASS(wxPropertyListDialog)
304 DECLARE_EVENT_TABLE()
305};
306
307/*
308 * A default panel class to use.
309 */
310
311class WXDLLEXPORT wxPropertyListPanel: public wxPanel
312{
313public:
314 wxPropertyListPanel(wxPropertyListView *v = NULL,
315 wxWindow *parent = NULL,
316 const wxPoint& pos = wxDefaultPosition,
317 const wxSize& size = wxDefaultSize,
318 long style = 0,
319 const wxString& name = _T("panel"))
320 : wxPanel(parent, -1, pos, size, style, name)
321 {
322 m_view = v;
323 }
324 ~wxPropertyListPanel();
325 void OnDefaultAction(wxControl *item);
326
327 inline void SetView(wxPropertyListView* v) { m_view = v; }
328 inline wxPropertyListView* GetView() const { return m_view; }
329
330 // Extend event processing to search the view's event table
331 virtual bool ProcessEvent(wxEvent& event);
332
333 // Call Layout()
334 void OnSize(wxSizeEvent& event);
335
336private:
337 wxPropertyListView* m_view;
338
339 DECLARE_EVENT_TABLE()
340 DECLARE_CLASS(wxPropertyListPanel)
341};
342
343/*
344 * A default frame class to use.
345 */
346
347class WXDLLEXPORT wxPropertyListFrame: public wxFrame
348{
349public:
350 wxPropertyListFrame(wxPropertyListView *v = NULL,
351 wxFrame *parent = NULL,
352 const wxString& title = wxEmptyString,
353 const wxPoint& pos = wxDefaultPosition,
354 const wxSize& size = wxDefaultSize,
355 long style = wxDEFAULT_FRAME_STYLE,
356 const wxString& name = _T("frame"))
357 : wxFrame(parent, -1, title, pos, size, style, name)
358 {
359 m_view = v;
360 m_propertyPanel = NULL;
361 }
362 void OnCloseWindow(wxCloseEvent& event);
363
364 // Must call this to create panel and associate view
365 virtual bool Initialize(void);
366 virtual wxPropertyListPanel *OnCreatePanel(wxFrame *parent, wxPropertyListView *v);
367 inline virtual wxPropertyListPanel *GetPropertyPanel(void) const { return m_propertyPanel; }
368 inline wxPropertyListView* GetView() const { return m_view; }
369
370private:
371 wxPropertyListView* m_view;
372 wxPropertyListPanel* m_propertyPanel;
373
374 DECLARE_EVENT_TABLE()
375 DECLARE_CLASS(wxPropertyListFrame)
376};
377
378/*
379 * Some default validators
380 */
381
382class WXDLLEXPORT wxRealListValidator: public wxPropertyListValidator
383{
384 DECLARE_DYNAMIC_CLASS(wxRealListValidator)
385 public:
386 // 0.0, 0.0 means no range
387 wxRealListValidator(float min = 0.0, float max = 0.0, long flags = wxPROP_ALLOW_TEXT_EDITING):wxPropertyListValidator(flags)
388 {
389 m_realMin = min; m_realMax = max;
390 }
391 ~wxRealListValidator(void) {}
392
393 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
394
395 // Called when TICK is pressed or focus is lost.
396 // Return FALSE if value didn't check out; signal to restore old value.
397 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
398
399 // Called when TICK is pressed or focus is lost or view wants to update
400 // the property list.
401 // Does the transfer from the property editing area to the property itself
402 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
403
404 protected:
405 float m_realMin;
406 float m_realMax;
407};
408
409class WXDLLEXPORT wxIntegerListValidator: public wxPropertyListValidator
410{
411 DECLARE_DYNAMIC_CLASS(wxIntegerListValidator)
412 public:
413 // 0, 0 means no range
414 wxIntegerListValidator(long min = 0, long max = 0, long flags = wxPROP_ALLOW_TEXT_EDITING):wxPropertyListValidator(flags)
415 {
416 m_integerMin = min; m_integerMax = max;
417 }
418 ~wxIntegerListValidator(void) {}
419
420 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
421
422 // Called when TICK is pressed or focus is lost.
423 // Return FALSE if value didn't check out; signal to restore old value.
424 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
425
426 // Called when TICK is pressed or focus is lost or view wants to update
427 // the property list.
428 // Does the transfer from the property editing area to the property itself
429 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
430
431 protected:
432 long m_integerMin;
433 long m_integerMax;
434};
435
436class WXDLLEXPORT wxBoolListValidator: public wxPropertyListValidator
437{
438 DECLARE_DYNAMIC_CLASS(wxBoolListValidator)
439 protected:
440 public:
441 wxBoolListValidator(long flags = 0):wxPropertyListValidator(flags)
442 {
443 }
444 ~wxBoolListValidator(void) {}
445
446 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
447 bool OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
448 bool OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
449
450 // Called when TICK is pressed or focus is lost.
451 // Return FALSE if value didn't check out; signal to restore old value.
452 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
453
454 // Called when TICK is pressed or focus is lost or view wants to update
455 // the property list.
456 // Does the transfer from the property editing area to the property itself
457 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
458 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
459
460 // Called when the property is double clicked. Extra functionality can be provided,
461 // cycling through possible values.
462 virtual bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
463};
464
465class WXDLLEXPORT wxStringListValidator: public wxPropertyListValidator
466{
467 DECLARE_DYNAMIC_CLASS(wxStringListValidator)
468 public:
469 wxStringListValidator(wxStringList *list = NULL, long flags = 0);
470
471 ~wxStringListValidator(void)
472 {
473 if (m_strings)
474 delete m_strings;
475 }
476
477 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
478 bool OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
479 bool OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
480
481 // Called when TICK is pressed or focus is lost.
482 // Return FALSE if value didn't check out; signal to restore old value.
483 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
484
485 // Called when TICK is pressed or focus is lost or view wants to update
486 // the property list.
487 // Does the transfer from the property editing area to the property itself
488 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
489 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
490
491 // Called when the property is double clicked. Extra functionality can be provided,
492 // cycling through possible values.
493 bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
494
495 protected:
496 wxStringList* m_strings;
497};
498
499class WXDLLEXPORT wxFilenameListValidator: public wxPropertyListValidator
500{
501 DECLARE_DYNAMIC_CLASS(wxFilenameListValidator)
502 public:
503 wxFilenameListValidator(wxString message = "Select a file", wxString wildcard = wxALL_FILES_PATTERN, long flags = 0);
504
505 ~wxFilenameListValidator(void);
506
507 // Called when TICK is pressed or focus is lost.
508 // Return FALSE if value didn't check out; signal to restore old value.
509 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
510
511 // Called when TICK is pressed or focus is lost or view wants to update
512 // the property list.
513 // Does the transferance from the property editing area to the property itself
514 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
515 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
516
517 bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
518
519 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
520
521 // Called when the edit (...) button is pressed.
522 void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
523
524 protected:
525 wxString m_filenameWildCard;
526 wxString m_filenameMessage;
527
528};
529
530class WXDLLEXPORT wxColourListValidator: public wxPropertyListValidator
531{
532 DECLARE_DYNAMIC_CLASS(wxColourListValidator)
533 protected:
534 public:
535 wxColourListValidator(long flags = 0);
536
537 ~wxColourListValidator(void);
538
539 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
540 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
541 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
542
543 bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
544
545 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
546
547 // Called when the edit (...) button is pressed.
548 void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
549};
550
551class WXDLLEXPORT wxListOfStringsListValidator: public wxPropertyListValidator
552{
553 DECLARE_DYNAMIC_CLASS(wxListOfStringsListValidator)
554 protected:
555 public:
556 wxListOfStringsListValidator(long flags = 0);
557
558 ~wxListOfStringsListValidator(void)
559 {
560 }
561
562 bool OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
563
564 // Called when TICK is pressed or focus is lost.
565 // Return FALSE if value didn't check out; signal to restore old value.
566 bool OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
567
568 // Called when TICK is pressed or focus is lost or view wants to update
569 // the property list.
570 // Does the transfer from the property editing area to the property itself
571 bool OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
572 bool OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
573
574 // Called when the property is double clicked.
575 bool OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
576
577 bool EditStringList(wxWindow *parent, wxStringList *stringList, const wxChar *title = wxT("String List Editor"));
578
579 // Called when the edit (...) button is pressed.
580 void OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow);
581};
582
583#endif
584 // wxUSE_PROPSHEET
585
586#endif
587 // _WX_PROPLIST_H_