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
189 wxPG_NO_INTERNAL_BORDER
= 0x00004000
192 #if wxPG_COMPATIBILITY_1_4
193 // In wxPG 1.4 this was used to enable now-default theme border support
194 // in wxPropertyGridManager.
195 #define wxPG_THEME_BORDER 0x00000000
199 enum wxPG_EX_WINDOW_STYLES
203 NOTE: wxPG_EX_xxx are extra window styles and must be set using
204 SetExtraStyle() member function.
206 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
207 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
208 not activated, and switching the mode first time becomes somewhat slower.
209 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
210 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
211 you don't plan to use categories at all, then using this style will result
212 in waste of resources.
215 wxPG_EX_INIT_NOCAT
= 0x00001000,
217 /** Extended window style that sets wxPropertyGridManager toolbar to not
220 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
222 /** Shows alphabetic/categoric mode buttons from toolbar.
224 wxPG_EX_MODE_BUTTONS
= 0x00008000,
226 /** Show property help strings as tool tips instead as text on the status bar.
227 You can set the help strings using SetPropertyHelpString member function.
229 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
231 /** Prevent TAB from focusing to wxButtons. This behavior was default
232 in version 1.2.0 and earlier.
233 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
234 atleast the button doesn't properly propagate key events (yes, I'm using
237 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
239 /** Allows relying on native double-buffering.
241 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
243 /** Set this style to let user have ability to set values of properties to
244 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
247 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
250 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
251 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
252 (thus they are not readable).
254 Note that this option is global, and applies to all wxPG property
257 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
259 /** Hides page selection buttons from toolbar.
261 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
263 /** Allows multiple properties to be selected by user (by pressing SHIFT
264 when clicking on a property, or by dragging with left mouse button
267 You can get array of selected properties with
268 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
269 mode wxPropertyGridInterface::GetSelection() returns
270 property which has editor active (usually the first one
271 selected). Other useful member functions are ClearSelection(),
272 AddToSelection() and RemoveFromSelection().
274 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
277 This enables top-level window tracking which allows wxPropertyGrid to
278 notify the application of last-minute property value changes by user.
280 This style is not enabled by default because it may cause crashes when
281 wxPropertyGrid is used in with wxAUI or similar system.
283 @remarks If you are not in fact using any system that may change
284 wxPropertyGrid's top-level parent window on its own, then you
285 are recommended to enable this style.
287 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
289 /** Don't show divider above toolbar, on Windows.
291 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x08000000,
293 /** Show a separator below the toolbar.
295 wxPG_EX_TOOLBAR_SEPARATOR
= 0x10000000
299 #if wxPG_COMPATIBILITY_1_4
300 #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
303 /** Combines various styles.
305 #define wxPG_DEFAULT_STYLE (0)
307 /** Combines various styles.
309 #define wxPGMAN_DEFAULT_STYLE (0)
314 // -----------------------------------------------------------------------
317 // Ids for sub-controls
318 // NB: It should not matter what these are.
319 #define wxPG_SUBID1 2
320 #define wxPG_SUBID2 3
321 #define wxPG_SUBID_TEMP1 4
323 // -----------------------------------------------------------------------
325 /** @class wxPGCommonValue
327 wxPropertyGrid stores information about common values in these
330 NB: Common value feature is not complete, and thus not mentioned in
333 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
337 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
340 m_renderer
= renderer
;
343 virtual ~wxPGCommonValue()
345 m_renderer
->DecRef();
348 virtual wxString
GetEditableText() const { return m_label
; }
349 const wxString
& GetLabel() const { return m_label
; }
350 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
354 wxPGCellRenderer
* m_renderer
;
357 // -----------------------------------------------------------------------
359 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
363 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
366 /** Prevents user from leaving property unless value is valid. If this
367 behavior flag is not used, then value change is instead cancelled.
369 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
371 /** Calls wxBell() on validation failure.
373 wxPG_VFB_BEEP
= 0x02,
375 /** Cell with invalid value will be marked (with red colour).
377 wxPG_VFB_MARK_CELL
= 0x04,
379 /** Display customizable text message explaining the situation.
381 wxPG_VFB_SHOW_MESSAGE
= 0x08,
384 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
386 /** Only used internally. */
387 wxPG_VFB_UNDEFINED
= 0x80
394 typedef wxByte wxPGVFBFlags
;
399 Used to convey validation information to and from functions that
400 actually perform validation. Mostly used in custom property
403 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
405 friend class wxPropertyGrid
;
408 @return Returns failure behavior which is a combination of
409 @ref propgrid_vfbflags.
411 wxPGVFBFlags
GetFailureBehavior() const
412 { return m_failureBehavior
; }
415 Returns current failure message.
417 const wxString
& GetFailureMessage() const
418 { return m_failureMessage
; }
421 Returns reference to pending value.
423 const wxVariant
& GetValue() const
429 /** Set validation failure behavior
431 @param failureBehavior
432 Mixture of @ref propgrid_vfbflags.
434 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
435 { m_failureBehavior
= failureBehavior
; }
438 Set current failure message.
440 void SetFailureMessage(const wxString
& message
)
441 { m_failureMessage
= message
; }
444 /** Value to be validated.
448 /** Message displayed on validation failure.
450 wxString m_failureMessage
;
452 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
454 wxPGVFBFlags m_failureBehavior
;
457 // -----------------------------------------------------------------------
459 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
461 These are used with wxPropertyGrid::AddActionTrigger() and
462 wxPropertyGrid::ClearActionTriggers().
466 enum wxPG_KEYBOARD_ACTIONS
468 wxPG_ACTION_INVALID
= 0,
469 wxPG_ACTION_NEXT_PROPERTY
,
470 wxPG_ACTION_PREV_PROPERTY
,
471 wxPG_ACTION_EXPAND_PROPERTY
,
472 wxPG_ACTION_COLLAPSE_PROPERTY
,
473 wxPG_ACTION_CANCEL_EDIT
,
474 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
481 // -----------------------------------------------------------------------
484 // wxPropertyGrid::DoSelectProperty flags (selFlags)
486 // Focuses to created editor
487 #define wxPG_SEL_FOCUS 0x0001
488 // Forces deletion and recreation of editor
489 #define wxPG_SEL_FORCE 0x0002
490 // For example, doesn't cause EnsureVisible
491 #define wxPG_SEL_NONVISIBLE 0x0004
492 // Do not validate editor's value before selecting
493 #define wxPG_SEL_NOVALIDATE 0x0008
494 // Property being deselected is about to be deleted
495 #define wxPG_SEL_DELETING 0x0010
496 // Property's values was set to unspecified by the user
497 #define wxPG_SEL_SETUNSPEC 0x0020
498 // Property's event handler changed the value
499 #define wxPG_SEL_DIALOGVAL 0x0040
500 // Set to disable sending of wxEVT_PG_SELECTED event
501 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
502 // Don't make any graphics updates
503 #define wxPG_SEL_NO_REFRESH 0x0100
505 // -----------------------------------------------------------------------
510 #define wxPG_FL_INITIALIZED 0x0001
511 // Set when creating editor controls if it was clicked on.
512 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
513 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
514 #define wxPG_FL_FOCUSED 0x0008
515 #define wxPG_FL_MOUSE_CAPTURED 0x0010
516 #define wxPG_FL_MOUSE_INSIDE 0x0020
517 #define wxPG_FL_VALUE_MODIFIED 0x0040
518 // don't clear background of m_wndEditor
519 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
520 // currently active editor uses custom image
521 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
522 // cell colours override selection colours for selected cell
523 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
524 #define wxPG_FL_SCROLLED 0x0400
525 // set when all added/inserted properties get hideable flag
526 #define wxPG_FL_ADDING_HIDEABLES 0x0800
527 // Disables showing help strings on statusbar.
528 #define wxPG_FL_NOSTATUSBARHELP 0x1000
529 // Marks that we created the state, so we have to destroy it too.
530 #define wxPG_FL_CREATEDSTATE 0x2000
531 // Set if scrollbar's existence was detected in last onresize.
532 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
533 // Set if wxPGMan requires redrawing of description text box.
534 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
535 // Set if contained in wxPropertyGridManager
536 #define wxPG_FL_IN_MANAGER 0x00020000
537 // Set after wxPropertyGrid is shown in its initial good size
538 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
539 // Set when in SelectProperty.
540 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
541 // Set when help string is shown in status bar
542 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
543 // Splitter position has been custom-set by the user
544 #define wxPG_FL_SPLITTER_PRE_SET 0x00400000
545 // Validation failed. Clear on modify event.
546 #define wxPG_FL_VALIDATION_FAILED 0x00800000
547 // Auto sort is enabled (for categorized mode)
548 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
549 // Set after page has been inserted to manager
550 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
551 // Active editor control is abnormally large
552 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
553 // Recursion guard for HandleCustomEditorEvent
554 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
555 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
556 // Editor control width should not change on resize
557 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
558 // Width of panel can be different than width of grid
559 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
560 // Prevents RecalculateVirtualSize re-entrancy
561 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
563 #endif // #ifndef SWIG
565 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
566 // Reduce compile time, but still include in user app
567 #include "wx/propgrid/props.h"
570 // -----------------------------------------------------------------------
572 /** @class wxPropertyGrid
574 wxPropertyGrid is a specialized grid for editing properties
575 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
576 used to do the very same thing, but it hasn't been updated for a while
577 and it is currently deprecated.
579 Please note that most member functions are inherited and as such not
580 documented on this page. This means you will probably also want to read
581 wxPropertyGridInterface class reference.
583 See also @ref overview_propgrid.
585 @section propgrid_window_styles_ Window Styles
587 See @ref propgrid_window_styles.
589 @section propgrid_event_handling Event Handling
591 To process input from a propertygrid control, use these event handler
592 macros to direct input to member functions that take a wxPropertyGridEvent
595 @beginEventTable{wxPropertyGridEvent}
596 @event{EVT_PG_SELECTED (id, func)}
597 Respond to wxEVT_PG_SELECTED event, generated when a property selection
598 has been changed, either by user action or by indirect program
599 function. For instance, collapsing a parent property programmatically
600 causes any selected child property to become unselected, and may
601 therefore cause this event to be generated.
602 @event{EVT_PG_CHANGING(id, func)}
603 Respond to wxEVT_PG_CHANGING event, generated when property value
604 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
605 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
606 to prevent change from taking place, if necessary.
607 @event{EVT_PG_HIGHLIGHTED(id, func)}
608 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
609 moves over a property. Event's property is NULL if hovered area does
610 not belong to any property.
611 @event{EVT_PG_RIGHT_CLICK(id, func)}
612 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
613 clicked on with right mouse button.
614 @event{EVT_PG_DOUBLE_CLICK(id, func)}
615 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
616 double-clicked onwith left mouse button.
617 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
618 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
619 a property or category..
620 @event{EVT_PG_ITEM_EXPANDED(id, func)}
621 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
622 a property or category..
623 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
624 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
625 begin editing a property label. You can veto this event to prevent the
627 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
628 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
629 end editing of a property label. You can veto this event to prevent the
635 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
636 will also delay sorting etc. miscellaneous calculations to the last
642 class WXDLLIMPEXP_PROPGRID
643 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
645 friend class wxPropertyGridPageState
;
646 friend class wxPropertyGridInterface
;
647 friend class wxPropertyGridManager
;
648 friend class wxPGCanvas
;
650 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
655 Two step constructor.
657 Call Create when this constructor is called to build up the
663 /** The default constructor. The styles to be used are styles valid for
664 the wxWindow and wxScrolledWindow.
666 @see @link wndflags Additional Window Styles @endlink
668 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
669 const wxPoint
& pos
= wxDefaultPosition
,
670 const wxSize
& size
= wxDefaultSize
,
671 long style
= wxPG_DEFAULT_STYLE
,
672 const wxString
& name
= wxPropertyGridNameStr
);
675 virtual ~wxPropertyGrid();
677 /** Adds given key combination to trigger given action.
680 Which action to trigger. See @link pgactions List of list of
681 wxPropertyGrid actions@endlink.
683 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
686 This static function enables or disables automatic use of
687 wxGetTranslation for following strings: wxEnumProperty list labels,
688 wxFlagsProperty sub-property labels.
692 static void AutoGetTranslation( bool enable
);
695 Changes value of a property, as if from an editor.
697 Use this instead of SetPropertyValue() if you need the value to run
698 through validation process, and also send the property change event.
701 Returns true if value was successfully changed.
703 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
706 Centers the splitter.
708 If argument is true, automatic splitter centering is enabled (only
709 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
711 void CenterSplitter( bool enable_auto_centering
= false );
713 /** Deletes all properties.
715 virtual void Clear();
717 /** Clears action triggers for given action.
719 Which action to trigger. See @link pgactions List of list of
720 wxPropertyGrid actions@endlink.
722 void ClearActionTriggers( int action
);
724 /** Forces updating the value of property from the editor control.
726 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
727 ProcessEvent, meaning your event handlers will be called immediately.
730 Returns true if anything was changed.
732 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
737 Whenever the control is created without any parameters, use Create to
738 actually create it. Don't access the control's public methods before
739 this is called @see @link wndflags Additional Window Styles@endlink
741 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
742 const wxPoint
& pos
= wxDefaultPosition
,
743 const wxSize
& size
= wxDefaultSize
,
744 long style
= wxPG_DEFAULT_STYLE
,
745 const wxString
& name
= wxPropertyGridNameStr
);
748 Call when editor widget's contents is modified.
750 For example, this is called when changes text in wxTextCtrl (used in
751 wxStringProperty and wxIntProperty).
754 This function should only be called by custom properties.
756 @see wxPGProperty::OnEvent()
758 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
760 /** Reverse of EditorsValueWasModified().
763 This function should only be called by custom properties.
765 void EditorsValueWasNotModified()
767 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
771 Enables or disables (shows/hides) categories according to parameter
774 bool EnableCategories( bool enable
);
776 /** Scrolls and/or expands items to ensure that the given item is visible.
777 Returns true if something was actually done.
779 bool EnsureVisible( wxPGPropArg id
);
782 Reduces column sizes to minimum possible that contents are still
783 visibly (naturally some margin space will be applied as well).
786 Minimum size for the grid to still display everything.
789 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
791 This function only works properly if grid size prior to call was already
794 Note that you can also get calculated column widths by calling
795 GetState->GetColumnWidth() immediately after this function returns.
799 wxSize sz
= m_pState
->DoFitColumns();
804 Returns wxWindow that the properties are painted on, and which should
805 be used as the parent for editor controls.
807 wxPanel
* GetPanel() const
812 /** Returns current category caption background colour. */
813 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
815 wxFont
& GetCaptionFont() { return m_captionFont
; }
817 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
819 /** Returns current category caption text colour. */
820 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
822 /** Returns current cell background colour. */
823 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
825 /** Returns current cell text colour when disabled. */
826 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
828 /** Returns current cell text colour. */
829 wxColour
GetCellTextColour() const { return m_colPropFore
; }
832 Returns number of columns currently on grid.
834 unsigned int GetColumnCount() const
836 return (unsigned int) m_pState
->m_colWidths
.size();
839 /** Returns colour of empty space below properties. */
840 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
842 /** Returns height of highest characters of used font. */
843 int GetFontHeight() const { return m_fontHeight
; }
845 /** Returns pointer to itself. Dummy function that enables same kind
846 of code to use wxPropertyGrid and wxPropertyGridManager.
848 wxPropertyGrid
* GetGrid() { return this; }
850 /** Returns rectangle of custom paint image.
852 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
854 /** Returns size of the custom paint image in front of property.
855 If no argument is given, returns preferred size.
857 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
860 /** Returns last item which could be iterated using given flags.
862 See @ref propgrid_iterator_flags.
864 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
866 return m_pState
->GetLastItem(flags
);
869 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
871 return m_pState
->GetLastItem(flags
);
875 /** Returns colour of lines between cells. */
876 wxColour
GetLineColour() const { return m_colLine
; }
878 /** Returns background colour of margin. */
879 wxColour
GetMarginColour() const { return m_colMargin
; }
882 Returns most up-to-date value of selected property. This will return
883 value different from GetSelectedProperty()->GetValue() only when text
884 editor is activate and string edited by user represents valid,
885 uncommitted property value.
887 wxVariant
GetUncommittedPropertyValue();
889 /** Returns "root property". It does not have name, etc. and it is not
890 visible. It is only useful for accessing its children.
892 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
894 /** Returns height of a single grid row (in pixels). */
895 int GetRowHeight() const { return m_lineHeight
; }
897 /** Returns currently selected property. */
898 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
900 /** Returns current selection background colour. */
901 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
903 /** Returns current selection text colour. */
904 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
906 /** Returns current splitter x position. */
907 int GetSplitterPosition() const
908 { return m_pState
->DoGetSplitterPosition(0); }
910 /** Returns wxTextCtrl active in currently selected property, if any. Takes
911 into account wxOwnerDrawnComboBox.
913 wxTextCtrl
* GetEditorTextCtrl() const;
915 wxPGValidationInfo
& GetValidationInfo()
917 return m_validationInfo
;
920 /** Returns current vertical spacing. */
921 int GetVerticalSpacing() const { return (int)m_vspacing
; }
924 Returns @true if a property editor control has focus.
926 bool IsEditorFocused() const;
928 /** Returns true if editor's value was marked modified.
930 bool IsEditorsValueModified() const
931 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
934 Returns information about arbitrary position in the grid.
937 Coordinates in the virtual grid space. You may need to use
938 wxScrolledWindow::CalcScrolledPosition() for translating
939 wxPropertyGrid client coordinates into something this member
942 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
944 /** Returns true if any property has been modified by the user. */
945 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
948 Returns true if updating is frozen (ie Freeze() called but not yet
951 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
954 It is recommended that you call this function any time your code causes
955 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
956 handler should be able to detect most changes, but it is not perfect.
959 New top-level parent that is about to be set. Old top-level parent
960 window should still exist as the current one.
962 @remarks This function is automatically called from wxPropertyGrid::
963 Reparent() and wxPropertyGridManager::Reparent(). You only
964 need to use it if you reparent wxPropertyGrid indirectly.
966 void OnTLPChanging( wxWindow
* newTLP
);
968 /** Redraws given property.
970 virtual void RefreshProperty( wxPGProperty
* p
);
973 /** Registers a new editor class.
975 Pointer to the editor class instance that should be used.
977 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
978 bool noDefCheck
= false )
980 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
983 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
984 const wxString
& editorName
,
985 bool noDefCheck
= false );
988 /** Resets all colours to the original system values.
994 Editor widget is automatically created, but not focused unless focus is
1001 True if selection finished successfully. Usually only fails if
1002 current value in editor is not valid.
1004 @remarks In wxPropertyGrid 1.4, this member function used to generate
1005 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
1008 @remarks This clears any previous selection.
1010 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
1013 Set entire new selection from given list of properties.
1015 void SetSelection( const wxArrayPGProperty
& newSelection
)
1017 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
1021 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
1022 extra style is not used, then this has same effect as
1023 calling SelectProperty().
1025 @remarks Multiple selection is not supported for categories. This
1026 means that if you have properties selected, you cannot
1027 add category to selection, and also if you have category
1028 selected, you cannot add other properties to selection.
1029 This member function will fail silently in these cases,
1030 even returning true.
1032 bool AddToSelection( wxPGPropArg id
)
1034 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1035 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1039 Removes given property from selection. If property is not selected,
1040 an assertion failure will occur.
1042 bool RemoveFromSelection( wxPGPropArg id
)
1044 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1045 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1049 Makes given column editable by user.
1052 Using @false here will disable column from being editable.
1054 void MakeColumnEditable( unsigned int column
, bool editable
= true );
1057 Creates label editor wxTextCtrl for given column, for property
1058 that is currently selected. When multiple selection is
1059 enabled, this applies to whatever property GetSelection()
1063 Which column's label to edit. Note that you should not
1064 use value 1, which is reserved for property value
1067 @see EndLabelEdit(), MakeColumnEditable()
1069 void BeginLabelEdit( unsigned int column
= 0 )
1071 DoBeginLabelEdit(column
, wxPG_SEL_DONT_SEND_EVENT
);
1075 Destroys label editor wxTextCtrl, if any.
1078 Use @true (default) to store edited label text in
1081 @see BeginLabelEdit(), MakeColumnEditable()
1083 void EndLabelEdit( bool commit
= true )
1085 DoEndLabelEdit(commit
, wxPG_SEL_DONT_SEND_EVENT
);
1089 Returns currently active label editor, NULL if none.
1091 wxTextCtrl
* GetLabelEditor() const
1093 return m_labelEditor
;
1096 /** Sets category caption background colour. */
1097 void SetCaptionBackgroundColour(const wxColour
& col
);
1099 /** Sets category caption text colour. */
1100 void SetCaptionTextColour(const wxColour
& col
);
1102 /** Sets default cell background colour - applies to property cells.
1103 Note that appearance of editor widgets may not be affected.
1105 void SetCellBackgroundColour(const wxColour
& col
);
1107 /** Sets cell text colour for disabled properties.
1109 void SetCellDisabledTextColour(const wxColour
& col
);
1111 /** Sets default cell text colour - applies to property name and value text.
1112 Note that appearance of editor widgets may not be affected.
1114 void SetCellTextColour(const wxColour
& col
);
1116 /** Set number of columns (2 or more).
1118 void SetColumnCount( int colCount
)
1120 m_pState
->SetColumnCount(colCount
);
1125 Sets the 'current' category - Append will add non-category properties
1128 void SetCurrentCategory( wxPGPropArg id
)
1130 wxPG_PROP_ARG_CALL_PROLOG()
1131 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1133 m_pState
->m_currentCategory
= pc
;
1136 /** Sets colour of empty space below properties. */
1137 void SetEmptySpaceColour(const wxColour
& col
);
1139 /** Sets colour of lines between cells. */
1140 void SetLineColour(const wxColour
& col
);
1142 /** Sets background colour of margin. */
1143 void SetMarginColour(const wxColour
& col
);
1146 Sets selection background colour - applies to selected property name
1149 void SetSelectionBackgroundColour(const wxColour
& col
);
1152 Sets selection foreground colour - applies to selected property name
1155 void SetSelectionTextColour(const wxColour
& col
);
1157 /** Sets x coordinate of the splitter.
1159 Splitter position cannot exceed grid size, and therefore setting it
1160 during form creation may fail as initial grid size is often smaller
1161 than desired splitter position, especially when sizers are being used.
1163 void SetSplitterPosition( int newxpos
, int col
= 0 )
1165 DoSetSplitterPosition_(newxpos
, true, col
);
1166 m_iFlags
|= wxPG_FL_SPLITTER_PRE_SET
;
1170 Sets the property sorting function.
1173 The sorting function to be used. It should return a value greater
1174 than 0 if position of p1 is after p2. So, for instance, when
1175 comparing property names, you can use following implementation:
1178 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1182 return p1->GetBaseName().compare( p2->GetBaseName() );
1187 Default property sort function sorts properties by their labels
1188 (case-insensitively).
1190 @see GetSortFunction, wxPropertyGridInterface::Sort,
1191 wxPropertyGridInterface::SortChildren
1193 void SetSortFunction( wxPGSortCallback sortFunction
)
1195 m_sortFunction
= sortFunction
;
1199 Returns the property sort function (default is @NULL).
1201 @see SetSortFunction
1203 wxPGSortCallback
GetSortFunction() const
1205 return m_sortFunction
;
1208 /** Set virtual width for this particular page. Width -1 indicates that the
1209 virtual width should be disabled. */
1210 void SetVirtualWidth( int width
);
1213 Moves splitter as left as possible, while still allowing all
1214 labels to be shown in full.
1216 @param privateChildrenToo
1217 If @false, will still allow private children to be cropped.
1219 void SetSplitterLeft( bool privateChildrenToo
= false )
1221 m_pState
->SetSplitterLeft(privateChildrenToo
);
1224 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1225 height. Value of 2 should be default on most platforms.
1227 void SetVerticalSpacing( int vspacing
)
1229 m_vspacing
= (unsigned char)vspacing
;
1230 CalculateFontAndBitmapStuff( vspacing
);
1231 if ( !m_pState
->m_itemsAdded
) Refresh();
1234 /** Shows an brief error message that is related to a property. */
1235 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1237 wxPG_PROP_ARG_CALL_PROLOG()
1238 DoShowPropertyError(p
, msg
);
1241 /////////////////////////////////////////////////////////////////
1243 // Following methods do not need to be (currently) documented
1245 /////////////////////////////////////////////////////////////////
1247 bool HasVirtualWidth() const
1248 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1250 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1252 return (wxPGCommonValue
*) m_commonValues
[i
];
1255 /** Returns number of common values.
1257 unsigned int GetCommonValueCount() const
1259 return (unsigned int) m_commonValues
.size();
1262 /** Returns label of given common value.
1264 wxString
GetCommonValueLabel( unsigned int i
) const
1266 wxASSERT( GetCommonValue(i
) );
1267 return GetCommonValue(i
)->GetLabel();
1271 Returns index of common value that will truly change value to
1274 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1276 /** Set index of common value that will truly change value to unspecified.
1277 Using -1 will set none to have such effect.
1280 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1283 Shortcut for creating dialog-caller button. Used, for example, by
1286 This should only be called by properties.
1288 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1290 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1291 fits as one). Call after control has been created (but before
1294 void FixPosForTextCtrl( wxWindow
* ctrl
,
1295 unsigned int forColumn
= 1,
1296 const wxPoint
& offset
= wxPoint(0, 0) );
1298 /** Shortcut for creating text editor widget.
1300 Same as pos given for CreateEditor.
1302 Same as sz given for CreateEditor.
1304 Initial text for wxTextCtrl.
1306 If right-side control, such as button, also created, then create it
1307 first and pass it as this parameter.
1309 Extra style flags to pass for wxTextCtrl.
1311 Note that this should generally be called only by new classes derived
1314 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1316 const wxString
& value
,
1317 wxWindow
* secondary
,
1320 unsigned int forColumn
= 1 );
1322 /* Generates both textctrl and button.
1324 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1325 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1326 wxPGProperty
* property
);
1328 /** Generates position for a widget editor dialog box.
1330 Property for which dialog is positioned.
1332 Known or over-approximated size of the dialog.
1334 Position for dialog.
1336 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1339 // Converts escape sequences in src_str to newlines,
1340 // tabs, etc. and copies result to dst_str.
1341 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1342 wxString
& src_str
);
1344 // Converts newlines, tabs, etc. in src_str to escape
1345 // sequences, and copies result to dst_str.
1346 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1347 wxString
& src_str
);
1350 Returns rectangle that fully contains properties between and including
1353 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1354 const wxPGProperty
* p2
) const;
1356 /** Returns pointer to current active primary editor control (NULL if none).
1358 wxWindow
* GetEditorControl() const;
1360 wxWindow
* GetPrimaryEditor() const
1362 return GetEditorControl();
1366 Returns pointer to current active secondary editor control (NULL if
1369 wxWindow
* GetEditorControlSecondary() const
1371 return m_wndEditor2
;
1375 Refreshes any active editor control.
1377 void RefreshEditor();
1379 // Events from editor controls are forward to this function
1380 void HandleCustomEditorEvent( wxEvent
&event
);
1385 Generates contents for string dst based on the contents of
1388 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1389 so on. Set flags to 1 inorder to convert backslashes to double-back-
1390 slashes and "(preDelims)"'s to "(preDelims)".
1392 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1393 wxChar preDelim
, wxChar postDelim
,
1396 // Mostly useful for page switching.
1397 void SwitchState( wxPropertyGridPageState
* pNewState
);
1399 long GetInternalFlags() const { return m_iFlags
; }
1400 bool HasInternalFlag( long flag
) const
1401 { return (m_iFlags
& flag
) ? true : false; }
1402 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1403 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1404 void IncFrozen() { m_frozen
++; }
1405 void DecFrozen() { m_frozen
--; }
1407 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1413 /** Standardized double-to-string conversion.
1415 static void DoubleToString( wxString
& target
,
1419 wxString
* precTemplate
);
1422 Call this from wxPGProperty::OnEvent() to cause property value to be
1423 changed after the function returns (with true as return value).
1424 ValueChangeInEvent() must be used if you wish the application to be
1425 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1427 void ValueChangeInEvent( wxVariant variant
)
1429 m_changeInEventValue
= variant
;
1430 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1434 You can use this member function, for instance, to detect in
1435 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1436 already called in wxPGEditor::OnEvent(). It really only detects
1437 if was value was changed using wxPGProperty::SetValueInEvent(), which
1438 is usually used when a 'picker' dialog is displayed. If value was
1439 written by "normal means" in wxPGProperty::StringToValue() or
1440 IntToValue(), then this function will return false (on the other hand,
1441 wxPGProperty::OnEvent() is not even called in those cases).
1443 bool WasValueChangedInEvent() const
1445 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1448 /** Returns true if given event is from first of an array of buttons
1449 (as can be in case when wxPGMultiButton is used).
1451 bool IsMainButtonEvent( const wxEvent
& event
)
1453 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1454 && (m_wndSecId
== event
.GetId());
1457 /** Pending value is expected to be passed in PerformValidation().
1459 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1460 unsigned int selFlags
= 0 );
1462 /** Called when validation for given property fails.
1464 Value which failed in validation.
1466 Return true if user is allowed to change to another property even
1467 if current has invalid value.
1469 To add your own validation failure behavior, override
1470 wxPropertyGrid::DoOnValidationFailure().
1472 bool OnValidationFailure( wxPGProperty
* property
,
1473 wxVariant
& invalidValue
);
1475 /** Called to indicate property and editor has valid value now.
1477 void OnValidationFailureReset( wxPGProperty
* property
)
1479 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1481 DoOnValidationFailureReset(property
);
1482 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1484 m_validationInfo
.m_failureMessage
.clear();
1487 /** Override in derived class to display error messages in custom manner
1488 (these message usually only result from validation failure).
1490 virtual void DoShowPropertyError( wxPGProperty
* property
,
1491 const wxString
& msg
);
1493 /** Override to customize property validation failure behavior.
1495 Value which failed in validation.
1497 Return true if user is allowed to change to another property even
1498 if current has invalid value.
1500 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1501 wxVariant
& invalidValue
);
1503 /** Override to customize resetting of property validation failure status.
1505 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1507 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1509 int GetSpacingY() const { return m_spacingy
; }
1512 Must be called in wxPGEditor::CreateControls() if primary editor window
1513 is wxTextCtrl, just before textctrl is created.
1515 Initial text value of created wxTextCtrl.
1517 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1520 Unfocuses or closes editor if one was open, but does not deselect
1523 bool UnfocusEditor();
1525 virtual void SetWindowStyleFlag( long style
);
1527 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1529 void DrawItem( wxPGProperty
* p
)
1534 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1537 Draws item, children, and consequtive parents as long as category is
1540 void DrawItemAndValueRelated( wxPGProperty
* p
);
1545 wxPropertyGridPageState used by the grid is created here.
1547 If grid is used in wxPropertyGridManager, there is no point overriding
1548 this - instead, set custom wxPropertyGridPage classes.
1550 virtual wxPropertyGridPageState
* CreateState() const;
1552 enum PerformValidationFlags
1554 SendEvtChanging
= 0x0001,
1555 IsStandaloneValidation
= 0x0002 // Not called in response to event
1559 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1560 Returns true if all tests passed. Implement in derived class to
1561 add additional validation behavior.
1563 virtual bool PerformValidation( wxPGProperty
* p
,
1564 wxVariant
& pendingValue
,
1565 int flags
= SendEvtChanging
);
1569 // Control font changer helper.
1570 void SetCurControlBoldFont();
1572 wxPGCell
& GetPropertyDefaultCell()
1574 return m_propertyDefaultCell
;
1577 wxPGCell
& GetCategoryDefaultCell()
1579 return m_categoryDefaultCell
;
1583 // Public methods for semi-public use
1585 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1587 // Overridden functions.
1588 virtual bool Destroy();
1589 // Returns property at given y coordinate (relative to grid's top left).
1590 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1592 virtual void Refresh( bool eraseBackground
= true,
1593 const wxRect
*rect
= (const wxRect
*) NULL
);
1594 virtual bool SetFont( const wxFont
& font
);
1595 #if wxPG_SUPPORT_TOOLTIPS
1596 void SetToolTip( const wxString
& tipString
);
1598 virtual void Freeze();
1599 virtual void SetExtraStyle( long exStyle
);
1600 virtual void Thaw();
1601 virtual bool Reparent( wxWindowBase
*newParent
);
1604 virtual wxSize
DoGetBestSize() const;
1606 #ifndef wxPG_ICON_WIDTH
1607 wxBitmap
*m_expandbmp
, *m_collbmp
;
1610 wxCursor
*m_cursorSizeWE
;
1612 /** wxWindow pointers to editor control(s). */
1613 wxWindow
*m_wndEditor
;
1614 wxWindow
*m_wndEditor2
;
1616 /** wxPGCanvas instance. */
1619 #if wxPG_DOUBLE_BUFFER
1620 wxBitmap
*m_doubleBuffer
;
1623 /** Local time ms when control was created. */
1624 wxLongLong m_timeCreated
;
1626 /** wxPGProperty::OnEvent can change value by setting this. */
1627 wxVariant m_changeInEventValue
;
1629 /** Id of m_wndEditor2, or its first child, if any. */
1632 /** Extra Y spacing between the items. */
1635 /** Control client area width; updated on resize. */
1638 /** Control client area height; updated on resize. */
1641 /** Current non-client width (needed when auto-centering). */
1644 /** Non-client width (auto-centering helper). */
1647 /** Previously recorded scroll start position. */
1651 The gutter spacing in front and back of the image.
1652 This determines the amount of spacing in front of each item
1656 /** Includes separator line. */
1659 /** Gutter*2 + image width. */
1662 // y spacing for expand/collapse button.
1663 int m_buttonSpacingY
;
1665 /** Extra margin for expanded sub-group items. */
1666 int m_subgroup_extramargin
;
1669 The image width of the [+] icon.
1671 This is also calculated in the gutter
1675 #ifndef wxPG_ICON_WIDTH
1678 The image height of the [+] icon.
1680 This is calculated as minimal size and to align
1685 /** Current cursor id. */
1689 This captionFont is made equal to the font of the wxScrolledWindow.
1691 As extra the bold face is set on it when this is wanted by the user
1694 wxFont m_captionFont
;
1696 int m_fontHeight
; // Height of the font.
1698 /** m_splitterx when drag began. */
1699 int m_startingSplitterX
;
1702 Index to splitter currently being dragged (0=one after the first
1705 int m_draggedSplitter
;
1707 /** Changed property, calculated in PerformValidation(). */
1708 wxPGProperty
* m_chgInfo_changedProperty
;
1711 Lowest property for which editing happened, but which does not have
1714 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1716 /** Changed property value, calculated in PerformValidation(). */
1717 wxVariant m_chgInfo_pendingValue
;
1719 /** Passed to SetValue. */
1720 wxVariant m_chgInfo_valueList
;
1722 /** Validation information. */
1723 wxPGValidationInfo m_validationInfo
;
1725 /** Actions and keys that trigger them. */
1726 wxPGHashMapI2I m_actionTriggers
;
1732 /** Bits are used to indicate which colours are customized. */
1733 unsigned short m_coloursCustomized
;
1735 /** x - m_splitterx. */
1736 signed char m_dragOffset
;
1738 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1739 unsigned char m_dragStatus
;
1741 /** 0 = margin, 1 = label, 2 = value. */
1742 unsigned char m_mouseSide
;
1744 /** True when editor control is focused. */
1745 unsigned char m_editorFocused
;
1747 /** 1 if m_latsCaption is also the bottommost caption. */
1748 //unsigned char m_lastCaptionBottomnest;
1750 /** Set to 1 when graphics frozen. */
1751 unsigned char m_frozen
;
1753 unsigned char m_vspacing
;
1755 // Used to track when Alt/Ctrl+Key was consumed.
1756 unsigned char m_keyComboConsumed
;
1758 /** 1 if in DoPropertyChanged() */
1759 unsigned char m_inDoPropertyChanged
;
1761 /** 1 if in CommitChangesFromEditor() */
1762 unsigned char m_inCommitChangesFromEditor
;
1764 /** 1 if in DoSelectProperty() */
1765 unsigned char m_inDoSelectProperty
;
1767 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1769 /** Internal flags - see wxPG_FL_XXX constants. */
1772 /** When drawing next time, clear this many item slots at the end. */
1773 int m_clearThisMany
;
1775 // Mouse is hovering over this column (index)
1776 unsigned int m_colHover
;
1778 // pointer to property that has mouse hovering
1779 wxPGProperty
* m_propHover
;
1781 // Active label editor
1782 wxTextCtrl
* m_labelEditor
;
1784 // For which property the label editor is active
1785 wxPGProperty
* m_labelEditorProperty
;
1787 // EventObject for wxPropertyGridEvents
1788 wxWindow
* m_eventObject
;
1790 // What (global) window is currently focused (needed to resolve event
1792 wxWindow
* m_curFocused
;
1794 // Event currently being sent - NULL if none at the moment
1795 wxPropertyGridEvent
* m_processedEvent
;
1797 // Last known top-level parent
1800 // Last closed top-level parent
1801 wxWindow
* m_tlpClosed
;
1803 // Local time ms when tlp was closed.
1804 wxLongLong m_tlpClosedTime
;
1807 wxPGSortCallback m_sortFunction
;
1809 // y coordinate of property that mouse hovering
1812 // Which column's editor is selected (usually 1)?
1813 unsigned int m_selColumn
;
1815 // x relative to splitter (needed for resize).
1818 // lines between cells
1820 // property labels and values are written in this colour
1821 wxColour m_colPropFore
;
1822 // or with this colour when disabled
1823 wxColour m_colDisPropFore
;
1824 // background for m_colPropFore
1825 wxColour m_colPropBack
;
1826 // text color for captions
1827 wxColour m_colCapFore
;
1828 // background color for captions
1829 wxColour m_colCapBack
;
1830 // foreground for selected property
1831 wxColour m_colSelFore
;
1832 // background for selected property (actually use background color when
1833 // control out-of-focus)
1834 wxColour m_colSelBack
;
1835 // background colour for margin
1836 wxColour m_colMargin
;
1837 // background colour for empty space below the grid
1838 wxColour m_colEmptySpace
;
1840 // Default property colours
1841 wxPGCell m_propertyDefaultCell
;
1843 // Default property category
1844 wxPGCell m_categoryDefaultCell
;
1846 // Backup of selected property's cells
1847 wxVector
<wxPGCell
> m_propCellsBackup
;
1849 // NB: These *cannot* be moved to globals.
1851 // labels when properties use common values
1852 wxVector
<wxPGCommonValue
*> m_commonValues
;
1854 // Which cv selection really sets value to unspecified?
1855 int m_cvUnspecified
;
1857 // Used to skip excess text editor events
1858 wxString m_prevTcValue
;
1862 // Sets some members to defaults (called constructors).
1865 // Initializes some members (called by Create and complex constructor).
1868 void OnPaint(wxPaintEvent
&event
);
1870 // main event receivers
1871 void OnMouseMove( wxMouseEvent
&event
);
1872 void OnMouseMoveBottom( wxMouseEvent
&event
);
1873 void OnMouseClick( wxMouseEvent
&event
);
1874 void OnMouseRightClick( wxMouseEvent
&event
);
1875 void OnMouseDoubleClick( wxMouseEvent
&event
);
1876 void OnMouseUp( wxMouseEvent
&event
);
1877 void OnKey( wxKeyEvent
&event
);
1878 void OnResize( wxSizeEvent
&event
);
1881 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
1882 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1883 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1884 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1885 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
1886 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
1888 void OnMouseEntry( wxMouseEvent
&event
);
1890 void OnIdle( wxIdleEvent
&event
);
1891 void OnFocusEvent( wxFocusEvent
&event
);
1892 void OnChildFocusEvent( wxChildFocusEvent
& event
);
1894 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
1895 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
1897 // sub-control event handlers
1898 void OnMouseClickChild( wxMouseEvent
&event
);
1899 void OnMouseRightClickChild( wxMouseEvent
&event
);
1900 void OnMouseMoveChild( wxMouseEvent
&event
);
1901 void OnMouseUpChild( wxMouseEvent
&event
);
1902 void OnChildKeyDown( wxKeyEvent
&event
);
1904 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
1906 void OnScrollEvent( wxScrollWinEvent
&event
);
1908 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
1910 void OnTLPClose( wxCloseEvent
& event
);
1914 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
1915 unsigned int colIndex
,
1916 wxMouseEvent
* event
= NULL
,
1920 Adjust the centering of the bitmap icons (collapse / expand) when the
1921 caption font changes.
1923 They need to be centered in the middle of the font, so a bit of deltaY
1924 adjustment is needed. On entry, m_captionFont must be set to window
1925 font. It will be modified properly.
1927 void CalculateFontAndBitmapStuff( int vspacing
);
1929 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
1931 void CorrectEditorWidgetSizeX();
1933 /** Called in RecalculateVirtualSize() to reposition control
1934 on virtual height changes.
1936 void CorrectEditorWidgetPosY();
1938 int DoDrawItems( wxDC
& dc
,
1939 const wxRect
* clipRect
,
1940 bool isBuffered
) const;
1942 /** Draws an expand/collapse (ie. +/-) button.
1944 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1945 wxPGProperty
* property
) const;
1947 /** Draws items from topitemy to bottomitemy */
1948 void DrawItems( wxDC
& dc
, unsigned int topitemy
, unsigned int bottomitemy
,
1949 const wxRect
* clip_rect
= (const wxRect
*) NULL
);
1951 // Translate wxKeyEvent to wxPG_ACTION_XXX
1952 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
1954 int KeyEventToAction(wxKeyEvent
&event
) const
1956 return KeyEventToActions(event
, NULL
);
1959 void ImprovedClientToScreen( int* px
, int* py
);
1961 // Called by focus event handlers. newFocused is the window that becomes
1963 void HandleFocusChange( wxWindow
* newFocused
);
1965 /** Reloads all non-customized colours from system settings. */
1966 void RegainColours();
1968 bool DoEditorValidate();
1970 // Similar to DoSelectProperty() but also works on columns
1971 // other than 1. Does not active editor if column is not
1973 bool DoSelectAndEdit( wxPGProperty
* prop
,
1974 unsigned int colIndex
,
1975 unsigned int selFlags
);
1977 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
1980 bool DoAddToSelection( wxPGProperty
* prop
,
1983 bool DoRemoveFromSelection( wxPGProperty
* prop
,
1986 void DoBeginLabelEdit( unsigned int colIndex
, int selFlags
= 0 );
1987 void DoEndLabelEdit( bool commit
, int selFlags
= 0 );
1988 void OnLabelEditorEnterPress( wxCommandEvent
& event
);
1989 void OnLabelEditorKeyPress( wxKeyEvent
& event
);
1991 wxPGProperty
* DoGetItemAtY( int y
) const;
1993 void DoSetSplitterPosition_( int newxpos
,
1994 bool refresh
= true,
1995 int splitterIndex
= 0,
1996 bool allPages
= false );
1998 void DestroyEditorWnd( wxWindow
* wnd
);
2001 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
2003 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
2005 // Returns nearest paint visible property (such that will be painted unless
2006 // window is scrolled or resized). If given property is paint visible, then
2007 // it itself will be returned.
2008 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
2010 static void RegisterDefaultEditors();
2012 // Sets up basic event handling for child control
2013 void SetupChildEventHandling( wxWindow
* wnd
);
2015 void CustomSetCursor( int type
, bool override
= false );
2018 Repositions scrollbar and underlying panel according to changed virtual
2021 void RecalculateVirtualSize( int forceXPos
= -1 );
2023 void PrepareAfterItemsAdded();
2025 // Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
2026 bool SendEvent( int eventType
, wxPGProperty
* p
,
2027 wxVariant
* pValue
= NULL
,
2028 unsigned int selFlags
= wxPG_SEL_NOVALIDATE
,
2029 unsigned int column
= 1 );
2031 void SetFocusOnCanvas();
2033 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
2037 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
2039 DECLARE_EVENT_TABLE()
2040 #endif // #ifndef SWIG
2043 // -----------------------------------------------------------------------
2045 // Bunch of inlines that need to resolved after all classes have been defined.
2049 inline bool wxPropertyGridPageState::IsDisplayed() const
2051 return ( this == m_pPropGrid
->GetState() );
2054 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
2056 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
2060 inline int wxPGProperty::GetDisplayedCommonValueCount() const
2062 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
2064 wxPropertyGrid
* pg
= GetGrid();
2066 return (int) pg
->GetCommonValueCount();
2071 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
2073 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
2076 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
2078 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
2081 inline bool wxPGProperty::Hide( bool hide
, int flags
)
2083 return GetGrid()->HideProperty(this, hide
, flags
);
2086 inline bool wxPGProperty::SetMaxLength( int maxLen
)
2088 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
2091 // -----------------------------------------------------------------------
2093 #define wxPG_BASE_EVT_PRE_ID 1775
2097 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
2098 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
2099 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
2100 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
2101 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
2102 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
2103 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
2104 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
2105 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
2106 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2107 wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
2108 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2109 wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
2113 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
2116 wxEVT_PG_HIGHLIGHTED
,
2117 wxEVT_PG_RIGHT_CLICK
,
2118 wxEVT_PG_PAGE_CHANGED
,
2119 wxEVT_PG_ITEM_COLLAPSED
,
2120 wxEVT_PG_ITEM_EXPANDED
,
2121 wxEVT_PG_DOUBLE_CLICK
,
2122 wxEVT_PG_LABEL_EDIT_BEGIN
,
2123 wxEVT_PG_LABEL_EDIT_ENDING
2128 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2129 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2133 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2135 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2136 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2137 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2138 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2139 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2140 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2141 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2142 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2143 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2144 #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 ),
2145 #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 ),
2147 #define wxPropertyGridEventHandler(fn) \
2148 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2153 /** @class wxPropertyGridEvent
2155 A propertygrid event holds information about events associated with
2156 wxPropertyGrid objects.
2158 @library{wxpropgrid}
2161 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2166 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2168 /** Copy constructor. */
2169 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2172 ~wxPropertyGridEvent();
2175 virtual wxEvent
* Clone() const;
2178 Returns the column index associated with this event.
2180 unsigned int GetColumn() const
2185 wxPGProperty
* GetMainParent() const
2187 wxASSERT(m_property
);
2188 return m_property
->GetMainParent();
2191 /** Returns id of associated property. */
2192 wxPGProperty
* GetProperty() const
2197 wxPGValidationInfo
& GetValidationInfo()
2199 wxASSERT(m_validationInfo
);
2200 return *m_validationInfo
;
2203 /** Returns true if you can veto the action that the event is signaling.
2205 bool CanVeto() const { return m_canVeto
; }
2208 Call this from your event handler to veto action that the event is
2211 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2214 Currently only wxEVT_PG_CHANGING supports vetoing.
2216 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2218 /** Returns value that is about to be set for wxEVT_PG_CHANGING.
2220 const wxVariant
& GetValue() const
2222 wxASSERT_MSG( m_validationInfo
,
2223 "Only call GetValue from a handler "
2224 "of event type that supports it" );
2225 return m_validationInfo
->GetValue();
2229 Set override validation failure behavior.
2231 Only effective if Veto was also called, and only allowed if event type
2232 is wxEVT_PG_CHANGING.
2234 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2236 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2237 m_validationInfo
->SetFailureBehavior( flags
);
2240 /** Sets custom failure message for this time only. Only applies if
2241 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2243 void SetValidationFailureMessage( const wxString
& message
)
2245 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2246 m_validationInfo
->SetFailureMessage( message
);
2250 wxPGVFBFlags
GetValidationFailureBehavior() const
2252 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2253 return m_validationInfo
->GetFailureBehavior();
2256 void SetColumn( unsigned int column
)
2261 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2262 bool WasVetoed() const { return m_wasVetoed
; }
2264 /** Changes the associated property. */
2265 void SetProperty( wxPGProperty
* p
) { m_property
= p
; }
2267 void SetPropertyGrid( wxPropertyGrid
* pg
) { m_pg
= pg
; }
2269 void SetupValidationInfo()
2272 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2273 m_validationInfo
= &m_pg
->GetValidationInfo();
2278 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2280 wxPGProperty
* m_property
;
2281 wxPropertyGrid
* m_pg
;
2282 wxPGValidationInfo
* m_validationInfo
;
2284 unsigned int m_column
;
2293 // -----------------------------------------------------------------------
2295 /** @class wxPropertyGridPopulator
2297 Allows populating wxPropertyGrid from arbitrary text source.
2299 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2302 /** Default constructor.
2304 wxPropertyGridPopulator();
2307 virtual ~wxPropertyGridPopulator();
2309 void SetState( wxPropertyGridPageState
* state
);
2311 void SetGrid( wxPropertyGrid
* pg
);
2313 /** Appends a new property under bottommost parent.
2315 Property class as string.
2317 wxPGProperty
* Add( const wxString
& propClass
,
2318 const wxString
& propLabel
,
2319 const wxString
& propName
,
2320 const wxString
* propValue
,
2321 wxPGChoices
* pChoices
= NULL
);
2324 Pushes property to the back of parent array (ie it becomes bottommost
2325 parent), and starts scanning/adding children for it.
2327 When finished, parent array is returned to the original state.
2329 void AddChildren( wxPGProperty
* property
);
2331 /** Adds attribute to the bottommost property.
2333 Allowed values: "string", (same as string), "int", "bool". Empty string
2336 bool AddAttribute( const wxString
& name
,
2337 const wxString
& type
,
2338 const wxString
& value
);
2340 /** Called once in AddChildren.
2342 virtual void DoScanForChildren() = 0;
2345 Returns id of parent property for which children can currently be
2348 wxPGProperty
* GetCurParent() const
2350 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2353 wxPropertyGridPageState
* GetState() { return m_state
; }
2354 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2356 /** Like wxString::ToLong, except allows N% in addition of N.
2358 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2360 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2361 wxPGChoices. Registers parsed result using idString (if not empty).
2362 Also, if choices with given id already registered, then don't parse but
2363 return those choices instead.
2365 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2366 const wxString
& idString
);
2368 /** Implement in derived class to do custom process when an error occurs.
2369 Default implementation uses wxLogError.
2371 virtual void ProcessError( const wxString
& msg
);
2375 /** Used property grid. */
2376 wxPropertyGrid
* m_pg
;
2378 /** Used property grid state. */
2379 wxPropertyGridPageState
* m_state
;
2381 /** Tree-hierarchy of added properties (that can have children). */
2382 wxArrayPGProperty m_propHierarchy
;
2384 /** Hashmap for string-id to wxPGChoicesData mapping. */
2385 wxPGHashMapS2P m_dictIdChoices
;
2388 // -----------------------------------------------------------------------
2391 // Undefine macros that are not needed outside propertygrid sources
2393 #ifndef __wxPG_SOURCE_FILE__
2394 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2395 #undef wxPG_FL_SCROLLBAR_DETECTED
2396 #undef wxPG_FL_CREATEDSTATE
2397 #undef wxPG_FL_NOSTATUSBARHELP
2398 #undef wxPG_FL_SCROLLED
2399 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2400 #undef wxPG_FL_FOCUS_INSIDE
2401 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2402 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2403 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2404 #undef wxPG_FL_VALUE_MODIFIED
2405 #undef wxPG_FL_MOUSE_INSIDE
2406 #undef wxPG_FL_FOCUSED
2407 #undef wxPG_FL_MOUSE_CAPTURED
2408 #undef wxPG_FL_INITIALIZED
2409 #undef wxPG_FL_ACTIVATION_BY_CLICK
2410 #undef wxPG_FL_DONT_CENTER_SPLITTER
2411 #undef wxPG_SUPPORT_TOOLTIPS
2412 #undef wxPG_DOUBLE_BUFFER
2413 #undef wxPG_ICON_WIDTH
2414 #undef wxPG_USE_RENDERER_NATIVE
2415 // Following are needed by the manager headers
2416 // #undef const wxString&
2419 // -----------------------------------------------------------------------
2423 #endif // _WX_PROPGRID_PROPGRID_H_