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,
186 /** wxPropertyGridManager only: don't show an internal border around the property grid
188 wxPG_NO_INTERNAL_BORDER
= 0x00004000
191 enum wxPG_EX_WINDOW_STYLES
195 NOTE: wxPG_EX_xxx are extra window styles and must be set using
196 SetExtraStyle() member function.
198 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
199 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
200 not activated, and switching the mode first time becomes somewhat slower.
201 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
202 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
203 you don't plan to use categories at all, then using this style will result
204 in waste of resources.
207 wxPG_EX_INIT_NOCAT
= 0x00001000,
209 /** Extended window style that sets wxPropertyGridManager toolbar to not
212 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
214 /** Shows alphabetic/categoric mode buttons from toolbar.
216 wxPG_EX_MODE_BUTTONS
= 0x00008000,
218 /** Show property help strings as tool tips instead as text on the status bar.
219 You can set the help strings using SetPropertyHelpString member function.
221 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
223 /** Prevent TAB from focusing to wxButtons. This behavior was default
224 in version 1.2.0 and earlier.
225 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
226 atleast the button doesn't properly propagate key events (yes, I'm using
229 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
231 /** Allows relying on native double-buffering.
233 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
235 /** Set this style to let user have ability to set values of properties to
236 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
239 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
242 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
243 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
244 (thus they are not readable).
246 Note that this option is global, and applies to all wxPG property
249 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
251 /** Hides page selection buttons from toolbar.
253 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
255 /** Allows multiple properties to be selected by user (by pressing SHIFT
256 when clicking on a property, or by dragging with left mouse button
259 You can get array of selected properties with
260 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
261 mode wxPropertyGridInterface::GetSelection() returns
262 property which has editor active (usually the first one
263 selected). Other useful member functions are ClearSelection(),
264 AddToSelection() and RemoveFromSelection().
266 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
269 This enables top-level window tracking which allows wxPropertyGrid to
270 notify the application of last-minute property value changes by user.
272 This style is not enabled by default because it may cause crashes when
273 wxPropertyGrid is used in with wxAUI or similar system.
275 @remarks If you are not in fact using any system that may change
276 wxPropertyGrid's top-level parent window on its own, then you
277 are recommended to enable this style.
279 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
281 /** Don't show divider above toolbar, on Windows.
283 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x08000000,
285 /** Show a separator below the toolbar.
287 wxPG_EX_TOOLBAR_SEPARATOR
= 0x10000000
291 #if wxPG_COMPATIBILITY_1_4
292 #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
295 /** Combines various styles.
297 #define wxPG_DEFAULT_STYLE (0)
299 /** Combines various styles.
301 #define wxPGMAN_DEFAULT_STYLE (0)
306 // -----------------------------------------------------------------------
309 // Ids for sub-controls
310 // NB: It should not matter what these are.
311 #define wxPG_SUBID1 2
312 #define wxPG_SUBID2 3
313 #define wxPG_SUBID_TEMP1 4
315 // -----------------------------------------------------------------------
317 /** @class wxPGCommonValue
319 wxPropertyGrid stores information about common values in these
322 NB: Common value feature is not complete, and thus not mentioned in
325 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
329 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
332 m_renderer
= renderer
;
335 virtual ~wxPGCommonValue()
337 m_renderer
->DecRef();
340 virtual wxString
GetEditableText() const { return m_label
; }
341 const wxString
& GetLabel() const { return m_label
; }
342 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
346 wxPGCellRenderer
* m_renderer
;
349 // -----------------------------------------------------------------------
351 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
355 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
358 /** Prevents user from leaving property unless value is valid. If this
359 behavior flag is not used, then value change is instead cancelled.
361 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
363 /** Calls wxBell() on validation failure.
365 wxPG_VFB_BEEP
= 0x02,
367 /** Cell with invalid value will be marked (with red colour).
369 wxPG_VFB_MARK_CELL
= 0x04,
371 /** Display customizable text message explaining the situation.
373 wxPG_VFB_SHOW_MESSAGE
= 0x08,
376 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
378 /** Only used internally. */
379 wxPG_VFB_UNDEFINED
= 0x80
386 typedef wxByte wxPGVFBFlags
;
391 Used to convey validation information to and from functions that
392 actually perform validation. Mostly used in custom property
395 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
397 friend class wxPropertyGrid
;
400 @return Returns failure behavior which is a combination of
401 @ref propgrid_vfbflags.
403 wxPGVFBFlags
GetFailureBehavior() const
404 { return m_failureBehavior
; }
407 Returns current failure message.
409 const wxString
& GetFailureMessage() const
410 { return m_failureMessage
; }
413 Returns reference to pending value.
415 const wxVariant
& GetValue() const
421 /** Set validation failure behavior
423 @param failureBehavior
424 Mixture of @ref propgrid_vfbflags.
426 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
427 { m_failureBehavior
= failureBehavior
; }
430 Set current failure message.
432 void SetFailureMessage(const wxString
& message
)
433 { m_failureMessage
= message
; }
436 /** Value to be validated.
440 /** Message displayed on validation failure.
442 wxString m_failureMessage
;
444 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
446 wxPGVFBFlags m_failureBehavior
;
449 // -----------------------------------------------------------------------
451 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
453 These are used with wxPropertyGrid::AddActionTrigger() and
454 wxPropertyGrid::ClearActionTriggers().
458 enum wxPG_KEYBOARD_ACTIONS
460 wxPG_ACTION_INVALID
= 0,
461 wxPG_ACTION_NEXT_PROPERTY
,
462 wxPG_ACTION_PREV_PROPERTY
,
463 wxPG_ACTION_EXPAND_PROPERTY
,
464 wxPG_ACTION_COLLAPSE_PROPERTY
,
465 wxPG_ACTION_CANCEL_EDIT
,
466 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
473 // -----------------------------------------------------------------------
476 // wxPropertyGrid::DoSelectProperty flags (selFlags)
478 // Focuses to created editor
479 #define wxPG_SEL_FOCUS 0x0001
480 // Forces deletion and recreation of editor
481 #define wxPG_SEL_FORCE 0x0002
482 // For example, doesn't cause EnsureVisible
483 #define wxPG_SEL_NONVISIBLE 0x0004
484 // Do not validate editor's value before selecting
485 #define wxPG_SEL_NOVALIDATE 0x0008
486 // Property being deselected is about to be deleted
487 #define wxPG_SEL_DELETING 0x0010
488 // Property's values was set to unspecified by the user
489 #define wxPG_SEL_SETUNSPEC 0x0020
490 // Property's event handler changed the value
491 #define wxPG_SEL_DIALOGVAL 0x0040
492 // Set to disable sending of wxEVT_PG_SELECTED event
493 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
494 // Don't make any graphics updates
495 #define wxPG_SEL_NO_REFRESH 0x0100
497 // -----------------------------------------------------------------------
502 #define wxPG_FL_INITIALIZED 0x0001
503 // Set when creating editor controls if it was clicked on.
504 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
505 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
506 #define wxPG_FL_FOCUSED 0x0008
507 #define wxPG_FL_MOUSE_CAPTURED 0x0010
508 #define wxPG_FL_MOUSE_INSIDE 0x0020
509 #define wxPG_FL_VALUE_MODIFIED 0x0040
510 // don't clear background of m_wndEditor
511 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
512 // currently active editor uses custom image
513 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
514 // cell colours override selection colours for selected cell
515 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
516 #define wxPG_FL_SCROLLED 0x0400
517 // set when all added/inserted properties get hideable flag
518 #define wxPG_FL_ADDING_HIDEABLES 0x0800
519 // Disables showing help strings on statusbar.
520 #define wxPG_FL_NOSTATUSBARHELP 0x1000
521 // Marks that we created the state, so we have to destroy it too.
522 #define wxPG_FL_CREATEDSTATE 0x2000
523 // Set if scrollbar's existence was detected in last onresize.
524 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
525 // Set if wxPGMan requires redrawing of description text box.
526 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
527 // Set if contained in wxPropertyGridManager
528 #define wxPG_FL_IN_MANAGER 0x00020000
529 // Set after wxPropertyGrid is shown in its initial good size
530 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
531 // Set when in SelectProperty.
532 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
533 // Set when help string is shown in status bar
534 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
535 // Splitter position has been custom-set by the user
536 #define wxPG_FL_SPLITTER_PRE_SET 0x00400000
537 // Validation failed. Clear on modify event.
538 #define wxPG_FL_VALIDATION_FAILED 0x00800000
539 // Auto sort is enabled (for categorized mode)
540 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
541 // Set after page has been inserted to manager
542 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
543 // Active editor control is abnormally large
544 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
545 // Recursion guard for HandleCustomEditorEvent
546 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
547 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
548 // Editor control width should not change on resize
549 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
550 // Width of panel can be different than width of grid
551 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
552 // Prevents RecalculateVirtualSize re-entrancy
553 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
555 #endif // #ifndef SWIG
557 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
558 // Reduce compile time, but still include in user app
559 #include "wx/propgrid/props.h"
562 // -----------------------------------------------------------------------
564 /** @class wxPropertyGrid
566 wxPropertyGrid is a specialized grid for editing properties
567 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
568 used to do the very same thing, but it hasn't been updated for a while
569 and it is currently deprecated.
571 Please note that most member functions are inherited and as such not
572 documented on this page. This means you will probably also want to read
573 wxPropertyGridInterface class reference.
575 See also @ref overview_propgrid.
577 @section propgrid_window_styles_ Window Styles
579 See @ref propgrid_window_styles.
581 @section propgrid_event_handling Event Handling
583 To process input from a propertygrid control, use these event handler
584 macros to direct input to member functions that take a wxPropertyGridEvent
587 @beginEventTable{wxPropertyGridEvent}
588 @event{EVT_PG_SELECTED (id, func)}
589 Respond to wxEVT_PG_SELECTED event, generated when a property selection
590 has been changed, either by user action or by indirect program
591 function. For instance, collapsing a parent property programmatically
592 causes any selected child property to become unselected, and may
593 therefore cause this event to be generated.
594 @event{EVT_PG_CHANGING(id, func)}
595 Respond to wxEVT_PG_CHANGING event, generated when property value
596 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
597 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
598 to prevent change from taking place, if necessary.
599 @event{EVT_PG_HIGHLIGHTED(id, func)}
600 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
601 moves over a property. Event's property is NULL if hovered area does
602 not belong to any property.
603 @event{EVT_PG_RIGHT_CLICK(id, func)}
604 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
605 clicked on with right mouse button.
606 @event{EVT_PG_DOUBLE_CLICK(id, func)}
607 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
608 double-clicked onwith left mouse button.
609 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
610 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
611 a property or category..
612 @event{EVT_PG_ITEM_EXPANDED(id, func)}
613 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
614 a property or category..
615 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
616 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
617 begin editing a property label. You can veto this event to prevent the
619 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
620 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
621 end editing of a property label. You can veto this event to prevent the
627 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
628 will also delay sorting etc. miscellaneous calculations to the last
634 class WXDLLIMPEXP_PROPGRID
635 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
637 friend class wxPropertyGridPageState
;
638 friend class wxPropertyGridInterface
;
639 friend class wxPropertyGridManager
;
640 friend class wxPGCanvas
;
642 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
647 Two step constructor.
649 Call Create when this constructor is called to build up the
655 /** The default constructor. The styles to be used are styles valid for
656 the wxWindow and wxScrolledWindow.
658 @see @link wndflags Additional Window Styles @endlink
660 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
661 const wxPoint
& pos
= wxDefaultPosition
,
662 const wxSize
& size
= wxDefaultSize
,
663 long style
= wxPG_DEFAULT_STYLE
,
664 const wxString
& name
= wxPropertyGridNameStr
);
667 virtual ~wxPropertyGrid();
669 /** Adds given key combination to trigger given action.
672 Which action to trigger. See @link pgactions List of list of
673 wxPropertyGrid actions@endlink.
675 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
678 This static function enables or disables automatic use of
679 wxGetTranslation for following strings: wxEnumProperty list labels,
680 wxFlagsProperty sub-property labels.
684 static void AutoGetTranslation( bool enable
);
687 Changes value of a property, as if from an editor.
689 Use this instead of SetPropertyValue() if you need the value to run
690 through validation process, and also send the property change event.
693 Returns true if value was successfully changed.
695 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
698 Centers the splitter.
700 If argument is true, automatic splitter centering is enabled (only
701 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
703 void CenterSplitter( bool enable_auto_centering
= false );
705 /** Deletes all properties.
707 virtual void Clear();
709 /** Clears action triggers for given action.
711 Which action to trigger. See @link pgactions List of list of
712 wxPropertyGrid actions@endlink.
714 void ClearActionTriggers( int action
);
716 /** Forces updating the value of property from the editor control.
718 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
719 ProcessEvent, meaning your event handlers will be called immediately.
722 Returns true if anything was changed.
724 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
729 Whenever the control is created without any parameters, use Create to
730 actually create it. Don't access the control's public methods before
731 this is called @see @link wndflags Additional Window Styles@endlink
733 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
734 const wxPoint
& pos
= wxDefaultPosition
,
735 const wxSize
& size
= wxDefaultSize
,
736 long style
= wxPG_DEFAULT_STYLE
,
737 const wxString
& name
= wxPropertyGridNameStr
);
740 Call when editor widget's contents is modified.
742 For example, this is called when changes text in wxTextCtrl (used in
743 wxStringProperty and wxIntProperty).
746 This function should only be called by custom properties.
748 @see wxPGProperty::OnEvent()
750 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
752 /** Reverse of EditorsValueWasModified().
755 This function should only be called by custom properties.
757 void EditorsValueWasNotModified()
759 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
763 Enables or disables (shows/hides) categories according to parameter
766 bool EnableCategories( bool enable
);
768 /** Scrolls and/or expands items to ensure that the given item is visible.
769 Returns true if something was actually done.
771 bool EnsureVisible( wxPGPropArg id
);
774 Reduces column sizes to minimum possible that contents are still
775 visibly (naturally some margin space will be applied as well).
778 Minimum size for the grid to still display everything.
781 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
783 This function only works properly if grid size prior to call was already
786 Note that you can also get calculated column widths by calling
787 GetState->GetColumnWidth() immediately after this function returns.
791 wxSize sz
= m_pState
->DoFitColumns();
796 Returns wxWindow that the properties are painted on, and which should
797 be used as the parent for editor controls.
799 wxPanel
* GetPanel() const
804 /** Returns current category caption background colour. */
805 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
807 wxFont
& GetCaptionFont() { return m_captionFont
; }
809 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
811 /** Returns current category caption text colour. */
812 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
814 /** Returns current cell background colour. */
815 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
817 /** Returns current cell text colour when disabled. */
818 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
820 /** Returns current cell text colour. */
821 wxColour
GetCellTextColour() const { return m_colPropFore
; }
824 Returns number of columns currently on grid.
826 unsigned int GetColumnCount() const
828 return (unsigned int) m_pState
->m_colWidths
.size();
831 /** Returns colour of empty space below properties. */
832 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
834 /** Returns height of highest characters of used font. */
835 int GetFontHeight() const { return m_fontHeight
; }
837 /** Returns pointer to itself. Dummy function that enables same kind
838 of code to use wxPropertyGrid and wxPropertyGridManager.
840 wxPropertyGrid
* GetGrid() { return this; }
842 /** Returns rectangle of custom paint image.
844 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
846 /** Returns size of the custom paint image in front of property.
847 If no argument is given, returns preferred size.
849 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
852 /** Returns last item which could be iterated using given flags.
854 See @ref propgrid_iterator_flags.
856 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
858 return m_pState
->GetLastItem(flags
);
861 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
863 return m_pState
->GetLastItem(flags
);
867 /** Returns colour of lines between cells. */
868 wxColour
GetLineColour() const { return m_colLine
; }
870 /** Returns background colour of margin. */
871 wxColour
GetMarginColour() const { return m_colMargin
; }
874 Returns most up-to-date value of selected property. This will return
875 value different from GetSelectedProperty()->GetValue() only when text
876 editor is activate and string edited by user represents valid,
877 uncommitted property value.
879 wxVariant
GetUncommittedPropertyValue();
881 /** Returns "root property". It does not have name, etc. and it is not
882 visible. It is only useful for accessing its children.
884 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
886 /** Returns height of a single grid row (in pixels). */
887 int GetRowHeight() const { return m_lineHeight
; }
889 /** Returns currently selected property. */
890 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
892 /** Returns current selection background colour. */
893 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
895 /** Returns current selection text colour. */
896 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
898 /** Returns current splitter x position. */
899 int GetSplitterPosition() const
900 { return m_pState
->DoGetSplitterPosition(0); }
902 /** Returns wxTextCtrl active in currently selected property, if any. Takes
903 into account wxOwnerDrawnComboBox.
905 wxTextCtrl
* GetEditorTextCtrl() const;
907 wxPGValidationInfo
& GetValidationInfo()
909 return m_validationInfo
;
912 /** Returns current vertical spacing. */
913 int GetVerticalSpacing() const { return (int)m_vspacing
; }
916 Returns @true if a property editor control has focus.
918 bool IsEditorFocused() const;
920 /** Returns true if editor's value was marked modified.
922 bool IsEditorsValueModified() const
923 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
926 Returns information about arbitrary position in the grid.
929 Coordinates in the virtual grid space. You may need to use
930 wxScrolledWindow::CalcScrolledPosition() for translating
931 wxPropertyGrid client coordinates into something this member
934 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
936 /** Returns true if any property has been modified by the user. */
937 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
940 Returns true if updating is frozen (ie Freeze() called but not yet
943 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
946 It is recommended that you call this function any time your code causes
947 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
948 handler should be able to detect most changes, but it is not perfect.
951 New top-level parent that is about to be set. Old top-level parent
952 window should still exist as the current one.
954 @remarks This function is automatically called from wxPropertyGrid::
955 Reparent() and wxPropertyGridManager::Reparent(). You only
956 need to use it if you reparent wxPropertyGrid indirectly.
958 void OnTLPChanging( wxWindow
* newTLP
);
960 /** Redraws given property.
962 virtual void RefreshProperty( wxPGProperty
* p
);
965 /** Registers a new editor class.
967 Pointer to the editor class instance that should be used.
969 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
970 bool noDefCheck
= false )
972 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
975 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
976 const wxString
& editorName
,
977 bool noDefCheck
= false );
980 /** Resets all colours to the original system values.
986 Editor widget is automatically created, but not focused unless focus is
993 True if selection finished successfully. Usually only fails if
994 current value in editor is not valid.
996 @remarks In wxPropertyGrid 1.4, this member function used to generate
997 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
1000 @remarks This clears any previous selection.
1002 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
1005 Set entire new selection from given list of properties.
1007 void SetSelection( const wxArrayPGProperty
& newSelection
)
1009 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
1013 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
1014 extra style is not used, then this has same effect as
1015 calling SelectProperty().
1017 @remarks Multiple selection is not supported for categories. This
1018 means that if you have properties selected, you cannot
1019 add category to selection, and also if you have category
1020 selected, you cannot add other properties to selection.
1021 This member function will fail silently in these cases,
1022 even returning true.
1024 bool AddToSelection( wxPGPropArg id
)
1026 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1027 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1031 Removes given property from selection. If property is not selected,
1032 an assertion failure will occur.
1034 bool RemoveFromSelection( wxPGPropArg id
)
1036 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1037 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1041 Makes given column editable by user.
1044 Using @false here will disable column from being editable.
1046 void MakeColumnEditable( unsigned int column
, bool editable
= true );
1049 Creates label editor wxTextCtrl for given column, for property
1050 that is currently selected. When multiple selection is
1051 enabled, this applies to whatever property GetSelection()
1055 Which column's label to edit. Note that you should not
1056 use value 1, which is reserved for property value
1059 @see EndLabelEdit(), MakeColumnEditable()
1061 void BeginLabelEdit( unsigned int column
= 0 )
1063 DoBeginLabelEdit(column
, wxPG_SEL_DONT_SEND_EVENT
);
1067 Destroys label editor wxTextCtrl, if any.
1070 Use @true (default) to store edited label text in
1073 @see BeginLabelEdit(), MakeColumnEditable()
1075 void EndLabelEdit( bool commit
= true )
1077 DoEndLabelEdit(commit
, wxPG_SEL_DONT_SEND_EVENT
);
1081 Returns currently active label editor, NULL if none.
1083 wxTextCtrl
* GetLabelEditor() const
1085 return m_labelEditor
;
1088 /** Sets category caption background colour. */
1089 void SetCaptionBackgroundColour(const wxColour
& col
);
1091 /** Sets category caption text colour. */
1092 void SetCaptionTextColour(const wxColour
& col
);
1094 /** Sets default cell background colour - applies to property cells.
1095 Note that appearance of editor widgets may not be affected.
1097 void SetCellBackgroundColour(const wxColour
& col
);
1099 /** Sets cell text colour for disabled properties.
1101 void SetCellDisabledTextColour(const wxColour
& col
);
1103 /** Sets default cell text colour - applies to property name and value text.
1104 Note that appearance of editor widgets may not be affected.
1106 void SetCellTextColour(const wxColour
& col
);
1108 /** Set number of columns (2 or more).
1110 void SetColumnCount( int colCount
)
1112 m_pState
->SetColumnCount(colCount
);
1117 Sets the 'current' category - Append will add non-category properties
1120 void SetCurrentCategory( wxPGPropArg id
)
1122 wxPG_PROP_ARG_CALL_PROLOG()
1123 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1125 m_pState
->m_currentCategory
= pc
;
1128 /** Sets colour of empty space below properties. */
1129 void SetEmptySpaceColour(const wxColour
& col
);
1131 /** Sets colour of lines between cells. */
1132 void SetLineColour(const wxColour
& col
);
1134 /** Sets background colour of margin. */
1135 void SetMarginColour(const wxColour
& col
);
1138 Sets selection background colour - applies to selected property name
1141 void SetSelectionBackgroundColour(const wxColour
& col
);
1144 Sets selection foreground colour - applies to selected property name
1147 void SetSelectionTextColour(const wxColour
& col
);
1149 /** Sets x coordinate of the splitter.
1151 Splitter position cannot exceed grid size, and therefore setting it
1152 during form creation may fail as initial grid size is often smaller
1153 than desired splitter position, especially when sizers are being used.
1155 void SetSplitterPosition( int newxpos
, int col
= 0 )
1157 DoSetSplitterPosition_(newxpos
, true, col
);
1158 m_iFlags
|= wxPG_FL_SPLITTER_PRE_SET
;
1162 Sets the property sorting function.
1165 The sorting function to be used. It should return a value greater
1166 than 0 if position of p1 is after p2. So, for instance, when
1167 comparing property names, you can use following implementation:
1170 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1174 return p1->GetBaseName().compare( p2->GetBaseName() );
1179 Default property sort function sorts properties by their labels
1180 (case-insensitively).
1182 @see GetSortFunction, wxPropertyGridInterface::Sort,
1183 wxPropertyGridInterface::SortChildren
1185 void SetSortFunction( wxPGSortCallback sortFunction
)
1187 m_sortFunction
= sortFunction
;
1191 Returns the property sort function (default is @NULL).
1193 @see SetSortFunction
1195 wxPGSortCallback
GetSortFunction() const
1197 return m_sortFunction
;
1200 /** Set virtual width for this particular page. Width -1 indicates that the
1201 virtual width should be disabled. */
1202 void SetVirtualWidth( int width
);
1205 Moves splitter as left as possible, while still allowing all
1206 labels to be shown in full.
1208 @param privateChildrenToo
1209 If @false, will still allow private children to be cropped.
1211 void SetSplitterLeft( bool privateChildrenToo
= false )
1213 m_pState
->SetSplitterLeft(privateChildrenToo
);
1216 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1217 height. Value of 2 should be default on most platforms.
1219 void SetVerticalSpacing( int vspacing
)
1221 m_vspacing
= (unsigned char)vspacing
;
1222 CalculateFontAndBitmapStuff( vspacing
);
1223 if ( !m_pState
->m_itemsAdded
) Refresh();
1226 /** Shows an brief error message that is related to a property. */
1227 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1229 wxPG_PROP_ARG_CALL_PROLOG()
1230 DoShowPropertyError(p
, msg
);
1233 /////////////////////////////////////////////////////////////////
1235 // Following methods do not need to be (currently) documented
1237 /////////////////////////////////////////////////////////////////
1239 bool HasVirtualWidth() const
1240 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1242 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1244 return (wxPGCommonValue
*) m_commonValues
[i
];
1247 /** Returns number of common values.
1249 unsigned int GetCommonValueCount() const
1251 return (unsigned int) m_commonValues
.size();
1254 /** Returns label of given common value.
1256 wxString
GetCommonValueLabel( unsigned int i
) const
1258 wxASSERT( GetCommonValue(i
) );
1259 return GetCommonValue(i
)->GetLabel();
1263 Returns index of common value that will truly change value to
1266 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1268 /** Set index of common value that will truly change value to unspecified.
1269 Using -1 will set none to have such effect.
1272 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1275 Shortcut for creating dialog-caller button. Used, for example, by
1278 This should only be called by properties.
1280 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1282 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1283 fits as one). Call after control has been created (but before
1286 void FixPosForTextCtrl( wxWindow
* ctrl
,
1287 unsigned int forColumn
= 1,
1288 const wxPoint
& offset
= wxPoint(0, 0) );
1290 /** Shortcut for creating text editor widget.
1292 Same as pos given for CreateEditor.
1294 Same as sz given for CreateEditor.
1296 Initial text for wxTextCtrl.
1298 If right-side control, such as button, also created, then create it
1299 first and pass it as this parameter.
1301 Extra style flags to pass for wxTextCtrl.
1303 Note that this should generally be called only by new classes derived
1306 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1308 const wxString
& value
,
1309 wxWindow
* secondary
,
1312 unsigned int forColumn
= 1 );
1314 /* Generates both textctrl and button.
1316 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1317 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1318 wxPGProperty
* property
);
1320 /** Generates position for a widget editor dialog box.
1322 Property for which dialog is positioned.
1324 Known or over-approximated size of the dialog.
1326 Position for dialog.
1328 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1331 // Converts escape sequences in src_str to newlines,
1332 // tabs, etc. and copies result to dst_str.
1333 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1334 wxString
& src_str
);
1336 // Converts newlines, tabs, etc. in src_str to escape
1337 // sequences, and copies result to dst_str.
1338 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1339 wxString
& src_str
);
1342 Returns rectangle that fully contains properties between and including
1345 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1346 const wxPGProperty
* p2
) const;
1348 /** Returns pointer to current active primary editor control (NULL if none).
1350 wxWindow
* GetEditorControl() const;
1352 wxWindow
* GetPrimaryEditor() const
1354 return GetEditorControl();
1358 Returns pointer to current active secondary editor control (NULL if
1361 wxWindow
* GetEditorControlSecondary() const
1363 return m_wndEditor2
;
1367 Refreshes any active editor control.
1369 void RefreshEditor();
1371 // Events from editor controls are forward to this function
1372 void HandleCustomEditorEvent( wxEvent
&event
);
1377 Generates contents for string dst based on the contents of
1380 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1381 so on. Set flags to 1 inorder to convert backslashes to double-back-
1382 slashes and "(preDelims)"'s to "(preDelims)".
1384 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1385 wxChar preDelim
, wxChar postDelim
,
1388 // Mostly useful for page switching.
1389 void SwitchState( wxPropertyGridPageState
* pNewState
);
1391 long GetInternalFlags() const { return m_iFlags
; }
1392 bool HasInternalFlag( long flag
) const
1393 { return (m_iFlags
& flag
) ? true : false; }
1394 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1395 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1396 void IncFrozen() { m_frozen
++; }
1397 void DecFrozen() { m_frozen
--; }
1399 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1405 /** Standardized double-to-string conversion.
1407 static void DoubleToString( wxString
& target
,
1411 wxString
* precTemplate
);
1414 Call this from wxPGProperty::OnEvent() to cause property value to be
1415 changed after the function returns (with true as return value).
1416 ValueChangeInEvent() must be used if you wish the application to be
1417 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1419 void ValueChangeInEvent( wxVariant variant
)
1421 m_changeInEventValue
= variant
;
1422 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1426 You can use this member function, for instance, to detect in
1427 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1428 already called in wxPGEditor::OnEvent(). It really only detects
1429 if was value was changed using wxPGProperty::SetValueInEvent(), which
1430 is usually used when a 'picker' dialog is displayed. If value was
1431 written by "normal means" in wxPGProperty::StringToValue() or
1432 IntToValue(), then this function will return false (on the other hand,
1433 wxPGProperty::OnEvent() is not even called in those cases).
1435 bool WasValueChangedInEvent() const
1437 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1440 /** Returns true if given event is from first of an array of buttons
1441 (as can be in case when wxPGMultiButton is used).
1443 bool IsMainButtonEvent( const wxEvent
& event
)
1445 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1446 && (m_wndSecId
== event
.GetId());
1449 /** Pending value is expected to be passed in PerformValidation().
1451 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1452 unsigned int selFlags
= 0 );
1454 /** Called when validation for given property fails.
1456 Value which failed in validation.
1458 Return true if user is allowed to change to another property even
1459 if current has invalid value.
1461 To add your own validation failure behavior, override
1462 wxPropertyGrid::DoOnValidationFailure().
1464 bool OnValidationFailure( wxPGProperty
* property
,
1465 wxVariant
& invalidValue
);
1467 /** Called to indicate property and editor has valid value now.
1469 void OnValidationFailureReset( wxPGProperty
* property
)
1471 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1473 DoOnValidationFailureReset(property
);
1474 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1476 m_validationInfo
.m_failureMessage
.clear();
1479 /** Override in derived class to display error messages in custom manner
1480 (these message usually only result from validation failure).
1482 virtual void DoShowPropertyError( wxPGProperty
* property
,
1483 const wxString
& msg
);
1485 /** Override to customize property validation failure behavior.
1487 Value which failed in validation.
1489 Return true if user is allowed to change to another property even
1490 if current has invalid value.
1492 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1493 wxVariant
& invalidValue
);
1495 /** Override to customize resetting of property validation failure status.
1497 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1499 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1501 int GetSpacingY() const { return m_spacingy
; }
1504 Must be called in wxPGEditor::CreateControls() if primary editor window
1505 is wxTextCtrl, just before textctrl is created.
1507 Initial text value of created wxTextCtrl.
1509 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1512 Unfocuses or closes editor if one was open, but does not deselect
1515 bool UnfocusEditor();
1517 virtual void SetWindowStyleFlag( long style
);
1519 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1521 void DrawItem( wxPGProperty
* p
)
1526 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1529 Draws item, children, and consequtive parents as long as category is
1532 void DrawItemAndValueRelated( wxPGProperty
* p
);
1537 wxPropertyGridPageState used by the grid is created here.
1539 If grid is used in wxPropertyGridManager, there is no point overriding
1540 this - instead, set custom wxPropertyGridPage classes.
1542 virtual wxPropertyGridPageState
* CreateState() const;
1544 enum PerformValidationFlags
1546 SendEvtChanging
= 0x0001,
1547 IsStandaloneValidation
= 0x0002 // Not called in response to event
1551 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1552 Returns true if all tests passed. Implement in derived class to
1553 add additional validation behavior.
1555 virtual bool PerformValidation( wxPGProperty
* p
,
1556 wxVariant
& pendingValue
,
1557 int flags
= SendEvtChanging
);
1561 // Control font changer helper.
1562 void SetCurControlBoldFont();
1564 wxPGCell
& GetPropertyDefaultCell()
1566 return m_propertyDefaultCell
;
1569 wxPGCell
& GetCategoryDefaultCell()
1571 return m_categoryDefaultCell
;
1575 // Public methods for semi-public use
1577 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1579 // Overridden functions.
1580 virtual bool Destroy();
1581 // Returns property at given y coordinate (relative to grid's top left).
1582 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1584 virtual void Refresh( bool eraseBackground
= true,
1585 const wxRect
*rect
= (const wxRect
*) NULL
);
1586 virtual bool SetFont( const wxFont
& font
);
1587 #if wxPG_SUPPORT_TOOLTIPS
1588 void SetToolTip( const wxString
& tipString
);
1590 virtual void Freeze();
1591 virtual void SetExtraStyle( long exStyle
);
1592 virtual void Thaw();
1593 virtual bool Reparent( wxWindowBase
*newParent
);
1596 virtual wxSize
DoGetBestSize() const;
1598 #ifndef wxPG_ICON_WIDTH
1599 wxBitmap
*m_expandbmp
, *m_collbmp
;
1602 wxCursor
*m_cursorSizeWE
;
1604 /** wxWindow pointers to editor control(s). */
1605 wxWindow
*m_wndEditor
;
1606 wxWindow
*m_wndEditor2
;
1608 /** wxPGCanvas instance. */
1611 #if wxPG_DOUBLE_BUFFER
1612 wxBitmap
*m_doubleBuffer
;
1615 /** Local time ms when control was created. */
1616 wxLongLong m_timeCreated
;
1618 /** wxPGProperty::OnEvent can change value by setting this. */
1619 wxVariant m_changeInEventValue
;
1621 /** Id of m_wndEditor2, or its first child, if any. */
1624 /** Extra Y spacing between the items. */
1627 /** Control client area width; updated on resize. */
1630 /** Control client area height; updated on resize. */
1633 /** Current non-client width (needed when auto-centering). */
1636 /** Non-client width (auto-centering helper). */
1639 /** Previously recorded scroll start position. */
1643 The gutter spacing in front and back of the image.
1644 This determines the amount of spacing in front of each item
1648 /** Includes separator line. */
1651 /** Gutter*2 + image width. */
1654 // y spacing for expand/collapse button.
1655 int m_buttonSpacingY
;
1657 /** Extra margin for expanded sub-group items. */
1658 int m_subgroup_extramargin
;
1661 The image width of the [+] icon.
1663 This is also calculated in the gutter
1667 #ifndef wxPG_ICON_WIDTH
1670 The image height of the [+] icon.
1672 This is calculated as minimal size and to align
1677 /** Current cursor id. */
1681 This captionFont is made equal to the font of the wxScrolledWindow.
1683 As extra the bold face is set on it when this is wanted by the user
1686 wxFont m_captionFont
;
1688 int m_fontHeight
; // Height of the font.
1690 /** m_splitterx when drag began. */
1691 int m_startingSplitterX
;
1694 Index to splitter currently being dragged (0=one after the first
1697 int m_draggedSplitter
;
1699 /** Changed property, calculated in PerformValidation(). */
1700 wxPGProperty
* m_chgInfo_changedProperty
;
1703 Lowest property for which editing happened, but which does not have
1706 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1708 /** Changed property value, calculated in PerformValidation(). */
1709 wxVariant m_chgInfo_pendingValue
;
1711 /** Passed to SetValue. */
1712 wxVariant m_chgInfo_valueList
;
1714 /** Validation information. */
1715 wxPGValidationInfo m_validationInfo
;
1717 /** Actions and keys that trigger them. */
1718 wxPGHashMapI2I m_actionTriggers
;
1724 /** Bits are used to indicate which colours are customized. */
1725 unsigned short m_coloursCustomized
;
1727 /** x - m_splitterx. */
1728 signed char m_dragOffset
;
1730 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1731 unsigned char m_dragStatus
;
1733 /** 0 = margin, 1 = label, 2 = value. */
1734 unsigned char m_mouseSide
;
1736 /** True when editor control is focused. */
1737 unsigned char m_editorFocused
;
1739 /** 1 if m_latsCaption is also the bottommost caption. */
1740 //unsigned char m_lastCaptionBottomnest;
1742 /** Set to 1 when graphics frozen. */
1743 unsigned char m_frozen
;
1745 unsigned char m_vspacing
;
1747 // Used to track when Alt/Ctrl+Key was consumed.
1748 unsigned char m_keyComboConsumed
;
1750 /** 1 if in DoPropertyChanged() */
1751 unsigned char m_inDoPropertyChanged
;
1753 /** 1 if in CommitChangesFromEditor() */
1754 unsigned char m_inCommitChangesFromEditor
;
1756 /** 1 if in DoSelectProperty() */
1757 unsigned char m_inDoSelectProperty
;
1759 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1761 /** Internal flags - see wxPG_FL_XXX constants. */
1764 /** When drawing next time, clear this many item slots at the end. */
1765 int m_clearThisMany
;
1767 // Mouse is hovering over this column (index)
1768 unsigned int m_colHover
;
1770 // pointer to property that has mouse hovering
1771 wxPGProperty
* m_propHover
;
1773 // Active label editor
1774 wxTextCtrl
* m_labelEditor
;
1776 // For which property the label editor is active
1777 wxPGProperty
* m_labelEditorProperty
;
1779 // EventObject for wxPropertyGridEvents
1780 wxWindow
* m_eventObject
;
1782 // What (global) window is currently focused (needed to resolve event
1784 wxWindow
* m_curFocused
;
1786 // Event currently being sent - NULL if none at the moment
1787 wxPropertyGridEvent
* m_processedEvent
;
1789 // Last known top-level parent
1792 // Last closed top-level parent
1793 wxWindow
* m_tlpClosed
;
1795 // Local time ms when tlp was closed.
1796 wxLongLong m_tlpClosedTime
;
1799 wxPGSortCallback m_sortFunction
;
1801 // y coordinate of property that mouse hovering
1804 // Which column's editor is selected (usually 1)?
1805 unsigned int m_selColumn
;
1807 // x relative to splitter (needed for resize).
1810 // lines between cells
1812 // property labels and values are written in this colour
1813 wxColour m_colPropFore
;
1814 // or with this colour when disabled
1815 wxColour m_colDisPropFore
;
1816 // background for m_colPropFore
1817 wxColour m_colPropBack
;
1818 // text color for captions
1819 wxColour m_colCapFore
;
1820 // background color for captions
1821 wxColour m_colCapBack
;
1822 // foreground for selected property
1823 wxColour m_colSelFore
;
1824 // background for selected property (actually use background color when
1825 // control out-of-focus)
1826 wxColour m_colSelBack
;
1827 // background colour for margin
1828 wxColour m_colMargin
;
1829 // background colour for empty space below the grid
1830 wxColour m_colEmptySpace
;
1832 // Default property colours
1833 wxPGCell m_propertyDefaultCell
;
1835 // Default property category
1836 wxPGCell m_categoryDefaultCell
;
1838 // Backup of selected property's cells
1839 wxVector
<wxPGCell
> m_propCellsBackup
;
1841 // NB: These *cannot* be moved to globals.
1843 // labels when properties use common values
1844 wxVector
<wxPGCommonValue
*> m_commonValues
;
1846 // Which cv selection really sets value to unspecified?
1847 int m_cvUnspecified
;
1849 // Used to skip excess text editor events
1850 wxString m_prevTcValue
;
1854 // Sets some members to defaults (called constructors).
1857 // Initializes some members (called by Create and complex constructor).
1860 void OnPaint(wxPaintEvent
&event
);
1862 // main event receivers
1863 void OnMouseMove( wxMouseEvent
&event
);
1864 void OnMouseMoveBottom( wxMouseEvent
&event
);
1865 void OnMouseClick( wxMouseEvent
&event
);
1866 void OnMouseRightClick( wxMouseEvent
&event
);
1867 void OnMouseDoubleClick( wxMouseEvent
&event
);
1868 void OnMouseUp( wxMouseEvent
&event
);
1869 void OnKey( wxKeyEvent
&event
);
1870 void OnResize( wxSizeEvent
&event
);
1873 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
1874 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1875 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1876 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1877 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
1878 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
1880 void OnMouseEntry( wxMouseEvent
&event
);
1882 void OnIdle( wxIdleEvent
&event
);
1883 void OnFocusEvent( wxFocusEvent
&event
);
1884 void OnChildFocusEvent( wxChildFocusEvent
& event
);
1886 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
1887 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
1889 // sub-control event handlers
1890 void OnMouseClickChild( wxMouseEvent
&event
);
1891 void OnMouseRightClickChild( wxMouseEvent
&event
);
1892 void OnMouseMoveChild( wxMouseEvent
&event
);
1893 void OnMouseUpChild( wxMouseEvent
&event
);
1894 void OnChildKeyDown( wxKeyEvent
&event
);
1896 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
1898 void OnScrollEvent( wxScrollWinEvent
&event
);
1900 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
1902 void OnTLPClose( wxCloseEvent
& event
);
1906 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
1907 unsigned int colIndex
,
1908 wxMouseEvent
* event
= NULL
,
1912 Adjust the centering of the bitmap icons (collapse / expand) when the
1913 caption font changes.
1915 They need to be centered in the middle of the font, so a bit of deltaY
1916 adjustment is needed. On entry, m_captionFont must be set to window
1917 font. It will be modified properly.
1919 void CalculateFontAndBitmapStuff( int vspacing
);
1921 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
1923 void CorrectEditorWidgetSizeX();
1925 /** Called in RecalculateVirtualSize() to reposition control
1926 on virtual height changes.
1928 void CorrectEditorWidgetPosY();
1930 int DoDrawItems( wxDC
& dc
,
1931 const wxRect
* clipRect
,
1932 bool isBuffered
) const;
1934 /** Draws an expand/collapse (ie. +/-) button.
1936 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1937 wxPGProperty
* property
) const;
1939 /** Draws items from topitemy to bottomitemy */
1940 void DrawItems( wxDC
& dc
, unsigned int topitemy
, unsigned int bottomitemy
,
1941 const wxRect
* clip_rect
= (const wxRect
*) NULL
);
1943 // Translate wxKeyEvent to wxPG_ACTION_XXX
1944 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
1946 int KeyEventToAction(wxKeyEvent
&event
) const
1948 return KeyEventToActions(event
, NULL
);
1951 void ImprovedClientToScreen( int* px
, int* py
);
1953 // Called by focus event handlers. newFocused is the window that becomes
1955 void HandleFocusChange( wxWindow
* newFocused
);
1957 /** Reloads all non-customized colours from system settings. */
1958 void RegainColours();
1960 bool DoEditorValidate();
1962 // Similar to DoSelectProperty() but also works on columns
1963 // other than 1. Does not active editor if column is not
1965 bool DoSelectAndEdit( wxPGProperty
* prop
,
1966 unsigned int colIndex
,
1967 unsigned int selFlags
);
1969 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
1972 bool DoAddToSelection( wxPGProperty
* prop
,
1975 bool DoRemoveFromSelection( wxPGProperty
* prop
,
1978 void DoBeginLabelEdit( unsigned int colIndex
, int selFlags
= 0 );
1979 void DoEndLabelEdit( bool commit
, int selFlags
= 0 );
1980 void OnLabelEditorEnterPress( wxCommandEvent
& event
);
1981 void OnLabelEditorKeyPress( wxKeyEvent
& event
);
1983 wxPGProperty
* DoGetItemAtY( int y
) const;
1985 void DoSetSplitterPosition_( int newxpos
,
1986 bool refresh
= true,
1987 int splitterIndex
= 0,
1988 bool allPages
= false );
1990 void DestroyEditorWnd( wxWindow
* wnd
);
1993 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
1995 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
1997 // Returns nearest paint visible property (such that will be painted unless
1998 // window is scrolled or resized). If given property is paint visible, then
1999 // it itself will be returned.
2000 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
2002 static void RegisterDefaultEditors();
2004 // Sets up basic event handling for child control
2005 void SetupChildEventHandling( wxWindow
* wnd
);
2007 void CustomSetCursor( int type
, bool override
= false );
2010 Repositions scrollbar and underlying panel according to changed virtual
2013 void RecalculateVirtualSize( int forceXPos
= -1 );
2015 void PrepareAfterItemsAdded();
2017 // Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
2018 bool SendEvent( int eventType
, wxPGProperty
* p
,
2019 wxVariant
* pValue
= NULL
,
2020 unsigned int selFlags
= wxPG_SEL_NOVALIDATE
,
2021 unsigned int column
= 1 );
2023 void SetFocusOnCanvas();
2025 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
2029 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
2031 DECLARE_EVENT_TABLE()
2032 #endif // #ifndef SWIG
2035 // -----------------------------------------------------------------------
2037 // Bunch of inlines that need to resolved after all classes have been defined.
2041 inline bool wxPropertyGridPageState::IsDisplayed() const
2043 return ( this == m_pPropGrid
->GetState() );
2046 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
2048 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
2052 inline int wxPGProperty::GetDisplayedCommonValueCount() const
2054 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
2056 wxPropertyGrid
* pg
= GetGrid();
2058 return (int) pg
->GetCommonValueCount();
2063 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
2065 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
2068 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
2070 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
2073 inline bool wxPGProperty::Hide( bool hide
, int flags
)
2075 return GetGrid()->HideProperty(this, hide
, flags
);
2078 inline bool wxPGProperty::SetMaxLength( int maxLen
)
2080 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
2083 // -----------------------------------------------------------------------
2085 #define wxPG_BASE_EVT_PRE_ID 1775
2089 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
2090 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
2091 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
2092 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
2093 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
2094 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
2095 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
2096 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
2097 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
2098 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2099 wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
2100 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2101 wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
2105 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
2108 wxEVT_PG_HIGHLIGHTED
,
2109 wxEVT_PG_RIGHT_CLICK
,
2110 wxEVT_PG_PAGE_CHANGED
,
2111 wxEVT_PG_ITEM_COLLAPSED
,
2112 wxEVT_PG_ITEM_EXPANDED
,
2113 wxEVT_PG_DOUBLE_CLICK
,
2114 wxEVT_PG_LABEL_EDIT_BEGIN
,
2115 wxEVT_PG_LABEL_EDIT_ENDING
2120 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2121 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2125 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2127 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2128 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2129 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2130 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2131 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2132 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2133 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2134 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2135 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2136 #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 ),
2137 #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 ),
2139 #define wxPropertyGridEventHandler(fn) \
2140 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2145 /** @class wxPropertyGridEvent
2147 A propertygrid event holds information about events associated with
2148 wxPropertyGrid objects.
2150 @library{wxpropgrid}
2153 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2158 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2160 /** Copy constructor. */
2161 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2164 ~wxPropertyGridEvent();
2167 virtual wxEvent
* Clone() const;
2170 Returns the column index associated with this event.
2172 unsigned int GetColumn() const
2177 wxPGProperty
* GetMainParent() const
2179 wxASSERT(m_property
);
2180 return m_property
->GetMainParent();
2183 /** Returns id of associated property. */
2184 wxPGProperty
* GetProperty() const
2189 wxPGValidationInfo
& GetValidationInfo()
2191 wxASSERT(m_validationInfo
);
2192 return *m_validationInfo
;
2195 /** Returns true if you can veto the action that the event is signaling.
2197 bool CanVeto() const { return m_canVeto
; }
2200 Call this from your event handler to veto action that the event is
2203 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2206 Currently only wxEVT_PG_CHANGING supports vetoing.
2208 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2210 /** Returns value that is about to be set for wxEVT_PG_CHANGING.
2212 const wxVariant
& GetValue() const
2214 wxASSERT_MSG( m_validationInfo
,
2215 "Only call GetValue from a handler "
2216 "of event type that supports it" );
2217 return m_validationInfo
->GetValue();
2221 Set override validation failure behavior.
2223 Only effective if Veto was also called, and only allowed if event type
2224 is wxEVT_PG_CHANGING.
2226 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2228 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2229 m_validationInfo
->SetFailureBehavior( flags
);
2232 /** Sets custom failure message for this time only. Only applies if
2233 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2235 void SetValidationFailureMessage( const wxString
& message
)
2237 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2238 m_validationInfo
->SetFailureMessage( message
);
2242 wxPGVFBFlags
GetValidationFailureBehavior() const
2244 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2245 return m_validationInfo
->GetFailureBehavior();
2248 void SetColumn( unsigned int column
)
2253 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2254 bool WasVetoed() const { return m_wasVetoed
; }
2256 /** Changes the associated property. */
2257 void SetProperty( wxPGProperty
* p
) { m_property
= p
; }
2259 void SetPropertyGrid( wxPropertyGrid
* pg
) { m_pg
= pg
; }
2261 void SetupValidationInfo()
2264 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2265 m_validationInfo
= &m_pg
->GetValidationInfo();
2270 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2272 wxPGProperty
* m_property
;
2273 wxPropertyGrid
* m_pg
;
2274 wxPGValidationInfo
* m_validationInfo
;
2276 unsigned int m_column
;
2285 // -----------------------------------------------------------------------
2287 /** @class wxPropertyGridPopulator
2289 Allows populating wxPropertyGrid from arbitrary text source.
2291 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2294 /** Default constructor.
2296 wxPropertyGridPopulator();
2299 virtual ~wxPropertyGridPopulator();
2301 void SetState( wxPropertyGridPageState
* state
);
2303 void SetGrid( wxPropertyGrid
* pg
);
2305 /** Appends a new property under bottommost parent.
2307 Property class as string.
2309 wxPGProperty
* Add( const wxString
& propClass
,
2310 const wxString
& propLabel
,
2311 const wxString
& propName
,
2312 const wxString
* propValue
,
2313 wxPGChoices
* pChoices
= NULL
);
2316 Pushes property to the back of parent array (ie it becomes bottommost
2317 parent), and starts scanning/adding children for it.
2319 When finished, parent array is returned to the original state.
2321 void AddChildren( wxPGProperty
* property
);
2323 /** Adds attribute to the bottommost property.
2325 Allowed values: "string", (same as string), "int", "bool". Empty string
2328 bool AddAttribute( const wxString
& name
,
2329 const wxString
& type
,
2330 const wxString
& value
);
2332 /** Called once in AddChildren.
2334 virtual void DoScanForChildren() = 0;
2337 Returns id of parent property for which children can currently be
2340 wxPGProperty
* GetCurParent() const
2342 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2345 wxPropertyGridPageState
* GetState() { return m_state
; }
2346 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2348 /** Like wxString::ToLong, except allows N% in addition of N.
2350 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2352 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2353 wxPGChoices. Registers parsed result using idString (if not empty).
2354 Also, if choices with given id already registered, then don't parse but
2355 return those choices instead.
2357 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2358 const wxString
& idString
);
2360 /** Implement in derived class to do custom process when an error occurs.
2361 Default implementation uses wxLogError.
2363 virtual void ProcessError( const wxString
& msg
);
2367 /** Used property grid. */
2368 wxPropertyGrid
* m_pg
;
2370 /** Used property grid state. */
2371 wxPropertyGridPageState
* m_state
;
2373 /** Tree-hierarchy of added properties (that can have children). */
2374 wxArrayPGProperty m_propHierarchy
;
2376 /** Hashmap for string-id to wxPGChoicesData mapping. */
2377 wxPGHashMapS2P m_dictIdChoices
;
2380 // -----------------------------------------------------------------------
2383 // Undefine macros that are not needed outside propertygrid sources
2385 #ifndef __wxPG_SOURCE_FILE__
2386 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2387 #undef wxPG_FL_SCROLLBAR_DETECTED
2388 #undef wxPG_FL_CREATEDSTATE
2389 #undef wxPG_FL_NOSTATUSBARHELP
2390 #undef wxPG_FL_SCROLLED
2391 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2392 #undef wxPG_FL_FOCUS_INSIDE
2393 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2394 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2395 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2396 #undef wxPG_FL_VALUE_MODIFIED
2397 #undef wxPG_FL_MOUSE_INSIDE
2398 #undef wxPG_FL_FOCUSED
2399 #undef wxPG_FL_MOUSE_CAPTURED
2400 #undef wxPG_FL_INITIALIZED
2401 #undef wxPG_FL_ACTIVATION_BY_CLICK
2402 #undef wxPG_FL_DONT_CENTER_SPLITTER
2403 #undef wxPG_SUPPORT_TOOLTIPS
2404 #undef wxPG_DOUBLE_BUFFER
2405 #undef wxPG_ICON_WIDTH
2406 #undef wxPG_USE_RENDERER_NATIVE
2407 // Following are needed by the manager headers
2408 // #undef const wxString&
2411 // -----------------------------------------------------------------------
2415 #endif // _WX_PROPGRID_PROPGRID_H_