1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPGRID_H_
13 #define _WX_PROPGRID_PROPGRID_H_
17 #include "wx/thread.h"
18 #include "wx/dcclient.h"
19 #include "wx/scrolwin.h"
20 #include "wx/tooltip.h"
21 #include "wx/datetime.h"
23 #include "wx/propgrid/property.h"
24 #include "wx/propgrid/propgridiface.h"
28 extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr
[];
33 // -----------------------------------------------------------------------
35 // -----------------------------------------------------------------------
39 // This is required for sharing common global variables.
40 class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
44 wxPGGlobalVarsClass();
45 ~wxPGGlobalVarsClass();
48 // Critical section for handling the globals. Generally it is not needed
49 // since GUI code is supposed to be in single thread. However,
50 // we do want the user to be able to convey wxPropertyGridEvents to other
52 wxCriticalSection m_critSect
;
55 // Used by advprops, but here to make things easier.
56 wxString m_pDefaultImageWildcard
;
58 // Map of editor class instances (keys are name string).
59 wxPGHashMapS2P m_mapEditorClasses
;
62 wxVector
<wxValidator
*> m_arrValidators
; // These wxValidators need to be freed
65 wxPGHashMapS2P m_dictPropertyClassInfo
; // PropertyName -> ClassInfo
67 wxPGChoices
* m_fontFamilyChoices
;
69 // Replace with your own to affect all properties using default renderer.
70 wxPGCellRenderer
* m_defaultRenderer
;
72 wxPGChoices m_boolChoices
;
74 wxVariant m_vEmptyString
;
76 wxVariant m_vMinusOne
;
80 // Cached constant strings
81 wxPGCachedString m_strstring
;
82 wxPGCachedString m_strlong
;
83 wxPGCachedString m_strbool
;
84 wxPGCachedString m_strlist
;
86 wxPGCachedString m_strDefaultValue
;
87 wxPGCachedString m_strMin
;
88 wxPGCachedString m_strMax
;
89 wxPGCachedString m_strUnits
;
90 wxPGCachedString m_strInlineHelp
;
92 // If true then some things are automatically translated
93 bool m_autoGetTranslation
;
95 // > 0 if errors cannot or should not be shown in statusbar etc.
98 int m_extraStyle
; // global extra style
102 int HasExtraStyle( int style
) const { return (m_extraStyle
& style
); }
105 extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
* wxPGGlobalVars
;
107 #define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
108 #define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
109 #define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
110 #define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
111 #define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
113 #define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
115 // When wxPG is loaded dynamically after the application is already running
116 // then the built-in module system won't pick this one up. Add it manually.
117 WXDLLIMPEXP_PROPGRID
void wxPGInitResourceModule();
121 // -----------------------------------------------------------------------
123 /** @section propgrid_window_styles wxPropertyGrid Window Styles
125 SetWindowStyleFlag method can be used to modify some of these at run-time.
128 enum wxPG_WINDOW_STYLES
131 /** This will cause Sort() automatically after an item is added.
132 When inserting a lot of items in this mode, it may make sense to
133 use Freeze() before operations and Thaw() afterwards to increase
136 wxPG_AUTO_SORT
= 0x00000010,
138 /** Categories are not initially shown (even if added).
139 IMPORTANT NOTE: If you do not plan to use categories, then this
140 style will waste resources.
141 This flag can also be changed using wxPropertyGrid::EnableCategories method.
143 wxPG_HIDE_CATEGORIES
= 0x00000020,
145 /* This style combines non-categoric mode and automatic sorting.
147 wxPG_ALPHABETIC_MODE
= (wxPG_HIDE_CATEGORIES
|wxPG_AUTO_SORT
),
149 /** Modified values are shown in bold font. Changing this requires Refresh()
152 wxPG_BOLD_MODIFIED
= 0x00000040,
154 /** When wxPropertyGrid is resized, splitter moves to the center. This
155 behavior stops once the user manually moves the splitter.
157 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
159 /** Display tooltips for cell text that cannot be shown completely. If
160 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
162 wxPG_TOOLTIPS
= 0x00000100,
164 /** Disables margin and hides all expand/collapse buttons that would appear
165 outside the margin (for sub-properties). Toggling this style automatically
166 expands all collapsed items.
168 wxPG_HIDE_MARGIN
= 0x00000200,
170 /** This style prevents user from moving the splitter.
172 wxPG_STATIC_SPLITTER
= 0x00000400,
174 /** Combination of other styles that make it impossible for user to modify
177 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
179 /** Disables wxTextCtrl based editors for properties which
180 can be edited in another way.
182 Equals calling wxPropertyGrid::LimitPropertyEditing for all added
185 wxPG_LIMITED_EDITING
= 0x00000800,
187 /** wxPropertyGridManager only: Show toolbar for mode and page selection. */
188 wxPG_TOOLBAR
= 0x00001000,
190 /** wxPropertyGridManager only: Show adjustable text box showing description
191 or help text, if available, for currently selected property.
193 wxPG_DESCRIPTION
= 0x00002000,
195 /** wxPropertyGridManager only: don't show an internal border around
198 wxPG_NO_INTERNAL_BORDER
= 0x00004000
201 #if wxPG_COMPATIBILITY_1_4
202 // In wxPG 1.4 this was used to enable now-default theme border support
203 // in wxPropertyGridManager.
204 #define wxPG_THEME_BORDER 0x00000000
208 enum wxPG_EX_WINDOW_STYLES
212 NOTE: wxPG_EX_xxx are extra window styles and must be set using
213 SetExtraStyle() member function.
215 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
216 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
217 not activated, and switching the mode first time becomes somewhat slower.
218 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
219 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
220 you don't plan to use categories at all, then using this style will result
221 in waste of resources.
224 wxPG_EX_INIT_NOCAT
= 0x00001000,
226 /** Extended window style that sets wxPropertyGridManager toolbar to not
229 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
231 /** Shows alphabetic/categoric mode buttons from toolbar.
233 wxPG_EX_MODE_BUTTONS
= 0x00008000,
235 /** Show property help strings as tool tips instead as text on the status bar.
236 You can set the help strings using SetPropertyHelpString member function.
238 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
240 /** Prevent TAB from focusing to wxButtons. This behavior was default
241 in version 1.2.0 and earlier.
242 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
243 atleast the button doesn't properly propagate key events (yes, I'm using
246 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
248 /** Allows relying on native double-buffering.
250 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
252 /** Set this style to let user have ability to set values of properties to
253 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
256 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
259 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
260 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
261 (thus they are not readable).
263 Note that this option is global, and applies to all wxPG property
266 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
268 /** Hides page selection buttons from toolbar.
270 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
272 /** Allows multiple properties to be selected by user (by pressing SHIFT
273 when clicking on a property, or by dragging with left mouse button
276 You can get array of selected properties with
277 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
278 mode wxPropertyGridInterface::GetSelection() returns
279 property which has editor active (usually the first one
280 selected). Other useful member functions are ClearSelection(),
281 AddToSelection() and RemoveFromSelection().
283 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
286 This enables top-level window tracking which allows wxPropertyGrid to
287 notify the application of last-minute property value changes by user.
289 This style is not enabled by default because it may cause crashes when
290 wxPropertyGrid is used in with wxAUI or similar system.
292 @remarks If you are not in fact using any system that may change
293 wxPropertyGrid's top-level parent window on its own, then you
294 are recommended to enable this style.
296 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
298 /** Don't show divider above toolbar, on Windows.
300 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x08000000,
302 /** Show a separator below the toolbar.
304 wxPG_EX_TOOLBAR_SEPARATOR
= 0x10000000
308 #if wxPG_COMPATIBILITY_1_4
309 #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
312 /** Combines various styles.
314 #define wxPG_DEFAULT_STYLE (0)
316 /** Combines various styles.
318 #define wxPGMAN_DEFAULT_STYLE (0)
323 // -----------------------------------------------------------------------
326 // Ids for sub-controls
327 // NB: It should not matter what these are.
328 #define wxPG_SUBID1 2
329 #define wxPG_SUBID2 3
330 #define wxPG_SUBID_TEMP1 4
332 // -----------------------------------------------------------------------
334 /** @class wxPGCommonValue
336 wxPropertyGrid stores information about common values in these
339 NB: Common value feature is not complete, and thus not mentioned in
342 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
346 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
349 m_renderer
= renderer
;
352 virtual ~wxPGCommonValue()
354 m_renderer
->DecRef();
357 virtual wxString
GetEditableText() const { return m_label
; }
358 const wxString
& GetLabel() const { return m_label
; }
359 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
363 wxPGCellRenderer
* m_renderer
;
366 // -----------------------------------------------------------------------
368 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
372 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
375 /** Prevents user from leaving property unless value is valid. If this
376 behavior flag is not used, then value change is instead cancelled.
378 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
380 /** Calls wxBell() on validation failure.
382 wxPG_VFB_BEEP
= 0x02,
384 /** Cell with invalid value will be marked (with red colour).
386 wxPG_VFB_MARK_CELL
= 0x04,
388 /** Display customizable text message explaining the situation.
390 wxPG_VFB_SHOW_MESSAGE
= 0x08,
393 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
395 /** Only used internally. */
396 wxPG_VFB_UNDEFINED
= 0x80
403 typedef wxByte wxPGVFBFlags
;
408 Used to convey validation information to and from functions that
409 actually perform validation. Mostly used in custom property
412 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
414 friend class wxPropertyGrid
;
417 @return Returns failure behavior which is a combination of
418 @ref propgrid_vfbflags.
420 wxPGVFBFlags
GetFailureBehavior() const
421 { return m_failureBehavior
; }
424 Returns current failure message.
426 const wxString
& GetFailureMessage() const
427 { return m_failureMessage
; }
430 Returns reference to pending value.
432 wxVariant
& GetValue()
438 /** Set validation failure behavior
440 @param failureBehavior
441 Mixture of @ref propgrid_vfbflags.
443 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
444 { m_failureBehavior
= failureBehavior
; }
447 Set current failure message.
449 void SetFailureMessage(const wxString
& message
)
450 { m_failureMessage
= message
; }
453 /** Value to be validated.
457 /** Message displayed on validation failure.
459 wxString m_failureMessage
;
461 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
463 wxPGVFBFlags m_failureBehavior
;
466 // -----------------------------------------------------------------------
468 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
470 These are used with wxPropertyGrid::AddActionTrigger() and
471 wxPropertyGrid::ClearActionTriggers().
475 enum wxPG_KEYBOARD_ACTIONS
477 wxPG_ACTION_INVALID
= 0,
478 wxPG_ACTION_NEXT_PROPERTY
,
479 wxPG_ACTION_PREV_PROPERTY
,
480 wxPG_ACTION_EXPAND_PROPERTY
,
481 wxPG_ACTION_COLLAPSE_PROPERTY
,
482 wxPG_ACTION_CANCEL_EDIT
,
483 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
490 // -----------------------------------------------------------------------
493 // wxPropertyGrid::DoSelectProperty flags (selFlags)
495 // Focuses to created editor
496 #define wxPG_SEL_FOCUS 0x0001
497 // Forces deletion and recreation of editor
498 #define wxPG_SEL_FORCE 0x0002
499 // For example, doesn't cause EnsureVisible
500 #define wxPG_SEL_NONVISIBLE 0x0004
501 // Do not validate editor's value before selecting
502 #define wxPG_SEL_NOVALIDATE 0x0008
503 // Property being deselected is about to be deleted
504 #define wxPG_SEL_DELETING 0x0010
505 // Property's values was set to unspecified by the user
506 #define wxPG_SEL_SETUNSPEC 0x0020
507 // Property's event handler changed the value
508 #define wxPG_SEL_DIALOGVAL 0x0040
509 // Set to disable sending of wxEVT_PG_SELECTED event
510 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
511 // Don't make any graphics updates
512 #define wxPG_SEL_NO_REFRESH 0x0100
514 // -----------------------------------------------------------------------
519 #define wxPG_FL_INITIALIZED 0x0001
520 // Set when creating editor controls if it was clicked on.
521 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
522 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
523 #define wxPG_FL_FOCUSED 0x0008
524 #define wxPG_FL_MOUSE_CAPTURED 0x0010
525 #define wxPG_FL_MOUSE_INSIDE 0x0020
526 #define wxPG_FL_VALUE_MODIFIED 0x0040
527 // don't clear background of m_wndEditor
528 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
529 // currently active editor uses custom image
530 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
531 // cell colours override selection colours for selected cell
532 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
533 #define wxPG_FL_SCROLLED 0x0400
534 // set when all added/inserted properties get hideable flag
535 #define wxPG_FL_ADDING_HIDEABLES 0x0800
536 // Disables showing help strings on statusbar.
537 #define wxPG_FL_NOSTATUSBARHELP 0x1000
538 // Marks that we created the state, so we have to destroy it too.
539 #define wxPG_FL_CREATEDSTATE 0x2000
540 // Set if scrollbar's existence was detected in last onresize.
541 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
542 // Set if wxPGMan requires redrawing of description text box.
543 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
544 // Set if contained in wxPropertyGridManager
545 #define wxPG_FL_IN_MANAGER 0x00020000
546 // Set after wxPropertyGrid is shown in its initial good size
547 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
548 // Set when in SelectProperty.
549 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
550 // Set when help string is shown in status bar
551 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
552 // Validation failed. Clear on modify event.
553 #define wxPG_FL_VALIDATION_FAILED 0x00800000
554 // Auto sort is enabled (for categorized mode)
555 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
556 // Set after page has been inserted to manager
557 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
558 // Active editor control is abnormally large
559 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
560 // Recursion guard for HandleCustomEditorEvent
561 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
562 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
563 // Editor control width should not change on resize
564 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
565 // Width of panel can be different than width of grid
566 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
567 // Prevents RecalculateVirtualSize re-entrancy
568 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
570 #endif // #ifndef SWIG
572 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
573 // Reduce compile time, but still include in user app
574 #include "wx/propgrid/props.h"
577 // -----------------------------------------------------------------------
579 /** @class wxPropertyGrid
581 wxPropertyGrid is a specialized grid for editing properties
582 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
583 used to do the very same thing, but it hasn't been updated for a while
584 and it is currently deprecated.
586 Please note that most member functions are inherited and as such not
587 documented on this page. This means you will probably also want to read
588 wxPropertyGridInterface class reference.
590 See also @ref overview_propgrid.
592 @section propgrid_window_styles_ Window Styles
594 See @ref propgrid_window_styles.
596 @section propgrid_event_handling Event Handling
598 To process input from a propertygrid control, use these event handler
599 macros to direct input to member functions that take a wxPropertyGridEvent
602 @beginEventTable{wxPropertyGridEvent}
603 @event{EVT_PG_SELECTED (id, func)}
604 Respond to wxEVT_PG_SELECTED event, generated when a property selection
605 has been changed, either by user action or by indirect program
606 function. For instance, collapsing a parent property programmatically
607 causes any selected child property to become unselected, and may
608 therefore cause this event to be generated.
609 @event{EVT_PG_CHANGING(id, func)}
610 Respond to wxEVT_PG_CHANGING event, generated when property value
611 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
612 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
613 to prevent change from taking place, if necessary.
614 @event{EVT_PG_HIGHLIGHTED(id, func)}
615 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
616 moves over a property. Event's property is NULL if hovered area does
617 not belong to any property.
618 @event{EVT_PG_RIGHT_CLICK(id, func)}
619 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
620 clicked on with right mouse button.
621 @event{EVT_PG_DOUBLE_CLICK(id, func)}
622 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
623 double-clicked onwith left mouse button.
624 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
625 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
626 a property or category..
627 @event{EVT_PG_ITEM_EXPANDED(id, func)}
628 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
629 a property or category..
630 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
631 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
632 begin editing a property label. You can veto this event to prevent the
634 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
635 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
636 end editing of a property label. You can veto this event to prevent the
642 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
643 will also delay sorting etc. miscellaneous calculations to the last
649 class WXDLLIMPEXP_PROPGRID
650 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
652 friend class wxPropertyGridEvent
;
653 friend class wxPropertyGridPageState
;
654 friend class wxPropertyGridInterface
;
655 friend class wxPropertyGridManager
;
657 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
662 Two step constructor.
664 Call Create when this constructor is called to build up the
670 /** The default constructor. The styles to be used are styles valid for
671 the wxWindow and wxScrolledWindow.
673 @see @link wndflags Additional Window Styles @endlink
675 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
676 const wxPoint
& pos
= wxDefaultPosition
,
677 const wxSize
& size
= wxDefaultSize
,
678 long style
= wxPG_DEFAULT_STYLE
,
679 const wxString
& name
= wxPropertyGridNameStr
);
682 virtual ~wxPropertyGrid();
684 /** Adds given key combination to trigger given action.
687 Which action to trigger. See @link pgactions List of list of
688 wxPropertyGrid actions@endlink.
690 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
693 This static function enables or disables automatic use of
694 wxGetTranslation for following strings: wxEnumProperty list labels,
695 wxFlagsProperty sub-property labels.
699 static void AutoGetTranslation( bool enable
);
702 Changes value of a property, as if from an editor.
704 Use this instead of SetPropertyValue() if you need the value to run
705 through validation process, and also send the property change event.
708 Returns true if value was successfully changed.
710 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
713 Centers the splitter.
715 If argument is true, automatic splitter centering is enabled (only
716 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
718 void CenterSplitter( bool enable_auto_centering
= false );
720 /** Deletes all properties.
722 virtual void Clear();
724 /** Clears action triggers for given action.
726 Which action to trigger. See @link pgactions List of list of
727 wxPropertyGrid actions@endlink.
729 void ClearActionTriggers( int action
);
731 /** Forces updating the value of property from the editor control.
733 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
734 ProcessEvent, meaning your event handlers will be called immediately.
737 Returns true if anything was changed.
739 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
744 Whenever the control is created without any parameters, use Create to
745 actually create it. Don't access the control's public methods before
746 this is called @see @link wndflags Additional Window Styles@endlink
748 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
749 const wxPoint
& pos
= wxDefaultPosition
,
750 const wxSize
& size
= wxDefaultSize
,
751 long style
= wxPG_DEFAULT_STYLE
,
752 const wxString
& name
= wxPropertyGridNameStr
);
755 Call when editor widget's contents is modified.
757 For example, this is called when changes text in wxTextCtrl (used in
758 wxStringProperty and wxIntProperty).
761 This function should only be called by custom properties.
763 @see wxPGProperty::OnEvent()
765 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
767 /** Reverse of EditorsValueWasModified().
770 This function should only be called by custom properties.
772 void EditorsValueWasNotModified()
774 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
778 Enables or disables (shows/hides) categories according to parameter
781 bool EnableCategories( bool enable
);
783 /** Scrolls and/or expands items to ensure that the given item is visible.
784 Returns true if something was actually done.
786 bool EnsureVisible( wxPGPropArg id
);
789 Reduces column sizes to minimum possible that contents are still
790 visibly (naturally some margin space will be applied as well).
793 Minimum size for the grid to still display everything.
796 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
798 This function only works properly if grid size prior to call was already
801 Note that you can also get calculated column widths by calling
802 GetState->GetColumnWidth() immediately after this function returns.
806 wxSize sz
= m_pState
->DoFitColumns();
811 Returns wxWindow that the properties are painted on, and which should
812 be used as the parent for editor controls.
819 /** Returns current category caption background colour. */
820 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
822 wxFont
& GetCaptionFont() { return m_captionFont
; }
824 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
826 /** Returns current category caption text colour. */
827 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
829 /** Returns current cell background colour. */
830 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
832 /** Returns current cell text colour when disabled. */
833 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
835 /** Returns current cell text colour. */
836 wxColour
GetCellTextColour() const { return m_colPropFore
; }
839 Returns number of columns currently on grid.
841 unsigned int GetColumnCount() const
843 return (unsigned int) m_pState
->m_colWidths
.size();
846 /** Returns colour of empty space below properties. */
847 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
849 /** Returns height of highest characters of used font. */
850 int GetFontHeight() const { return m_fontHeight
; }
852 /** Returns pointer to itself. Dummy function that enables same kind
853 of code to use wxPropertyGrid and wxPropertyGridManager.
855 wxPropertyGrid
* GetGrid() { return this; }
857 /** Returns rectangle of custom paint image.
859 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
861 /** Returns size of the custom paint image in front of property.
862 If no argument is given, returns preferred size.
864 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
867 /** Returns last item which could be iterated using given flags.
869 See @ref propgrid_iterator_flags.
871 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
873 return m_pState
->GetLastItem(flags
);
876 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
878 return m_pState
->GetLastItem(flags
);
882 /** Returns colour of lines between cells. */
883 wxColour
GetLineColour() const { return m_colLine
; }
885 /** Returns background colour of margin. */
886 wxColour
GetMarginColour() const { return m_colMargin
; }
889 Returns most up-to-date value of selected property. This will return
890 value different from GetSelectedProperty()->GetValue() only when text
891 editor is activate and string edited by user represents valid,
892 uncommitted property value.
894 wxVariant
GetUncommittedPropertyValue();
896 /** Returns "root property". It does not have name, etc. and it is not
897 visible. It is only useful for accessing its children.
899 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
901 /** Returns height of a single grid row (in pixels). */
902 int GetRowHeight() const { return m_lineHeight
; }
904 /** Returns currently selected property. */
905 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
907 /** Returns current selection background colour. */
908 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
910 /** Returns current selection text colour. */
911 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
913 /** Returns current splitter x position. */
914 int GetSplitterPosition() const
915 { return m_pState
->DoGetSplitterPosition(0); }
917 /** Returns wxTextCtrl active in currently selected property, if any. Takes
918 into account wxOwnerDrawnComboBox.
920 wxTextCtrl
* GetEditorTextCtrl() const;
922 wxPGValidationInfo
& GetValidationInfo()
924 return m_validationInfo
;
927 /** Returns current vertical spacing. */
928 int GetVerticalSpacing() const { return (int)m_vspacing
; }
931 Returns @true if a property editor control has focus.
933 bool IsEditorFocused() const;
935 /** Returns true if editor's value was marked modified.
937 bool IsEditorsValueModified() const
938 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
941 Returns information about arbitrary position in the grid.
944 Coordinates in the virtual grid space. You may need to use
945 wxScrolledWindow::CalcScrolledPosition() for translating
946 wxPropertyGrid client coordinates into something this member
949 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
951 /** Returns true if any property has been modified by the user. */
952 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
955 Returns true if updating is frozen (ie Freeze() called but not yet
958 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
961 It is recommended that you call this function any time your code causes
962 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
963 handler should be able to detect most changes, but it is not perfect.
966 New top-level parent that is about to be set. Old top-level parent
967 window should still exist as the current one.
969 @remarks This function is automatically called from wxPropertyGrid::
970 Reparent() and wxPropertyGridManager::Reparent(). You only
971 need to use it if you reparent wxPropertyGrid indirectly.
973 void OnTLPChanging( wxWindow
* newTLP
);
975 /** Redraws given property.
977 virtual void RefreshProperty( wxPGProperty
* p
);
980 /** Registers a new editor class.
982 Pointer to the editor class instance that should be used.
984 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
985 bool noDefCheck
= false )
987 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
990 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
991 const wxString
& editorName
,
992 bool noDefCheck
= false );
995 /** Resets all colours to the original system values.
1001 Editor widget is automatically created, but not focused unless focus is
1008 True if selection finished successfully. Usually only fails if
1009 current value in editor is not valid.
1011 @remarks In wxPropertyGrid 1.4, this member function used to generate
1012 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
1015 @remarks This clears any previous selection.
1017 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
1020 Set entire new selection from given list of properties.
1022 void SetSelection( const wxArrayPGProperty
& newSelection
)
1024 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
1028 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
1029 extra style is not used, then this has same effect as
1030 calling SelectProperty().
1032 @remarks Multiple selection is not supported for categories. This
1033 means that if you have properties selected, you cannot
1034 add category to selection, and also if you have category
1035 selected, you cannot add other properties to selection.
1036 This member function will fail silently in these cases,
1037 even returning true.
1039 bool AddToSelection( wxPGPropArg id
)
1041 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1042 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1046 Removes given property from selection. If property is not selected,
1047 an assertion failure will occur.
1049 bool RemoveFromSelection( wxPGPropArg id
)
1051 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1052 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1056 Makes given column editable by user.
1059 Using @false here will disable column from being editable.
1061 void MakeColumnEditable( unsigned int column
, bool editable
= true );
1064 Creates label editor wxTextCtrl for given column, for property
1065 that is currently selected. When multiple selection is
1066 enabled, this applies to whatever property GetSelection()
1070 Which column's label to edit. Note that you should not
1071 use value 1, which is reserved for property value
1074 @see EndLabelEdit(), MakeColumnEditable()
1076 void BeginLabelEdit( unsigned int column
= 0 )
1078 DoBeginLabelEdit(column
, wxPG_SEL_DONT_SEND_EVENT
);
1082 Destroys label editor wxTextCtrl, if any.
1085 Use @true (default) to store edited label text in
1088 @see BeginLabelEdit(), MakeColumnEditable()
1090 void EndLabelEdit( bool commit
= true )
1092 DoEndLabelEdit(commit
, wxPG_SEL_DONT_SEND_EVENT
);
1096 Returns currently active label editor, NULL if none.
1098 wxTextCtrl
* GetLabelEditor() const
1100 return m_labelEditor
;
1103 /** Sets category caption background colour. */
1104 void SetCaptionBackgroundColour(const wxColour
& col
);
1106 /** Sets category caption text colour. */
1107 void SetCaptionTextColour(const wxColour
& col
);
1109 /** Sets default cell background colour - applies to property cells.
1110 Note that appearance of editor widgets may not be affected.
1112 void SetCellBackgroundColour(const wxColour
& col
);
1114 /** Sets cell text colour for disabled properties.
1116 void SetCellDisabledTextColour(const wxColour
& col
);
1118 /** Sets default cell text colour - applies to property name and value text.
1119 Note that appearance of editor widgets may not be affected.
1121 void SetCellTextColour(const wxColour
& col
);
1123 /** Set number of columns (2 or more).
1125 void SetColumnCount( int colCount
)
1127 m_pState
->SetColumnCount(colCount
);
1132 Sets the 'current' category - Append will add non-category properties
1135 void SetCurrentCategory( wxPGPropArg id
)
1137 wxPG_PROP_ARG_CALL_PROLOG()
1138 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1140 m_pState
->m_currentCategory
= pc
;
1143 /** Sets colour of empty space below properties. */
1144 void SetEmptySpaceColour(const wxColour
& col
);
1146 /** Sets colour of lines between cells. */
1147 void SetLineColour(const wxColour
& col
);
1149 /** Sets background colour of margin. */
1150 void SetMarginColour(const wxColour
& col
);
1153 Sets selection background colour - applies to selected property name
1156 void SetSelectionBackgroundColour(const wxColour
& col
);
1159 Sets selection foreground colour - applies to selected property name
1162 void SetSelectionTextColour(const wxColour
& col
);
1164 /** Sets x coordinate of the splitter.
1166 Splitter position cannot exceed grid size, and therefore setting it
1167 during form creation may fail as initial grid size is often smaller
1168 than desired splitter position, especially when sizers are being used.
1170 void SetSplitterPosition( int newxpos
, int col
= 0 )
1172 DoSetSplitterPosition_(newxpos
, true, col
);
1173 m_pState
->m_isSplitterPreSet
= true;
1177 Sets the property sorting function.
1180 The sorting function to be used. It should return a value greater
1181 than 0 if position of p1 is after p2. So, for instance, when
1182 comparing property names, you can use following implementation:
1185 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1189 return p1->GetBaseName().compare( p2->GetBaseName() );
1194 Default property sort function sorts properties by their labels
1195 (case-insensitively).
1197 @see GetSortFunction, wxPropertyGridInterface::Sort,
1198 wxPropertyGridInterface::SortChildren
1200 void SetSortFunction( wxPGSortCallback sortFunction
)
1202 m_sortFunction
= sortFunction
;
1206 Returns the property sort function (default is @NULL).
1208 @see SetSortFunction
1210 wxPGSortCallback
GetSortFunction() const
1212 return m_sortFunction
;
1215 /** Set virtual width for this particular page. Width -1 indicates that the
1216 virtual width should be disabled. */
1217 void SetVirtualWidth( int width
);
1220 Moves splitter as left as possible, while still allowing all
1221 labels to be shown in full.
1223 @param privateChildrenToo
1224 If @false, will still allow private children to be cropped.
1226 void SetSplitterLeft( bool privateChildrenToo
= false )
1228 m_pState
->SetSplitterLeft(privateChildrenToo
);
1231 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1232 height. Value of 2 should be default on most platforms.
1234 void SetVerticalSpacing( int vspacing
)
1236 m_vspacing
= (unsigned char)vspacing
;
1237 CalculateFontAndBitmapStuff( vspacing
);
1238 if ( !m_pState
->m_itemsAdded
) Refresh();
1241 /** Shows an brief error message that is related to a property. */
1242 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1244 wxPG_PROP_ARG_CALL_PROLOG()
1245 DoShowPropertyError(p
, msg
);
1248 /////////////////////////////////////////////////////////////////
1250 // Following methods do not need to be (currently) documented
1252 /////////////////////////////////////////////////////////////////
1254 bool HasVirtualWidth() const
1255 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1257 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1259 return (wxPGCommonValue
*) m_commonValues
[i
];
1262 /** Returns number of common values.
1264 unsigned int GetCommonValueCount() const
1266 return (unsigned int) m_commonValues
.size();
1269 /** Returns label of given common value.
1271 wxString
GetCommonValueLabel( unsigned int i
) const
1273 wxASSERT( GetCommonValue(i
) );
1274 return GetCommonValue(i
)->GetLabel();
1278 Returns index of common value that will truly change value to
1281 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1283 /** Set index of common value that will truly change value to unspecified.
1284 Using -1 will set none to have such effect.
1287 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1290 Shortcut for creating dialog-caller button. Used, for example, by
1293 This should only be called by properties.
1295 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1297 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1298 fits as one). Call after control has been created (but before
1301 void FixPosForTextCtrl( wxWindow
* ctrl
,
1302 unsigned int forColumn
= 1,
1303 const wxPoint
& offset
= wxPoint(0, 0) );
1305 /** Shortcut for creating text editor widget.
1307 Same as pos given for CreateEditor.
1309 Same as sz given for CreateEditor.
1311 Initial text for wxTextCtrl.
1313 If right-side control, such as button, also created, then create it
1314 first and pass it as this parameter.
1316 Extra style flags to pass for wxTextCtrl.
1318 Note that this should generally be called only by new classes derived
1321 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1323 const wxString
& value
,
1324 wxWindow
* secondary
,
1327 unsigned int forColumn
= 1 );
1329 /* Generates both textctrl and button.
1331 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1332 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1333 wxPGProperty
* property
);
1335 /** Generates position for a widget editor dialog box.
1337 Property for which dialog is positioned.
1339 Known or over-approximated size of the dialog.
1341 Position for dialog.
1343 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1346 // Converts escape sequences in src_str to newlines,
1347 // tabs, etc. and copies result to dst_str.
1348 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1349 wxString
& src_str
);
1351 // Converts newlines, tabs, etc. in src_str to escape
1352 // sequences, and copies result to dst_str.
1353 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1354 wxString
& src_str
);
1357 Returns rectangle that fully contains properties between and including
1360 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1361 const wxPGProperty
* p2
) const;
1363 /** Returns pointer to current active primary editor control (NULL if none).
1365 wxWindow
* GetEditorControl() const;
1367 wxWindow
* GetPrimaryEditor() const
1369 return GetEditorControl();
1373 Returns pointer to current active secondary editor control (NULL if
1376 wxWindow
* GetEditorControlSecondary() const
1378 return m_wndEditor2
;
1382 Refreshes any active editor control.
1384 void RefreshEditor();
1386 // Events from editor controls are forward to this function
1387 void HandleCustomEditorEvent( wxEvent
&event
);
1392 Generates contents for string dst based on the contents of
1395 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1396 so on. Set flags to 1 inorder to convert backslashes to double-back-
1397 slashes and "(preDelims)"'s to "(preDelims)".
1399 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1400 wxChar preDelim
, wxChar postDelim
,
1403 // Mostly useful for page switching.
1404 void SwitchState( wxPropertyGridPageState
* pNewState
);
1406 long GetInternalFlags() const { return m_iFlags
; }
1407 bool HasInternalFlag( long flag
) const
1408 { return (m_iFlags
& flag
) ? true : false; }
1409 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1410 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1411 void IncFrozen() { m_frozen
++; }
1412 void DecFrozen() { m_frozen
--; }
1414 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1420 /** Standardized double-to-string conversion.
1422 static void DoubleToString( wxString
& target
,
1426 wxString
* precTemplate
);
1429 Call this from wxPGProperty::OnEvent() to cause property value to be
1430 changed after the function returns (with true as return value).
1431 ValueChangeInEvent() must be used if you wish the application to be
1432 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1434 void ValueChangeInEvent( wxVariant variant
)
1436 m_changeInEventValue
= variant
;
1437 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1441 You can use this member function, for instance, to detect in
1442 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1443 already called in wxPGEditor::OnEvent(). It really only detects
1444 if was value was changed using wxPGProperty::SetValueInEvent(), which
1445 is usually used when a 'picker' dialog is displayed. If value was
1446 written by "normal means" in wxPGProperty::StringToValue() or
1447 IntToValue(), then this function will return false (on the other hand,
1448 wxPGProperty::OnEvent() is not even called in those cases).
1450 bool WasValueChangedInEvent() const
1452 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1455 /** Returns true if given event is from first of an array of buttons
1456 (as can be in case when wxPGMultiButton is used).
1458 bool IsMainButtonEvent( const wxEvent
& event
)
1460 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1461 && (m_wndSecId
== event
.GetId());
1464 /** Pending value is expected to be passed in PerformValidation().
1466 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1467 unsigned int selFlags
= 0 );
1469 /** Called when validation for given property fails.
1471 Value which failed in validation.
1473 Return true if user is allowed to change to another property even
1474 if current has invalid value.
1476 To add your own validation failure behavior, override
1477 wxPropertyGrid::DoOnValidationFailure().
1479 bool OnValidationFailure( wxPGProperty
* property
,
1480 wxVariant
& invalidValue
);
1482 /** Called to indicate property and editor has valid value now.
1484 void OnValidationFailureReset( wxPGProperty
* property
)
1486 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1488 DoOnValidationFailureReset(property
);
1489 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1491 m_validationInfo
.m_failureMessage
.clear();
1494 /** Override in derived class to display error messages in custom manner
1495 (these message usually only result from validation failure).
1497 virtual void DoShowPropertyError( wxPGProperty
* property
,
1498 const wxString
& msg
);
1500 /** Override to customize property validation failure behavior.
1502 Value which failed in validation.
1504 Return true if user is allowed to change to another property even
1505 if current has invalid value.
1507 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1508 wxVariant
& invalidValue
);
1510 /** Override to customize resetting of property validation failure status.
1512 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1514 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1516 int GetSpacingY() const { return m_spacingy
; }
1519 Must be called in wxPGEditor::CreateControls() if primary editor window
1520 is wxTextCtrl, just before textctrl is created.
1522 Initial text value of created wxTextCtrl.
1524 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1527 Unfocuses or closes editor if one was open, but does not deselect
1530 bool UnfocusEditor();
1532 virtual void SetWindowStyleFlag( long style
);
1534 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1536 void DrawItem( wxPGProperty
* p
)
1541 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1544 Draws item, children, and consequtive parents as long as category is
1547 void DrawItemAndValueRelated( wxPGProperty
* p
);
1552 wxPropertyGridPageState used by the grid is created here.
1554 If grid is used in wxPropertyGridManager, there is no point overriding
1555 this - instead, set custom wxPropertyGridPage classes.
1557 virtual wxPropertyGridPageState
* CreateState() const;
1559 enum PerformValidationFlags
1561 SendEvtChanging
= 0x0001,
1562 IsStandaloneValidation
= 0x0002 // Not called in response to event
1566 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1567 Returns true if all tests passed. Implement in derived class to
1568 add additional validation behavior.
1570 virtual bool PerformValidation( wxPGProperty
* p
,
1571 wxVariant
& pendingValue
,
1572 int flags
= SendEvtChanging
);
1576 // Control font changer helper.
1577 void SetCurControlBoldFont();
1579 wxPGCell
& GetPropertyDefaultCell()
1581 return m_propertyDefaultCell
;
1584 wxPGCell
& GetCategoryDefaultCell()
1586 return m_categoryDefaultCell
;
1590 // Public methods for semi-public use
1592 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1594 // Overridden functions.
1595 virtual bool Destroy();
1596 // Returns property at given y coordinate (relative to grid's top left).
1597 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1599 virtual void Refresh( bool eraseBackground
= true,
1600 const wxRect
*rect
= (const wxRect
*) NULL
);
1601 virtual bool SetFont( const wxFont
& font
);
1602 #if wxPG_SUPPORT_TOOLTIPS
1603 void SetToolTip( const wxString
& tipString
);
1605 virtual void Freeze();
1606 virtual void SetExtraStyle( long exStyle
);
1607 virtual void Thaw();
1608 virtual bool Reparent( wxWindowBase
*newParent
);
1611 virtual wxSize
DoGetBestSize() const;
1613 #ifndef wxPG_ICON_WIDTH
1614 wxBitmap
*m_expandbmp
, *m_collbmp
;
1617 wxCursor
*m_cursorSizeWE
;
1619 /** wxWindow pointers to editor control(s). */
1620 wxWindow
*m_wndEditor
;
1621 wxWindow
*m_wndEditor2
;
1623 #if wxPG_DOUBLE_BUFFER
1624 wxBitmap
*m_doubleBuffer
;
1627 /** Local time ms when control was created. */
1628 wxLongLong m_timeCreated
;
1630 /** wxPGProperty::OnEvent can change value by setting this. */
1631 wxVariant m_changeInEventValue
;
1633 /** Id of m_wndEditor2, or its first child, if any. */
1636 /** Extra Y spacing between the items. */
1639 /** Control client area width; updated on resize. */
1642 /** Control client area height; updated on resize. */
1645 /** Current non-client width (needed when auto-centering). */
1648 /** Non-client width (auto-centering helper). */
1651 /** Previously recorded scroll start position. */
1655 The gutter spacing in front and back of the image.
1656 This determines the amount of spacing in front of each item
1660 /** Includes separator line. */
1663 /** Gutter*2 + image width. */
1666 // y spacing for expand/collapse button.
1667 int m_buttonSpacingY
;
1669 /** Extra margin for expanded sub-group items. */
1670 int m_subgroup_extramargin
;
1673 The image width of the [+] icon.
1675 This is also calculated in the gutter
1679 #ifndef wxPG_ICON_WIDTH
1682 The image height of the [+] icon.
1684 This is calculated as minimal size and to align
1689 /** Current cursor id. */
1693 This captionFont is made equal to the font of the wxScrolledWindow.
1695 As extra the bold face is set on it when this is wanted by the user
1698 wxFont m_captionFont
;
1700 int m_fontHeight
; // Height of the font.
1702 /** m_splitterx when drag began. */
1703 int m_startingSplitterX
;
1706 Index to splitter currently being dragged (0=one after the first
1709 int m_draggedSplitter
;
1711 /** Changed property, calculated in PerformValidation(). */
1712 wxPGProperty
* m_chgInfo_changedProperty
;
1715 Lowest property for which editing happened, but which does not have
1718 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1720 /** Changed property value, calculated in PerformValidation(). */
1721 wxVariant m_chgInfo_pendingValue
;
1723 /** Passed to SetValue. */
1724 wxVariant m_chgInfo_valueList
;
1726 /** Validation information. */
1727 wxPGValidationInfo m_validationInfo
;
1729 /** Actions and keys that trigger them. */
1730 wxPGHashMapI2I m_actionTriggers
;
1736 /** Bits are used to indicate which colours are customized. */
1737 unsigned short m_coloursCustomized
;
1739 /** x - m_splitterx. */
1740 signed char m_dragOffset
;
1742 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1743 unsigned char m_dragStatus
;
1745 /** 0 = margin, 1 = label, 2 = value. */
1746 unsigned char m_mouseSide
;
1748 /** True when editor control is focused. */
1749 unsigned char m_editorFocused
;
1751 /** 1 if m_latsCaption is also the bottommost caption. */
1752 //unsigned char m_lastCaptionBottomnest;
1754 /** Set to 1 when graphics frozen. */
1755 unsigned char m_frozen
;
1757 unsigned char m_vspacing
;
1759 // Used to track when Alt/Ctrl+Key was consumed.
1760 unsigned char m_keyComboConsumed
;
1762 /** 1 if in DoPropertyChanged() */
1763 unsigned char m_inDoPropertyChanged
;
1765 /** 1 if in CommitChangesFromEditor() */
1766 unsigned char m_inCommitChangesFromEditor
;
1768 /** 1 if in DoSelectProperty() */
1769 unsigned char m_inDoSelectProperty
;
1771 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1773 /** Internal flags - see wxPG_FL_XXX constants. */
1776 /** When drawing next time, clear this many item slots at the end. */
1777 int m_clearThisMany
;
1779 // Mouse is hovering over this column (index)
1780 unsigned int m_colHover
;
1782 // pointer to property that has mouse hovering
1783 wxPGProperty
* m_propHover
;
1785 // Active label editor
1786 wxTextCtrl
* m_labelEditor
;
1788 // For which property the label editor is active
1789 wxPGProperty
* m_labelEditorProperty
;
1791 // EventObject for wxPropertyGridEvents
1792 wxWindow
* m_eventObject
;
1794 // What (global) window is currently focused (needed to resolve event
1796 wxWindow
* m_curFocused
;
1798 // Event currently being sent - NULL if none at the moment
1799 wxPropertyGridEvent
* m_processedEvent
;
1801 // Last known top-level parent
1804 // Last closed top-level parent
1805 wxWindow
* m_tlpClosed
;
1807 // Local time ms when tlp was closed.
1808 wxLongLong m_tlpClosedTime
;
1811 wxPGSortCallback m_sortFunction
;
1813 // y coordinate of property that mouse hovering
1816 // Which column's editor is selected (usually 1)?
1817 unsigned int m_selColumn
;
1819 // x relative to splitter (needed for resize).
1822 // lines between cells
1824 // property labels and values are written in this colour
1825 wxColour m_colPropFore
;
1826 // or with this colour when disabled
1827 wxColour m_colDisPropFore
;
1828 // background for m_colPropFore
1829 wxColour m_colPropBack
;
1830 // text color for captions
1831 wxColour m_colCapFore
;
1832 // background color for captions
1833 wxColour m_colCapBack
;
1834 // foreground for selected property
1835 wxColour m_colSelFore
;
1836 // background for selected property (actually use background color when
1837 // control out-of-focus)
1838 wxColour m_colSelBack
;
1839 // background colour for margin
1840 wxColour m_colMargin
;
1841 // background colour for empty space below the grid
1842 wxColour m_colEmptySpace
;
1844 // Default property colours
1845 wxPGCell m_propertyDefaultCell
;
1847 // Default property category
1848 wxPGCell m_categoryDefaultCell
;
1850 // Backup of selected property's cells
1851 wxVector
<wxPGCell
> m_propCellsBackup
;
1853 // NB: These *cannot* be moved to globals.
1855 // labels when properties use common values
1856 wxVector
<wxPGCommonValue
*> m_commonValues
;
1858 // array of live events
1859 wxVector
<wxPropertyGridEvent
*> m_liveEvents
;
1861 // Which cv selection really sets value to unspecified?
1862 int m_cvUnspecified
;
1864 // Used to skip excess text editor events
1865 wxString m_prevTcValue
;
1869 // Sets some members to defaults (called constructors).
1872 // Initializes some members (called by Create and complex constructor).
1875 void OnPaint(wxPaintEvent
&event
);
1877 // main event receivers
1878 void OnMouseMove( wxMouseEvent
&event
);
1879 void OnMouseClick( wxMouseEvent
&event
);
1880 void OnMouseRightClick( wxMouseEvent
&event
);
1881 void OnMouseDoubleClick( wxMouseEvent
&event
);
1882 void OnMouseUp( wxMouseEvent
&event
);
1883 void OnKey( wxKeyEvent
&event
);
1884 void OnResize( wxSizeEvent
&event
);
1887 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
1888 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1889 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1890 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1891 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
1892 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
1894 void OnMouseEntry( wxMouseEvent
&event
);
1896 void OnIdle( wxIdleEvent
&event
);
1897 void OnFocusEvent( wxFocusEvent
&event
);
1898 void OnChildFocusEvent( wxChildFocusEvent
& event
);
1900 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
1901 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
1903 // sub-control event handlers
1904 void OnMouseClickChild( wxMouseEvent
&event
);
1905 void OnMouseRightClickChild( wxMouseEvent
&event
);
1906 void OnMouseMoveChild( wxMouseEvent
&event
);
1907 void OnMouseUpChild( wxMouseEvent
&event
);
1908 void OnChildKeyDown( wxKeyEvent
&event
);
1910 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
1912 void OnScrollEvent( wxScrollWinEvent
&event
);
1914 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
1916 void OnTLPClose( wxCloseEvent
& event
);
1920 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
1921 unsigned int colIndex
,
1922 wxMouseEvent
* event
= NULL
,
1926 Adjust the centering of the bitmap icons (collapse / expand) when the
1927 caption font changes.
1929 They need to be centered in the middle of the font, so a bit of deltaY
1930 adjustment is needed. On entry, m_captionFont must be set to window
1931 font. It will be modified properly.
1933 void CalculateFontAndBitmapStuff( int vspacing
);
1935 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
1937 void CorrectEditorWidgetSizeX();
1939 /** Called in RecalculateVirtualSize() to reposition control
1940 on virtual height changes.
1942 void CorrectEditorWidgetPosY();
1944 int DoDrawItems( wxDC
& dc
,
1945 const wxRect
* drawRect
,
1946 bool isBuffered
) const;
1948 /** Draws an expand/collapse (ie. +/-) button.
1950 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1951 wxPGProperty
* property
) const;
1953 /** Draws items from topitemy to bottomitemy */
1954 void DrawItems( wxDC
& dc
,
1955 unsigned int topItemY
,
1956 unsigned int bottomItemY
,
1957 const wxRect
* drawRect
= NULL
);
1959 // Translate wxKeyEvent to wxPG_ACTION_XXX
1960 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
1962 int KeyEventToAction(wxKeyEvent
&event
) const
1964 return KeyEventToActions(event
, NULL
);
1967 void ImprovedClientToScreen( int* px
, int* py
);
1969 // Called by focus event handlers. newFocused is the window that becomes
1971 void HandleFocusChange( wxWindow
* newFocused
);
1973 /** Reloads all non-customized colours from system settings. */
1974 void RegainColours();
1976 bool DoEditorValidate();
1978 // Similar to DoSelectProperty() but also works on columns
1979 // other than 1. Does not active editor if column is not
1981 bool DoSelectAndEdit( wxPGProperty
* prop
,
1982 unsigned int colIndex
,
1983 unsigned int selFlags
);
1985 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
1988 bool DoAddToSelection( wxPGProperty
* prop
,
1991 bool DoRemoveFromSelection( wxPGProperty
* prop
,
1994 void DoBeginLabelEdit( unsigned int colIndex
, int selFlags
= 0 );
1995 void DoEndLabelEdit( bool commit
, int selFlags
= 0 );
1996 void OnLabelEditorEnterPress( wxCommandEvent
& event
);
1997 void OnLabelEditorKeyPress( wxKeyEvent
& event
);
1999 wxPGProperty
* DoGetItemAtY( int y
) const;
2001 void DoSetSplitterPosition_( int newxpos
,
2002 bool refresh
= true,
2003 int splitterIndex
= 0,
2004 bool allPages
= false );
2006 void DestroyEditorWnd( wxWindow
* wnd
);
2009 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
2011 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
2013 // Returns nearest paint visible property (such that will be painted unless
2014 // window is scrolled or resized). If given property is paint visible, then
2015 // it itself will be returned.
2016 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
2018 static void RegisterDefaultEditors();
2020 // Sets up basic event handling for child control
2021 void SetupChildEventHandling( wxWindow
* wnd
);
2023 void CustomSetCursor( int type
, bool override
= false );
2026 Repositions scrollbar and underlying panel according to changed virtual
2029 void RecalculateVirtualSize( int forceXPos
= -1 );
2031 void PrepareAfterItemsAdded();
2033 // Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
2034 bool SendEvent( int eventType
, wxPGProperty
* p
,
2035 wxVariant
* pValue
= NULL
,
2036 unsigned int selFlags
= wxPG_SEL_NOVALIDATE
,
2037 unsigned int column
= 1 );
2039 void SetFocusOnCanvas();
2041 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
2045 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
2047 DECLARE_EVENT_TABLE()
2048 #endif // #ifndef SWIG
2051 // -----------------------------------------------------------------------
2053 // Bunch of inlines that need to resolved after all classes have been defined.
2057 inline bool wxPropertyGridPageState::IsDisplayed() const
2059 return ( this == m_pPropGrid
->GetState() );
2062 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
2064 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
2068 inline int wxPGProperty::GetDisplayedCommonValueCount() const
2070 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
2072 wxPropertyGrid
* pg
= GetGrid();
2074 return (int) pg
->GetCommonValueCount();
2079 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
2081 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
2084 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
2086 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
2089 inline bool wxPGProperty::Hide( bool hide
, int flags
)
2091 return GetGrid()->HideProperty(this, hide
, flags
);
2094 inline bool wxPGProperty::SetMaxLength( int maxLen
)
2096 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
2099 // -----------------------------------------------------------------------
2101 #define wxPG_BASE_EVT_PRE_ID 1775
2105 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
2106 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
2107 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
2108 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
2109 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
2110 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
2111 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
2112 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
2113 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
2114 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2115 wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
2116 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2117 wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
2121 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
2124 wxEVT_PG_HIGHLIGHTED
,
2125 wxEVT_PG_RIGHT_CLICK
,
2126 wxEVT_PG_PAGE_CHANGED
,
2127 wxEVT_PG_ITEM_COLLAPSED
,
2128 wxEVT_PG_ITEM_EXPANDED
,
2129 wxEVT_PG_DOUBLE_CLICK
,
2130 wxEVT_PG_LABEL_EDIT_BEGIN
,
2131 wxEVT_PG_LABEL_EDIT_ENDING
2136 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2137 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2141 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2143 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2144 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2145 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2146 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2147 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2148 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2149 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2150 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2151 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2152 #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 ),
2153 #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 ),
2155 #define wxPropertyGridEventHandler(fn) \
2156 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2161 /** @class wxPropertyGridEvent
2163 A propertygrid event holds information about events associated with
2164 wxPropertyGrid objects.
2166 @library{wxpropgrid}
2169 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2174 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2176 /** Copy constructor. */
2177 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2180 ~wxPropertyGridEvent();
2183 virtual wxEvent
* Clone() const;
2186 Returns the column index associated with this event.
2188 unsigned int GetColumn() const
2193 wxPGProperty
* GetMainParent() const
2195 wxASSERT(m_property
);
2196 return m_property
->GetMainParent();
2199 /** Returns id of associated property. */
2200 wxPGProperty
* GetProperty() const
2205 wxPGValidationInfo
& GetValidationInfo()
2207 wxASSERT(m_validationInfo
);
2208 return *m_validationInfo
;
2211 /** Returns true if you can veto the action that the event is signaling.
2213 bool CanVeto() const { return m_canVeto
; }
2216 Call this from your event handler to veto action that the event is
2219 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2222 Currently only wxEVT_PG_CHANGING supports vetoing.
2224 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2227 Returns name of the associated property.
2229 @remarks Property name is stored in event, so it remains
2230 accessible even after the associated property or
2231 the property grid has been deleted.
2233 wxString
GetPropertyName() const
2235 return m_propertyName
;
2239 Returns value of the associated property. Works for all event
2240 types, but for wxEVT_PG_CHANGING this member function returns
2241 the value that is pending, so you can call Veto() if the
2242 value is not satisfactory.
2244 @remarks Property value is stored in event, so it remains
2245 accessible even after the associated property or
2246 the property grid has been deleted.
2248 wxVariant
GetPropertyValue() const
2250 if ( m_validationInfo
)
2251 return m_validationInfo
->GetValue();
2256 Returns value of the associated property.
2258 @see GetPropertyValue
2260 wxVariant
GetValue() const
2262 return GetPropertyValue();
2266 Set override validation failure behavior.
2268 Only effective if Veto was also called, and only allowed if event type
2269 is wxEVT_PG_CHANGING.
2271 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2273 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2274 m_validationInfo
->SetFailureBehavior( flags
);
2277 /** Sets custom failure message for this time only. Only applies if
2278 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2280 void SetValidationFailureMessage( const wxString
& message
)
2282 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2283 m_validationInfo
->SetFailureMessage( message
);
2287 wxPGVFBFlags
GetValidationFailureBehavior() const
2289 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2290 return m_validationInfo
->GetFailureBehavior();
2293 void SetColumn( unsigned int column
)
2298 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2299 bool WasVetoed() const { return m_wasVetoed
; }
2301 /** Changes the associated property. */
2302 void SetProperty( wxPGProperty
* p
)
2306 m_propertyName
= p
->GetName();
2309 void SetPropertyValue( wxVariant value
)
2314 void SetPropertyGrid( wxPropertyGrid
* pg
)
2317 OnPropertyGridSet();
2320 void SetupValidationInfo()
2323 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2324 m_validationInfo
= &m_pg
->GetValidationInfo();
2325 m_value
= m_validationInfo
->GetValue();
2330 void OnPropertyGridSet();
2331 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2333 wxPGProperty
* m_property
;
2334 wxPropertyGrid
* m_pg
;
2335 wxPGValidationInfo
* m_validationInfo
;
2337 wxString m_propertyName
;
2340 unsigned int m_column
;
2349 // -----------------------------------------------------------------------
2351 /** @class wxPropertyGridPopulator
2353 Allows populating wxPropertyGrid from arbitrary text source.
2355 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2358 /** Default constructor.
2360 wxPropertyGridPopulator();
2363 virtual ~wxPropertyGridPopulator();
2365 void SetState( wxPropertyGridPageState
* state
);
2367 void SetGrid( wxPropertyGrid
* pg
);
2369 /** Appends a new property under bottommost parent.
2371 Property class as string.
2373 wxPGProperty
* Add( const wxString
& propClass
,
2374 const wxString
& propLabel
,
2375 const wxString
& propName
,
2376 const wxString
* propValue
,
2377 wxPGChoices
* pChoices
= NULL
);
2380 Pushes property to the back of parent array (ie it becomes bottommost
2381 parent), and starts scanning/adding children for it.
2383 When finished, parent array is returned to the original state.
2385 void AddChildren( wxPGProperty
* property
);
2387 /** Adds attribute to the bottommost property.
2389 Allowed values: "string", (same as string), "int", "bool". Empty string
2392 bool AddAttribute( const wxString
& name
,
2393 const wxString
& type
,
2394 const wxString
& value
);
2396 /** Called once in AddChildren.
2398 virtual void DoScanForChildren() = 0;
2401 Returns id of parent property for which children can currently be
2404 wxPGProperty
* GetCurParent() const
2406 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2409 wxPropertyGridPageState
* GetState() { return m_state
; }
2410 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2412 /** Like wxString::ToLong, except allows N% in addition of N.
2414 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2416 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2417 wxPGChoices. Registers parsed result using idString (if not empty).
2418 Also, if choices with given id already registered, then don't parse but
2419 return those choices instead.
2421 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2422 const wxString
& idString
);
2424 /** Implement in derived class to do custom process when an error occurs.
2425 Default implementation uses wxLogError.
2427 virtual void ProcessError( const wxString
& msg
);
2431 /** Used property grid. */
2432 wxPropertyGrid
* m_pg
;
2434 /** Used property grid state. */
2435 wxPropertyGridPageState
* m_state
;
2437 /** Tree-hierarchy of added properties (that can have children). */
2438 wxArrayPGProperty m_propHierarchy
;
2440 /** Hashmap for string-id to wxPGChoicesData mapping. */
2441 wxPGHashMapS2P m_dictIdChoices
;
2444 // -----------------------------------------------------------------------
2447 // Undefine macros that are not needed outside propertygrid sources
2449 #ifndef __wxPG_SOURCE_FILE__
2450 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2451 #undef wxPG_FL_SCROLLBAR_DETECTED
2452 #undef wxPG_FL_CREATEDSTATE
2453 #undef wxPG_FL_NOSTATUSBARHELP
2454 #undef wxPG_FL_SCROLLED
2455 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2456 #undef wxPG_FL_FOCUS_INSIDE
2457 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2458 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2459 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2460 #undef wxPG_FL_VALUE_MODIFIED
2461 #undef wxPG_FL_MOUSE_INSIDE
2462 #undef wxPG_FL_FOCUSED
2463 #undef wxPG_FL_MOUSE_CAPTURED
2464 #undef wxPG_FL_INITIALIZED
2465 #undef wxPG_FL_ACTIVATION_BY_CLICK
2466 #undef wxPG_SUPPORT_TOOLTIPS
2467 #undef wxPG_DOUBLE_BUFFER
2468 #undef wxPG_ICON_WIDTH
2469 #undef wxPG_USE_RENDERER_NATIVE
2470 // Following are needed by the manager headers
2471 // #undef const wxString&
2474 // -----------------------------------------------------------------------
2478 #endif // _WX_PROPGRID_PROPGRID_H_