1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPropertyGrid
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
11 @section propgrid_window_styles wxPropertyGrid Window Styles
13 SetWindowStyleFlag method can be used to modify some of these at run-time.
16 enum wxPG_WINDOW_STYLES
20 This will cause Sort() automatically after an item is added.
21 When inserting a lot of items in this mode, it may make sense to
22 use Freeze() before operations and Thaw() afterwards to increase
25 wxPG_AUTO_SORT
= 0x00000010,
28 Categories are not initially shown (even if added).
29 IMPORTANT NOTE: If you do not plan to use categories, then this
30 style will waste resources.
31 This flag can also be changed using wxPropertyGrid::EnableCategories method.
33 wxPG_HIDE_CATEGORIES
= 0x00000020,
36 This style combines non-categoric mode and automatic sorting.
38 wxPG_ALPHABETIC_MODE
= (wxPG_HIDE_CATEGORIES
|wxPG_AUTO_SORT
),
41 Modified values are shown in bold font. Changing this requires Refresh()
44 wxPG_BOLD_MODIFIED
= 0x00000040,
47 When wxPropertyGrid is resized, splitter moves to the center. This
48 behavior stops once the user manually moves the splitter.
50 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
53 Display tool tips for cell text that cannot be shown completely. If
54 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
56 wxPG_TOOLTIPS
= 0x00000100,
59 Disables margin and hides all expand/collapse buttons that would appear
60 outside the margin (for sub-properties). Toggling this style automatically
61 expands all collapsed items.
63 wxPG_HIDE_MARGIN
= 0x00000200,
66 This style prevents user from moving the splitter.
68 wxPG_STATIC_SPLITTER
= 0x00000400,
71 Combination of other styles that make it impossible for user to modify
74 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
77 Disables wxTextCtrl based editors for properties which
78 can be edited in another way. Equals calling
79 wxPropertyGrid::LimitPropertyEditing() for all added properties.
81 wxPG_LIMITED_EDITING
= 0x00000800,
84 wxPropertyGridManager only: Show tool bar for mode and page selection.
86 wxPG_TOOLBAR
= 0x00001000,
89 wxPropertyGridManager only: Show adjustable text box showing description
90 or help text, if available, for currently selected property.
92 wxPG_DESCRIPTION
= 0x00002000,
94 /** wxPropertyGridManager only: don't show an internal border around the
95 property grid. Recommended if you use a header.
97 wxPG_NO_INTERNAL_BORDER
= 0x00004000
101 enum wxPG_EX_WINDOW_STYLES
105 NOTE: wxPG_EX_xxx are extra window styles and must be set using SetExtraStyle()
108 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
109 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is not
110 activated, and switching the mode first time becomes somewhat slower.
111 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
113 NOTE: If you do plan not switching to non-categoric mode, or if
114 you don't plan to use categories at all, then using this style will result
115 in waste of resources.
117 wxPG_EX_INIT_NOCAT
= 0x00001000,
120 Extended window style that sets wxPropertyGridManager tool bar to not
123 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
126 Shows alphabetic/categoric mode buttons from tool bar.
128 wxPG_EX_MODE_BUTTONS
= 0x00008000,
131 Show property help strings as tool tips instead as text on the status bar.
132 You can set the help strings using SetPropertyHelpString member function.
134 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
137 Allows relying on native double-buffering.
139 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
142 Set this style to let user have ability to set values of properties to
143 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
146 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
149 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION and
150 wxPG_STRING_PASSWORD) are not stored into property's attribute storage (thus
151 they are not readable).
153 Note that this option is global, and applies to all wxPG property containers.
155 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
158 Hides page selection buttons from tool bar.
160 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
162 /** Allows multiple properties to be selected by user (by pressing SHIFT
163 when clicking on a property, or by dragging with left mouse button
166 You can get array of selected properties with
167 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
168 mode wxPropertyGridInterface::GetSelection() returns
169 property which has editor active (usually the first one
170 selected). Other useful member functions are ClearSelection(),
171 AddToSelection() and RemoveFromSelection().
173 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
176 This enables top-level window tracking which allows wxPropertyGrid to
177 notify the application of last-minute property value changes by user.
179 This style is not enabled by default because it may cause crashes when
180 wxPropertyGrid is used in with wxAUI or similar system.
182 @remarks If you are not in fact using any system that may change
183 wxPropertyGrid's top-level parent window on its own, then you
184 are recommended to enable this style.
186 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
188 /** Don't show divider above toolbar, on Windows.
190 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x04000000,
192 /** Show a separator below the toolbar.
194 wxPG_EX_TOOLBAR_SEPARATOR
= 0x08000000
198 /** Combines various styles.
200 #define wxPG_DEFAULT_STYLE (0)
202 /** Combines various styles.
204 #define wxPGMAN_DEFAULT_STYLE (0)
209 // -----------------------------------------------------------------------
212 @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
216 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
220 Prevents user from leaving property unless value is valid. If this
221 behavior flag is not used, then value change is instead cancelled.
223 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
226 Calls wxBell() on validation failure.
228 wxPG_VFB_BEEP
= 0x02,
231 Cell with invalid value will be marked (with red colour).
233 wxPG_VFB_MARK_CELL
= 0x04,
236 Display a text message explaining the situation.
238 To customize the way the message is displayed, you need to
239 reimplement wxPropertyGrid::DoShowPropertyError() in a
240 derived class. Default behavior is to display the text on
241 the top-level frame's status bar, if present, and otherwise
244 wxPG_VFB_SHOW_MESSAGE
= 0x08,
247 Similar to wxPG_VFB_SHOW_MESSAGE, except always displays the
248 message using wxMessageBox.
250 wxPG_VFB_SHOW_MESSAGEBOX
= 0x10,
253 Similar to wxPG_VFB_SHOW_MESSAGE, except always displays the
254 message on the status bar (when present - you can reimplement
255 wxPropertyGrid::GetStatusBar() in a derived class to specify
258 wxPG_VFB_SHOW_MESSAGE_ON_STATUSBAR
= 0x20,
263 wxPG_VFB_DEFAULT
= wxPG_VFB_MARK_CELL
|
264 wxPG_VFB_SHOW_MESSAGEBOX
,
270 typedef wxByte wxPGVFBFlags
;
275 Used to convey validation information to and from functions that
276 actually perform validation. Mostly used in custom property classes.
278 class wxPGValidationInfo
282 @return Returns failure behavior which is a combination of
283 @ref propgrid_vfbflags.
285 wxPGVFBFlags
GetFailureBehavior();
288 Returns current failure message.
290 const wxString
& GetFailureMessage() const;
293 Returns reference to pending value.
295 wxVariant
& GetValue();
297 /** Set validation failure behavior
299 @param failureBehavior
300 Mixture of @ref propgrid_vfbflags.
302 void SetFailureBehavior(wxPGVFBFlags failureBehavior
);
305 Set current failure message.
307 void SetFailureMessage(const wxString
& message
);
310 // -----------------------------------------------------------------------
313 @section propgrid_keyboard_actions wxPropertyGrid Action Identifiers
315 These are used with wxPropertyGrid::AddActionTrigger() and
316 wxPropertyGrid::ClearActionTriggers().
320 enum wxPG_KEYBOARD_ACTIONS
322 wxPG_ACTION_INVALID
= 0,
324 /** Select the next property. */
325 wxPG_ACTION_NEXT_PROPERTY
,
327 /** Select the previous property. */
328 wxPG_ACTION_PREV_PROPERTY
,
330 /** Expand the selected property, if it has child items. */
331 wxPG_ACTION_EXPAND_PROPERTY
,
333 /** Collapse the selected property, if it has child items. */
334 wxPG_ACTION_COLLAPSE_PROPERTY
,
336 /** Cancel and undo any editing done in the currently active property
339 wxPG_ACTION_CANCEL_EDIT
,
341 /** Move focus to the editor control of the currently selected
346 /** Causes editor's button (if any) to be pressed. */
347 wxPG_ACTION_PRESS_BUTTON
,
355 /** This callback function is used for sorting properties.
357 Call wxPropertyGrid::SetSortFunction() to set it.
359 Sort function should return a value greater than 0 if position of p1 is
360 after p2. So, for instance, when comparing property names, you can use
361 following implementation:
364 int MyPropertySortFunction(wxPropertyGrid* propGrid,
368 return p1->GetBaseName().compare( p2->GetBaseName() );
372 typedef int (*wxPGSortCallback
)(wxPropertyGrid
* propGrid
,
376 // -----------------------------------------------------------------------
379 @class wxPropertyGrid
381 wxPropertyGrid is a specialized grid for editing properties - in other
382 words name = value pairs. List of ready-to-use property classes include
383 strings, numbers, flag sets, fonts, colours and many others. It is possible,
384 for example, to categorize properties, set up a complete tree-hierarchy,
385 add more than two columns, and set arbitrary per-property attributes.
387 Please note that most member functions are inherited and as such not
388 documented on this page. This means you will probably also want to read
389 wxPropertyGridInterface class reference.
391 See also @ref overview_propgrid.
393 @section propgrid_window_styles_ Window Styles
395 See @ref propgrid_window_styles.
397 @section propgrid_event_handling Event Handling
399 To process input from a property grid control, use these event handler macros
400 to direct input to member functions that take a wxPropertyGridEvent argument.
402 @beginEventEmissionTable{wxPropertyGridEvent}
403 @event{EVT_PG_SELECTED (id, func)}
404 Respond to @c wxEVT_PG_SELECTED event, generated when a property selection
405 has been changed, either by user action or by indirect program
406 function. For instance, collapsing a parent property programmatically
407 causes any selected child property to become unselected, and may
408 therefore cause this event to be generated.
409 @event{EVT_PG_CHANGED(id, func)}
410 Respond to @c wxEVT_PG_CHANGED event, generated when property value
411 has been changed by the user.
412 @event{EVT_PG_CHANGING(id, func)}
413 Respond to @c wxEVT_PG_CHANGING event, generated when property value
414 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
415 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
416 to prevent change from taking place, if necessary.
417 @event{EVT_PG_HIGHLIGHTED(id, func)}
418 Respond to @c wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
419 moves over a property. Event's property is NULL if hovered area does
420 not belong to any property.
421 @event{EVT_PG_RIGHT_CLICK(id, func)}
422 Respond to @c wxEVT_PG_RIGHT_CLICK event, which occurs when property is
423 clicked on with right mouse button.
424 @event{EVT_PG_DOUBLE_CLICK(id, func)}
425 Respond to @c wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
426 double-clicked on with left mouse button.
427 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
428 Respond to @c wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
429 a property or category.
430 @event{EVT_PG_ITEM_EXPANDED(id, func)}
431 Respond to @c wxEVT_PG_ITEM_EXPANDED event, generated when user expands
432 a property or category.
433 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
434 Respond to @c wxEVT_PG_LABEL_EDIT_BEGIN event, generated when user is
435 about to begin editing a property label. You can veto this event to
437 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
438 Respond to @c wxEVT_PG_LABEL_EDIT_ENDING event, generated when user is
439 about to end editing of a property label. You can veto this event to
441 @event{EVT_PG_COL_BEGIN_DRAG(id, func)}
442 Respond to @c wxEVT_PG_COL_BEGIN_DRAG event, generated when user
443 starts resizing a column - can be vetoed.
444 @event{EVT_PG_COL_DRAGGING,(id, func)}
445 Respond to @c wxEVT_PG_COL_DRAGGING, event, generated when a
446 column resize by user is in progress. This event is also generated
447 when user double-clicks the splitter in order to recenter
449 @event{EVT_PG_COL_END_DRAG(id, func)}
450 Respond to @c wxEVT_PG_COL_END_DRAG event, generated after column
451 resize by user has finished.
455 Use Freeze() and Thaw() respectively to disable and enable drawing.
456 This will also delay sorting etc. miscellaneous calculations to the last
461 @appearance{propertygrid.png}
463 class wxPropertyGrid
: public wxControl
,
464 public wxScrollHelper
,
465 public wxPropertyGridInterface
469 Two step constructor.
470 Call Create() when this constructor is called to build up the wxPropertyGrid
476 The styles to be used are styles valid for the wxWindow.
478 @see @ref propgrid_window_styles.
480 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
481 const wxPoint
& pos
= wxDefaultPosition
,
482 const wxSize
& size
= wxDefaultSize
,
483 long style
= wxPG_DEFAULT_STYLE
,
484 const wxChar
* name
= wxPropertyGridNameStr
);
487 virtual ~wxPropertyGrid();
490 Adds given key combination to trigger given action.
492 Here is a sample code to make Enter key press move focus to
496 propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
498 propGrid->DedicateKey(WXK_RETURN);
502 Which action to trigger. See @ref propgrid_keyboard_actions.
504 Which keycode triggers the action.
506 Which key event modifiers, in addition to keycode, are needed to
509 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
512 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
513 extra style is not used, then this has same effect as
514 calling SelectProperty().
516 @remarks Multiple selection is not supported for categories. This
517 means that if you have properties selected, you cannot
518 add category to selection, and also if you have category
519 selected, you cannot add other properties to selection.
520 This member function will fail silently in these cases,
523 bool AddToSelection( wxPGPropArg id
);
526 This static function enables or disables automatic use of
527 wxGetTranslation() for following strings: wxEnumProperty list labels,
528 wxFlagsProperty child property labels.
532 static void AutoGetTranslation( bool enable
);
535 Creates label editor wxTextCtrl for given column, for property
536 that is currently selected. When multiple selection is
537 enabled, this applies to whatever property GetSelection()
541 Which column's label to edit. Note that you should not
542 use value 1, which is reserved for property value
545 @see EndLabelEdit(), MakeColumnEditable()
547 void BeginLabelEdit( unsigned int colIndex
= 0 );
550 Changes value of a property, as if from an editor. Use this instead of
551 SetPropertyValue() if you need the value to run through validation
552 process, and also send the property change event.
554 @return Returns true if value was successfully changed.
556 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
559 Centers the splitter.
561 @param enableAutoResizing
562 If @true, automatic column resizing is enabled (only applicapple
563 if window style wxPG_SPLITTER_AUTO_CENTER is used).
565 void CenterSplitter( bool enableAutoResizing
= false );
568 Deletes all properties.
570 virtual void Clear();
573 Clears action triggers for given action.
576 Which action to trigger. @ref propgrid_keyboard_actions.
578 void ClearActionTriggers( int action
);
581 Forces updating the value of property from the editor control.
582 Note that @c wxEVT_PG_CHANGING and @c wxEVT_PG_CHANGED are dispatched using
583 ProcessEvent, meaning your event handlers will be called immediately.
585 @return Returns @true if anything was changed.
587 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
590 Two step creation. Whenever the control is created without any
591 parameters, use Create to actually create it. Don't access the control's
592 public methods before this is called
594 @see @ref propgrid_window_styles.
596 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
597 const wxPoint
& pos
= wxDefaultPosition
,
598 const wxSize
& size
= wxDefaultSize
,
599 long style
= wxPG_DEFAULT_STYLE
,
600 const wxChar
* name
= wxPropertyGridNameStr
);
603 Dedicates a specific keycode to wxPropertyGrid. This means that such
604 key presses will not be redirected to editor controls.
606 Using this function allows, for example, navigation between
607 properties using arrow keys even when the focus is in the editor
610 void DedicateKey( int keycode
);
613 Enables or disables (shows/hides) categories according to parameter
616 @remarks This functions deselects selected property, if any. Validation
617 failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
618 selection is cleared even if editor had invalid value.
620 bool EnableCategories( bool enable
);
623 Destroys label editor wxTextCtrl, if any.
626 Use @true (default) to store edited label text in
629 @see BeginLabelEdit(), MakeColumnEditable()
631 void EndLabelEdit( bool commit
= true );
634 Scrolls and/or expands items to ensure that the given item is visible.
636 @return Returns @true if something was actually done.
638 bool EnsureVisible( wxPGPropArg id
);
641 Reduces column sizes to minimum possible, while still retaining
642 fully visible grid contents (labels, images).
644 @return Minimum size for the grid to still display everything.
646 @remarks Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
648 This function only works properly if grid size prior to call was
649 already fairly large.
651 Note that you can also get calculated column widths by calling
652 GetState->GetColumnWidth() immediately after this function
658 Returns currently active label editor, NULL if none.
660 wxTextCtrl
* GetLabelEditor() const;
663 Returns wxWindow that the properties are painted on, and which should be
664 used as the parent for editor controls.
666 wxWindow
* GetPanel();
669 Returns current category caption background colour.
671 wxColour
GetCaptionBackgroundColour() const;
674 Returns current category caption font.
676 wxFont
& GetCaptionFont();
679 Returns current category caption text colour.
681 wxColour
GetCaptionForegroundColour() const;
684 Returns current cell background colour.
686 wxColour
GetCellBackgroundColour() const;
689 Returns current cell text colour when disabled.
691 wxColour
GetCellDisabledTextColour() const;
694 Returns current cell text colour.
696 wxColour
GetCellTextColour() const;
699 Returns number of columns currently on grid.
701 unsigned int GetColumnCount() const;
704 Returns colour of empty space below properties.
706 wxColour
GetEmptySpaceColour() const;
709 Returns height of highest characters of used font.
711 int GetFontHeight() const;
714 Returns pointer to itself. Dummy function that enables same kind
715 of code to use wxPropertyGrid and wxPropertyGridManager.
717 wxPropertyGrid
* GetGrid();
720 Returns rectangle of custom paint image.
723 Return image rectangle for this property.
726 Which choice of property to use (each choice may have
729 wxRect
GetImageRect( wxPGProperty
* property
, int item
) const;
732 Returns size of the custom paint image in front of property.
735 Return image rectangle for this property.
736 If this argument is NULL, then preferred size is returned.
739 Which choice of property to use (each choice may have
742 wxSize
GetImageSize( wxPGProperty
* property
= NULL
, int item
= -1 ) const;
745 Returns last item which could be iterated using given flags.
748 See @ref propgrid_iterator_flags.
750 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
);
753 Returns colour of lines between cells.
755 wxColour
GetLineColour() const;
758 Returns background colour of margin.
760 wxColour
GetMarginColour() const;
763 Returns "root property". It does not have name, etc. and it is not
764 visible. It is only useful for accessing its children.
766 wxPGProperty
* GetRoot() const;
769 Returns height of a single grid row (in pixels).
771 int GetRowHeight() const;
774 Returns currently selected property.
776 wxPGProperty
* GetSelectedProperty() const;
779 Returns currently selected property.
781 wxPGProperty
* GetSelection() const;
784 Returns current selection background colour.
786 wxColour
GetSelectionBackgroundColour() const;
789 Returns current selection text colour.
791 wxColour
GetSelectionForegroundColour() const;
794 Returns the property sort function (default is @NULL).
798 wxPGSortCallback
GetSortFunction() const;
801 Returns current splitter x position.
803 int GetSplitterPosition( unsigned int splitterIndex
= 0 ) const;
806 Returns wxTextCtrl active in currently selected property, if any. Takes
807 wxOwnerDrawnComboBox into account.
809 wxTextCtrl
* GetEditorTextCtrl() const;
812 Returns current appearance of unspecified value cells.
814 @see SetUnspecifiedValueAppearance()
816 const wxPGCell
& GetUnspecifiedValueAppearance() const;
819 Returns (visual) text representation of the unspecified
822 @param argFlags For internal use only.
824 wxString
GetUnspecifiedValueText( int argFlags
= 0 ) const;
827 Returns current vertical spacing.
829 int GetVerticalSpacing() const;
832 Returns information about arbitrary position in the grid.
835 Coordinates in the virtual grid space. You may need to use
836 wxScrolled<T>::CalcScrolledPosition() for translating
837 wxPropertyGrid client coordinates into something this member
840 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
843 Returns true if any property has been modified by the user.
845 bool IsAnyModified() const;
848 Returns @true if a property editor control has focus.
850 bool IsEditorFocused() const;
853 Returns true if updating is frozen (ie. Freeze() called but not
856 bool IsFrozen() const;
859 Makes given column editable by user.
862 The index of the column to make editable.
864 Using @false here will disable column from being editable.
866 @see BeginLabelEdit(), EndLabelEdit()
868 void MakeColumnEditable( unsigned int column
, bool editable
= true );
871 It is recommended that you call this function any time your code causes
872 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
873 handler should be able to detect most changes, but it is not perfect.
876 New top-level parent that is about to be set. Old top-level parent
877 window should still exist as the current one.
879 @remarks This function is automatically called from wxPropertyGrid::
880 Reparent() and wxPropertyGridManager::Reparent(). You only
881 need to use it if you reparent wxPropertyGrid indirectly.
883 void OnTLPChanging( wxWindow
* newTLP
);
886 Refreshes any active editor control.
888 void RefreshEditor();
891 Redraws given property.
893 virtual void RefreshProperty( wxPGProperty
* p
);
896 Registers a new editor class.
898 @return Returns pointer to the editor class instance that should be used.
900 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
901 const wxString
& name
,
902 bool noDefCheck
= false );
905 Resets all colours to the original system values.
910 Resets column sizes and splitter positions, based on proportions.
912 @param enableAutoResizing
913 If @true, automatic column resizing is enabled (only applicapple
914 if window style wxPG_SPLITTER_AUTO_CENTER is used).
916 @see wxPropertyGridInterface::SetColumnProportion()
918 void ResetColumnSizes( bool enableAutoResizing
= false );
921 Removes given property from selection. If property is not selected,
922 an assertion failure will occur.
924 bool RemoveFromSelection( wxPGPropArg id
);
927 Selects a property. Editor widget is automatically created, but
928 not focused unless focus is true.
931 Property to select (name or pointer).
934 If @true, move keyboard focus to the created editor right away.
936 @return returns @true if selection finished successfully. Usually only
937 fails if current value in editor is not valid.
939 @remarks In wxPropertyGrid 1.4, this member function used to generate
940 @c wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
943 @remarks This clears any previous selection.
945 @see wxPropertyGridInterface::ClearSelection()
947 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
950 Changes keyboard shortcut to push the editor button.
952 @remarks You can set default with keycode 0. Good value for the platform
953 is guessed, but don't expect it to be very accurate.
955 void SetButtonShortcut( int keycode
, bool ctrlDown
= false, bool altDown
= false );
958 Sets category caption background colour.
960 void SetCaptionBackgroundColour(const wxColour
& col
);
963 Sets category caption text colour.
965 void SetCaptionTextColour(const wxColour
& col
);
968 Sets default cell background colour - applies to property cells.
969 Note that appearance of editor widgets may not be affected.
971 void SetCellBackgroundColour(const wxColour
& col
);
974 Sets cell text colour for disabled properties.
976 void SetCellDisabledTextColour(const wxColour
& col
);
979 Sets default cell text colour - applies to property name and value text.
980 Note that appearance of editor widgets may not be affected.
982 void SetCellTextColour(const wxColour
& col
);
985 Set number of columns (2 or more).
987 void SetColumnCount( int colCount
);
990 Sets the 'current' category - Append will add non-category properties
993 void SetCurrentCategory( wxPGPropArg id
);
996 Sets colour of empty space below properties.
998 void SetEmptySpaceColour(const wxColour
& col
);
1001 Sets colour of lines between cells.
1003 void SetLineColour(const wxColour
& col
);
1006 Sets background colour of margin.
1008 void SetMarginColour(const wxColour
& col
);
1011 Set entire new selection from given list of properties.
1013 void SetSelection( const wxArrayPGProperty
& newSelection
);
1016 Sets selection background colour - applies to selected property name
1019 void SetSelectionBackgroundColour(const wxColour
& col
);
1022 Sets selection foreground colour - applies to selected property name text.
1024 void SetSelectionTextColour(const wxColour
& col
);
1028 Sets the property sorting function.
1031 The sorting function to be used. It should return a value greater
1032 than 0 if position of p1 is after p2. So, for instance, when
1033 comparing property names, you can use following implementation:
1036 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1040 return p1->GetBaseName().compare( p2->GetBaseName() );
1045 Default property sort function sorts properties by their labels
1046 (case-insensitively).
1048 @see GetSortFunction, wxPropertyGridInterface::Sort,
1049 wxPropertyGridInterface::SortChildren
1051 void SetSortFunction( wxPGSortCallback sortFunction
);
1054 Sets x coordinate of the splitter.
1056 @remarks Splitter position cannot exceed grid size, and therefore setting
1057 it during form creation may fail as initial grid size is often
1058 smaller than desired splitter position, especially when sizers
1061 void SetSplitterPosition( int newxpos
, int col
= 0 );
1064 Moves splitter as left as possible, while still allowing all
1065 labels to be shown in full.
1067 @param privateChildrenToo
1068 If @false, will still allow private children to be cropped.
1070 void SetSplitterLeft( bool privateChildrenToo
= false );
1073 Sets appearance of value cells representing an unspecified property
1074 value. Default appearance is blank.
1076 @remarks If you set the unspecified value to have any
1077 textual representation, then that will override
1078 "InlineHelp" attribute.
1080 @see wxPGProperty::SetValueToUnspecified(),
1081 wxPGProperty::IsValueUnspecified()
1083 void SetUnspecifiedValueAppearance( const wxPGCell
& cell
);
1086 Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1087 height. Value of 2 should be default on most platforms.
1089 void SetVerticalSpacing( int vspacing
);
1092 @name wxPropertyGrid customization
1094 Reimplement these member functions in derived class for better
1095 control over wxPropertyGrid behavior.
1100 Override in derived class to display error messages in custom manner
1101 (these message usually only result from validation failure).
1103 @remarks If you implement this, then you also need to implement
1104 DoHidePropertyError() - possibly to do nothing, if error
1105 does not need hiding (e.g. it was logged or shown in a
1108 @see DoHidePropertyError()
1110 virtual void DoShowPropertyError( wxPGProperty
* property
,
1111 const wxString
& msg
);
1114 Override in derived class to hide an error displayed by
1115 DoShowPropertyError().
1117 @see DoShowPropertyError()
1119 virtual void DoHidePropertyError( wxPGProperty
* property
);
1122 Return wxStatusBar that is used by this wxPropertyGrid. You can
1123 reimplement this member function in derived class to override
1124 the default behavior of using the top-level wxFrame's status
1127 virtual wxStatusBar
* GetStatusBar();
1132 @name Property development functions
1134 These member functions are usually only called when creating custom
1140 Call when editor widget's contents is modified. For example, this is
1141 called when changes text in wxTextCtrl (used in wxStringProperty and
1144 @remarks This function should only be called by custom properties.
1146 @see wxPGProperty::OnEvent()
1148 void EditorsValueWasModified();
1151 Reverse of EditorsValueWasModified().
1153 @remarks This function should only be called by custom properties.
1155 void EditorsValueWasNotModified();
1158 Returns most up-to-date value of selected property. This will return
1159 value different from GetSelectedProperty()->GetValue() only when text
1160 editor is activate and string edited by user represents valid,
1161 uncommitted property value.
1163 wxVariant
GetUncommittedPropertyValue();
1166 Returns true if editor's value was marked modified.
1168 bool IsEditorsValueModified() const;
1171 Shows an brief error message that is related to a property.
1173 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
);
1176 You can use this member function, for instance, to detect in
1177 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1178 already called in wxPGEditor::OnEvent(). It really only detects
1179 if was value was changed using wxPGProperty::SetValueInEvent(), which
1180 is usually used when a 'picker' dialog is displayed. If value was
1181 written by "normal means" in wxPGProperty::StringToValue() or
1182 IntToValue(), then this function will return false (on the other hand,
1183 wxPGProperty::OnEvent() is not even called in those cases).
1185 bool WasValueChangedInEvent() const;
1192 @class wxPropertyGridEvent
1194 A property grid event holds information about events associated with
1195 wxPropertyGrid objects.
1197 @library{wxpropgrid}
1200 class wxPropertyGridEvent
: public wxCommandEvent
1205 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
1207 /** Copy constructor. */
1208 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
1211 ~wxPropertyGridEvent();
1214 Returns true if you can veto the action that the event is signaling.
1216 bool CanVeto() const;
1219 Returns the column index associated with this event.
1220 For the column dragging events, it is the column to the left
1221 of the splitter being dragged
1223 unsigned int GetColumn() const;
1226 Returns highest level non-category, non-root parent of property for
1227 which event occurred. Useful when you have nested properties with
1230 @remarks If immediate parent is root or category, this will return the
1233 wxPGProperty
* GetMainParent() const;
1236 Returns property associated with this event.
1238 @remarks You should assume that this property can always be NULL.
1239 For instance, @c wxEVT_PG_SELECTED is emitted not only when
1240 a new property is selected, but also when selection is
1241 cleared by user activity.
1243 wxPGProperty
* GetProperty() const;
1246 Returns current validation failure flags.
1248 wxPGVFBFlags
GetValidationFailureBehavior() const;
1251 Returns name of the associated property.
1253 @remarks Property name is stored in event, so it remains
1254 accessible even after the associated property or
1255 the property grid has been deleted.
1257 wxString
GetPropertyName() const;
1260 Returns value of the associated property. Works for all event
1261 types, but for @c wxEVT_PG_CHANGING this member function returns
1262 the value that is pending, so you can call Veto() if the
1263 value is not satisfactory.
1265 @remarks Property value is stored in event, so it remains
1266 accessible even after the associated property or
1267 the property grid has been deleted.
1269 wxVariant
GetPropertyValue() const
1272 @see GetPropertyValue()
1274 wxVariant
GetValue() const;
1277 Set if event can be vetoed.
1279 void SetCanVeto( bool canVeto
);
1281 /** Changes the property associated with this event. */
1282 void SetProperty( wxPGProperty
* p
);
1285 Set override validation failure behavior. Only effective if Veto() was
1286 also called, and only allowed if event type is @c wxEVT_PG_CHANGING.
1288 void SetValidationFailureBehavior( wxPGVFBFlags flags
);
1291 Sets custom failure message for this time only. Only applies if
1292 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
1294 void SetValidationFailureMessage( const wxString
& message
);
1297 Call this from your event handler to veto action that the event is
1298 signaling. You can only veto a shutdown if wxPropertyGridEvent::CanVeto()
1301 @remarks Currently only @c wxEVT_PG_CHANGING supports vetoing.
1303 void Veto( bool veto
= true );
1306 Returns @true if event was vetoed.
1308 bool WasVetoed() const;