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/dcclient.h"
18 #include "wx/scrolwin.h"
19 #include "wx/tooltip.h"
20 #include "wx/datetime.h"
22 #include "wx/propgrid/property.h"
23 #include "wx/propgrid/propgridiface.h"
27 extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr
[];
32 // -----------------------------------------------------------------------
34 // -----------------------------------------------------------------------
38 // This is required for sharing common global variables.
39 class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
43 wxPGGlobalVarsClass();
44 ~wxPGGlobalVarsClass();
46 // Used by advprops, but here to make things easier.
47 wxString m_pDefaultImageWildcard
;
49 // Map of editor class instances (keys are name string).
50 wxPGHashMapS2P m_mapEditorClasses
;
53 wxVector
<wxValidator
*> m_arrValidators
; // These wxValidators need to be freed
56 wxPGHashMapS2P m_dictPropertyClassInfo
; // PropertyName -> ClassInfo
58 wxPGChoices
* m_fontFamilyChoices
;
60 // Replace with your own to affect all properties using default renderer.
61 wxPGCellRenderer
* m_defaultRenderer
;
63 wxPGChoices m_boolChoices
;
65 wxVariant m_vEmptyString
;
67 wxVariant m_vMinusOne
;
71 // Cached constant strings
72 wxPGCachedString m_strstring
;
73 wxPGCachedString m_strlong
;
74 wxPGCachedString m_strbool
;
75 wxPGCachedString m_strlist
;
77 wxPGCachedString m_strDefaultValue
;
78 wxPGCachedString m_strMin
;
79 wxPGCachedString m_strMax
;
80 wxPGCachedString m_strUnits
;
81 wxPGCachedString m_strInlineHelp
;
83 // If true then some things are automatically translated
84 bool m_autoGetTranslation
;
86 // > 0 if errors cannot or should not be shown in statusbar etc.
89 int m_extraStyle
; // global extra style
93 int HasExtraStyle( int style
) const { return (m_extraStyle
& style
); }
96 extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
* wxPGGlobalVars
;
98 #define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
99 #define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
100 #define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
101 #define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
102 #define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
104 #define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
106 // When wxPG is loaded dynamically after the application is already running
107 // then the built-in module system won't pick this one up. Add it manually.
108 WXDLLIMPEXP_PROPGRID
void wxPGInitResourceModule();
112 // -----------------------------------------------------------------------
114 /** @section propgrid_window_styles wxPropertyGrid Window Styles
116 SetWindowStyleFlag method can be used to modify some of these at run-time.
119 enum wxPG_WINDOW_STYLES
122 /** This will cause Sort() automatically after an item is added.
123 When inserting a lot of items in this mode, it may make sense to
124 use Freeze() before operations and Thaw() afterwards to increase
127 wxPG_AUTO_SORT
= 0x00000010,
129 /** Categories are not initially shown (even if added).
130 IMPORTANT NOTE: If you do not plan to use categories, then this
131 style will waste resources.
132 This flag can also be changed using wxPropertyGrid::EnableCategories method.
134 wxPG_HIDE_CATEGORIES
= 0x00000020,
136 /* This style combines non-categoric mode and automatic sorting.
138 wxPG_ALPHABETIC_MODE
= (wxPG_HIDE_CATEGORIES
|wxPG_AUTO_SORT
),
140 /** Modified values are shown in bold font. Changing this requires Refresh()
143 wxPG_BOLD_MODIFIED
= 0x00000040,
145 /** When wxPropertyGrid is resized, splitter moves to the center. This
146 behavior stops once the user manually moves the splitter.
148 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
150 /** Display tooltips for cell text that cannot be shown completely. If
151 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
153 wxPG_TOOLTIPS
= 0x00000100,
155 /** Disables margin and hides all expand/collapse buttons that would appear
156 outside the margin (for sub-properties). Toggling this style automatically
157 expands all collapsed items.
159 wxPG_HIDE_MARGIN
= 0x00000200,
161 /** This style prevents user from moving the splitter.
163 wxPG_STATIC_SPLITTER
= 0x00000400,
165 /** Combination of other styles that make it impossible for user to modify
168 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
170 /** Disables wxTextCtrl based editors for properties which
171 can be edited in another way.
173 Equals calling wxPropertyGrid::LimitPropertyEditing for all added
176 wxPG_LIMITED_EDITING
= 0x00000800,
178 /** wxPropertyGridManager only: Show toolbar for mode and page selection. */
179 wxPG_TOOLBAR
= 0x00001000,
181 /** wxPropertyGridManager only: Show adjustable text box showing description
182 or help text, if available, for currently selected property.
184 wxPG_DESCRIPTION
= 0x00002000
188 enum wxPG_EX_WINDOW_STYLES
192 NOTE: wxPG_EX_xxx are extra window styles and must be set using
193 SetExtraStyle() member function.
195 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
196 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
197 not activated, and switching the mode first time becomes somewhat slower.
198 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
199 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
200 you don't plan to use categories at all, then using this style will result
201 in waste of resources.
204 wxPG_EX_INIT_NOCAT
= 0x00001000,
206 /** Extended window style that sets wxPropertyGridManager toolbar to not
209 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
211 /** Shows alphabetic/categoric mode buttons from toolbar.
213 wxPG_EX_MODE_BUTTONS
= 0x00008000,
215 /** Show property help strings as tool tips instead as text on the status bar.
216 You can set the help strings using SetPropertyHelpString member function.
218 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
220 /** Prevent TAB from focusing to wxButtons. This behavior was default
221 in version 1.2.0 and earlier.
222 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
223 atleast the button doesn't properly propagate key events (yes, I'm using
226 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
228 /** Allows relying on native double-buffering.
230 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
232 /** Set this style to let user have ability to set values of properties to
233 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
236 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
239 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
240 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
241 (thus they are not readable).
243 Note that this option is global, and applies to all wxPG property
246 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
248 /** Hides page selection buttons from toolbar.
250 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
252 /** Allows multiple properties to be selected by user (by pressing SHIFT
253 when clicking on a property, or by dragging with left mouse button
256 You can get array of selected properties with
257 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
258 mode wxPropertyGridInterface::GetSelection() returns
259 property which has editor active (usually the first one
260 selected). Other useful member functions are ClearSelection(),
261 AddToSelection() and RemoveFromSelection().
263 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
266 This enables top-level window tracking which allows wxPropertyGrid to
267 notify the application of last-minute property value changes by user.
269 This style is not enabled by default because it may cause crashes when
270 wxPropertyGrid is used in with wxAUI or similar system.
272 @remarks If you are not in fact using any system that may change
273 wxPropertyGrid's top-level parent window on its own, then you
274 are recommended to enable this style.
276 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000
280 #if wxPG_COMPATIBILITY_1_4
281 #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
284 /** Combines various styles.
286 #define wxPG_DEFAULT_STYLE (0)
288 /** Combines various styles.
290 #define wxPGMAN_DEFAULT_STYLE (0)
295 // -----------------------------------------------------------------------
298 // Ids for sub-controls
299 // NB: It should not matter what these are.
300 #define wxPG_SUBID1 2
301 #define wxPG_SUBID2 3
302 #define wxPG_SUBID_TEMP1 4
304 // -----------------------------------------------------------------------
306 /** @class wxPGCommonValue
308 wxPropertyGrid stores information about common values in these
311 NB: Common value feature is not complete, and thus not mentioned in
314 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
318 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
321 m_renderer
= renderer
;
324 virtual ~wxPGCommonValue()
326 m_renderer
->DecRef();
329 virtual wxString
GetEditableText() const { return m_label
; }
330 const wxString
& GetLabel() const { return m_label
; }
331 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
335 wxPGCellRenderer
* m_renderer
;
338 // -----------------------------------------------------------------------
340 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
344 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
347 /** Prevents user from leaving property unless value is valid. If this
348 behavior flag is not used, then value change is instead cancelled.
350 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
352 /** Calls wxBell() on validation failure.
354 wxPG_VFB_BEEP
= 0x02,
356 /** Cell with invalid value will be marked (with red colour).
358 wxPG_VFB_MARK_CELL
= 0x04,
360 /** Display customizable text message explaining the situation.
362 wxPG_VFB_SHOW_MESSAGE
= 0x08,
365 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
367 /** Only used internally. */
368 wxPG_VFB_UNDEFINED
= 0x80
375 typedef wxByte wxPGVFBFlags
;
380 Used to convey validation information to and from functions that
381 actually perform validation. Mostly used in custom property
384 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
386 friend class wxPropertyGrid
;
389 @return Returns failure behavior which is a combination of
390 @ref propgrid_vfbflags.
392 wxPGVFBFlags
GetFailureBehavior() const
393 { return m_failureBehavior
; }
396 Returns current failure message.
398 const wxString
& GetFailureMessage() const
399 { return m_failureMessage
; }
402 Returns reference to pending value.
404 const wxVariant
& GetValue() const
410 /** Set validation failure behavior
412 @param failureBehavior
413 Mixture of @ref propgrid_vfbflags.
415 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
416 { m_failureBehavior
= failureBehavior
; }
419 Set current failure message.
421 void SetFailureMessage(const wxString
& message
)
422 { m_failureMessage
= message
; }
425 /** Value to be validated.
429 /** Message displayed on validation failure.
431 wxString m_failureMessage
;
433 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
435 wxPGVFBFlags m_failureBehavior
;
438 // -----------------------------------------------------------------------
440 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
442 These are used with wxPropertyGrid::AddActionTrigger() and
443 wxPropertyGrid::ClearActionTriggers().
447 enum wxPG_KEYBOARD_ACTIONS
449 wxPG_ACTION_INVALID
= 0,
450 wxPG_ACTION_NEXT_PROPERTY
,
451 wxPG_ACTION_PREV_PROPERTY
,
452 wxPG_ACTION_EXPAND_PROPERTY
,
453 wxPG_ACTION_COLLAPSE_PROPERTY
,
454 wxPG_ACTION_CANCEL_EDIT
,
455 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
462 // -----------------------------------------------------------------------
465 // wxPropertyGrid::DoSelectProperty flags (selFlags)
467 // Focuses to created editor
468 #define wxPG_SEL_FOCUS 0x0001
469 // Forces deletion and recreation of editor
470 #define wxPG_SEL_FORCE 0x0002
471 // For example, doesn't cause EnsureVisible
472 #define wxPG_SEL_NONVISIBLE 0x0004
473 // Do not validate editor's value before selecting
474 #define wxPG_SEL_NOVALIDATE 0x0008
475 // Property being deselected is about to be deleted
476 #define wxPG_SEL_DELETING 0x0010
477 // Property's values was set to unspecified by the user
478 #define wxPG_SEL_SETUNSPEC 0x0020
479 // Property's event handler changed the value
480 #define wxPG_SEL_DIALOGVAL 0x0040
481 // Set to disable sending of wxEVT_PG_SELECTED event
482 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
483 // Don't make any graphics updates
484 #define wxPG_SEL_NO_REFRESH 0x0100
486 // -----------------------------------------------------------------------
491 #define wxPG_FL_INITIALIZED 0x0001
492 // Set when creating editor controls if it was clicked on.
493 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
494 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
495 #define wxPG_FL_FOCUSED 0x0008
496 #define wxPG_FL_MOUSE_CAPTURED 0x0010
497 #define wxPG_FL_MOUSE_INSIDE 0x0020
498 #define wxPG_FL_VALUE_MODIFIED 0x0040
499 // don't clear background of m_wndEditor
500 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
501 // currently active editor uses custom image
502 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
503 // cell colours override selection colours for selected cell
504 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
505 #define wxPG_FL_SCROLLED 0x0400
506 // set when all added/inserted properties get hideable flag
507 #define wxPG_FL_ADDING_HIDEABLES 0x0800
508 // Disables showing help strings on statusbar.
509 #define wxPG_FL_NOSTATUSBARHELP 0x1000
510 // Marks that we created the state, so we have to destroy it too.
511 #define wxPG_FL_CREATEDSTATE 0x2000
512 // Set if scrollbar's existence was detected in last onresize.
513 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
514 // Set if wxPGMan requires redrawing of description text box.
515 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
516 // Set if contained in wxPropertyGridManager
517 #define wxPG_FL_IN_MANAGER 0x00020000
518 // Set after wxPropertyGrid is shown in its initial good size
519 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
520 // Set when in SelectProperty.
521 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
522 // Set when help string is shown in status bar
523 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
524 // Splitter position has been custom-set by the user
525 #define wxPG_FL_SPLITTER_PRE_SET 0x00400000
526 // Validation failed. Clear on modify event.
527 #define wxPG_FL_VALIDATION_FAILED 0x00800000
528 // Auto sort is enabled (for categorized mode)
529 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
530 // Set after page has been inserted to manager
531 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
532 // Active editor control is abnormally large
533 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
534 // Recursion guard for HandleCustomEditorEvent
535 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
536 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
537 // Editor control width should not change on resize
538 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
539 // Width of panel can be different than width of grid
540 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
541 // Prevents RecalculateVirtualSize re-entrancy
542 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
544 #endif // #ifndef SWIG
546 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
547 // Reduce compile time, but still include in user app
548 #include "wx/propgrid/props.h"
551 // -----------------------------------------------------------------------
553 /** @class wxPropertyGrid
555 wxPropertyGrid is a specialized grid for editing properties
556 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
557 used to do the very same thing, but it hasn't been updated for a while
558 and it is currently deprecated.
560 Please note that most member functions are inherited and as such not
561 documented on this page. This means you will probably also want to read
562 wxPropertyGridInterface class reference.
564 See also @ref overview_propgrid.
566 @section propgrid_window_styles_ Window Styles
568 See @ref propgrid_window_styles.
570 @section propgrid_event_handling Event Handling
572 To process input from a propertygrid control, use these event handler
573 macros to direct input to member functions that take a wxPropertyGridEvent
576 @beginEventTable{wxPropertyGridEvent}
577 @event{EVT_PG_SELECTED (id, func)}
578 Respond to wxEVT_PG_SELECTED event, generated when a property selection
579 has been changed, either by user action or by indirect program
580 function. For instance, collapsing a parent property programmatically
581 causes any selected child property to become unselected, and may
582 therefore cause this event to be generated.
583 @event{EVT_PG_CHANGING(id, func)}
584 Respond to wxEVT_PG_CHANGING event, generated when property value
585 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
586 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
587 to prevent change from taking place, if necessary.
588 @event{EVT_PG_HIGHLIGHTED(id, func)}
589 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
590 moves over a property. Event's property is NULL if hovered area does
591 not belong to any property.
592 @event{EVT_PG_RIGHT_CLICK(id, func)}
593 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
594 clicked on with right mouse button.
595 @event{EVT_PG_DOUBLE_CLICK(id, func)}
596 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
597 double-clicked onwith left mouse button.
598 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
599 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
600 a property or category..
601 @event{EVT_PG_ITEM_EXPANDED(id, func)}
602 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
603 a property or category..
604 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
605 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
606 begin editing a property label. You can veto this event to prevent the
608 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
609 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
610 end editing of a property label. You can veto this event to prevent the
616 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
617 will also delay sorting etc. miscellaneous calculations to the last
623 class WXDLLIMPEXP_PROPGRID
624 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
626 friend class wxPropertyGridPageState
;
627 friend class wxPropertyGridInterface
;
628 friend class wxPropertyGridManager
;
629 friend class wxPGCanvas
;
631 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
636 Two step constructor.
638 Call Create when this constructor is called to build up the
644 /** The default constructor. The styles to be used are styles valid for
645 the wxWindow and wxScrolledWindow.
647 @see @link wndflags Additional Window Styles @endlink
649 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
650 const wxPoint
& pos
= wxDefaultPosition
,
651 const wxSize
& size
= wxDefaultSize
,
652 long style
= wxPG_DEFAULT_STYLE
,
653 const wxString
& name
= wxPropertyGridNameStr
);
656 virtual ~wxPropertyGrid();
658 /** Adds given key combination to trigger given action.
661 Which action to trigger. See @link pgactions List of list of
662 wxPropertyGrid actions@endlink.
664 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
667 This static function enables or disables automatic use of
668 wxGetTranslation for following strings: wxEnumProperty list labels,
669 wxFlagsProperty sub-property labels.
673 static void AutoGetTranslation( bool enable
);
676 Changes value of a property, as if from an editor.
678 Use this instead of SetPropertyValue() if you need the value to run
679 through validation process, and also send the property change event.
682 Returns true if value was successfully changed.
684 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
687 Centers the splitter.
689 If argument is true, automatic splitter centering is enabled (only
690 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
692 void CenterSplitter( bool enable_auto_centering
= false );
694 /** Deletes all properties.
696 virtual void Clear();
698 /** Clears action triggers for given action.
700 Which action to trigger. See @link pgactions List of list of
701 wxPropertyGrid actions@endlink.
703 void ClearActionTriggers( int action
);
705 /** Forces updating the value of property from the editor control.
707 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
708 ProcessEvent, meaning your event handlers will be called immediately.
711 Returns true if anything was changed.
713 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
718 Whenever the control is created without any parameters, use Create to
719 actually create it. Don't access the control's public methods before
720 this is called @see @link wndflags Additional Window Styles@endlink
722 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
723 const wxPoint
& pos
= wxDefaultPosition
,
724 const wxSize
& size
= wxDefaultSize
,
725 long style
= wxPG_DEFAULT_STYLE
,
726 const wxString
& name
= wxPropertyGridNameStr
);
729 Call when editor widget's contents is modified.
731 For example, this is called when changes text in wxTextCtrl (used in
732 wxStringProperty and wxIntProperty).
735 This function should only be called by custom properties.
737 @see wxPGProperty::OnEvent()
739 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
741 /** Reverse of EditorsValueWasModified().
744 This function should only be called by custom properties.
746 void EditorsValueWasNotModified()
748 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
752 Enables or disables (shows/hides) categories according to parameter
755 bool EnableCategories( bool enable
);
757 /** Scrolls and/or expands items to ensure that the given item is visible.
758 Returns true if something was actually done.
760 bool EnsureVisible( wxPGPropArg id
);
763 Reduces column sizes to minimum possible that contents are still
764 visibly (naturally some margin space will be applied as well).
767 Minimum size for the grid to still display everything.
770 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
772 This function only works properly if grid size prior to call was already
775 Note that you can also get calculated column widths by calling
776 GetState->GetColumnWidth() immediately after this function returns.
780 wxSize sz
= m_pState
->DoFitColumns();
785 Returns wxWindow that the properties are painted on, and which should
786 be used as the parent for editor controls.
788 wxPanel
* GetPanel() const
793 /** Returns current category caption background colour. */
794 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
796 wxFont
& GetCaptionFont() { return m_captionFont
; }
798 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
800 /** Returns current category caption text colour. */
801 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
803 /** Returns current cell background colour. */
804 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
806 /** Returns current cell text colour when disabled. */
807 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
809 /** Returns current cell text colour. */
810 wxColour
GetCellTextColour() const { return m_colPropFore
; }
813 Returns number of columns currently on grid.
815 unsigned int GetColumnCount() const
817 return (unsigned int) m_pState
->m_colWidths
.size();
820 /** Returns colour of empty space below properties. */
821 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
823 /** Returns height of highest characters of used font. */
824 int GetFontHeight() const { return m_fontHeight
; }
826 /** Returns pointer to itself. Dummy function that enables same kind
827 of code to use wxPropertyGrid and wxPropertyGridManager.
829 wxPropertyGrid
* GetGrid() { return this; }
831 /** Returns rectangle of custom paint image.
833 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
835 /** Returns size of the custom paint image in front of property.
836 If no argument is given, returns preferred size.
838 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
841 /** Returns last item which could be iterated using given flags.
843 See @ref propgrid_iterator_flags.
845 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
847 return m_pState
->GetLastItem(flags
);
850 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
852 return m_pState
->GetLastItem(flags
);
856 /** Returns colour of lines between cells. */
857 wxColour
GetLineColour() const { return m_colLine
; }
859 /** Returns background colour of margin. */
860 wxColour
GetMarginColour() const { return m_colMargin
; }
863 Returns most up-to-date value of selected property. This will return
864 value different from GetSelectedProperty()->GetValue() only when text
865 editor is activate and string edited by user represents valid,
866 uncommitted property value.
868 wxVariant
GetUncommittedPropertyValue();
870 /** Returns "root property". It does not have name, etc. and it is not
871 visible. It is only useful for accessing its children.
873 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
875 /** Returns height of a single grid row (in pixels). */
876 int GetRowHeight() const { return m_lineHeight
; }
878 /** Returns currently selected property. */
879 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
881 /** Returns current selection background colour. */
882 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
884 /** Returns current selection text colour. */
885 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
887 /** Returns current splitter x position. */
888 int GetSplitterPosition() const
889 { return m_pState
->DoGetSplitterPosition(0); }
891 /** Returns wxTextCtrl active in currently selected property, if any. Takes
892 into account wxOwnerDrawnComboBox.
894 wxTextCtrl
* GetEditorTextCtrl() const;
896 wxPGValidationInfo
& GetValidationInfo()
898 return m_validationInfo
;
901 /** Returns current vertical spacing. */
902 int GetVerticalSpacing() const { return (int)m_vspacing
; }
905 Returns @true if a property editor control has focus.
907 bool IsEditorFocused() const;
909 /** Returns true if editor's value was marked modified.
911 bool IsEditorsValueModified() const
912 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
915 Returns information about arbitrary position in the grid.
918 Coordinates in the virtual grid space. You may need to use
919 wxScrolledWindow::CalcScrolledPosition() for translating
920 wxPropertyGrid client coordinates into something this member
923 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
925 /** Returns true if any property has been modified by the user. */
926 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
929 Returns true if updating is frozen (ie Freeze() called but not yet
932 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
935 It is recommended that you call this function any time your code causes
936 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
937 handler should be able to detect most changes, but it is not perfect.
940 New top-level parent that is about to be set. Old top-level parent
941 window should still exist as the current one.
943 @remarks This function is automatically called from wxPropertyGrid::
944 Reparent() and wxPropertyGridManager::Reparent(). You only
945 need to use it if you reparent wxPropertyGrid indirectly.
947 void OnTLPChanging( wxWindow
* newTLP
);
949 /** Redraws given property.
951 virtual void RefreshProperty( wxPGProperty
* p
);
954 /** Registers a new editor class.
956 Pointer to the editor class instance that should be used.
958 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
959 bool noDefCheck
= false )
961 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
964 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
965 const wxString
& editorName
,
966 bool noDefCheck
= false );
969 /** Resets all colours to the original system values.
975 Editor widget is automatically created, but not focused unless focus is
982 True if selection finished successfully. Usually only fails if
983 current value in editor is not valid.
985 @remarks In wxPropertyGrid 1.4, this member function used to generate
986 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
989 @remarks This clears any previous selection.
991 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
994 Set entire new selection from given list of properties.
996 void SetSelection( const wxArrayPGProperty
& newSelection
)
998 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
1002 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
1003 extra style is not used, then this has same effect as
1004 calling SelectProperty().
1006 @remarks Multiple selection is not supported for categories. This
1007 means that if you have properties selected, you cannot
1008 add category to selection, and also if you have category
1009 selected, you cannot add other properties to selection.
1010 This member function will fail silently in these cases,
1011 even returning true.
1013 bool AddToSelection( wxPGPropArg id
)
1015 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1016 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1020 Removes given property from selection. If property is not selected,
1021 an assertion failure will occur.
1023 bool RemoveFromSelection( wxPGPropArg id
)
1025 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1026 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1030 Makes given column editable by user.
1033 Using @false here will disable column from being editable.
1035 void MakeColumnEditable( unsigned int column
, bool editable
= true );
1038 Creates label editor wxTextCtrl for given column, for property
1039 that is currently selected. When multiple selection is
1040 enabled, this applies to whatever property GetSelection()
1044 Which column's label to edit. Note that you should not
1045 use value 1, which is reserved for property value
1048 @see EndLabelEdit(), MakeColumnEditable()
1050 void BeginLabelEdit( unsigned int column
= 0 )
1052 DoBeginLabelEdit(column
, wxPG_SEL_DONT_SEND_EVENT
);
1056 Destroys label editor wxTextCtrl, if any.
1059 Use @true (default) to store edited label text in
1062 @see BeginLabelEdit(), MakeColumnEditable()
1064 void EndLabelEdit( bool commit
= true )
1066 DoEndLabelEdit(commit
, wxPG_SEL_DONT_SEND_EVENT
);
1070 Returns currently active label editor, NULL if none.
1072 wxTextCtrl
* GetLabelEditor() const
1074 return m_labelEditor
;
1077 /** Sets category caption background colour. */
1078 void SetCaptionBackgroundColour(const wxColour
& col
);
1080 /** Sets category caption text colour. */
1081 void SetCaptionTextColour(const wxColour
& col
);
1083 /** Sets default cell background colour - applies to property cells.
1084 Note that appearance of editor widgets may not be affected.
1086 void SetCellBackgroundColour(const wxColour
& col
);
1088 /** Sets cell text colour for disabled properties.
1090 void SetCellDisabledTextColour(const wxColour
& col
);
1092 /** Sets default cell text colour - applies to property name and value text.
1093 Note that appearance of editor widgets may not be affected.
1095 void SetCellTextColour(const wxColour
& col
);
1097 /** Set number of columns (2 or more).
1099 void SetColumnCount( int colCount
)
1101 m_pState
->SetColumnCount(colCount
);
1106 Sets the 'current' category - Append will add non-category properties
1109 void SetCurrentCategory( wxPGPropArg id
)
1111 wxPG_PROP_ARG_CALL_PROLOG()
1112 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1114 m_pState
->m_currentCategory
= pc
;
1117 /** Sets colour of empty space below properties. */
1118 void SetEmptySpaceColour(const wxColour
& col
);
1120 /** Sets colour of lines between cells. */
1121 void SetLineColour(const wxColour
& col
);
1123 /** Sets background colour of margin. */
1124 void SetMarginColour(const wxColour
& col
);
1127 Sets selection background colour - applies to selected property name
1130 void SetSelectionBackgroundColour(const wxColour
& col
);
1133 Sets selection foreground colour - applies to selected property name
1136 void SetSelectionTextColour(const wxColour
& col
);
1138 /** Sets x coordinate of the splitter.
1140 Splitter position cannot exceed grid size, and therefore setting it
1141 during form creation may fail as initial grid size is often smaller
1142 than desired splitter position, especially when sizers are being used.
1144 void SetSplitterPosition( int newxpos
, int col
= 0 )
1146 DoSetSplitterPosition_(newxpos
, true, col
);
1147 m_iFlags
|= wxPG_FL_SPLITTER_PRE_SET
;
1151 Sets the property sorting function.
1154 The sorting function to be used. It should return a value greater
1155 than 0 if position of p1 is after p2. So, for instance, when
1156 comparing property names, you can use following implementation:
1159 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1163 return p1->GetBaseName().compare( p2->GetBaseName() );
1168 Default property sort function sorts properties by their labels
1169 (case-insensitively).
1171 @see GetSortFunction, wxPropertyGridInterface::Sort,
1172 wxPropertyGridInterface::SortChildren
1174 void SetSortFunction( wxPGSortCallback sortFunction
)
1176 m_sortFunction
= sortFunction
;
1180 Returns the property sort function (default is @NULL).
1182 @see SetSortFunction
1184 wxPGSortCallback
GetSortFunction() const
1186 return m_sortFunction
;
1189 /** Set virtual width for this particular page. Width -1 indicates that the
1190 virtual width should be disabled. */
1191 void SetVirtualWidth( int width
);
1194 Moves splitter as left as possible, while still allowing all
1195 labels to be shown in full.
1197 @param privateChildrenToo
1198 If @false, will still allow private children to be cropped.
1200 void SetSplitterLeft( bool privateChildrenToo
= false )
1202 m_pState
->SetSplitterLeft(privateChildrenToo
);
1205 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1206 height. Value of 2 should be default on most platforms.
1208 void SetVerticalSpacing( int vspacing
)
1210 m_vspacing
= (unsigned char)vspacing
;
1211 CalculateFontAndBitmapStuff( vspacing
);
1212 if ( !m_pState
->m_itemsAdded
) Refresh();
1215 /** Shows an brief error message that is related to a property. */
1216 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1218 wxPG_PROP_ARG_CALL_PROLOG()
1219 DoShowPropertyError(p
, msg
);
1222 /////////////////////////////////////////////////////////////////
1224 // Following methods do not need to be (currently) documented
1226 /////////////////////////////////////////////////////////////////
1228 bool HasVirtualWidth() const
1229 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1231 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1233 return (wxPGCommonValue
*) m_commonValues
[i
];
1236 /** Returns number of common values.
1238 unsigned int GetCommonValueCount() const
1240 return (unsigned int) m_commonValues
.size();
1243 /** Returns label of given common value.
1245 wxString
GetCommonValueLabel( unsigned int i
) const
1247 wxASSERT( GetCommonValue(i
) );
1248 return GetCommonValue(i
)->GetLabel();
1252 Returns index of common value that will truly change value to
1255 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1257 /** Set index of common value that will truly change value to unspecified.
1258 Using -1 will set none to have such effect.
1261 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1264 Shortcut for creating dialog-caller button. Used, for example, by
1267 This should only be called by properties.
1269 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1271 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1272 fits as one). Call after control has been created (but before
1275 void FixPosForTextCtrl( wxWindow
* ctrl
,
1276 unsigned int forColumn
= 1,
1277 const wxPoint
& offset
= wxPoint(0, 0) );
1279 /** Shortcut for creating text editor widget.
1281 Same as pos given for CreateEditor.
1283 Same as sz given for CreateEditor.
1285 Initial text for wxTextCtrl.
1287 If right-side control, such as button, also created, then create it
1288 first and pass it as this parameter.
1290 Extra style flags to pass for wxTextCtrl.
1292 Note that this should generally be called only by new classes derived
1295 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1297 const wxString
& value
,
1298 wxWindow
* secondary
,
1301 unsigned int forColumn
= 1 );
1303 /* Generates both textctrl and button.
1305 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1306 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1307 wxPGProperty
* property
);
1309 /** Generates position for a widget editor dialog box.
1311 Property for which dialog is positioned.
1313 Known or over-approximated size of the dialog.
1315 Position for dialog.
1317 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1320 // Converts escape sequences in src_str to newlines,
1321 // tabs, etc. and copies result to dst_str.
1322 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1323 wxString
& src_str
);
1325 // Converts newlines, tabs, etc. in src_str to escape
1326 // sequences, and copies result to dst_str.
1327 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1328 wxString
& src_str
);
1331 Returns rectangle that fully contains properties between and including
1334 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1335 const wxPGProperty
* p2
) const;
1337 /** Returns pointer to current active primary editor control (NULL if none).
1339 wxWindow
* GetEditorControl() const;
1341 wxWindow
* GetPrimaryEditor() const
1343 return GetEditorControl();
1347 Returns pointer to current active secondary editor control (NULL if
1350 wxWindow
* GetEditorControlSecondary() const
1352 return m_wndEditor2
;
1356 Refreshes any active editor control.
1358 void RefreshEditor();
1360 // Events from editor controls are forward to this function
1361 void HandleCustomEditorEvent( wxEvent
&event
);
1366 Generates contents for string dst based on the contents of
1369 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1370 so on. Set flags to 1 inorder to convert backslashes to double-back-
1371 slashes and "(preDelims)"'s to "(preDelims)".
1373 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1374 wxChar preDelim
, wxChar postDelim
,
1377 // Mostly useful for page switching.
1378 void SwitchState( wxPropertyGridPageState
* pNewState
);
1380 long GetInternalFlags() const { return m_iFlags
; }
1381 bool HasInternalFlag( long flag
) const
1382 { return (m_iFlags
& flag
) ? true : false; }
1383 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1384 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1385 void IncFrozen() { m_frozen
++; }
1386 void DecFrozen() { m_frozen
--; }
1388 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1394 /** Standardized double-to-string conversion.
1396 static void DoubleToString( wxString
& target
,
1400 wxString
* precTemplate
);
1403 Call this from wxPGProperty::OnEvent() to cause property value to be
1404 changed after the function returns (with true as return value).
1405 ValueChangeInEvent() must be used if you wish the application to be
1406 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1408 void ValueChangeInEvent( wxVariant variant
)
1410 m_changeInEventValue
= variant
;
1411 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1415 You can use this member function, for instance, to detect in
1416 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1417 already called in wxPGEditor::OnEvent(). It really only detects
1418 if was value was changed using wxPGProperty::SetValueInEvent(), which
1419 is usually used when a 'picker' dialog is displayed. If value was
1420 written by "normal means" in wxPGProperty::StringToValue() or
1421 IntToValue(), then this function will return false (on the other hand,
1422 wxPGProperty::OnEvent() is not even called in those cases).
1424 bool WasValueChangedInEvent() const
1426 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1429 /** Returns true if given event is from first of an array of buttons
1430 (as can be in case when wxPGMultiButton is used).
1432 bool IsMainButtonEvent( const wxEvent
& event
)
1434 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1435 && (m_wndSecId
== event
.GetId());
1438 /** Pending value is expected to be passed in PerformValidation().
1440 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1441 unsigned int selFlags
= 0 );
1443 /** Called when validation for given property fails.
1445 Value which failed in validation.
1447 Return true if user is allowed to change to another property even
1448 if current has invalid value.
1450 To add your own validation failure behavior, override
1451 wxPropertyGrid::DoOnValidationFailure().
1453 bool OnValidationFailure( wxPGProperty
* property
,
1454 wxVariant
& invalidValue
);
1456 /** Called to indicate property and editor has valid value now.
1458 void OnValidationFailureReset( wxPGProperty
* property
)
1460 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1462 DoOnValidationFailureReset(property
);
1463 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1465 m_validationInfo
.m_failureMessage
.clear();
1468 /** Override in derived class to display error messages in custom manner
1469 (these message usually only result from validation failure).
1471 virtual void DoShowPropertyError( wxPGProperty
* property
,
1472 const wxString
& msg
);
1474 /** Override to customize property validation failure behavior.
1476 Value which failed in validation.
1478 Return true if user is allowed to change to another property even
1479 if current has invalid value.
1481 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1482 wxVariant
& invalidValue
);
1484 /** Override to customize resetting of property validation failure status.
1486 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1488 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1490 int GetSpacingY() const { return m_spacingy
; }
1493 Must be called in wxPGEditor::CreateControls() if primary editor window
1494 is wxTextCtrl, just before textctrl is created.
1496 Initial text value of created wxTextCtrl.
1498 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1501 Unfocuses or closes editor if one was open, but does not deselect
1504 bool UnfocusEditor();
1506 virtual void SetWindowStyleFlag( long style
);
1508 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1510 void DrawItem( wxPGProperty
* p
)
1515 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1518 Draws item, children, and consequtive parents as long as category is
1521 void DrawItemAndValueRelated( wxPGProperty
* p
);
1526 wxPropertyGridPageState used by the grid is created here.
1528 If grid is used in wxPropertyGridManager, there is no point overriding
1529 this - instead, set custom wxPropertyGridPage classes.
1531 virtual wxPropertyGridPageState
* CreateState() const;
1533 enum PerformValidationFlags
1535 SendEvtChanging
= 0x0001,
1536 IsStandaloneValidation
= 0x0002 // Not called in response to event
1540 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1541 Returns true if all tests passed. Implement in derived class to
1542 add additional validation behavior.
1544 virtual bool PerformValidation( wxPGProperty
* p
,
1545 wxVariant
& pendingValue
,
1546 int flags
= SendEvtChanging
);
1550 // Control font changer helper.
1551 void SetCurControlBoldFont();
1553 wxPGCell
& GetPropertyDefaultCell()
1555 return m_propertyDefaultCell
;
1558 wxPGCell
& GetCategoryDefaultCell()
1560 return m_categoryDefaultCell
;
1564 // Public methods for semi-public use
1566 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1568 // Overridden functions.
1569 virtual bool Destroy();
1570 // Returns property at given y coordinate (relative to grid's top left).
1571 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1573 virtual void Refresh( bool eraseBackground
= true,
1574 const wxRect
*rect
= (const wxRect
*) NULL
);
1575 virtual bool SetFont( const wxFont
& font
);
1576 #if wxPG_SUPPORT_TOOLTIPS
1577 void SetToolTip( const wxString
& tipString
);
1579 virtual void Freeze();
1580 virtual void SetExtraStyle( long exStyle
);
1581 virtual void Thaw();
1582 virtual bool Reparent( wxWindowBase
*newParent
);
1585 virtual wxSize
DoGetBestSize() const;
1587 #ifndef wxPG_ICON_WIDTH
1588 wxBitmap
*m_expandbmp
, *m_collbmp
;
1591 wxCursor
*m_cursorSizeWE
;
1593 /** wxWindow pointers to editor control(s). */
1594 wxWindow
*m_wndEditor
;
1595 wxWindow
*m_wndEditor2
;
1597 /** wxPGCanvas instance. */
1600 #if wxPG_DOUBLE_BUFFER
1601 wxBitmap
*m_doubleBuffer
;
1604 /** Local time ms when control was created. */
1605 wxLongLong m_timeCreated
;
1607 /** wxPGProperty::OnEvent can change value by setting this. */
1608 wxVariant m_changeInEventValue
;
1610 /** Id of m_wndEditor2, or its first child, if any. */
1613 /** Extra Y spacing between the items. */
1616 /** Control client area width; updated on resize. */
1619 /** Control client area height; updated on resize. */
1622 /** Current non-client width (needed when auto-centering). */
1625 /** Non-client width (auto-centering helper). */
1628 /** Previously recorded scroll start position. */
1632 The gutter spacing in front and back of the image.
1633 This determines the amount of spacing in front of each item
1637 /** Includes separator line. */
1640 /** Gutter*2 + image width. */
1643 // y spacing for expand/collapse button.
1644 int m_buttonSpacingY
;
1646 /** Extra margin for expanded sub-group items. */
1647 int m_subgroup_extramargin
;
1650 The image width of the [+] icon.
1652 This is also calculated in the gutter
1656 #ifndef wxPG_ICON_WIDTH
1659 The image height of the [+] icon.
1661 This is calculated as minimal size and to align
1666 /** Current cursor id. */
1670 This captionFont is made equal to the font of the wxScrolledWindow.
1672 As extra the bold face is set on it when this is wanted by the user
1675 wxFont m_captionFont
;
1677 int m_fontHeight
; // Height of the font.
1679 /** m_splitterx when drag began. */
1680 int m_startingSplitterX
;
1683 Index to splitter currently being dragged (0=one after the first
1686 int m_draggedSplitter
;
1688 /** Changed property, calculated in PerformValidation(). */
1689 wxPGProperty
* m_chgInfo_changedProperty
;
1692 Lowest property for which editing happened, but which does not have
1695 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1697 /** Changed property value, calculated in PerformValidation(). */
1698 wxVariant m_chgInfo_pendingValue
;
1700 /** Passed to SetValue. */
1701 wxVariant m_chgInfo_valueList
;
1703 /** Validation information. */
1704 wxPGValidationInfo m_validationInfo
;
1706 /** Actions and keys that trigger them. */
1707 wxPGHashMapI2I m_actionTriggers
;
1713 /** Bits are used to indicate which colours are customized. */
1714 unsigned short m_coloursCustomized
;
1716 /** x - m_splitterx. */
1717 signed char m_dragOffset
;
1719 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1720 unsigned char m_dragStatus
;
1722 /** 0 = margin, 1 = label, 2 = value. */
1723 unsigned char m_mouseSide
;
1725 /** True when editor control is focused. */
1726 unsigned char m_editorFocused
;
1728 /** 1 if m_latsCaption is also the bottommost caption. */
1729 //unsigned char m_lastCaptionBottomnest;
1731 /** Set to 1 when graphics frozen. */
1732 unsigned char m_frozen
;
1734 unsigned char m_vspacing
;
1736 // Used to track when Alt/Ctrl+Key was consumed.
1737 unsigned char m_keyComboConsumed
;
1739 /** 1 if in DoPropertyChanged() */
1740 unsigned char m_inDoPropertyChanged
;
1742 /** 1 if in CommitChangesFromEditor() */
1743 unsigned char m_inCommitChangesFromEditor
;
1745 /** 1 if in DoSelectProperty() */
1746 unsigned char m_inDoSelectProperty
;
1748 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1750 /** Internal flags - see wxPG_FL_XXX constants. */
1753 /** When drawing next time, clear this many item slots at the end. */
1754 int m_clearThisMany
;
1756 // Mouse is hovering over this column (index)
1757 unsigned int m_colHover
;
1759 // pointer to property that has mouse hovering
1760 wxPGProperty
* m_propHover
;
1762 // Active label editor
1763 wxTextCtrl
* m_labelEditor
;
1765 // For which property the label editor is active
1766 wxPGProperty
* m_labelEditorProperty
;
1768 // EventObject for wxPropertyGridEvents
1769 wxWindow
* m_eventObject
;
1771 // What (global) window is currently focused (needed to resolve event
1773 wxWindow
* m_curFocused
;
1775 // Last known top-level parent
1778 // Last closed top-level parent
1779 wxWindow
* m_tlpClosed
;
1781 // Local time ms when tlp was closed.
1782 wxLongLong m_tlpClosedTime
;
1785 wxPGSortCallback m_sortFunction
;
1787 // y coordinate of property that mouse hovering
1790 // Which column's editor is selected (usually 1)?
1791 unsigned int m_selColumn
;
1793 // x relative to splitter (needed for resize).
1796 // lines between cells
1798 // property labels and values are written in this colour
1799 wxColour m_colPropFore
;
1800 // or with this colour when disabled
1801 wxColour m_colDisPropFore
;
1802 // background for m_colPropFore
1803 wxColour m_colPropBack
;
1804 // text color for captions
1805 wxColour m_colCapFore
;
1806 // background color for captions
1807 wxColour m_colCapBack
;
1808 // foreground for selected property
1809 wxColour m_colSelFore
;
1810 // background for selected property (actually use background color when
1811 // control out-of-focus)
1812 wxColour m_colSelBack
;
1813 // background colour for margin
1814 wxColour m_colMargin
;
1815 // background colour for empty space below the grid
1816 wxColour m_colEmptySpace
;
1818 // Default property colours
1819 wxPGCell m_propertyDefaultCell
;
1821 // Default property category
1822 wxPGCell m_categoryDefaultCell
;
1824 // Backup of selected property's cells
1825 wxVector
<wxPGCell
> m_propCellsBackup
;
1827 // NB: These *cannot* be moved to globals.
1829 // labels when properties use common values
1830 wxVector
<wxPGCommonValue
*> m_commonValues
;
1832 // Which cv selection really sets value to unspecified?
1833 int m_cvUnspecified
;
1835 // Used to skip excess text editor events
1836 wxString m_prevTcValue
;
1840 // Sets some members to defaults (called constructors).
1843 // Initializes some members (called by Create and complex constructor).
1846 void OnPaint(wxPaintEvent
&event
);
1848 // main event receivers
1849 void OnMouseMove( wxMouseEvent
&event
);
1850 void OnMouseMoveBottom( wxMouseEvent
&event
);
1851 void OnMouseClick( wxMouseEvent
&event
);
1852 void OnMouseRightClick( wxMouseEvent
&event
);
1853 void OnMouseDoubleClick( wxMouseEvent
&event
);
1854 void OnMouseUp( wxMouseEvent
&event
);
1855 void OnKey( wxKeyEvent
&event
);
1856 void OnResize( wxSizeEvent
&event
);
1859 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
1860 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1861 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1862 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1863 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
1864 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
1866 void OnMouseEntry( wxMouseEvent
&event
);
1868 void OnIdle( wxIdleEvent
&event
);
1869 void OnFocusEvent( wxFocusEvent
&event
);
1870 void OnChildFocusEvent( wxChildFocusEvent
& event
);
1872 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
1873 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
1875 // sub-control event handlers
1876 void OnMouseClickChild( wxMouseEvent
&event
);
1877 void OnMouseRightClickChild( wxMouseEvent
&event
);
1878 void OnMouseMoveChild( wxMouseEvent
&event
);
1879 void OnMouseUpChild( wxMouseEvent
&event
);
1880 void OnChildKeyDown( wxKeyEvent
&event
);
1882 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
1884 void OnScrollEvent( wxScrollWinEvent
&event
);
1886 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
1888 void OnTLPClose( wxCloseEvent
& event
);
1892 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
1893 unsigned int colIndex
,
1894 wxMouseEvent
* event
= NULL
,
1898 Adjust the centering of the bitmap icons (collapse / expand) when the
1899 caption font changes.
1901 They need to be centered in the middle of the font, so a bit of deltaY
1902 adjustment is needed. On entry, m_captionFont must be set to window
1903 font. It will be modified properly.
1905 void CalculateFontAndBitmapStuff( int vspacing
);
1907 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
1909 void CorrectEditorWidgetSizeX();
1911 /** Called in RecalculateVirtualSize() to reposition control
1912 on virtual height changes.
1914 void CorrectEditorWidgetPosY();
1916 int DoDrawItems( wxDC
& dc
,
1917 const wxRect
* clipRect
,
1918 bool isBuffered
) const;
1920 /** Draws an expand/collapse (ie. +/-) button.
1922 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1923 wxPGProperty
* property
) const;
1925 /** Draws items from topitemy to bottomitemy */
1926 void DrawItems( wxDC
& dc
, unsigned int topitemy
, unsigned int bottomitemy
,
1927 const wxRect
* clip_rect
= (const wxRect
*) NULL
);
1929 // Translate wxKeyEvent to wxPG_ACTION_XXX
1930 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
1932 int KeyEventToAction(wxKeyEvent
&event
) const
1934 return KeyEventToActions(event
, NULL
);
1937 void ImprovedClientToScreen( int* px
, int* py
);
1939 // Called by focus event handlers. newFocused is the window that becomes
1941 void HandleFocusChange( wxWindow
* newFocused
);
1943 /** Reloads all non-customized colours from system settings. */
1944 void RegainColours();
1946 bool DoEditorValidate();
1948 // Similar to DoSelectProperty() but also works on columns
1949 // other than 1. Does not active editor if column is not
1951 bool DoSelectAndEdit( wxPGProperty
* prop
,
1952 unsigned int colIndex
,
1953 unsigned int selFlags
);
1955 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
1958 bool DoAddToSelection( wxPGProperty
* prop
,
1961 bool DoRemoveFromSelection( wxPGProperty
* prop
,
1964 void DoBeginLabelEdit( unsigned int colIndex
, int selFlags
= 0 );
1965 void DoEndLabelEdit( bool commit
, int selFlags
= 0 );
1966 void OnLabelEditorEnterPress( wxCommandEvent
& event
);
1967 void OnLabelEditorKeyPress( wxKeyEvent
& event
);
1969 wxPGProperty
* DoGetItemAtY( int y
) const;
1971 void DoSetSplitterPosition_( int newxpos
,
1972 bool refresh
= true,
1973 int splitterIndex
= 0,
1974 bool allPages
= false );
1976 void DestroyEditorWnd( wxWindow
* wnd
);
1979 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
1981 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
1983 // Returns nearest paint visible property (such that will be painted unless
1984 // window is scrolled or resized). If given property is paint visible, then
1985 // it itself will be returned.
1986 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
1988 static void RegisterDefaultEditors();
1990 // Sets up basic event handling for child control
1991 void SetupChildEventHandling( wxWindow
* wnd
);
1993 void CustomSetCursor( int type
, bool override
= false );
1996 Repositions scrollbar and underlying panel according to changed virtual
1999 void RecalculateVirtualSize( int forceXPos
= -1 );
2001 void PrepareAfterItemsAdded();
2003 // Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
2004 bool SendEvent( int eventType
, wxPGProperty
* p
,
2005 wxVariant
* pValue
= NULL
,
2006 unsigned int selFlags
= wxPG_SEL_NOVALIDATE
,
2007 unsigned int column
= 1 );
2009 void SetFocusOnCanvas();
2011 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
2015 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
2017 DECLARE_EVENT_TABLE()
2018 #endif // #ifndef SWIG
2021 // -----------------------------------------------------------------------
2023 // Bunch of inlines that need to resolved after all classes have been defined.
2027 inline bool wxPropertyGridPageState::IsDisplayed() const
2029 return ( this == m_pPropGrid
->GetState() );
2032 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
2034 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
2038 inline int wxPGProperty::GetDisplayedCommonValueCount() const
2040 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
2042 wxPropertyGrid
* pg
= GetGrid();
2044 return (int) pg
->GetCommonValueCount();
2049 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
2051 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
2054 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
2056 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
2059 inline bool wxPGProperty::Hide( bool hide
, int flags
)
2061 return GetGrid()->HideProperty(this, hide
, flags
);
2064 inline bool wxPGProperty::SetMaxLength( int maxLen
)
2066 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
2069 // -----------------------------------------------------------------------
2071 #define wxPG_BASE_EVT_PRE_ID 1775
2075 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
2076 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
2077 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
2078 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
2079 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
2080 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
2081 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
2082 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
2083 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
2084 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2085 wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
2086 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2087 wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
2091 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
2094 wxEVT_PG_HIGHLIGHTED
,
2095 wxEVT_PG_RIGHT_CLICK
,
2096 wxEVT_PG_PAGE_CHANGED
,
2097 wxEVT_PG_ITEM_COLLAPSED
,
2098 wxEVT_PG_ITEM_EXPANDED
,
2099 wxEVT_PG_DOUBLE_CLICK
,
2100 wxEVT_PG_LABEL_EDIT_BEGIN
,
2101 wxEVT_PG_LABEL_EDIT_ENDING
2106 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2107 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2111 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2113 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2114 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2115 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2116 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2117 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2118 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2119 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2120 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2121 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2122 #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 ),
2123 #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 ),
2125 #define wxPropertyGridEventHandler(fn) \
2126 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2131 /** @class wxPropertyGridEvent
2133 A propertygrid event holds information about events associated with
2134 wxPropertyGrid objects.
2136 @library{wxpropgrid}
2139 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2144 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2146 /** Copy constructor. */
2147 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2150 ~wxPropertyGridEvent();
2153 virtual wxEvent
* Clone() const;
2156 Returns the column index associated with this event.
2158 unsigned int GetColumn() const
2163 wxPGProperty
* GetMainParent() const
2165 wxASSERT(m_property
);
2166 return m_property
->GetMainParent();
2169 /** Returns id of associated property. */
2170 wxPGProperty
* GetProperty() const
2175 wxPGValidationInfo
& GetValidationInfo()
2177 wxASSERT(m_validationInfo
);
2178 return *m_validationInfo
;
2181 /** Returns true if you can veto the action that the event is signaling.
2183 bool CanVeto() const { return m_canVeto
; }
2186 Call this from your event handler to veto action that the event is
2189 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2192 Currently only wxEVT_PG_CHANGING supports vetoing.
2194 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2196 /** Returns value that is about to be set for wxEVT_PG_CHANGING.
2198 const wxVariant
& GetValue() const
2200 wxASSERT_MSG( m_validationInfo
,
2201 "Only call GetValue from a handler "
2202 "of event type that supports it" );
2203 return m_validationInfo
->GetValue();
2207 Set override validation failure behavior.
2209 Only effective if Veto was also called, and only allowed if event type
2210 is wxEVT_PG_CHANGING.
2212 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2214 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2215 m_validationInfo
->SetFailureBehavior( flags
);
2218 /** Sets custom failure message for this time only. Only applies if
2219 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2221 void SetValidationFailureMessage( const wxString
& message
)
2223 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2224 m_validationInfo
->SetFailureMessage( message
);
2228 wxPGVFBFlags
GetValidationFailureBehavior() const
2230 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2231 return m_validationInfo
->GetFailureBehavior();
2234 void SetColumn( unsigned int column
)
2239 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2240 bool WasVetoed() const { return m_wasVetoed
; }
2242 /** Changes the associated property. */
2243 void SetProperty( wxPGProperty
* p
) { m_property
= p
; }
2245 void SetPropertyGrid( wxPropertyGrid
* pg
) { m_pg
= pg
; }
2247 void SetupValidationInfo()
2250 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2251 m_validationInfo
= &m_pg
->GetValidationInfo();
2256 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2258 wxPGProperty
* m_property
;
2259 wxPropertyGrid
* m_pg
;
2260 wxPGValidationInfo
* m_validationInfo
;
2262 unsigned int m_column
;
2271 // -----------------------------------------------------------------------
2273 /** @class wxPropertyGridPopulator
2275 Allows populating wxPropertyGrid from arbitrary text source.
2277 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2280 /** Default constructor.
2282 wxPropertyGridPopulator();
2285 virtual ~wxPropertyGridPopulator();
2287 void SetState( wxPropertyGridPageState
* state
);
2289 void SetGrid( wxPropertyGrid
* pg
);
2291 /** Appends a new property under bottommost parent.
2293 Property class as string.
2295 wxPGProperty
* Add( const wxString
& propClass
,
2296 const wxString
& propLabel
,
2297 const wxString
& propName
,
2298 const wxString
* propValue
,
2299 wxPGChoices
* pChoices
= NULL
);
2302 Pushes property to the back of parent array (ie it becomes bottommost
2303 parent), and starts scanning/adding children for it.
2305 When finished, parent array is returned to the original state.
2307 void AddChildren( wxPGProperty
* property
);
2309 /** Adds attribute to the bottommost property.
2311 Allowed values: "string", (same as string), "int", "bool". Empty string
2314 bool AddAttribute( const wxString
& name
,
2315 const wxString
& type
,
2316 const wxString
& value
);
2318 /** Called once in AddChildren.
2320 virtual void DoScanForChildren() = 0;
2323 Returns id of parent property for which children can currently be
2326 wxPGProperty
* GetCurParent() const
2328 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2331 wxPropertyGridPageState
* GetState() { return m_state
; }
2332 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2334 /** Like wxString::ToLong, except allows N% in addition of N.
2336 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2338 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2339 wxPGChoices. Registers parsed result using idString (if not empty).
2340 Also, if choices with given id already registered, then don't parse but
2341 return those choices instead.
2343 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2344 const wxString
& idString
);
2346 /** Implement in derived class to do custom process when an error occurs.
2347 Default implementation uses wxLogError.
2349 virtual void ProcessError( const wxString
& msg
);
2353 /** Used property grid. */
2354 wxPropertyGrid
* m_pg
;
2356 /** Used property grid state. */
2357 wxPropertyGridPageState
* m_state
;
2359 /** Tree-hierarchy of added properties (that can have children). */
2360 wxArrayPGProperty m_propHierarchy
;
2362 /** Hashmap for string-id to wxPGChoicesData mapping. */
2363 wxPGHashMapS2P m_dictIdChoices
;
2366 // -----------------------------------------------------------------------
2369 // Undefine macros that are not needed outside propertygrid sources
2371 #ifndef __wxPG_SOURCE_FILE__
2372 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2373 #undef wxPG_FL_SCROLLBAR_DETECTED
2374 #undef wxPG_FL_CREATEDSTATE
2375 #undef wxPG_FL_NOSTATUSBARHELP
2376 #undef wxPG_FL_SCROLLED
2377 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2378 #undef wxPG_FL_FOCUS_INSIDE
2379 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2380 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2381 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2382 #undef wxPG_FL_VALUE_MODIFIED
2383 #undef wxPG_FL_MOUSE_INSIDE
2384 #undef wxPG_FL_FOCUSED
2385 #undef wxPG_FL_MOUSE_CAPTURED
2386 #undef wxPG_FL_INITIALIZED
2387 #undef wxPG_FL_ACTIVATION_BY_CLICK
2388 #undef wxPG_FL_DONT_CENTER_SPLITTER
2389 #undef wxPG_SUPPORT_TOOLTIPS
2390 #undef wxPG_DOUBLE_BUFFER
2391 #undef wxPG_ICON_WIDTH
2392 #undef wxPG_USE_RENDERER_NATIVE
2393 // Following are needed by the manager headers
2394 // #undef const wxString&
2397 // -----------------------------------------------------------------------
2401 #endif // _WX_PROPGRID_PROPGRID_H_