1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Property list classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 (1) Optional popup-help for each item, and an optional Help button
19 (2) Align Ok, Cancel, Help buttons properly.
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.
25 (4) Deriveable types for wxPropertyValue => may need to reorganise
26 wxPropertyValue to use inheritance rather than present all-types-in-one
29 (5) Optional popup panel for value list, perhaps.
31 (6) Floating point checking routine still crashes with Floating
32 point error for zany input.
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?
39 (8) More example validators, e.g. colour selector.
42 #ifndef _WX_PROPLIST_H_
43 #define _WX_PROPLIST_H_
45 #include "wx/deprecated/setup.h"
49 #include "wx/deprecated/prop.h"
52 #define wxPROP_BUTTON_CLOSE 1
53 #define wxPROP_BUTTON_OK 2
54 #define wxPROP_BUTTON_CANCEL 4
55 #define wxPROP_BUTTON_CHECK_CROSS 8
56 #define wxPROP_BUTTON_HELP 16
57 #define wxPROP_DYNAMIC_VALUE_FIELD 32
58 #define wxPROP_PULLDOWN 64
59 #define wxPROP_SHOWVALUES 128
61 // Show OK/Cancel buttons on X-based systems where window management is
63 #if defined(__WXMOTIF__) || defined(__WXGTK__)
64 #define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN
66 #define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN | wxPROP_SHOWVALUES
69 #define wxID_PROP_CROSS 3000
70 #define wxID_PROP_CHECK 3001
71 #define wxID_PROP_EDIT 3002
72 #define wxID_PROP_TEXT 3003
73 #define wxID_PROP_SELECT 3004
74 #define wxID_PROP_VALUE_SELECT 3005
76 // Mediates between a physical panel and the property sheet
77 class WXDLLIMPEXP_DEPRECATED wxPropertyListView
: public wxPropertyView
80 wxPropertyListView(wxPanel
*propPanel
= NULL
, long flags
= wxPROP_BUTTON_DEFAULT
);
81 ~wxPropertyListView(void);
83 // Associates and shows the view
84 virtual void ShowView(wxPropertySheet
*propertySheet
, wxPanel
*panel
);
86 // Update this view of the viewed object, called e.g. by
88 virtual bool OnUpdateView(void);
90 wxString
MakeNameValueString(wxString name
, wxString value
);
92 // Update a single line in the list of properties
93 virtual bool UpdatePropertyDisplayInList(wxProperty
*property
);
95 // Update the whole list
96 virtual bool UpdatePropertyList(bool clearEditArea
= true);
98 // Find the wxListBox index corresponding to this property
99 virtual int FindListIndexForProperty(wxProperty
*property
);
101 // Select and show string representation in editor the given
102 // property. NULL resets to show no property.
103 virtual bool ShowProperty(wxProperty
*property
, bool select
= true);
104 virtual bool EditProperty(wxProperty
*property
);
106 // Update the display from the property
107 virtual bool DisplayProperty(wxProperty
*property
);
108 // Update the property from the display
109 virtual bool RetrieveProperty(wxProperty
*property
);
111 // Find appropriate validator and load property into value controls
112 virtual bool BeginShowingProperty(wxProperty
*property
);
113 // Find appropriate validator and unload property from value controls
114 virtual bool EndShowingProperty(wxProperty
*property
);
116 // Begin detailed editing (e.g. using value listbox)
117 virtual void BeginDetailedEditing(void);
119 // End detailed editing (e.g. using value listbox)
120 virtual void EndDetailedEditing(void);
122 // Called by the property listbox
123 void OnPropertySelect(wxCommandEvent
& event
);
125 // Called by the value listbox
126 void OnValueListSelect(wxCommandEvent
& event
);
128 virtual bool CreateControls(void);
129 virtual void ShowTextControl(bool show
);
130 virtual void ShowListBoxControl(bool show
);
131 virtual void EnableCheck(bool show
);
132 virtual void EnableCross(bool show
);
134 void OnOk(wxCommandEvent
& event
);
135 void OnCancel(wxCommandEvent
& event
);
136 void OnHelp(wxCommandEvent
& event
);
137 void OnPropertyDoubleClick(wxCommandEvent
& event
);
138 // virtual void OnDoubleClick(void);
140 void OnCheck(wxCommandEvent
& event
);
141 void OnCross(wxCommandEvent
& event
);
142 void OnEdit(wxCommandEvent
& event
);
143 void OnText(wxCommandEvent
& event
);
145 inline virtual wxListBox
*GetPropertyScrollingList() const { return m_propertyScrollingList
; }
146 inline virtual wxListBox
*GetValueList() const { return m_valueList
; }
147 inline virtual wxTextCtrl
*GetValueText() const { return m_valueText
; }
148 inline virtual wxButton
*GetConfirmButton() const { return m_confirmButton
; }
149 inline virtual wxButton
*GetCancelButton() const { return m_cancelButton
; }
150 inline virtual wxButton
*GetEditButton() const { return m_editButton
; }
151 inline virtual bool GetDetailedEditing(void) const { return m_detailedEditing
; }
153 inline virtual void AssociatePanel(wxPanel
*win
) { m_propertyWindow
= win
; }
154 inline virtual wxPanel
*GetPanel(void) const { return m_propertyWindow
; }
156 inline virtual void SetManagedWindow(wxWindow
*win
) { m_managedWindow
= win
; }
157 inline virtual wxWindow
*GetManagedWindow(void) const { return m_managedWindow
; }
159 inline virtual wxButton
*GetWindowCloseButton() const { return m_windowCloseButton
; }
160 inline virtual wxButton
*GetWindowCancelButton() const { return m_windowCancelButton
; }
161 inline virtual wxButton
*GetHelpButton() const { return m_windowHelpButton
; }
166 static bool sm_dialogCancelled
;
169 wxListBox
* m_propertyScrollingList
;
170 wxListBox
* m_valueList
; // Should really be a combobox, but we don't have one.
171 wxTextCtrl
* m_valueText
;
172 wxButton
* m_confirmButton
; // A tick, as in VB
173 wxButton
* m_cancelButton
; // A cross, as in VB
174 wxButton
* m_editButton
; // Invokes the custom validator, if any
175 wxSizer
* m_middleSizer
;
177 bool m_detailedEditing
; // E.g. using listbox for choices
179 wxPanel
* m_propertyWindow
; // Panel that the controls will appear on
180 wxWindow
* m_managedWindow
; // Frame or dialog
182 wxButton
* m_windowCloseButton
; // Or OK
183 wxButton
* m_windowCancelButton
;
184 wxButton
* m_windowHelpButton
;
187 DECLARE_DYNAMIC_CLASS(wxPropertyListView
)
188 DECLARE_EVENT_TABLE()
190 virtual void ShowView(wxPropertySheet
*propertySheet
, wxWindow
*window
)
191 { wxPropertyView::ShowView(propertySheet
, window
); };
194 class WXDLLIMPEXP_DEPRECATED wxPropertyTextEdit
: public wxTextCtrl
197 wxPropertyTextEdit(wxPropertyListView
*v
= NULL
,
198 wxWindow
*parent
= NULL
,
199 const wxWindowID id
= wxID_ANY
,
200 const wxString
& value
= wxEmptyString
,
201 const wxPoint
& pos
= wxDefaultPosition
,
202 const wxSize
& size
= wxDefaultSize
,
204 const wxString
& name
= wxT("text"));
209 wxPropertyListView
* m_view
;
212 DECLARE_CLASS(wxPropertyTextEdit
)
215 #define wxPROP_ALLOW_TEXT_EDITING 1
218 * The type of validator used for property lists (Visual Basic style)
221 class WXDLLIMPEXP_DEPRECATED wxPropertyListValidator
: public wxPropertyValidator
224 wxPropertyListValidator(long flags
= wxPROP_ALLOW_TEXT_EDITING
): wxPropertyValidator(flags
) { }
225 ~wxPropertyListValidator() {}
227 // Called when the property is selected or deselected: typically displays the value
228 // in the edit control (having chosen a suitable control to display: (non)editable text or listbox)
229 virtual bool OnSelect(bool select
, wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
231 // Called when the property is double clicked. Extra functionality can be provided, such as
232 // cycling through possible values.
233 inline virtual bool OnDoubleClick(
234 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
237 // Called when the value listbox is selected. Default behaviour is to copy
238 // string to text control, and retrieve the value into the property.
239 virtual bool OnValueListSelect(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
241 // Called when the property value is edited using standard text control
242 inline virtual bool OnPrepareControls(
243 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
246 virtual bool OnClearControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
248 // Called when the property is edited in detail
249 inline virtual bool OnPrepareDetailControls(
250 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
253 // Called if focus lost, IF we're in a modeless property editing situation.
254 inline virtual bool OnClearDetailControls(
255 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
258 // Called when the edit (...) button is pressed. The default implementation
259 // calls view->BeginDetailedEditing; the filename validator (for example) overrides
260 // this function to show the file selector.
261 virtual void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
263 // Called when TICK is pressed or focus is lost.
264 // Return false if value didn't check out; signal to restore old value.
265 inline virtual bool OnCheckValue(
266 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
269 // Called when TICK is pressed or focus is lost or view wants to update
270 // the property list.
271 // Does the transferance from the property editing area to the property itself
272 virtual bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
274 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
277 DECLARE_DYNAMIC_CLASS(wxPropertyListValidator
)
281 * A default dialog box class to use.
284 class WXDLLIMPEXP_DEPRECATED wxPropertyListDialog
: public wxDialog
287 wxPropertyListDialog(wxPropertyListView
*v
= NULL
,
288 wxWindow
*parent
= NULL
,
289 const wxString
& title
= wxEmptyString
,
290 const wxPoint
& pos
= wxDefaultPosition
,
291 const wxSize
& size
= wxDefaultSize
,
292 long style
= wxDEFAULT_DIALOG_STYLE
,
293 const wxString
& name
= wxT("dialogBox"));
295 void OnCloseWindow(wxCloseEvent
& event
);
296 void OnDefaultAction(wxControl
*item
);
297 void OnCancel(wxCommandEvent
& event
);
299 // Extend event processing to search the view's event table
300 virtual bool ProcessEvent(wxEvent
& event
);
303 wxPropertyListView
* m_view
;
306 DECLARE_CLASS(wxPropertyListDialog
)
307 DECLARE_EVENT_TABLE()
311 * A default panel class to use.
314 class WXDLLIMPEXP_DEPRECATED wxPropertyListPanel
: public wxPanel
317 wxPropertyListPanel(wxPropertyListView
*v
= NULL
,
318 wxWindow
*parent
= NULL
,
319 const wxPoint
& pos
= wxDefaultPosition
,
320 const wxSize
& size
= wxDefaultSize
,
322 const wxString
& name
= wxT("panel"))
323 : wxPanel(parent
, wxID_ANY
, pos
, size
, style
, name
)
327 ~wxPropertyListPanel();
328 void OnDefaultAction(wxControl
*item
);
330 inline void SetView(wxPropertyListView
* v
) { m_view
= v
; }
331 inline wxPropertyListView
* GetView() const { return m_view
; }
333 // Extend event processing to search the view's event table
334 virtual bool ProcessEvent(wxEvent
& event
);
337 void OnSize(wxSizeEvent
& event
);
340 wxPropertyListView
* m_view
;
343 DECLARE_EVENT_TABLE()
344 DECLARE_CLASS(wxPropertyListPanel
)
348 * A default frame class to use.
351 class WXDLLIMPEXP_DEPRECATED wxPropertyListFrame
: public wxFrame
354 wxPropertyListFrame(wxPropertyListView
*v
= NULL
,
355 wxFrame
*parent
= NULL
,
356 const wxString
& title
= wxEmptyString
,
357 const wxPoint
& pos
= wxDefaultPosition
,
358 const wxSize
& size
= wxDefaultSize
,
359 long style
= wxDEFAULT_FRAME_STYLE
,
360 const wxString
& name
= _T("frame"))
361 : wxFrame(parent
, wxID_ANY
, title
, pos
, size
, style
, name
)
364 m_propertyPanel
= NULL
;
366 void OnCloseWindow(wxCloseEvent
& event
);
368 // Must call this to create panel and associate view
369 virtual bool Initialize(void);
370 virtual wxPropertyListPanel
*OnCreatePanel(wxFrame
*parent
, wxPropertyListView
*v
);
371 inline virtual wxPropertyListPanel
*GetPropertyPanel(void) const { return m_propertyPanel
; }
372 inline wxPropertyListView
* GetView() const { return m_view
; }
375 wxPropertyListView
* m_view
;
376 wxPropertyListPanel
* m_propertyPanel
;
379 DECLARE_EVENT_TABLE()
380 DECLARE_CLASS(wxPropertyListFrame
)
384 * Some default validators
387 class WXDLLIMPEXP_DEPRECATED wxRealListValidator
: public wxPropertyListValidator
390 // 0.0, 0.0 means no range
391 wxRealListValidator(float min
= 0.0, float max
= 0.0, long flags
= wxPROP_ALLOW_TEXT_EDITING
):wxPropertyListValidator(flags
)
392 { m_realMin
= min
; m_realMax
= max
; }
393 ~wxRealListValidator() {}
395 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
397 // Called when TICK is pressed or focus is lost.
398 // Return false if value didn't check out; signal to restore old value.
399 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
401 // Called when TICK is pressed or focus is lost or view wants to update
402 // the property list.
403 // Does the transfer from the property editing area to the property itself
404 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
411 DECLARE_DYNAMIC_CLASS(wxRealListValidator
)
414 class WXDLLIMPEXP_DEPRECATED wxIntegerListValidator
: public wxPropertyListValidator
417 // 0, 0 means no range
418 wxIntegerListValidator(long min
= 0, long max
= 0, long flags
= wxPROP_ALLOW_TEXT_EDITING
):wxPropertyListValidator(flags
)
420 m_integerMin
= min
; m_integerMax
= max
;
422 ~wxIntegerListValidator() {}
424 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
426 // Called when TICK is pressed or focus is lost.
427 // Return false if value didn't check out; signal to restore old value.
428 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
430 // Called when TICK is pressed or focus is lost or view wants to update
431 // the property list.
432 // Does the transfer from the property editing area to the property itself
433 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
440 DECLARE_DYNAMIC_CLASS(wxIntegerListValidator
)
443 class WXDLLIMPEXP_DEPRECATED wxBoolListValidator
: public wxPropertyListValidator
446 wxBoolListValidator(long flags
= 0):wxPropertyListValidator(flags
) {}
447 ~wxBoolListValidator() {}
449 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
450 bool OnPrepareDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
451 bool OnClearDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
453 // Called when TICK is pressed or focus is lost.
454 // Return false if value didn't check out; signal to restore old value.
455 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
457 // Called when TICK is pressed or focus is lost or view wants to update
458 // the property list.
459 // Does the transfer from the property editing area to the property itself
460 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
461 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
463 // Called when the property is double clicked. Extra functionality can be provided,
464 // cycling through possible values.
465 virtual bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
468 DECLARE_DYNAMIC_CLASS(wxBoolListValidator
)
471 class WXDLLIMPEXP_DEPRECATED wxStringListValidator
: public wxPropertyListValidator
474 wxStringListValidator(wxStringList
*list
= NULL
, long flags
= 0);
476 ~wxStringListValidator()
482 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
483 bool OnPrepareDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
484 bool OnClearDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
486 // Called when TICK is pressed or focus is lost.
487 // Return false if value didn't check out; signal to restore old value.
488 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
490 // Called when TICK is pressed or focus is lost or view wants to update
491 // the property list.
492 // Does the transfer from the property editing area to the property itself
493 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
494 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
496 // Called when the property is double clicked. Extra functionality can be provided,
497 // cycling through possible values.
498 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
501 wxStringList
* m_strings
;
504 DECLARE_DYNAMIC_CLASS(wxStringListValidator
)
507 class WXDLLIMPEXP_DEPRECATED wxFilenameListValidator
: public wxPropertyListValidator
510 wxFilenameListValidator(wxString message
= wxT("Select a file"), wxString wildcard
= wxALL_FILES_PATTERN
, long flags
= 0);
511 ~wxFilenameListValidator();
513 // Called when TICK is pressed or focus is lost.
514 // Return false if value didn't check out; signal to restore old value.
515 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
517 // Called when TICK is pressed or focus is lost or view wants to update
518 // the property list.
519 // Does the transferance from the property editing area to the property itself
520 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
521 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
523 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
525 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
527 // Called when the edit (...) button is pressed.
528 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
531 wxString m_filenameWildCard
;
532 wxString m_filenameMessage
;
535 DECLARE_DYNAMIC_CLASS(wxFilenameListValidator
)
538 class WXDLLIMPEXP_DEPRECATED wxColourListValidator
: public wxPropertyListValidator
541 wxColourListValidator(long flags
= 0);
542 ~wxColourListValidator();
544 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
545 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
546 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
548 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
550 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
552 // Called when the edit (...) button is pressed.
553 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
556 DECLARE_DYNAMIC_CLASS(wxColourListValidator
)
559 class WXDLLIMPEXP_DEPRECATED wxListOfStringsListValidator
: public wxPropertyListValidator
562 wxListOfStringsListValidator(long flags
= 0);
563 ~wxListOfStringsListValidator() {}
565 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
567 // Called when TICK is pressed or focus is lost.
568 // Return false if value didn't check out; signal to restore old value.
569 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
571 // Called when TICK is pressed or focus is lost or view wants to update
572 // the property list.
573 // Does the transfer from the property editing area to the property itself
574 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
575 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
577 // Called when the property is double clicked.
578 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
580 bool EditStringList(wxWindow
*parent
, wxStringList
*stringList
, const wxChar
*title
= wxT("String List Editor"));
582 // Called when the edit (...) button is pressed.
583 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
586 DECLARE_DYNAMIC_CLASS(wxListOfStringsListValidator
)