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 #if defined(__GNUG__) && !defined(__APPLE__)
46 #pragma interface "proplist.h"
49 #include "wx/deprecated/setup.h"
53 #include "wx/deprecated/prop.h"
56 #define wxPROP_BUTTON_CLOSE 1
57 #define wxPROP_BUTTON_OK 2
58 #define wxPROP_BUTTON_CANCEL 4
59 #define wxPROP_BUTTON_CHECK_CROSS 8
60 #define wxPROP_BUTTON_HELP 16
61 #define wxPROP_DYNAMIC_VALUE_FIELD 32
62 #define wxPROP_PULLDOWN 64
63 #define wxPROP_SHOWVALUES 128
65 // Show OK/Cancel buttons on X-based systems where window management is
67 #if defined(__WXMOTIF__) || defined(__WXGTK__)
68 #define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_OK | wxPROP_BUTTON_CANCEL | wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN
70 #define wxPROP_BUTTON_DEFAULT wxPROP_BUTTON_CHECK_CROSS | wxPROP_PULLDOWN | wxPROP_SHOWVALUES
73 #define wxID_PROP_CROSS 3000
74 #define wxID_PROP_CHECK 3001
75 #define wxID_PROP_EDIT 3002
76 #define wxID_PROP_TEXT 3003
77 #define wxID_PROP_SELECT 3004
78 #define wxID_PROP_VALUE_SELECT 3005
80 // Mediates between a physical panel and the property sheet
81 class WXDLLIMPEXP_DEPRECATED wxPropertyListView
: public wxPropertyView
84 wxPropertyListView(wxPanel
*propPanel
= NULL
, long flags
= wxPROP_BUTTON_DEFAULT
);
85 ~wxPropertyListView(void);
87 // Associates and shows the view
88 virtual void ShowView(wxPropertySheet
*propertySheet
, wxPanel
*panel
);
90 // Update this view of the viewed object, called e.g. by
92 virtual bool OnUpdateView(void);
94 wxString
MakeNameValueString(wxString name
, wxString value
);
96 // Update a single line in the list of properties
97 virtual bool UpdatePropertyDisplayInList(wxProperty
*property
);
99 // Update the whole list
100 virtual bool UpdatePropertyList(bool clearEditArea
= TRUE
);
102 // Find the wxListBox index corresponding to this property
103 virtual int FindListIndexForProperty(wxProperty
*property
);
105 // Select and show string representation in editor the given
106 // property. NULL resets to show no property.
107 virtual bool ShowProperty(wxProperty
*property
, bool select
= TRUE
);
108 virtual bool EditProperty(wxProperty
*property
);
110 // Update the display from the property
111 virtual bool DisplayProperty(wxProperty
*property
);
112 // Update the property from the display
113 virtual bool RetrieveProperty(wxProperty
*property
);
115 // Find appropriate validator and load property into value controls
116 virtual bool BeginShowingProperty(wxProperty
*property
);
117 // Find appropriate validator and unload property from value controls
118 virtual bool EndShowingProperty(wxProperty
*property
);
120 // Begin detailed editing (e.g. using value listbox)
121 virtual void BeginDetailedEditing(void);
123 // End detailed editing (e.g. using value listbox)
124 virtual void EndDetailedEditing(void);
126 // Called by the property listbox
127 void OnPropertySelect(wxCommandEvent
& event
);
129 // Called by the value listbox
130 void OnValueListSelect(wxCommandEvent
& event
);
132 virtual bool CreateControls(void);
133 virtual void ShowTextControl(bool show
);
134 virtual void ShowListBoxControl(bool show
);
135 virtual void EnableCheck(bool show
);
136 virtual void EnableCross(bool show
);
138 void OnOk(wxCommandEvent
& event
);
139 void OnCancel(wxCommandEvent
& event
);
140 void OnHelp(wxCommandEvent
& event
);
141 void OnPropertyDoubleClick(wxCommandEvent
& event
);
142 // virtual void OnDoubleClick(void);
144 void OnCheck(wxCommandEvent
& event
);
145 void OnCross(wxCommandEvent
& event
);
146 void OnEdit(wxCommandEvent
& event
);
147 void OnText(wxCommandEvent
& event
);
149 inline virtual wxListBox
*GetPropertyScrollingList() const { return m_propertyScrollingList
; }
150 inline virtual wxListBox
*GetValueList() const { return m_valueList
; }
151 inline virtual wxTextCtrl
*GetValueText() const { return m_valueText
; }
152 inline virtual wxButton
*GetConfirmButton() const { return m_confirmButton
; }
153 inline virtual wxButton
*GetCancelButton() const { return m_cancelButton
; }
154 inline virtual wxButton
*GetEditButton() const { return m_editButton
; }
155 inline virtual bool GetDetailedEditing(void) const { return m_detailedEditing
; }
157 inline virtual void AssociatePanel(wxPanel
*win
) { m_propertyWindow
= win
; }
158 inline virtual wxPanel
*GetPanel(void) const { return m_propertyWindow
; }
160 inline virtual void SetManagedWindow(wxWindow
*win
) { m_managedWindow
= win
; }
161 inline virtual wxWindow
*GetManagedWindow(void) const { return m_managedWindow
; }
163 inline virtual wxButton
*GetWindowCloseButton() const { return m_windowCloseButton
; }
164 inline virtual wxButton
*GetWindowCancelButton() const { return m_windowCancelButton
; }
165 inline virtual wxButton
*GetHelpButton() const { return m_windowHelpButton
; }
170 static bool sm_dialogCancelled
;
173 wxListBox
* m_propertyScrollingList
;
174 wxListBox
* m_valueList
; // Should really be a combobox, but we don't have one.
175 wxTextCtrl
* m_valueText
;
176 wxButton
* m_confirmButton
; // A tick, as in VB
177 wxButton
* m_cancelButton
; // A cross, as in VB
178 wxButton
* m_editButton
; // Invokes the custom validator, if any
179 wxSizer
* m_middleSizer
;
181 bool m_detailedEditing
; // E.g. using listbox for choices
183 wxPanel
* m_propertyWindow
; // Panel that the controls will appear on
184 wxWindow
* m_managedWindow
; // Frame or dialog
186 wxButton
* m_windowCloseButton
; // Or OK
187 wxButton
* m_windowCancelButton
;
188 wxButton
* m_windowHelpButton
;
191 DECLARE_DYNAMIC_CLASS(wxPropertyListView
)
192 DECLARE_EVENT_TABLE()
194 virtual void ShowView(wxPropertySheet
*propertySheet
, wxWindow
*window
)
195 { wxPropertyView::ShowView(propertySheet
, window
); };
198 class WXDLLIMPEXP_DEPRECATED wxPropertyTextEdit
: public wxTextCtrl
201 wxPropertyTextEdit(wxPropertyListView
*v
= NULL
,
202 wxWindow
*parent
= NULL
,
203 const wxWindowID id
= -1,
204 const wxString
& value
= wxEmptyString
,
205 const wxPoint
& pos
= wxDefaultPosition
,
206 const wxSize
& size
= wxDefaultSize
,
208 const wxString
& name
= wxT("text"));
213 wxPropertyListView
* m_view
;
216 DECLARE_CLASS(wxPropertyTextEdit
)
219 #define wxPROP_ALLOW_TEXT_EDITING 1
222 * The type of validator used for property lists (Visual Basic style)
225 class WXDLLIMPEXP_DEPRECATED wxPropertyListValidator
: public wxPropertyValidator
228 wxPropertyListValidator(long flags
= wxPROP_ALLOW_TEXT_EDITING
): wxPropertyValidator(flags
) { }
229 ~wxPropertyListValidator() {}
231 // Called when the property is selected or deselected: typically displays the value
232 // in the edit control (having chosen a suitable control to display: (non)editable text or listbox)
233 virtual bool OnSelect(bool select
, wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
235 // Called when the property is double clicked. Extra functionality can be provided, such as
236 // cycling through possible values.
237 inline virtual bool OnDoubleClick(
238 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
241 // Called when the value listbox is selected. Default behaviour is to copy
242 // string to text control, and retrieve the value into the property.
243 virtual bool OnValueListSelect(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
245 // Called when the property value is edited using standard text control
246 inline virtual bool OnPrepareControls(
247 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
250 virtual bool OnClearControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
252 // Called when the property is edited in detail
253 inline virtual bool OnPrepareDetailControls(
254 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
257 // Called if focus lost, IF we're in a modeless property editing situation.
258 inline virtual bool OnClearDetailControls(
259 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
262 // Called when the edit (...) button is pressed. The default implementation
263 // calls view->BeginDetailedEditing; the filename validator (for example) overrides
264 // this function to show the file selector.
265 virtual void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
267 // Called when TICK is pressed or focus is lost.
268 // Return FALSE if value didn't check out; signal to restore old value.
269 inline virtual bool OnCheckValue(
270 wxProperty
*WXUNUSED(property
), wxPropertyListView
*WXUNUSED(view
), wxWindow
*WXUNUSED(parentWindow
) )
273 // Called when TICK is pressed or focus is lost or view wants to update
274 // the property list.
275 // Does the transferance from the property editing area to the property itself
276 virtual bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
278 virtual bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
281 DECLARE_DYNAMIC_CLASS(wxPropertyListValidator
)
285 * A default dialog box class to use.
288 class WXDLLIMPEXP_DEPRECATED wxPropertyListDialog
: public wxDialog
291 wxPropertyListDialog(wxPropertyListView
*v
= NULL
,
292 wxWindow
*parent
= NULL
,
293 const wxString
& title
= wxEmptyString
,
294 const wxPoint
& pos
= wxDefaultPosition
,
295 const wxSize
& size
= wxDefaultSize
,
296 long style
= wxDEFAULT_DIALOG_STYLE
,
297 const wxString
& name
= wxT("dialogBox"));
299 void OnCloseWindow(wxCloseEvent
& event
);
300 void OnDefaultAction(wxControl
*item
);
301 void OnCancel(wxCommandEvent
& event
);
303 // Extend event processing to search the view's event table
304 virtual bool ProcessEvent(wxEvent
& event
);
307 wxPropertyListView
* m_view
;
310 DECLARE_CLASS(wxPropertyListDialog
)
311 DECLARE_EVENT_TABLE()
315 * A default panel class to use.
318 class WXDLLIMPEXP_DEPRECATED wxPropertyListPanel
: public wxPanel
321 wxPropertyListPanel(wxPropertyListView
*v
= NULL
,
322 wxWindow
*parent
= NULL
,
323 const wxPoint
& pos
= wxDefaultPosition
,
324 const wxSize
& size
= wxDefaultSize
,
326 const wxString
& name
= wxT("panel"))
327 : wxPanel(parent
, -1, pos
, size
, style
, name
)
331 ~wxPropertyListPanel();
332 void OnDefaultAction(wxControl
*item
);
334 inline void SetView(wxPropertyListView
* v
) { m_view
= v
; }
335 inline wxPropertyListView
* GetView() const { return m_view
; }
337 // Extend event processing to search the view's event table
338 virtual bool ProcessEvent(wxEvent
& event
);
341 void OnSize(wxSizeEvent
& event
);
344 wxPropertyListView
* m_view
;
347 DECLARE_EVENT_TABLE()
348 DECLARE_CLASS(wxPropertyListPanel
)
352 * A default frame class to use.
355 class WXDLLIMPEXP_DEPRECATED wxPropertyListFrame
: public wxFrame
358 wxPropertyListFrame(wxPropertyListView
*v
= NULL
,
359 wxFrame
*parent
= NULL
,
360 const wxString
& title
= wxEmptyString
,
361 const wxPoint
& pos
= wxDefaultPosition
,
362 const wxSize
& size
= wxDefaultSize
,
363 long style
= wxDEFAULT_FRAME_STYLE
,
364 const wxString
& name
= _T("frame"))
365 : wxFrame(parent
, -1, title
, pos
, size
, style
, name
)
368 m_propertyPanel
= NULL
;
370 void OnCloseWindow(wxCloseEvent
& event
);
372 // Must call this to create panel and associate view
373 virtual bool Initialize(void);
374 virtual wxPropertyListPanel
*OnCreatePanel(wxFrame
*parent
, wxPropertyListView
*v
);
375 inline virtual wxPropertyListPanel
*GetPropertyPanel(void) const { return m_propertyPanel
; }
376 inline wxPropertyListView
* GetView() const { return m_view
; }
379 wxPropertyListView
* m_view
;
380 wxPropertyListPanel
* m_propertyPanel
;
383 DECLARE_EVENT_TABLE()
384 DECLARE_CLASS(wxPropertyListFrame
)
388 * Some default validators
391 class WXDLLIMPEXP_DEPRECATED wxRealListValidator
: public wxPropertyListValidator
394 // 0.0, 0.0 means no range
395 wxRealListValidator(float min
= 0.0, float max
= 0.0, long flags
= wxPROP_ALLOW_TEXT_EDITING
):wxPropertyListValidator(flags
)
396 { m_realMin
= min
; m_realMax
= max
; }
397 ~wxRealListValidator() {}
399 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
401 // Called when TICK is pressed or focus is lost.
402 // Return FALSE if value didn't check out; signal to restore old value.
403 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
405 // Called when TICK is pressed or focus is lost or view wants to update
406 // the property list.
407 // Does the transfer from the property editing area to the property itself
408 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
415 DECLARE_DYNAMIC_CLASS(wxRealListValidator
)
418 class WXDLLIMPEXP_DEPRECATED wxIntegerListValidator
: public wxPropertyListValidator
421 // 0, 0 means no range
422 wxIntegerListValidator(long min
= 0, long max
= 0, long flags
= wxPROP_ALLOW_TEXT_EDITING
):wxPropertyListValidator(flags
)
424 m_integerMin
= min
; m_integerMax
= max
;
426 ~wxIntegerListValidator() {}
428 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
430 // Called when TICK is pressed or focus is lost.
431 // Return FALSE if value didn't check out; signal to restore old value.
432 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
434 // Called when TICK is pressed or focus is lost or view wants to update
435 // the property list.
436 // Does the transfer from the property editing area to the property itself
437 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
444 DECLARE_DYNAMIC_CLASS(wxIntegerListValidator
)
447 class WXDLLIMPEXP_DEPRECATED wxBoolListValidator
: public wxPropertyListValidator
450 wxBoolListValidator(long flags
= 0):wxPropertyListValidator(flags
) {}
451 ~wxBoolListValidator() {}
453 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
454 bool OnPrepareDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
455 bool OnClearDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
457 // Called when TICK is pressed or focus is lost.
458 // Return FALSE if value didn't check out; signal to restore old value.
459 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
461 // Called when TICK is pressed or focus is lost or view wants to update
462 // the property list.
463 // Does the transfer from the property editing area to the property itself
464 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
465 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
467 // Called when the property is double clicked. Extra functionality can be provided,
468 // cycling through possible values.
469 virtual bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
472 DECLARE_DYNAMIC_CLASS(wxBoolListValidator
)
475 class WXDLLIMPEXP_DEPRECATED wxStringListValidator
: public wxPropertyListValidator
478 wxStringListValidator(wxStringList
*list
= NULL
, long flags
= 0);
480 ~wxStringListValidator()
486 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
487 bool OnPrepareDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
488 bool OnClearDetailControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
490 // Called when TICK is pressed or focus is lost.
491 // Return FALSE if value didn't check out; signal to restore old value.
492 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
494 // Called when TICK is pressed or focus is lost or view wants to update
495 // the property list.
496 // Does the transfer from the property editing area to the property itself
497 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
498 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
500 // Called when the property is double clicked. Extra functionality can be provided,
501 // cycling through possible values.
502 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
505 wxStringList
* m_strings
;
508 DECLARE_DYNAMIC_CLASS(wxStringListValidator
)
511 class WXDLLIMPEXP_DEPRECATED wxFilenameListValidator
: public wxPropertyListValidator
514 wxFilenameListValidator(wxString message
= wxT("Select a file"), wxString wildcard
= wxALL_FILES_PATTERN
, long flags
= 0);
515 ~wxFilenameListValidator();
517 // Called when TICK is pressed or focus is lost.
518 // Return FALSE if value didn't check out; signal to restore old value.
519 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
521 // Called when TICK is pressed or focus is lost or view wants to update
522 // the property list.
523 // Does the transferance from the property editing area to the property itself
524 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
525 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
527 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
529 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
531 // Called when the edit (...) button is pressed.
532 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
535 wxString m_filenameWildCard
;
536 wxString m_filenameMessage
;
539 DECLARE_DYNAMIC_CLASS(wxFilenameListValidator
)
542 class WXDLLIMPEXP_DEPRECATED wxColourListValidator
: public wxPropertyListValidator
545 wxColourListValidator(long flags
= 0);
546 ~wxColourListValidator();
548 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
549 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
550 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
552 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
554 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
556 // Called when the edit (...) button is pressed.
557 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
560 DECLARE_DYNAMIC_CLASS(wxColourListValidator
)
563 class WXDLLIMPEXP_DEPRECATED wxListOfStringsListValidator
: public wxPropertyListValidator
566 wxListOfStringsListValidator(long flags
= 0);
567 ~wxListOfStringsListValidator() {}
569 bool OnPrepareControls(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
571 // Called when TICK is pressed or focus is lost.
572 // Return FALSE if value didn't check out; signal to restore old value.
573 bool OnCheckValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
575 // Called when TICK is pressed or focus is lost or view wants to update
576 // the property list.
577 // Does the transfer from the property editing area to the property itself
578 bool OnRetrieveValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
579 bool OnDisplayValue(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
581 // Called when the property is double clicked.
582 bool OnDoubleClick(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
584 bool EditStringList(wxWindow
*parent
, wxStringList
*stringList
, const wxChar
*title
= wxT("String List Editor"));
586 // Called when the edit (...) button is pressed.
587 void OnEdit(wxProperty
*property
, wxPropertyListView
*view
, wxWindow
*parentWindow
);
590 DECLARE_DYNAMIC_CLASS(wxListOfStringsListValidator
)