1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPGRID_H_
13 #define _WX_PROPGRID_PROPGRID_H_
17 #include "wx/thread.h"
18 #include "wx/dcclient.h"
19 #include "wx/scrolwin.h"
20 #include "wx/tooltip.h"
21 #include "wx/datetime.h"
23 #include "wx/propgrid/property.h"
24 #include "wx/propgrid/propgridiface.h"
28 extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr
[];
33 // -----------------------------------------------------------------------
35 // -----------------------------------------------------------------------
39 // This is required for sharing common global variables.
40 class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
44 wxPGGlobalVarsClass();
45 ~wxPGGlobalVarsClass();
48 // Critical section for handling the globals. Generally it is not needed
49 // since GUI code is supposed to be in single thread. However,
50 // we do want the user to be able to convey wxPropertyGridEvents to other
52 wxCriticalSection m_critSect
;
55 // Used by advprops, but here to make things easier.
56 wxString m_pDefaultImageWildcard
;
58 // Map of editor class instances (keys are name string).
59 wxPGHashMapS2P m_mapEditorClasses
;
62 wxVector
<wxValidator
*> m_arrValidators
; // These wxValidators need to be freed
65 wxPGHashMapS2P m_dictPropertyClassInfo
; // PropertyName -> ClassInfo
67 wxPGChoices
* m_fontFamilyChoices
;
69 // Replace with your own to affect all properties using default renderer.
70 wxPGCellRenderer
* m_defaultRenderer
;
72 wxPGChoices m_boolChoices
;
74 wxVariant m_vEmptyString
;
76 wxVariant m_vMinusOne
;
80 // Cached constant strings
81 wxPGCachedString m_strstring
;
82 wxPGCachedString m_strlong
;
83 wxPGCachedString m_strbool
;
84 wxPGCachedString m_strlist
;
86 wxPGCachedString m_strDefaultValue
;
87 wxPGCachedString m_strMin
;
88 wxPGCachedString m_strMax
;
89 wxPGCachedString m_strUnits
;
90 wxPGCachedString m_strInlineHelp
;
92 // If true then some things are automatically translated
93 bool m_autoGetTranslation
;
95 // > 0 if errors cannot or should not be shown in statusbar etc.
98 int m_extraStyle
; // global extra style
102 int HasExtraStyle( int style
) const { return (m_extraStyle
& style
); }
105 extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
* wxPGGlobalVars
;
107 #define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
108 #define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
109 #define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
110 #define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
111 #define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
113 #define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
115 // When wxPG is loaded dynamically after the application is already running
116 // then the built-in module system won't pick this one up. Add it manually.
117 WXDLLIMPEXP_PROPGRID
void wxPGInitResourceModule();
121 // -----------------------------------------------------------------------
123 /** @section propgrid_window_styles wxPropertyGrid Window Styles
125 SetWindowStyleFlag method can be used to modify some of these at run-time.
128 enum wxPG_WINDOW_STYLES
131 /** This will cause Sort() automatically after an item is added.
132 When inserting a lot of items in this mode, it may make sense to
133 use Freeze() before operations and Thaw() afterwards to increase
136 wxPG_AUTO_SORT
= 0x00000010,
138 /** Categories are not initially shown (even if added).
139 IMPORTANT NOTE: If you do not plan to use categories, then this
140 style will waste resources.
141 This flag can also be changed using wxPropertyGrid::EnableCategories method.
143 wxPG_HIDE_CATEGORIES
= 0x00000020,
145 /* This style combines non-categoric mode and automatic sorting.
147 wxPG_ALPHABETIC_MODE
= (wxPG_HIDE_CATEGORIES
|wxPG_AUTO_SORT
),
149 /** Modified values are shown in bold font. Changing this requires Refresh()
152 wxPG_BOLD_MODIFIED
= 0x00000040,
154 /** When wxPropertyGrid is resized, splitter moves to the center. This
155 behavior stops once the user manually moves the splitter.
157 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
159 /** Display tooltips for cell text that cannot be shown completely. If
160 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
162 wxPG_TOOLTIPS
= 0x00000100,
164 /** Disables margin and hides all expand/collapse buttons that would appear
165 outside the margin (for sub-properties). Toggling this style automatically
166 expands all collapsed items.
168 wxPG_HIDE_MARGIN
= 0x00000200,
170 /** This style prevents user from moving the splitter.
172 wxPG_STATIC_SPLITTER
= 0x00000400,
174 /** Combination of other styles that make it impossible for user to modify
177 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
179 /** Disables wxTextCtrl based editors for properties which
180 can be edited in another way.
182 Equals calling wxPropertyGrid::LimitPropertyEditing for all added
185 wxPG_LIMITED_EDITING
= 0x00000800,
187 /** wxPropertyGridManager only: Show toolbar for mode and page selection. */
188 wxPG_TOOLBAR
= 0x00001000,
190 /** wxPropertyGridManager only: Show adjustable text box showing description
191 or help text, if available, for currently selected property.
193 wxPG_DESCRIPTION
= 0x00002000,
195 /** wxPropertyGridManager only: don't show an internal border around the
196 property grid. Recommended if you use a header.
198 wxPG_NO_INTERNAL_BORDER
= 0x00004000
201 #if wxPG_COMPATIBILITY_1_4
202 // In wxPG 1.4 this was used to enable now-default theme border support
203 // in wxPropertyGridManager.
204 #define wxPG_THEME_BORDER 0x00000000
208 enum wxPG_EX_WINDOW_STYLES
212 NOTE: wxPG_EX_xxx are extra window styles and must be set using
213 SetExtraStyle() member function.
215 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
216 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
217 not activated, and switching the mode first time becomes somewhat slower.
218 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
219 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
220 you don't plan to use categories at all, then using this style will result
221 in waste of resources.
224 wxPG_EX_INIT_NOCAT
= 0x00001000,
226 /** Extended window style that sets wxPropertyGridManager toolbar to not
229 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
231 /** Shows alphabetic/categoric mode buttons from toolbar.
233 wxPG_EX_MODE_BUTTONS
= 0x00008000,
235 /** Show property help strings as tool tips instead as text on the status bar.
236 You can set the help strings using SetPropertyHelpString member function.
238 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
240 /** Prevent TAB from focusing to wxButtons. This behavior was default
241 in version 1.2.0 and earlier.
242 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
243 atleast the button doesn't properly propagate key events (yes, I'm using
246 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
248 /** Allows relying on native double-buffering.
250 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
252 /** Set this style to let user have ability to set values of properties to
253 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
256 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
259 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
260 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
261 (thus they are not readable).
263 Note that this option is global, and applies to all wxPG property
266 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
268 /** Hides page selection buttons from toolbar.
270 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
272 /** Allows multiple properties to be selected by user (by pressing SHIFT
273 when clicking on a property, or by dragging with left mouse button
276 You can get array of selected properties with
277 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
278 mode wxPropertyGridInterface::GetSelection() returns
279 property which has editor active (usually the first one
280 selected). Other useful member functions are ClearSelection(),
281 AddToSelection() and RemoveFromSelection().
283 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
286 This enables top-level window tracking which allows wxPropertyGrid to
287 notify the application of last-minute property value changes by user.
289 This style is not enabled by default because it may cause crashes when
290 wxPropertyGrid is used in with wxAUI or similar system.
292 @remarks If you are not in fact using any system that may change
293 wxPropertyGrid's top-level parent window on its own, then you
294 are recommended to enable this style.
296 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
298 /** Don't show divider above toolbar, on Windows.
300 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x08000000,
302 /** Show a separator below the toolbar.
304 wxPG_EX_TOOLBAR_SEPARATOR
= 0x10000000
308 #if wxPG_COMPATIBILITY_1_4
309 #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
312 /** Combines various styles.
314 #define wxPG_DEFAULT_STYLE (0)
316 /** Combines various styles.
318 #define wxPGMAN_DEFAULT_STYLE (0)
323 // -----------------------------------------------------------------------
326 // Ids for sub-controls
327 // NB: It should not matter what these are.
328 #define wxPG_SUBID1 2
329 #define wxPG_SUBID2 3
330 #define wxPG_SUBID_TEMP1 4
332 // -----------------------------------------------------------------------
334 /** @class wxPGCommonValue
336 wxPropertyGrid stores information about common values in these
339 NB: Common value feature is not complete, and thus not mentioned in
342 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
346 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
349 m_renderer
= renderer
;
352 virtual ~wxPGCommonValue()
354 m_renderer
->DecRef();
357 virtual wxString
GetEditableText() const { return m_label
; }
358 const wxString
& GetLabel() const { return m_label
; }
359 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
363 wxPGCellRenderer
* m_renderer
;
366 // -----------------------------------------------------------------------
368 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
372 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
375 /** Prevents user from leaving property unless value is valid. If this
376 behavior flag is not used, then value change is instead cancelled.
378 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
380 /** Calls wxBell() on validation failure.
382 wxPG_VFB_BEEP
= 0x02,
384 /** Cell with invalid value will be marked (with red colour).
386 wxPG_VFB_MARK_CELL
= 0x04,
388 /** Display customizable text message explaining the situation.
390 wxPG_VFB_SHOW_MESSAGE
= 0x08,
393 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
395 /** Only used internally. */
396 wxPG_VFB_UNDEFINED
= 0x80
403 typedef wxByte wxPGVFBFlags
;
408 Used to convey validation information to and from functions that
409 actually perform validation. Mostly used in custom property
412 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
414 friend class wxPropertyGrid
;
417 @return Returns failure behavior which is a combination of
418 @ref propgrid_vfbflags.
420 wxPGVFBFlags
GetFailureBehavior() const
421 { return m_failureBehavior
; }
424 Returns current failure message.
426 const wxString
& GetFailureMessage() const
427 { return m_failureMessage
; }
430 Returns reference to pending value.
432 wxVariant
& GetValue()
438 /** Set validation failure behavior
440 @param failureBehavior
441 Mixture of @ref propgrid_vfbflags.
443 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
444 { m_failureBehavior
= failureBehavior
; }
447 Set current failure message.
449 void SetFailureMessage(const wxString
& message
)
450 { m_failureMessage
= message
; }
453 /** Value to be validated.
457 /** Message displayed on validation failure.
459 wxString m_failureMessage
;
461 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
463 wxPGVFBFlags m_failureBehavior
;
466 // -----------------------------------------------------------------------
468 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
470 These are used with wxPropertyGrid::AddActionTrigger() and
471 wxPropertyGrid::ClearActionTriggers().
475 enum wxPG_KEYBOARD_ACTIONS
477 wxPG_ACTION_INVALID
= 0,
478 wxPG_ACTION_NEXT_PROPERTY
,
479 wxPG_ACTION_PREV_PROPERTY
,
480 wxPG_ACTION_EXPAND_PROPERTY
,
481 wxPG_ACTION_COLLAPSE_PROPERTY
,
482 wxPG_ACTION_CANCEL_EDIT
,
483 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
490 // -----------------------------------------------------------------------
493 // wxPropertyGrid::DoSelectProperty flags (selFlags)
495 // Focuses to created editor
496 #define wxPG_SEL_FOCUS 0x0001
497 // Forces deletion and recreation of editor
498 #define wxPG_SEL_FORCE 0x0002
499 // For example, doesn't cause EnsureVisible
500 #define wxPG_SEL_NONVISIBLE 0x0004
501 // Do not validate editor's value before selecting
502 #define wxPG_SEL_NOVALIDATE 0x0008
503 // Property being deselected is about to be deleted
504 #define wxPG_SEL_DELETING 0x0010
505 // Property's values was set to unspecified by the user
506 #define wxPG_SEL_SETUNSPEC 0x0020
507 // Property's event handler changed the value
508 #define wxPG_SEL_DIALOGVAL 0x0040
509 // Set to disable sending of wxEVT_PG_SELECTED event
510 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
511 // Don't make any graphics updates
512 #define wxPG_SEL_NO_REFRESH 0x0100
514 // -----------------------------------------------------------------------
516 // DoSetSplitterPosition() flags
518 enum wxPG_SET_SPLITTER_POSITION_SPLITTER_FLAGS
520 wxPG_SPLITTER_REFRESH
= 0x0001,
521 wxPG_SPLITTER_ALL_PAGES
= 0x0002,
522 wxPG_SPLITTER_FROM_EVENT
= 0x0004,
523 wxPG_SPLITTER_FROM_AUTO_CENTER
= 0x0008
527 // -----------------------------------------------------------------------
532 #define wxPG_FL_INITIALIZED 0x0001
533 // Set when creating editor controls if it was clicked on.
534 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
535 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
536 #define wxPG_FL_FOCUSED 0x0008
537 #define wxPG_FL_MOUSE_CAPTURED 0x0010
538 #define wxPG_FL_MOUSE_INSIDE 0x0020
539 #define wxPG_FL_VALUE_MODIFIED 0x0040
540 // don't clear background of m_wndEditor
541 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
542 // currently active editor uses custom image
543 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
544 // cell colours override selection colours for selected cell
545 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
546 #define wxPG_FL_SCROLLED 0x0400
547 // set when all added/inserted properties get hideable flag
548 #define wxPG_FL_ADDING_HIDEABLES 0x0800
549 // Disables showing help strings on statusbar.
550 #define wxPG_FL_NOSTATUSBARHELP 0x1000
551 // Marks that we created the state, so we have to destroy it too.
552 #define wxPG_FL_CREATEDSTATE 0x2000
553 // Set if scrollbar's existence was detected in last onresize.
554 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
555 // Set if wxPGMan requires redrawing of description text box.
556 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
557 // Set if contained in wxPropertyGridManager
558 #define wxPG_FL_IN_MANAGER 0x00020000
559 // Set after wxPropertyGrid is shown in its initial good size
560 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
561 // Set when in SelectProperty.
562 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
563 // Set when help string is shown in status bar
564 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
565 // Validation failed. Clear on modify event.
566 #define wxPG_FL_VALIDATION_FAILED 0x00800000
567 // Auto sort is enabled (for categorized mode)
568 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
569 // Set after page has been inserted to manager
570 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
571 // Active editor control is abnormally large
572 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
573 // Recursion guard for HandleCustomEditorEvent
574 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
575 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
576 // Editor control width should not change on resize
577 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
578 // Width of panel can be different than width of grid
579 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
580 // Prevents RecalculateVirtualSize re-entrancy
581 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
583 #endif // #ifndef SWIG
585 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
586 // Reduce compile time, but still include in user app
587 #include "wx/propgrid/props.h"
590 // -----------------------------------------------------------------------
592 /** @class wxPropertyGrid
594 wxPropertyGrid is a specialized grid for editing properties
595 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
596 used to do the very same thing, but it hasn't been updated for a while
597 and it is currently deprecated.
599 Please note that most member functions are inherited and as such not
600 documented on this page. This means you will probably also want to read
601 wxPropertyGridInterface class reference.
603 See also @ref overview_propgrid.
605 @section propgrid_window_styles_ Window Styles
607 See @ref propgrid_window_styles.
609 @section propgrid_event_handling Event Handling
611 To process input from a propertygrid control, use these event handler
612 macros to direct input to member functions that take a wxPropertyGridEvent
615 @beginEventTable{wxPropertyGridEvent}
616 @event{EVT_PG_SELECTED (id, func)}
617 Respond to wxEVT_PG_SELECTED event, generated when a property selection
618 has been changed, either by user action or by indirect program
619 function. For instance, collapsing a parent property programmatically
620 causes any selected child property to become unselected, and may
621 therefore cause this event to be generated.
622 @event{EVT_PG_CHANGING(id, func)}
623 Respond to wxEVT_PG_CHANGING event, generated when property value
624 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
625 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
626 to prevent change from taking place, if necessary.
627 @event{EVT_PG_HIGHLIGHTED(id, func)}
628 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
629 moves over a property. Event's property is NULL if hovered area does
630 not belong to any property.
631 @event{EVT_PG_RIGHT_CLICK(id, func)}
632 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
633 clicked on with right mouse button.
634 @event{EVT_PG_DOUBLE_CLICK(id, func)}
635 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
636 double-clicked onwith left mouse button.
637 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
638 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
639 a property or category..
640 @event{EVT_PG_ITEM_EXPANDED(id, func)}
641 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
642 a property or category..
643 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
644 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
645 begin editing a property label. You can veto this event to prevent the
647 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
648 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
649 end editing of a property label. You can veto this event to prevent the
651 @event{EVT_PG_COL_BEGIN_DRAG(id, func)}
652 Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user
653 starts resizing a column - can be vetoed.
654 @event{EVT_PG_COL_DRAGGING,(id, func)}
655 Respond to wxEVT_PG_COL_DRAGGING, event, generated when a
656 column resize by user is in progress. This event is also generated
657 when user double-clicks the splitter in order to recenter
659 @event{EVT_PG_COL_END_DRAG(id, func)}
660 Respond to wxEVT_PG_COL_END_DRAG event, generated after column
661 resize by user has finished.
666 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
667 will also delay sorting etc. miscellaneous calculations to the last
673 class WXDLLIMPEXP_PROPGRID
674 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
676 friend class wxPropertyGridEvent
;
677 friend class wxPropertyGridPageState
;
678 friend class wxPropertyGridInterface
;
679 friend class wxPropertyGridManager
;
680 friend class wxPGHeaderCtrl
;
682 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
687 Two step constructor.
689 Call Create when this constructor is called to build up the
695 /** The default constructor. The styles to be used are styles valid for
696 the wxWindow and wxScrolledWindow.
698 @see @link wndflags Additional Window Styles @endlink
700 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
701 const wxPoint
& pos
= wxDefaultPosition
,
702 const wxSize
& size
= wxDefaultSize
,
703 long style
= wxPG_DEFAULT_STYLE
,
704 const wxString
& name
= wxPropertyGridNameStr
);
707 virtual ~wxPropertyGrid();
709 /** Adds given key combination to trigger given action.
712 Which action to trigger. See @link pgactions List of list of
713 wxPropertyGrid actions@endlink.
715 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
718 This static function enables or disables automatic use of
719 wxGetTranslation for following strings: wxEnumProperty list labels,
720 wxFlagsProperty sub-property labels.
724 static void AutoGetTranslation( bool enable
);
727 Changes value of a property, as if from an editor.
729 Use this instead of SetPropertyValue() if you need the value to run
730 through validation process, and also send the property change event.
733 Returns true if value was successfully changed.
735 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
738 Centers the splitter.
740 If argument is true, automatic splitter centering is enabled (only
741 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
743 void CenterSplitter( bool enable_auto_centering
= false );
745 /** Deletes all properties.
747 virtual void Clear();
749 /** Clears action triggers for given action.
751 Which action to trigger. See @link pgactions List of list of
752 wxPropertyGrid actions@endlink.
754 void ClearActionTriggers( int action
);
756 /** Forces updating the value of property from the editor control.
758 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
759 ProcessEvent, meaning your event handlers will be called immediately.
762 Returns true if anything was changed.
764 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
769 Whenever the control is created without any parameters, use Create to
770 actually create it. Don't access the control's public methods before
771 this is called @see @link wndflags Additional Window Styles@endlink
773 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
774 const wxPoint
& pos
= wxDefaultPosition
,
775 const wxSize
& size
= wxDefaultSize
,
776 long style
= wxPG_DEFAULT_STYLE
,
777 const wxString
& name
= wxPropertyGridNameStr
);
780 Call when editor widget's contents is modified.
782 For example, this is called when changes text in wxTextCtrl (used in
783 wxStringProperty and wxIntProperty).
786 This function should only be called by custom properties.
788 @see wxPGProperty::OnEvent()
790 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
792 /** Reverse of EditorsValueWasModified().
795 This function should only be called by custom properties.
797 void EditorsValueWasNotModified()
799 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
803 Enables or disables (shows/hides) categories according to parameter
806 bool EnableCategories( bool enable
);
808 /** Scrolls and/or expands items to ensure that the given item is visible.
809 Returns true if something was actually done.
811 bool EnsureVisible( wxPGPropArg id
);
814 Reduces column sizes to minimum possible that contents are still
815 visibly (naturally some margin space will be applied as well).
818 Minimum size for the grid to still display everything.
821 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
823 This function only works properly if grid size prior to call was already
826 Note that you can also get calculated column widths by calling
827 GetState->GetColumnWidth() immediately after this function returns.
831 wxSize sz
= m_pState
->DoFitColumns();
836 Returns wxWindow that the properties are painted on, and which should
837 be used as the parent for editor controls.
844 /** Returns current category caption background colour. */
845 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
847 wxFont
& GetCaptionFont() { return m_captionFont
; }
849 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
851 /** Returns current category caption text colour. */
852 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
854 /** Returns current cell background colour. */
855 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
857 /** Returns current cell text colour when disabled. */
858 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
860 /** Returns current cell text colour. */
861 wxColour
GetCellTextColour() const { return m_colPropFore
; }
864 Returns number of columns currently on grid.
866 unsigned int GetColumnCount() const
868 return (unsigned int) m_pState
->m_colWidths
.size();
871 /** Returns colour of empty space below properties. */
872 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
874 /** Returns height of highest characters of used font. */
875 int GetFontHeight() const { return m_fontHeight
; }
877 /** Returns pointer to itself. Dummy function that enables same kind
878 of code to use wxPropertyGrid and wxPropertyGridManager.
880 wxPropertyGrid
* GetGrid() { return this; }
882 /** Returns rectangle of custom paint image.
884 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
886 /** Returns size of the custom paint image in front of property.
887 If no argument is given, returns preferred size.
889 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
892 /** Returns last item which could be iterated using given flags.
894 See @ref propgrid_iterator_flags.
896 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
898 return m_pState
->GetLastItem(flags
);
901 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
903 return m_pState
->GetLastItem(flags
);
907 /** Returns colour of lines between cells. */
908 wxColour
GetLineColour() const { return m_colLine
; }
910 /** Returns background colour of margin. */
911 wxColour
GetMarginColour() const { return m_colMargin
; }
913 /** Returns margin width. */
914 int GetMarginWidth() const { return m_marginWidth
; }
917 Returns most up-to-date value of selected property. This will return
918 value different from GetSelectedProperty()->GetValue() only when text
919 editor is activate and string edited by user represents valid,
920 uncommitted property value.
922 wxVariant
GetUncommittedPropertyValue();
924 /** Returns "root property". It does not have name, etc. and it is not
925 visible. It is only useful for accessing its children.
927 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
929 /** Returns height of a single grid row (in pixels). */
930 int GetRowHeight() const { return m_lineHeight
; }
932 /** Returns currently selected property. */
933 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
935 /** Returns current selection background colour. */
936 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
938 /** Returns current selection text colour. */
939 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
941 /** Returns current splitter x position. */
942 int GetSplitterPosition() const
943 { return m_pState
->DoGetSplitterPosition(0); }
945 /** Returns wxTextCtrl active in currently selected property, if any. Takes
946 into account wxOwnerDrawnComboBox.
948 wxTextCtrl
* GetEditorTextCtrl() const;
950 wxPGValidationInfo
& GetValidationInfo()
952 return m_validationInfo
;
955 /** Returns current vertical spacing. */
956 int GetVerticalSpacing() const { return (int)m_vspacing
; }
959 Returns @true if a property editor control has focus.
961 bool IsEditorFocused() const;
963 /** Returns true if editor's value was marked modified.
965 bool IsEditorsValueModified() const
966 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
969 Returns information about arbitrary position in the grid.
972 Coordinates in the virtual grid space. You may need to use
973 wxScrolledWindow::CalcScrolledPosition() for translating
974 wxPropertyGrid client coordinates into something this member
977 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
979 /** Returns true if any property has been modified by the user. */
980 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
983 Returns true if updating is frozen (ie Freeze() called but not yet
986 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
989 It is recommended that you call this function any time your code causes
990 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
991 handler should be able to detect most changes, but it is not perfect.
994 New top-level parent that is about to be set. Old top-level parent
995 window should still exist as the current one.
997 @remarks This function is automatically called from wxPropertyGrid::
998 Reparent() and wxPropertyGridManager::Reparent(). You only
999 need to use it if you reparent wxPropertyGrid indirectly.
1001 void OnTLPChanging( wxWindow
* newTLP
);
1003 /** Redraws given property.
1005 virtual void RefreshProperty( wxPGProperty
* p
);
1008 /** Registers a new editor class.
1010 Pointer to the editor class instance that should be used.
1012 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
1013 bool noDefCheck
= false )
1015 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
1018 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
1019 const wxString
& editorName
,
1020 bool noDefCheck
= false );
1023 /** Resets all colours to the original system values.
1025 void ResetColours();
1029 Editor widget is automatically created, but not focused unless focus is
1036 True if selection finished successfully. Usually only fails if
1037 current value in editor is not valid.
1039 @remarks In wxPropertyGrid 1.4, this member function used to generate
1040 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
1043 @remarks This clears any previous selection.
1045 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
1048 Set entire new selection from given list of properties.
1050 void SetSelection( const wxArrayPGProperty
& newSelection
)
1052 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
1056 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
1057 extra style is not used, then this has same effect as
1058 calling SelectProperty().
1060 @remarks Multiple selection is not supported for categories. This
1061 means that if you have properties selected, you cannot
1062 add category to selection, and also if you have category
1063 selected, you cannot add other properties to selection.
1064 This member function will fail silently in these cases,
1065 even returning true.
1067 bool AddToSelection( wxPGPropArg id
)
1069 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1070 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1074 Removes given property from selection. If property is not selected,
1075 an assertion failure will occur.
1077 bool RemoveFromSelection( wxPGPropArg id
)
1079 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1080 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1084 Makes given column editable by user.
1087 Using @false here will disable column from being editable.
1089 void MakeColumnEditable( unsigned int column
, bool editable
= true );
1092 Creates label editor wxTextCtrl for given column, for property
1093 that is currently selected. When multiple selection is
1094 enabled, this applies to whatever property GetSelection()
1098 Which column's label to edit. Note that you should not
1099 use value 1, which is reserved for property value
1102 @see EndLabelEdit(), MakeColumnEditable()
1104 void BeginLabelEdit( unsigned int column
= 0 )
1106 DoBeginLabelEdit(column
, wxPG_SEL_DONT_SEND_EVENT
);
1110 Destroys label editor wxTextCtrl, if any.
1113 Use @true (default) to store edited label text in
1116 @see BeginLabelEdit(), MakeColumnEditable()
1118 void EndLabelEdit( bool commit
= true )
1120 DoEndLabelEdit(commit
, wxPG_SEL_DONT_SEND_EVENT
);
1124 Returns currently active label editor, NULL if none.
1126 wxTextCtrl
* GetLabelEditor() const
1128 return m_labelEditor
;
1131 /** Sets category caption background colour. */
1132 void SetCaptionBackgroundColour(const wxColour
& col
);
1134 /** Sets category caption text colour. */
1135 void SetCaptionTextColour(const wxColour
& col
);
1137 /** Sets default cell background colour - applies to property cells.
1138 Note that appearance of editor widgets may not be affected.
1140 void SetCellBackgroundColour(const wxColour
& col
);
1142 /** Sets cell text colour for disabled properties.
1144 void SetCellDisabledTextColour(const wxColour
& col
);
1146 /** Sets default cell text colour - applies to property name and value text.
1147 Note that appearance of editor widgets may not be affected.
1149 void SetCellTextColour(const wxColour
& col
);
1151 /** Set number of columns (2 or more).
1153 void SetColumnCount( int colCount
)
1155 m_pState
->SetColumnCount(colCount
);
1160 Sets the 'current' category - Append will add non-category properties
1163 void SetCurrentCategory( wxPGPropArg id
)
1165 wxPG_PROP_ARG_CALL_PROLOG()
1166 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1168 m_pState
->m_currentCategory
= pc
;
1171 /** Sets colour of empty space below properties. */
1172 void SetEmptySpaceColour(const wxColour
& col
);
1174 /** Sets colour of lines between cells. */
1175 void SetLineColour(const wxColour
& col
);
1177 /** Sets background colour of margin. */
1178 void SetMarginColour(const wxColour
& col
);
1181 Sets selection background colour - applies to selected property name
1184 void SetSelectionBackgroundColour(const wxColour
& col
);
1187 Sets selection foreground colour - applies to selected property name
1190 void SetSelectionTextColour(const wxColour
& col
);
1192 /** Sets x coordinate of the splitter.
1194 Splitter position cannot exceed grid size, and therefore setting it
1195 during form creation may fail as initial grid size is often smaller
1196 than desired splitter position, especially when sizers are being used.
1198 void SetSplitterPosition( int newXPos
, int col
= 0 )
1200 DoSetSplitterPosition(newXPos
, col
, wxPG_SPLITTER_REFRESH
);
1204 Sets the property sorting function.
1207 The sorting function to be used. It should return a value greater
1208 than 0 if position of p1 is after p2. So, for instance, when
1209 comparing property names, you can use following implementation:
1212 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1216 return p1->GetBaseName().compare( p2->GetBaseName() );
1221 Default property sort function sorts properties by their labels
1222 (case-insensitively).
1224 @see GetSortFunction, wxPropertyGridInterface::Sort,
1225 wxPropertyGridInterface::SortChildren
1227 void SetSortFunction( wxPGSortCallback sortFunction
)
1229 m_sortFunction
= sortFunction
;
1233 Returns the property sort function (default is @NULL).
1235 @see SetSortFunction
1237 wxPGSortCallback
GetSortFunction() const
1239 return m_sortFunction
;
1242 /** Set virtual width for this particular page. Width -1 indicates that the
1243 virtual width should be disabled. */
1244 void SetVirtualWidth( int width
);
1247 Moves splitter as left as possible, while still allowing all
1248 labels to be shown in full.
1250 @param privateChildrenToo
1251 If @false, will still allow private children to be cropped.
1253 void SetSplitterLeft( bool privateChildrenToo
= false )
1255 m_pState
->SetSplitterLeft(privateChildrenToo
);
1258 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1259 height. Value of 2 should be default on most platforms.
1261 void SetVerticalSpacing( int vspacing
)
1263 m_vspacing
= (unsigned char)vspacing
;
1264 CalculateFontAndBitmapStuff( vspacing
);
1265 if ( !m_pState
->m_itemsAdded
) Refresh();
1268 /** Shows an brief error message that is related to a property. */
1269 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1271 wxPG_PROP_ARG_CALL_PROLOG()
1272 DoShowPropertyError(p
, msg
);
1275 /////////////////////////////////////////////////////////////////
1277 // Following methods do not need to be (currently) documented
1279 /////////////////////////////////////////////////////////////////
1281 bool HasVirtualWidth() const
1282 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1284 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1286 return (wxPGCommonValue
*) m_commonValues
[i
];
1289 /** Returns number of common values.
1291 unsigned int GetCommonValueCount() const
1293 return (unsigned int) m_commonValues
.size();
1296 /** Returns label of given common value.
1298 wxString
GetCommonValueLabel( unsigned int i
) const
1300 wxASSERT( GetCommonValue(i
) );
1301 return GetCommonValue(i
)->GetLabel();
1305 Returns index of common value that will truly change value to
1308 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1310 /** Set index of common value that will truly change value to unspecified.
1311 Using -1 will set none to have such effect.
1314 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1317 Shortcut for creating dialog-caller button. Used, for example, by
1320 This should only be called by properties.
1322 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1324 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1325 fits as one). Call after control has been created (but before
1328 void FixPosForTextCtrl( wxWindow
* ctrl
,
1329 unsigned int forColumn
= 1,
1330 const wxPoint
& offset
= wxPoint(0, 0) );
1332 /** Shortcut for creating text editor widget.
1334 Same as pos given for CreateEditor.
1336 Same as sz given for CreateEditor.
1338 Initial text for wxTextCtrl.
1340 If right-side control, such as button, also created, then create it
1341 first and pass it as this parameter.
1343 Extra style flags to pass for wxTextCtrl.
1345 Note that this should generally be called only by new classes derived
1348 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1350 const wxString
& value
,
1351 wxWindow
* secondary
,
1354 unsigned int forColumn
= 1 );
1356 /* Generates both textctrl and button.
1358 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1359 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1360 wxPGProperty
* property
);
1362 /** Generates position for a widget editor dialog box.
1364 Property for which dialog is positioned.
1366 Known or over-approximated size of the dialog.
1368 Position for dialog.
1370 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1373 // Converts escape sequences in src_str to newlines,
1374 // tabs, etc. and copies result to dst_str.
1375 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1376 wxString
& src_str
);
1378 // Converts newlines, tabs, etc. in src_str to escape
1379 // sequences, and copies result to dst_str.
1380 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1381 wxString
& src_str
);
1384 Returns rectangle that fully contains properties between and including
1387 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1388 const wxPGProperty
* p2
) const;
1390 /** Returns pointer to current active primary editor control (NULL if none).
1392 wxWindow
* GetEditorControl() const;
1394 wxWindow
* GetPrimaryEditor() const
1396 return GetEditorControl();
1400 Returns pointer to current active secondary editor control (NULL if
1403 wxWindow
* GetEditorControlSecondary() const
1405 return m_wndEditor2
;
1409 Refreshes any active editor control.
1411 void RefreshEditor();
1413 // Events from editor controls are forward to this function
1414 void HandleCustomEditorEvent( wxEvent
&event
);
1419 Generates contents for string dst based on the contents of
1422 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1423 so on. Set flags to 1 inorder to convert backslashes to double-back-
1424 slashes and "(preDelims)"'s to "(preDelims)".
1426 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1427 wxChar preDelim
, wxChar postDelim
,
1430 // Mostly useful for page switching.
1431 void SwitchState( wxPropertyGridPageState
* pNewState
);
1433 long GetInternalFlags() const { return m_iFlags
; }
1434 bool HasInternalFlag( long flag
) const
1435 { return (m_iFlags
& flag
) ? true : false; }
1436 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1437 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1438 void IncFrozen() { m_frozen
++; }
1439 void DecFrozen() { m_frozen
--; }
1441 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1447 /** Standardized double-to-string conversion.
1449 static void DoubleToString( wxString
& target
,
1453 wxString
* precTemplate
);
1456 Call this from wxPGProperty::OnEvent() to cause property value to be
1457 changed after the function returns (with true as return value).
1458 ValueChangeInEvent() must be used if you wish the application to be
1459 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1461 void ValueChangeInEvent( wxVariant variant
)
1463 m_changeInEventValue
= variant
;
1464 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1468 You can use this member function, for instance, to detect in
1469 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1470 already called in wxPGEditor::OnEvent(). It really only detects
1471 if was value was changed using wxPGProperty::SetValueInEvent(), which
1472 is usually used when a 'picker' dialog is displayed. If value was
1473 written by "normal means" in wxPGProperty::StringToValue() or
1474 IntToValue(), then this function will return false (on the other hand,
1475 wxPGProperty::OnEvent() is not even called in those cases).
1477 bool WasValueChangedInEvent() const
1479 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1482 /** Returns true if given event is from first of an array of buttons
1483 (as can be in case when wxPGMultiButton is used).
1485 bool IsMainButtonEvent( const wxEvent
& event
)
1487 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1488 && (m_wndSecId
== event
.GetId());
1491 /** Pending value is expected to be passed in PerformValidation().
1493 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1494 unsigned int selFlags
= 0 );
1496 /** Called when validation for given property fails.
1498 Value which failed in validation.
1500 Return true if user is allowed to change to another property even
1501 if current has invalid value.
1503 To add your own validation failure behavior, override
1504 wxPropertyGrid::DoOnValidationFailure().
1506 bool OnValidationFailure( wxPGProperty
* property
,
1507 wxVariant
& invalidValue
);
1509 /** Called to indicate property and editor has valid value now.
1511 void OnValidationFailureReset( wxPGProperty
* property
)
1513 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1515 DoOnValidationFailureReset(property
);
1516 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1518 m_validationInfo
.m_failureMessage
.clear();
1521 /** Override in derived class to display error messages in custom manner
1522 (these message usually only result from validation failure).
1524 virtual void DoShowPropertyError( wxPGProperty
* property
,
1525 const wxString
& msg
);
1527 /** Override to customize property validation failure behavior.
1529 Value which failed in validation.
1531 Return true if user is allowed to change to another property even
1532 if current has invalid value.
1534 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1535 wxVariant
& invalidValue
);
1537 /** Override to customize resetting of property validation failure status.
1539 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1541 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1543 int GetSpacingY() const { return m_spacingy
; }
1546 Must be called in wxPGEditor::CreateControls() if primary editor window
1547 is wxTextCtrl, just before textctrl is created.
1549 Initial text value of created wxTextCtrl.
1551 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1554 Unfocuses or closes editor if one was open, but does not deselect
1557 bool UnfocusEditor();
1559 virtual void SetWindowStyleFlag( long style
);
1561 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1563 void DrawItem( wxPGProperty
* p
)
1568 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1571 Draws item, children, and consequtive parents as long as category is
1574 void DrawItemAndValueRelated( wxPGProperty
* p
);
1579 wxPropertyGridPageState used by the grid is created here.
1581 If grid is used in wxPropertyGridManager, there is no point overriding
1582 this - instead, set custom wxPropertyGridPage classes.
1584 virtual wxPropertyGridPageState
* CreateState() const;
1586 enum PerformValidationFlags
1588 SendEvtChanging
= 0x0001,
1589 IsStandaloneValidation
= 0x0002 // Not called in response to event
1593 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1594 Returns true if all tests passed. Implement in derived class to
1595 add additional validation behavior.
1597 virtual bool PerformValidation( wxPGProperty
* p
,
1598 wxVariant
& pendingValue
,
1599 int flags
= SendEvtChanging
);
1603 // Control font changer helper.
1604 void SetCurControlBoldFont();
1606 wxPGCell
& GetPropertyDefaultCell()
1608 return m_propertyDefaultCell
;
1611 wxPGCell
& GetCategoryDefaultCell()
1613 return m_categoryDefaultCell
;
1617 // Public methods for semi-public use
1619 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1621 // Overridden functions.
1622 virtual bool Destroy();
1623 // Returns property at given y coordinate (relative to grid's top left).
1624 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1626 virtual void Refresh( bool eraseBackground
= true,
1627 const wxRect
*rect
= (const wxRect
*) NULL
);
1628 virtual bool SetFont( const wxFont
& font
);
1629 #if wxPG_SUPPORT_TOOLTIPS
1630 void SetToolTip( const wxString
& tipString
);
1632 virtual void Freeze();
1633 virtual void SetExtraStyle( long exStyle
);
1634 virtual void Thaw();
1635 virtual bool Reparent( wxWindowBase
*newParent
);
1638 virtual wxSize
DoGetBestSize() const;
1640 #ifndef wxPG_ICON_WIDTH
1641 wxBitmap
*m_expandbmp
, *m_collbmp
;
1644 wxCursor
*m_cursorSizeWE
;
1646 /** wxWindow pointers to editor control(s). */
1647 wxWindow
*m_wndEditor
;
1648 wxWindow
*m_wndEditor2
;
1650 #if wxPG_DOUBLE_BUFFER
1651 wxBitmap
*m_doubleBuffer
;
1654 /** Local time ms when control was created. */
1655 wxLongLong m_timeCreated
;
1657 /** wxPGProperty::OnEvent can change value by setting this. */
1658 wxVariant m_changeInEventValue
;
1660 /** Id of m_wndEditor2, or its first child, if any. */
1663 /** Extra Y spacing between the items. */
1666 /** Control client area width; updated on resize. */
1669 /** Control client area height; updated on resize. */
1672 /** Current non-client width (needed when auto-centering). */
1675 /** Non-client width (auto-centering helper). */
1678 /** Previously recorded scroll start position. */
1682 The gutter spacing in front and back of the image.
1683 This determines the amount of spacing in front of each item
1687 /** Includes separator line. */
1690 /** Gutter*2 + image width. */
1693 // y spacing for expand/collapse button.
1694 int m_buttonSpacingY
;
1696 /** Extra margin for expanded sub-group items. */
1697 int m_subgroup_extramargin
;
1700 The image width of the [+] icon.
1702 This is also calculated in the gutter
1706 #ifndef wxPG_ICON_WIDTH
1709 The image height of the [+] icon.
1711 This is calculated as minimal size and to align
1716 /** Current cursor id. */
1720 This captionFont is made equal to the font of the wxScrolledWindow.
1722 As extra the bold face is set on it when this is wanted by the user
1725 wxFont m_captionFont
;
1727 int m_fontHeight
; // Height of the font.
1729 /** m_splitterx when drag began. */
1730 int m_startingSplitterX
;
1733 Index to splitter currently being dragged (0=one after the first
1736 int m_draggedSplitter
;
1738 /** Changed property, calculated in PerformValidation(). */
1739 wxPGProperty
* m_chgInfo_changedProperty
;
1742 Lowest property for which editing happened, but which does not have
1745 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1747 /** Changed property value, calculated in PerformValidation(). */
1748 wxVariant m_chgInfo_pendingValue
;
1750 /** Passed to SetValue. */
1751 wxVariant m_chgInfo_valueList
;
1753 /** Validation information. */
1754 wxPGValidationInfo m_validationInfo
;
1756 /** Actions and keys that trigger them. */
1757 wxPGHashMapI2I m_actionTriggers
;
1763 /** Bits are used to indicate which colours are customized. */
1764 unsigned short m_coloursCustomized
;
1766 /** x - m_splitterx. */
1767 signed char m_dragOffset
;
1769 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1770 unsigned char m_dragStatus
;
1772 /** 0 = margin, 1 = label, 2 = value. */
1773 unsigned char m_mouseSide
;
1775 /** True when editor control is focused. */
1776 unsigned char m_editorFocused
;
1778 /** 1 if m_latsCaption is also the bottommost caption. */
1779 //unsigned char m_lastCaptionBottomnest;
1781 /** Set to 1 when graphics frozen. */
1782 unsigned char m_frozen
;
1784 unsigned char m_vspacing
;
1786 // Used to track when Alt/Ctrl+Key was consumed.
1787 unsigned char m_keyComboConsumed
;
1789 /** 1 if in DoPropertyChanged() */
1790 unsigned char m_inDoPropertyChanged
;
1792 /** 1 if in CommitChangesFromEditor() */
1793 unsigned char m_inCommitChangesFromEditor
;
1795 /** 1 if in DoSelectProperty() */
1796 unsigned char m_inDoSelectProperty
;
1798 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1800 /** Internal flags - see wxPG_FL_XXX constants. */
1803 /** When drawing next time, clear this many item slots at the end. */
1804 int m_clearThisMany
;
1806 // Mouse is hovering over this column (index)
1807 unsigned int m_colHover
;
1809 // pointer to property that has mouse hovering
1810 wxPGProperty
* m_propHover
;
1812 // Active label editor
1813 wxTextCtrl
* m_labelEditor
;
1815 // For which property the label editor is active
1816 wxPGProperty
* m_labelEditorProperty
;
1818 // EventObject for wxPropertyGridEvents
1819 wxWindow
* m_eventObject
;
1821 // What (global) window is currently focused (needed to resolve event
1823 wxWindow
* m_curFocused
;
1825 // Event currently being sent - NULL if none at the moment
1826 wxPropertyGridEvent
* m_processedEvent
;
1828 // Last known top-level parent
1831 // Last closed top-level parent
1832 wxWindow
* m_tlpClosed
;
1834 // Local time ms when tlp was closed.
1835 wxLongLong m_tlpClosedTime
;
1838 wxPGSortCallback m_sortFunction
;
1840 // y coordinate of property that mouse hovering
1843 // Which column's editor is selected (usually 1)?
1844 unsigned int m_selColumn
;
1846 // x relative to splitter (needed for resize).
1849 // lines between cells
1851 // property labels and values are written in this colour
1852 wxColour m_colPropFore
;
1853 // or with this colour when disabled
1854 wxColour m_colDisPropFore
;
1855 // background for m_colPropFore
1856 wxColour m_colPropBack
;
1857 // text color for captions
1858 wxColour m_colCapFore
;
1859 // background color for captions
1860 wxColour m_colCapBack
;
1861 // foreground for selected property
1862 wxColour m_colSelFore
;
1863 // background for selected property (actually use background color when
1864 // control out-of-focus)
1865 wxColour m_colSelBack
;
1866 // background colour for margin
1867 wxColour m_colMargin
;
1868 // background colour for empty space below the grid
1869 wxColour m_colEmptySpace
;
1871 // Default property colours
1872 wxPGCell m_propertyDefaultCell
;
1874 // Default property category
1875 wxPGCell m_categoryDefaultCell
;
1877 // Backup of selected property's cells
1878 wxVector
<wxPGCell
> m_propCellsBackup
;
1880 // NB: These *cannot* be moved to globals.
1882 // labels when properties use common values
1883 wxVector
<wxPGCommonValue
*> m_commonValues
;
1885 // array of live events
1886 wxVector
<wxPropertyGridEvent
*> m_liveEvents
;
1888 // Which cv selection really sets value to unspecified?
1889 int m_cvUnspecified
;
1891 // Used to skip excess text editor events
1892 wxString m_prevTcValue
;
1896 // Sets some members to defaults (called constructors).
1899 // Initializes some members (called by Create and complex constructor).
1902 void OnPaint(wxPaintEvent
&event
);
1904 // main event receivers
1905 void OnMouseMove( wxMouseEvent
&event
);
1906 void OnMouseClick( wxMouseEvent
&event
);
1907 void OnMouseRightClick( wxMouseEvent
&event
);
1908 void OnMouseDoubleClick( wxMouseEvent
&event
);
1909 void OnMouseUp( wxMouseEvent
&event
);
1910 void OnKey( wxKeyEvent
&event
);
1911 void OnResize( wxSizeEvent
&event
);
1914 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
1915 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1916 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1917 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1918 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
1919 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
1921 void OnMouseEntry( wxMouseEvent
&event
);
1923 void OnIdle( wxIdleEvent
&event
);
1924 void OnFocusEvent( wxFocusEvent
&event
);
1925 void OnChildFocusEvent( wxChildFocusEvent
& event
);
1927 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
1928 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
1930 // sub-control event handlers
1931 void OnMouseClickChild( wxMouseEvent
&event
);
1932 void OnMouseRightClickChild( wxMouseEvent
&event
);
1933 void OnMouseMoveChild( wxMouseEvent
&event
);
1934 void OnMouseUpChild( wxMouseEvent
&event
);
1935 void OnChildKeyDown( wxKeyEvent
&event
);
1937 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
1939 void OnScrollEvent( wxScrollWinEvent
&event
);
1941 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
1943 void OnTLPClose( wxCloseEvent
& event
);
1947 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
1948 unsigned int colIndex
,
1949 wxMouseEvent
* event
= NULL
,
1953 Adjust the centering of the bitmap icons (collapse / expand) when the
1954 caption font changes.
1956 They need to be centered in the middle of the font, so a bit of deltaY
1957 adjustment is needed. On entry, m_captionFont must be set to window
1958 font. It will be modified properly.
1960 void CalculateFontAndBitmapStuff( int vspacing
);
1962 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
1964 void CorrectEditorWidgetSizeX();
1966 /** Called in RecalculateVirtualSize() to reposition control
1967 on virtual height changes.
1969 void CorrectEditorWidgetPosY();
1971 int DoDrawItems( wxDC
& dc
,
1972 const wxRect
* drawRect
,
1973 bool isBuffered
) const;
1975 /** Draws an expand/collapse (ie. +/-) button.
1977 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1978 wxPGProperty
* property
) const;
1980 /** Draws items from topitemy to bottomitemy */
1981 void DrawItems( wxDC
& dc
,
1982 unsigned int topItemY
,
1983 unsigned int bottomItemY
,
1984 const wxRect
* drawRect
= NULL
);
1986 // Translate wxKeyEvent to wxPG_ACTION_XXX
1987 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
1989 int KeyEventToAction(wxKeyEvent
&event
) const
1991 return KeyEventToActions(event
, NULL
);
1994 void ImprovedClientToScreen( int* px
, int* py
);
1996 // Called by focus event handlers. newFocused is the window that becomes
1998 void HandleFocusChange( wxWindow
* newFocused
);
2000 /** Reloads all non-customized colours from system settings. */
2001 void RegainColours();
2003 bool DoEditorValidate();
2005 // Similar to DoSelectProperty() but also works on columns
2006 // other than 1. Does not active editor if column is not
2008 bool DoSelectAndEdit( wxPGProperty
* prop
,
2009 unsigned int colIndex
,
2010 unsigned int selFlags
);
2012 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
2015 void DoSetSplitterPosition( int newxpos
,
2016 int splitterIndex
= 0,
2017 int flags
= wxPG_SPLITTER_REFRESH
);
2019 bool DoAddToSelection( wxPGProperty
* prop
,
2022 bool DoRemoveFromSelection( wxPGProperty
* prop
,
2025 void DoBeginLabelEdit( unsigned int colIndex
, int selFlags
= 0 );
2026 void DoEndLabelEdit( bool commit
, int selFlags
= 0 );
2027 void OnLabelEditorEnterPress( wxCommandEvent
& event
);
2028 void OnLabelEditorKeyPress( wxKeyEvent
& event
);
2030 wxPGProperty
* DoGetItemAtY( int y
) const;
2032 void DestroyEditorWnd( wxWindow
* wnd
);
2035 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
2037 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
2039 // Returns nearest paint visible property (such that will be painted unless
2040 // window is scrolled or resized). If given property is paint visible, then
2041 // it itself will be returned.
2042 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
2044 static void RegisterDefaultEditors();
2046 // Sets up basic event handling for child control
2047 void SetupChildEventHandling( wxWindow
* wnd
);
2049 void CustomSetCursor( int type
, bool override
= false );
2052 Repositions scrollbar and underlying panel according to changed virtual
2055 void RecalculateVirtualSize( int forceXPos
= -1 );
2057 void PrepareAfterItemsAdded();
2060 Send event from the property grid.
2062 Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
2064 bool SendEvent( int eventType
, wxPGProperty
* p
,
2065 wxVariant
* pValue
= NULL
,
2066 unsigned int selFlags
= wxPG_SEL_NOVALIDATE
,
2067 unsigned int column
= 1 );
2069 void SetFocusOnCanvas();
2071 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
2075 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
2077 DECLARE_EVENT_TABLE()
2078 #endif // #ifndef SWIG
2081 // -----------------------------------------------------------------------
2083 // Bunch of inlines that need to resolved after all classes have been defined.
2087 inline bool wxPropertyGridPageState::IsDisplayed() const
2089 return ( this == m_pPropGrid
->GetState() );
2092 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
2094 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
2098 inline int wxPGProperty::GetDisplayedCommonValueCount() const
2100 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
2102 wxPropertyGrid
* pg
= GetGrid();
2104 return (int) pg
->GetCommonValueCount();
2109 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
2111 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
2114 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
2116 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
2119 inline bool wxPGProperty::Hide( bool hide
, int flags
)
2121 return GetGrid()->HideProperty(this, hide
, flags
);
2124 inline bool wxPGProperty::SetMaxLength( int maxLen
)
2126 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
2129 // -----------------------------------------------------------------------
2131 #define wxPG_BASE_EVT_PRE_ID 1775
2135 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
2136 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
2137 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
2138 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
2139 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
2140 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
2141 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
2142 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
2143 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
2144 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2145 wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
2146 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2147 wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
2148 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2149 wxEVT_PG_COL_BEGIN_DRAG
, wxPropertyGridEvent
);
2150 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2151 wxEVT_PG_COL_DRAGGING
, wxPropertyGridEvent
);
2152 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2153 wxEVT_PG_COL_END_DRAG
, wxPropertyGridEvent
);
2157 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
2160 wxEVT_PG_HIGHLIGHTED
,
2161 wxEVT_PG_RIGHT_CLICK
,
2162 wxEVT_PG_PAGE_CHANGED
,
2163 wxEVT_PG_ITEM_COLLAPSED
,
2164 wxEVT_PG_ITEM_EXPANDED
,
2165 wxEVT_PG_DOUBLE_CLICK
,
2166 wxEVT_PG_LABEL_EDIT_BEGIN
,
2167 wxEVT_PG_LABEL_EDIT_ENDING
,
2168 wxEVT_PG_COL_BEGIN_DRAG
,
2169 wxEVT_PG_COL_DRAGGING
,
2170 wxEVT_PG_COL_END_DRAG
2175 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2176 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2180 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2182 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2183 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2184 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2185 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2186 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2187 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2188 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2189 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2190 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2191 #define EVT_PG_LABEL_EDIT_BEGIN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_BEGIN, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2192 #define EVT_PG_LABEL_EDIT_ENDING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_ENDING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2193 #define EVT_PG_COL_BEGIN_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_BEGIN_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2194 #define EVT_PG_COL_DRAGGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_DRAGGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2195 #define EVT_PG_COL_END_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_END_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2197 #define wxPropertyGridEventHandler(fn) \
2198 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2203 /** @class wxPropertyGridEvent
2205 A propertygrid event holds information about events associated with
2206 wxPropertyGrid objects.
2208 @library{wxpropgrid}
2211 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2216 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2218 /** Copy constructor. */
2219 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2222 ~wxPropertyGridEvent();
2225 virtual wxEvent
* Clone() const;
2228 Returns the column index associated with this event.
2229 For the column dragging events, it is the column to the left
2230 of the splitter being dragged
2232 unsigned int GetColumn() const
2237 wxPGProperty
* GetMainParent() const
2239 wxASSERT(m_property
);
2240 return m_property
->GetMainParent();
2243 /** Returns id of associated property. */
2244 wxPGProperty
* GetProperty() const
2249 wxPGValidationInfo
& GetValidationInfo()
2251 wxASSERT(m_validationInfo
);
2252 return *m_validationInfo
;
2255 /** Returns true if you can veto the action that the event is signaling.
2257 bool CanVeto() const { return m_canVeto
; }
2260 Call this from your event handler to veto action that the event is
2263 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2266 Currently only wxEVT_PG_CHANGING supports vetoing.
2268 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2271 Returns name of the associated property.
2273 @remarks Property name is stored in event, so it remains
2274 accessible even after the associated property or
2275 the property grid has been deleted.
2277 wxString
GetPropertyName() const
2279 return m_propertyName
;
2283 Returns value of the associated property. Works for all event
2284 types, but for wxEVT_PG_CHANGING this member function returns
2285 the value that is pending, so you can call Veto() if the
2286 value is not satisfactory.
2288 @remarks Property value is stored in event, so it remains
2289 accessible even after the associated property or
2290 the property grid has been deleted.
2292 wxVariant
GetPropertyValue() const
2294 if ( m_validationInfo
)
2295 return m_validationInfo
->GetValue();
2300 Returns value of the associated property.
2302 @see GetPropertyValue
2304 wxVariant
GetValue() const
2306 return GetPropertyValue();
2310 Set override validation failure behavior.
2312 Only effective if Veto was also called, and only allowed if event type
2313 is wxEVT_PG_CHANGING.
2315 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2317 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2318 m_validationInfo
->SetFailureBehavior( flags
);
2321 /** Sets custom failure message for this time only. Only applies if
2322 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2324 void SetValidationFailureMessage( const wxString
& message
)
2326 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2327 m_validationInfo
->SetFailureMessage( message
);
2331 wxPGVFBFlags
GetValidationFailureBehavior() const
2333 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2334 return m_validationInfo
->GetFailureBehavior();
2337 void SetColumn( unsigned int column
)
2342 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2343 bool WasVetoed() const { return m_wasVetoed
; }
2345 /** Changes the associated property. */
2346 void SetProperty( wxPGProperty
* p
)
2350 m_propertyName
= p
->GetName();
2353 void SetPropertyValue( wxVariant value
)
2358 void SetPropertyGrid( wxPropertyGrid
* pg
)
2361 OnPropertyGridSet();
2364 void SetupValidationInfo()
2367 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2368 m_validationInfo
= &m_pg
->GetValidationInfo();
2369 m_value
= m_validationInfo
->GetValue();
2374 void OnPropertyGridSet();
2375 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2377 wxPGProperty
* m_property
;
2378 wxPropertyGrid
* m_pg
;
2379 wxPGValidationInfo
* m_validationInfo
;
2381 wxString m_propertyName
;
2384 unsigned int m_column
;
2393 // -----------------------------------------------------------------------
2395 /** @class wxPropertyGridPopulator
2397 Allows populating wxPropertyGrid from arbitrary text source.
2399 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2402 /** Default constructor.
2404 wxPropertyGridPopulator();
2407 virtual ~wxPropertyGridPopulator();
2409 void SetState( wxPropertyGridPageState
* state
);
2411 void SetGrid( wxPropertyGrid
* pg
);
2413 /** Appends a new property under bottommost parent.
2415 Property class as string.
2417 wxPGProperty
* Add( const wxString
& propClass
,
2418 const wxString
& propLabel
,
2419 const wxString
& propName
,
2420 const wxString
* propValue
,
2421 wxPGChoices
* pChoices
= NULL
);
2424 Pushes property to the back of parent array (ie it becomes bottommost
2425 parent), and starts scanning/adding children for it.
2427 When finished, parent array is returned to the original state.
2429 void AddChildren( wxPGProperty
* property
);
2431 /** Adds attribute to the bottommost property.
2433 Allowed values: "string", (same as string), "int", "bool". Empty string
2436 bool AddAttribute( const wxString
& name
,
2437 const wxString
& type
,
2438 const wxString
& value
);
2440 /** Called once in AddChildren.
2442 virtual void DoScanForChildren() = 0;
2445 Returns id of parent property for which children can currently be
2448 wxPGProperty
* GetCurParent() const
2450 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2453 wxPropertyGridPageState
* GetState() { return m_state
; }
2454 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2456 /** Like wxString::ToLong, except allows N% in addition of N.
2458 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2460 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2461 wxPGChoices. Registers parsed result using idString (if not empty).
2462 Also, if choices with given id already registered, then don't parse but
2463 return those choices instead.
2465 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2466 const wxString
& idString
);
2468 /** Implement in derived class to do custom process when an error occurs.
2469 Default implementation uses wxLogError.
2471 virtual void ProcessError( const wxString
& msg
);
2475 /** Used property grid. */
2476 wxPropertyGrid
* m_pg
;
2478 /** Used property grid state. */
2479 wxPropertyGridPageState
* m_state
;
2481 /** Tree-hierarchy of added properties (that can have children). */
2482 wxArrayPGProperty m_propHierarchy
;
2484 /** Hashmap for string-id to wxPGChoicesData mapping. */
2485 wxPGHashMapS2P m_dictIdChoices
;
2488 // -----------------------------------------------------------------------
2491 // Undefine macros that are not needed outside propertygrid sources
2493 #ifndef __wxPG_SOURCE_FILE__
2494 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2495 #undef wxPG_FL_SCROLLBAR_DETECTED
2496 #undef wxPG_FL_CREATEDSTATE
2497 #undef wxPG_FL_NOSTATUSBARHELP
2498 #undef wxPG_FL_SCROLLED
2499 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2500 #undef wxPG_FL_FOCUS_INSIDE
2501 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2502 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2503 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2504 #undef wxPG_FL_VALUE_MODIFIED
2505 #undef wxPG_FL_MOUSE_INSIDE
2506 #undef wxPG_FL_FOCUSED
2507 #undef wxPG_FL_MOUSE_CAPTURED
2508 #undef wxPG_FL_INITIALIZED
2509 #undef wxPG_FL_ACTIVATION_BY_CLICK
2510 #undef wxPG_SUPPORT_TOOLTIPS
2511 #undef wxPG_DOUBLE_BUFFER
2512 #undef wxPG_ICON_WIDTH
2513 #undef wxPG_USE_RENDERER_NATIVE
2514 // Following are needed by the manager headers
2515 // #undef const wxString&
2518 // -----------------------------------------------------------------------
2522 #endif // _WX_PROPGRID_PROPGRID_H_