1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPropertyGrid
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
10 @section propgrid_window_styles wxPropertyGrid Window Styles
12 SetWindowStyleFlag method can be used to modify some of these at run-time.
15 enum wxPG_WINDOW_STYLES
19 This will cause Sort() automatically after an item is added.
20 When inserting a lot of items in this mode, it may make sense to
21 use Freeze() before operations and Thaw() afterwards to increase
24 wxPG_AUTO_SORT
= 0x00000010,
27 Categories are not initially shown (even if added).
28 IMPORTANT NOTE: If you do not plan to use categories, then this
29 style will waste resources.
30 This flag can also be changed using wxPropertyGrid::EnableCategories method.
32 wxPG_HIDE_CATEGORIES
= 0x00000020,
35 This style combines non-categoric mode and automatic sorting.
37 wxPG_ALPHABETIC_MODE
= (wxPG_HIDE_CATEGORIES
|wxPG_AUTO_SORT
),
40 Modified values are shown in bold font. Changing this requires Refresh()
43 wxPG_BOLD_MODIFIED
= 0x00000040,
46 When wxPropertyGrid is resized, splitter moves to the center. This
47 behaviour stops once the user manually moves the splitter.
49 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
52 Display tool tips for cell text that cannot be shown completely. If
53 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
55 wxPG_TOOLTIPS
= 0x00000100,
58 Disables margin and hides all expand/collapse buttons that would appear
59 outside the margin (for sub-properties). Toggling this style automatically
60 expands all collapsed items.
62 wxPG_HIDE_MARGIN
= 0x00000200,
65 This style prevents user from moving the splitter.
67 wxPG_STATIC_SPLITTER
= 0x00000400,
70 Combination of other styles that make it impossible for user to modify
73 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
76 Disables wxTextCtrl based editors for properties which
77 can be edited in another way. Equals calling
78 wxPropertyGrid::LimitPropertyEditing() for all added properties.
80 wxPG_LIMITED_EDITING
= 0x00000800,
83 wxPropertyGridManager only: Show tool bar for mode and page selection.
85 wxPG_TOOLBAR
= 0x00001000,
88 wxPropertyGridManager only: Show adjustable text box showing description
89 or help text, if available, for currently selected property.
91 wxPG_DESCRIPTION
= 0x00002000,
93 /** wxPropertyGridManager only: don't show an internal border around the
94 property grid. Recommended if you use a header.
96 wxPG_NO_INTERNAL_BORDER
= 0x00004000
100 enum wxPG_EX_WINDOW_STYLES
104 NOTE: wxPG_EX_xxx are extra window styles and must be set using SetExtraStyle()
107 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
108 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is not
109 activated, and switching the mode first time becomes somewhat slower.
110 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
112 NOTE: If you do plan not switching to non-categoric mode, or if
113 you don't plan to use categories at all, then using this style will result
114 in waste of resources.
116 wxPG_EX_INIT_NOCAT
= 0x00001000,
119 Extended window style that sets wxPropertyGridManager tool bar to not
122 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
125 Shows alphabetic/categoric mode buttons from tool bar.
127 wxPG_EX_MODE_BUTTONS
= 0x00008000,
130 Show property help strings as tool tips instead as text on the status bar.
131 You can set the help strings using SetPropertyHelpString member function.
133 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
136 Allows relying on native double-buffering.
138 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
141 Set this style to let user have ability to set values of properties to
142 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
145 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
148 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION and
149 wxPG_STRING_PASSWORD) are not stored into property's attribute storage (thus
150 they are not readable).
152 Note that this option is global, and applies to all wxPG property containers.
154 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
157 Hides page selection buttons from tool bar.
159 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
161 /** Allows multiple properties to be selected by user (by pressing SHIFT
162 when clicking on a property, or by dragging with left mouse button
165 You can get array of selected properties with
166 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
167 mode wxPropertyGridInterface::GetSelection() returns
168 property which has editor active (usually the first one
169 selected). Other useful member functions are ClearSelection(),
170 AddToSelection() and RemoveFromSelection().
172 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
175 This enables top-level window tracking which allows wxPropertyGrid to
176 notify the application of last-minute property value changes by user.
178 This style is not enabled by default because it may cause crashes when
179 wxPropertyGrid is used in with wxAUI or similar system.
181 @remarks If you are not in fact using any system that may change
182 wxPropertyGrid's top-level parent window on its own, then you
183 are recommended to enable this style.
185 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
187 /** Don't show divider above toolbar, on Windows.
189 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x04000000,
191 /** Show a separator below the toolbar.
193 wxPG_EX_TOOLBAR_SEPARATOR
= 0x08000000
197 /** Combines various styles.
199 #define wxPG_DEFAULT_STYLE (0)
201 /** Combines various styles.
203 #define wxPGMAN_DEFAULT_STYLE (0)
208 // -----------------------------------------------------------------------
211 @section propgrid_vfbflags wxPropertyGrid Validation Failure behaviour Flags
215 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
219 Prevents user from leaving property unless value is valid. If this
220 behaviour flag is not used, then value change is instead cancelled.
222 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
225 Calls wxBell() on validation failure.
227 wxPG_VFB_BEEP
= 0x02,
230 Cell with invalid value will be marked (with red colour).
232 wxPG_VFB_MARK_CELL
= 0x04,
235 Display a text message explaining the situation.
237 To customize the way the message is displayed, you need to
238 reimplement wxPropertyGrid::DoShowPropertyError() in a
239 derived class. Default behaviour is to display the text on
240 the top-level frame's status bar, if present, and otherwise
243 wxPG_VFB_SHOW_MESSAGE
= 0x08,
246 Similar to wxPG_VFB_SHOW_MESSAGE, except always displays the
247 message using wxMessageBox.
249 wxPG_VFB_SHOW_MESSAGEBOX
= 0x10,
252 Similar to wxPG_VFB_SHOW_MESSAGE, except always displays the
253 message on the status bar (when present - you can reimplement
254 wxPropertyGrid::GetStatusBar() in a derived class to specify
257 wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR
= 0x20,
262 wxPG_VFB_DEFAULT
= wxPG_VFB_MARK_CELL
|
263 wxPG_VFB_SHOW_MESSAGEBOX
,
269 typedef wxByte wxPGVFBFlags
;
274 Used to convey validation information to and from functions that
275 actually perform validation. Mostly used in custom property classes.
277 class wxPGValidationInfo
281 @return Returns failure behaviour which is a combination of
282 @ref propgrid_vfbflags.
284 wxPGVFBFlags
GetFailureBehavior();
287 Returns current failure message.
289 const wxString
& GetFailureMessage() const;
292 Returns reference to pending value.
294 wxVariant
& GetValue();
296 /** Set validation failure behaviour
298 @param failureBehavior
299 Mixture of @ref propgrid_vfbflags.
301 void SetFailureBehavior(wxPGVFBFlags failureBehavior
);
304 Set current failure message.
306 void SetFailureMessage(const wxString
& message
);
309 // -----------------------------------------------------------------------
312 @section propgrid_keyboard_actions wxPropertyGrid Action Identifiers
314 These are used with wxPropertyGrid::AddActionTrigger() and
315 wxPropertyGrid::ClearActionTriggers().
319 enum wxPG_KEYBOARD_ACTIONS
321 wxPG_ACTION_INVALID
= 0,
323 /** Select the next property. */
324 wxPG_ACTION_NEXT_PROPERTY
,
326 /** Select the previous property. */
327 wxPG_ACTION_PREV_PROPERTY
,
329 /** Expand the selected property, if it has child items. */
330 wxPG_ACTION_EXPAND_PROPERTY
,
332 /** Collapse the selected property, if it has child items. */
333 wxPG_ACTION_COLLAPSE_PROPERTY
,
335 /** Cancel and undo any editing done in the currently active property
338 wxPG_ACTION_CANCEL_EDIT
,
340 /** Move focus to the editor control of the currently selected
345 /** Causes editor's button (if any) to be pressed. */
346 wxPG_ACTION_PRESS_BUTTON
,
354 /** This callback function is used for sorting properties.
356 Call wxPropertyGrid::SetSortFunction() to set it.
358 Sort function should return a value greater than 0 if position of p1 is
359 after p2. So, for instance, when comparing property names, you can use
360 following implementation:
363 int MyPropertySortFunction(wxPropertyGrid* propGrid,
367 return p1->GetBaseName().compare( p2->GetBaseName() );
371 typedef int (*wxPGSortCallback
)(wxPropertyGrid
* propGrid
,
375 // -----------------------------------------------------------------------
378 @class wxPropertyGrid
380 wxPropertyGrid is a specialized grid for editing properties - in other
381 words name = value pairs. List of ready-to-use property classes include
382 strings, numbers, flag sets, fonts, colours and many others. It is possible,
383 for example, to categorize properties, set up a complete tree-hierarchy,
384 add more than two columns, and set arbitrary per-property attributes.
386 Please note that most member functions are inherited and as such not
387 documented on this page. This means you will probably also want to read
388 wxPropertyGridInterface class reference.
390 See also @ref overview_propgrid.
392 @section propgrid_window_styles_ Window Styles
394 See @ref propgrid_window_styles.
396 @section propgrid_event_handling Event Handling
398 To process input from a property grid control, use these event handler macros
399 to direct input to member functions that take a wxPropertyGridEvent argument.
401 @beginEventEmissionTable{wxPropertyGridEvent}
402 @event{EVT_PG_SELECTED (id, func)}
403 Respond to @c wxEVT_PG_SELECTED event, generated when a property selection
404 has been changed, either by user action or by indirect program
405 function. For instance, collapsing a parent property programmatically
406 causes any selected child property to become unselected, and may
407 therefore cause this event to be generated.
408 @event{EVT_PG_CHANGED(id, func)}
409 Respond to @c wxEVT_PG_CHANGED event, generated when property value
410 has been changed by the user.
411 @event{EVT_PG_CHANGING(id, func)}
412 Respond to @c wxEVT_PG_CHANGING event, generated when property value
413 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
414 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
415 to prevent change from taking place, if necessary.
416 @event{EVT_PG_HIGHLIGHTED(id, func)}
417 Respond to @c wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
418 moves over a property. Event's property is NULL if hovered area does
419 not belong to any property.
420 @event{EVT_PG_RIGHT_CLICK(id, func)}
421 Respond to @c wxEVT_PG_RIGHT_CLICK event, which occurs when property is
422 clicked on with right mouse button.
423 @event{EVT_PG_DOUBLE_CLICK(id, func)}
424 Respond to @c wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
425 double-clicked on with left mouse button.
426 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
427 Respond to @c wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
428 a property or category.
429 @event{EVT_PG_ITEM_EXPANDED(id, func)}
430 Respond to @c wxEVT_PG_ITEM_EXPANDED event, generated when user expands
431 a property or category.
432 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
433 Respond to @c wxEVT_PG_LABEL_EDIT_BEGIN event, generated when user is
434 about to begin editing a property label. You can veto this event to
436 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
437 Respond to @c wxEVT_PG_LABEL_EDIT_ENDING event, generated when user is
438 about to end editing of a property label. You can veto this event to
440 @event{EVT_PG_COL_BEGIN_DRAG(id, func)}
441 Respond to @c wxEVT_PG_COL_BEGIN_DRAG event, generated when user
442 starts resizing a column - can be vetoed.
443 @event{EVT_PG_COL_DRAGGING,(id, func)}
444 Respond to @c wxEVT_PG_COL_DRAGGING, event, generated when a
445 column resize by user is in progress. This event is also generated
446 when user double-clicks the splitter in order to recenter
448 @event{EVT_PG_COL_END_DRAG(id, func)}
449 Respond to @c wxEVT_PG_COL_END_DRAG event, generated after column
450 resize by user has finished.
454 Use Freeze() and Thaw() respectively to disable and enable drawing.
455 This will also delay sorting etc. miscellaneous calculations to the last
460 @appearance{propertygrid}
462 class wxPropertyGrid
: public wxControl
,
463 public wxScrollHelper
,
464 public wxPropertyGridInterface
468 Two step constructor.
469 Call Create() when this constructor is called to build up the wxPropertyGrid
475 The styles to be used are styles valid for the wxWindow.
477 @see @ref propgrid_window_styles.
479 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
480 const wxPoint
& pos
= wxDefaultPosition
,
481 const wxSize
& size
= wxDefaultSize
,
482 long style
= wxPG_DEFAULT_STYLE
,
483 const wxString
& name
= wxPropertyGridNameStr
);
486 virtual ~wxPropertyGrid();
489 Adds given key combination to trigger given action.
491 Here is a sample code to make Enter key press move focus to
495 propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
497 propGrid->DedicateKey(WXK_RETURN);
501 Which action to trigger. See @ref propgrid_keyboard_actions.
503 Which keycode triggers the action.
505 Which key event modifiers, in addition to keycode, are needed to
508 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
511 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
512 extra style is not used, then this has same effect as
513 calling SelectProperty().
515 @remarks Multiple selection is not supported for categories. This
516 means that if you have properties selected, you cannot
517 add category to selection, and also if you have category
518 selected, you cannot add other properties to selection.
519 This member function will fail silently in these cases,
522 bool AddToSelection( wxPGPropArg id
);
525 This static function enables or disables automatic use of
526 wxGetTranslation() for following strings: wxEnumProperty list labels,
527 wxFlagsProperty child property labels.
531 static void AutoGetTranslation( bool enable
);
534 Creates label editor wxTextCtrl for given column, for property
535 that is currently selected. When multiple selection is
536 enabled, this applies to whatever property GetSelection()
540 Which column's label to edit. Note that you should not
541 use value 1, which is reserved for property value
544 @see EndLabelEdit(), MakeColumnEditable()
546 void BeginLabelEdit( unsigned int colIndex
= 0 );
549 Changes value of a property, as if from an editor. Use this instead of
550 SetPropertyValue() if you need the value to run through validation
551 process, and also send the property change event.
553 @return Returns true if value was successfully changed.
555 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
558 Centers the splitter.
560 @param enableAutoResizing
561 If @true, automatic column resizing is enabled (only applicapple
562 if window style wxPG_SPLITTER_AUTO_CENTER is used).
564 void CenterSplitter( bool enableAutoResizing
= false );
567 Deletes all properties.
569 virtual void Clear();
572 Clears action triggers for given action.
575 Which action to trigger. @ref propgrid_keyboard_actions.
577 void ClearActionTriggers( int action
);
580 Forces updating the value of property from the editor control.
581 Note that @c wxEVT_PG_CHANGING and @c wxEVT_PG_CHANGED are dispatched using
582 ProcessEvent, meaning your event handlers will be called immediately.
584 @return Returns @true if anything was changed.
586 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
589 Two step creation. Whenever the control is created without any
590 parameters, use Create to actually create it. Don't access the control's
591 public methods before this is called
593 @see @ref propgrid_window_styles.
595 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
596 const wxPoint
& pos
= wxDefaultPosition
,
597 const wxSize
& size
= wxDefaultSize
,
598 long style
= wxPG_DEFAULT_STYLE
,
599 const wxString
& name
= wxPropertyGridNameStr
);
602 Dedicates a specific keycode to wxPropertyGrid. This means that such
603 key presses will not be redirected to editor controls.
605 Using this function allows, for example, navigation between
606 properties using arrow keys even when the focus is in the editor
609 void DedicateKey( int keycode
);
612 Enables or disables (shows/hides) categories according to parameter
615 @remarks This functions deselects selected property, if any. Validation
616 failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
617 selection is cleared even if editor had invalid value.
619 bool EnableCategories( bool enable
);
622 Destroys label editor wxTextCtrl, if any.
625 Use @true (default) to store edited label text in
628 @see BeginLabelEdit(), MakeColumnEditable()
630 void EndLabelEdit( bool commit
= true );
633 Scrolls and/or expands items to ensure that the given item is visible.
635 @return Returns @true if something was actually done.
637 bool EnsureVisible( wxPGPropArg id
);
640 Reduces column sizes to minimum possible, while still retaining
641 fully visible grid contents (labels, images).
643 @return Minimum size for the grid to still display everything.
645 @remarks Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
647 This function only works properly if grid size prior to call was
648 already fairly large.
650 Note that you can also get calculated column widths by calling
651 GetState->GetColumnWidth() immediately after this function
657 Returns currently active label editor, NULL if none.
659 wxTextCtrl
* GetLabelEditor() const;
662 Returns wxWindow that the properties are painted on, and which should be
663 used as the parent for editor controls.
665 wxWindow
* GetPanel();
668 Returns current category caption background colour.
670 wxColour
GetCaptionBackgroundColour() const;
673 Returns current category caption font.
675 wxFont
& GetCaptionFont();
678 Returns current category caption text colour.
680 wxColour
GetCaptionForegroundColour() const;
683 Returns current cell background colour.
685 wxColour
GetCellBackgroundColour() const;
688 Returns current cell text colour when disabled.
690 wxColour
GetCellDisabledTextColour() const;
693 Returns current cell text colour.
695 wxColour
GetCellTextColour() const;
698 Returns number of columns currently on grid.
700 unsigned int GetColumnCount() const;
703 Returns colour of empty space below properties.
705 wxColour
GetEmptySpaceColour() const;
708 Returns height of highest characters of used font.
710 int GetFontHeight() const;
713 Returns pointer to itself. Dummy function that enables same kind
714 of code to use wxPropertyGrid and wxPropertyGridManager.
716 wxPropertyGrid
* GetGrid();
719 Returns rectangle of custom paint image.
722 Return image rectangle for this property.
725 Which choice of property to use (each choice may have
728 wxRect
GetImageRect( wxPGProperty
* property
, int item
) const;
731 Returns size of the custom paint image in front of property.
734 Return image rectangle for this property.
735 If this argument is NULL, then preferred size is returned.
738 Which choice of property to use (each choice may have
741 wxSize
GetImageSize( wxPGProperty
* property
= NULL
, int item
= -1 ) const;
744 Returns last item which could be iterated using given flags.
747 See @ref propgrid_iterator_flags.
749 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
);
752 Returns colour of lines between cells.
754 wxColour
GetLineColour() const;
757 Returns background colour of margin.
759 wxColour
GetMarginColour() const;
762 Returns "root property". It does not have name, etc. and it is not
763 visible. It is only useful for accessing its children.
765 wxPGProperty
* GetRoot() const;
768 Returns height of a single grid row (in pixels).
770 int GetRowHeight() const;
773 Returns currently selected property.
775 wxPGProperty
* GetSelectedProperty() const;
778 Returns currently selected property.
780 wxPGProperty
* GetSelection() const;
783 Returns current selection background colour.
785 wxColour
GetSelectionBackgroundColour() const;
788 Returns current selection text colour.
790 wxColour
GetSelectionForegroundColour() const;
793 Returns the property sort function (default is @NULL).
797 wxPGSortCallback
GetSortFunction() const;
800 Returns current splitter x position.
802 int GetSplitterPosition( unsigned int splitterIndex
= 0 ) const;
805 Returns wxTextCtrl active in currently selected property, if any. Takes
806 wxOwnerDrawnComboBox into account.
808 wxTextCtrl
* GetEditorTextCtrl() const;
811 Returns current appearance of unspecified value cells.
813 @see SetUnspecifiedValueAppearance()
815 const wxPGCell
& GetUnspecifiedValueAppearance() const;
818 Returns (visual) text representation of the unspecified
821 @param argFlags For internal use only.
823 wxString
GetUnspecifiedValueText( int argFlags
= 0 ) const;
826 Returns current vertical spacing.
828 int GetVerticalSpacing() const;
831 Returns information about arbitrary position in the grid.
834 Coordinates in the virtual grid space. You may need to use
835 wxScrolled<T>::CalcScrolledPosition() for translating
836 wxPropertyGrid client coordinates into something this member
839 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
842 Returns true if any property has been modified by the user.
844 bool IsAnyModified() const;
847 Returns @true if a property editor control has focus.
849 bool IsEditorFocused() const;
852 Returns true if updating is frozen (ie. Freeze() called but not
855 bool IsFrozen() const;
858 Makes given column editable by user.
861 The index of the column to make editable.
863 Using @false here will disable column from being editable.
865 @see BeginLabelEdit(), EndLabelEdit()
867 void MakeColumnEditable( unsigned int column
, bool editable
= true );
870 It is recommended that you call this function any time your code causes
871 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
872 handler should be able to detect most changes, but it is not perfect.
875 New top-level parent that is about to be set. Old top-level parent
876 window should still exist as the current one.
878 @remarks This function is automatically called from wxPropertyGrid::
879 Reparent() and wxPropertyGridManager::Reparent(). You only
880 need to use it if you reparent wxPropertyGrid indirectly.
882 void OnTLPChanging( wxWindow
* newTLP
);
885 Refreshes any active editor control.
887 void RefreshEditor();
890 Redraws given property.
892 virtual void RefreshProperty( wxPGProperty
* p
);
895 /** Forwards to DoRegisterEditorClass with empty name. */
896 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
897 bool noDefCheck
= false );
899 Registers a new editor class.
901 @return Returns pointer to the editor class instance that should be used.
903 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editor
,
904 const wxString
& name
,
905 bool noDefCheck
= false );
908 Resets all colours to the original system values.
913 Resets column sizes and splitter positions, based on proportions.
915 @param enableAutoResizing
916 If @true, automatic column resizing is enabled (only applicapple
917 if window style wxPG_SPLITTER_AUTO_CENTER is used).
919 @see wxPropertyGridInterface::SetColumnProportion()
921 void ResetColumnSizes( bool enableAutoResizing
= false );
924 Removes given property from selection. If property is not selected,
925 an assertion failure will occur.
927 bool RemoveFromSelection( wxPGPropArg id
);
930 Selects a property. Editor widget is automatically created, but
931 not focused unless focus is true.
934 Property to select (name or pointer).
937 If @true, move keyboard focus to the created editor right away.
939 @return returns @true if selection finished successfully. Usually only
940 fails if current value in editor is not valid.
942 @remarks In wxPropertyGrid 1.4, this member function used to generate
943 @c wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
946 @remarks This clears any previous selection.
948 @see wxPropertyGridInterface::ClearSelection()
950 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
953 Sets category caption background colour.
955 void SetCaptionBackgroundColour(const wxColour
& col
);
958 Sets category caption text colour.
960 void SetCaptionTextColour(const wxColour
& col
);
963 Sets default cell background colour - applies to property cells.
964 Note that appearance of editor widgets may not be affected.
966 void SetCellBackgroundColour(const wxColour
& col
);
969 Sets cell text colour for disabled properties.
971 void SetCellDisabledTextColour(const wxColour
& col
);
974 Sets default cell text colour - applies to property name and value text.
975 Note that appearance of editor widgets may not be affected.
977 void SetCellTextColour(const wxColour
& col
);
980 Set number of columns (2 or more).
982 void SetColumnCount( int colCount
);
985 Sets the 'current' category - Append will add non-category properties
988 void SetCurrentCategory( wxPGPropArg id
);
991 Sets colour of empty space below properties.
993 void SetEmptySpaceColour(const wxColour
& col
);
996 Sets colour of lines between cells.
998 void SetLineColour(const wxColour
& col
);
1001 Sets background colour of margin.
1003 void SetMarginColour(const wxColour
& col
);
1006 Set entire new selection from given list of properties.
1008 void SetSelection( const wxArrayPGProperty
& newSelection
);
1011 Sets selection background colour - applies to selected property name
1014 void SetSelectionBackgroundColour(const wxColour
& col
);
1017 Sets selection foreground colour - applies to selected property name text.
1019 void SetSelectionTextColour(const wxColour
& col
);
1023 Sets the property sorting function.
1026 The sorting function to be used. It should return a value greater
1027 than 0 if position of p1 is after p2. So, for instance, when
1028 comparing property names, you can use following implementation:
1031 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1035 return p1->GetBaseName().compare( p2->GetBaseName() );
1040 Default property sort function sorts properties by their labels
1041 (case-insensitively).
1043 @see GetSortFunction, wxPropertyGridInterface::Sort,
1044 wxPropertyGridInterface::SortChildren
1046 void SetSortFunction( wxPGSortCallback sortFunction
);
1049 Sets x coordinate of the splitter.
1051 @remarks Splitter position cannot exceed grid size, and therefore setting
1052 it during form creation may fail as initial grid size is often
1053 smaller than desired splitter position, especially when sizers
1056 void SetSplitterPosition( int newxpos
, int col
= 0 );
1059 Moves splitter as left as possible, while still allowing all
1060 labels to be shown in full.
1062 @param privateChildrenToo
1063 If @false, will still allow private children to be cropped.
1065 void SetSplitterLeft( bool privateChildrenToo
= false );
1068 Sets appearance of value cells representing an unspecified property
1069 value. Default appearance is blank.
1071 @remarks If you set the unspecified value to have any
1072 textual representation, then that will override
1073 "InlineHelp" attribute.
1075 @see wxPGProperty::SetValueToUnspecified(),
1076 wxPGProperty::IsValueUnspecified()
1078 void SetUnspecifiedValueAppearance( const wxPGCell
& cell
);
1081 Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1082 height. Value of 2 should be default on most platforms.
1084 void SetVerticalSpacing( int vspacing
);
1087 @name wxPropertyGrid customization
1089 Reimplement these member functions in derived class for better
1090 control over wxPropertyGrid behaviour.
1095 Override in derived class to display error messages in custom manner
1096 (these message usually only result from validation failure).
1098 @remarks If you implement this, then you also need to implement
1099 DoHidePropertyError() - possibly to do nothing, if error
1100 does not need hiding (e.g. it was logged or shown in a
1103 @see DoHidePropertyError()
1105 virtual void DoShowPropertyError( wxPGProperty
* property
,
1106 const wxString
& msg
);
1109 Override in derived class to hide an error displayed by
1110 DoShowPropertyError().
1112 @see DoShowPropertyError()
1114 virtual void DoHidePropertyError( wxPGProperty
* property
);
1117 Return wxStatusBar that is used by this wxPropertyGrid. You can
1118 reimplement this member function in derived class to override
1119 the default behaviour of using the top-level wxFrame's status
1122 virtual wxStatusBar
* GetStatusBar();
1127 @name Property development functions
1129 These member functions are usually only called when creating custom
1135 Call when editor widget's contents is modified. For example, this is
1136 called when changes text in wxTextCtrl (used in wxStringProperty and
1139 @remarks This function should only be called by custom properties.
1141 @see wxPGProperty::OnEvent()
1143 void EditorsValueWasModified();
1146 Reverse of EditorsValueWasModified().
1148 @remarks This function should only be called by custom properties.
1150 void EditorsValueWasNotModified();
1153 Returns most up-to-date value of selected property. This will return
1154 value different from GetSelectedProperty()->GetValue() only when text
1155 editor is activate and string edited by user represents valid,
1156 uncommitted property value.
1158 wxVariant
GetUncommittedPropertyValue();
1161 Returns true if editor's value was marked modified.
1163 bool IsEditorsValueModified() const;
1166 Shows an brief error message that is related to a property.
1168 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
);
1171 You can use this member function, for instance, to detect in
1172 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1173 already called in wxPGEditor::OnEvent(). It really only detects
1174 if was value was changed using wxPGProperty::SetValueInEvent(), which
1175 is usually used when a 'picker' dialog is displayed. If value was
1176 written by "normal means" in wxPGProperty::StringToValue() or
1177 IntToValue(), then this function will return false (on the other hand,
1178 wxPGProperty::OnEvent() is not even called in those cases).
1180 bool WasValueChangedInEvent() const;
1187 @class wxPropertyGridEvent
1189 A property grid event holds information about events associated with
1190 wxPropertyGrid objects.
1192 @library{wxpropgrid}
1195 class wxPropertyGridEvent
: public wxCommandEvent
1200 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
1202 /** Copy constructor. */
1203 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
1206 ~wxPropertyGridEvent();
1209 Returns true if you can veto the action that the event is signaling.
1211 bool CanVeto() const;
1214 Returns the column index associated with this event.
1215 For the column dragging events, it is the column to the left
1216 of the splitter being dragged
1218 unsigned int GetColumn() const;
1221 Returns highest level non-category, non-root parent of property for
1222 which event occurred. Useful when you have nested properties with
1225 @remarks If immediate parent is root or category, this will return the
1228 wxPGProperty
* GetMainParent() const;
1231 Returns property associated with this event.
1233 @remarks You should assume that this property can always be NULL.
1234 For instance, @c wxEVT_PG_SELECTED is emitted not only when
1235 a new property is selected, but also when selection is
1236 cleared by user activity.
1238 wxPGProperty
* GetProperty() const;
1241 Returns current validation failure flags.
1243 wxPGVFBFlags
GetValidationFailureBehavior() const;
1246 Returns name of the associated property.
1248 @remarks Property name is stored in event, so it remains
1249 accessible even after the associated property or
1250 the property grid has been deleted.
1252 wxString
GetPropertyName() const;
1255 Returns value of the associated property. Works for all event
1256 types, but for @c wxEVT_PG_CHANGING this member function returns
1257 the value that is pending, so you can call Veto() if the
1258 value is not satisfactory.
1260 @remarks Property value is stored in event, so it remains
1261 accessible even after the associated property or
1262 the property grid has been deleted.
1264 wxVariant
GetPropertyValue() const
1267 @see GetPropertyValue()
1269 wxVariant
GetValue() const;
1272 Set if event can be vetoed.
1274 void SetCanVeto( bool canVeto
);
1276 /** Changes the property associated with this event. */
1277 void SetProperty( wxPGProperty
* p
);
1280 Set override validation failure behaviour. Only effective if Veto() was
1281 also called, and only allowed if event type is @c wxEVT_PG_CHANGING.
1283 void SetValidationFailureBehavior( wxPGVFBFlags flags
);
1286 Sets custom failure message for this time only. Only applies if
1287 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
1289 void SetValidationFailureMessage( const wxString
& message
);
1292 Call this from your event handler to veto action that the event is
1293 signaling. You can only veto a shutdown if wxPropertyGridEvent::CanVeto()
1296 @remarks Currently only @c wxEVT_PG_CHANGING supports vetoing.
1298 void Veto( bool veto
= true );
1301 Returns @true if event was vetoed.
1303 bool WasVetoed() const;