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"
22 #include "wx/recguard.h"
24 #include "wx/propgrid/property.h"
25 #include "wx/propgrid/propgridiface.h"
29 extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr
[];
34 // -----------------------------------------------------------------------
36 // -----------------------------------------------------------------------
38 // This is required for sharing common global variables.
39 class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
43 wxPGGlobalVarsClass();
44 ~wxPGGlobalVarsClass();
47 // Critical section for handling the globals. Generally it is not needed
48 // since GUI code is supposed to be in single thread. However,
49 // we do want the user to be able to convey wxPropertyGridEvents to other
51 wxCriticalSection m_critSect
;
54 // Used by advprops, but here to make things easier.
55 wxString m_pDefaultImageWildcard
;
57 // Map of editor class instances (keys are name string).
58 wxPGHashMapS2P m_mapEditorClasses
;
61 wxVector
<wxValidator
*> m_arrValidators
; // These wxValidators need to be freed
64 wxPGHashMapS2P m_dictPropertyClassInfo
; // PropertyName -> ClassInfo
66 wxPGChoices
* m_fontFamilyChoices
;
68 // Replace with your own to affect all properties using default renderer.
69 wxPGCellRenderer
* m_defaultRenderer
;
71 wxPGChoices m_boolChoices
;
73 wxVariant m_vEmptyString
;
75 wxVariant m_vMinusOne
;
79 // Cached constant strings
80 wxPGCachedString m_strstring
;
81 wxPGCachedString m_strlong
;
82 wxPGCachedString m_strbool
;
83 wxPGCachedString m_strlist
;
85 wxPGCachedString m_strDefaultValue
;
86 wxPGCachedString m_strMin
;
87 wxPGCachedString m_strMax
;
88 wxPGCachedString m_strUnits
;
89 wxPGCachedString m_strHint
;
90 #if wxPG_COMPATIBILITY_1_4
91 wxPGCachedString m_strInlineHelp
;
94 // If true then some things are automatically translated
95 bool m_autoGetTranslation
;
97 // > 0 if errors cannot or should not be shown in statusbar etc.
100 int m_extraStyle
; // global extra style
104 int HasExtraStyle( int style
) const { return (m_extraStyle
& style
); }
107 extern WXDLLIMPEXP_DATA_PROPGRID(wxPGGlobalVarsClass
*) wxPGGlobalVars
;
109 #define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
110 #define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
111 #define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
112 #define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
113 #define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
115 #define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
117 // When wxPG is loaded dynamically after the application is already running
118 // then the built-in module system won't pick this one up. Add it manually.
119 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 /** Using this style, the column splitters move automatically based on column
155 proportions (default is equal proportion for every column). This behavior
156 stops once the user manually moves a splitter, and returns when a
157 splitter is double-clicked.
159 @see wxPropertyGridInterface::SetColumnProportion().
161 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
163 /** Display tooltips for cell text that cannot be shown completely. If
164 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
166 wxPG_TOOLTIPS
= 0x00000100,
168 /** Disables margin and hides all expand/collapse buttons that would appear
169 outside the margin (for sub-properties). Toggling this style automatically
170 expands all collapsed items.
172 wxPG_HIDE_MARGIN
= 0x00000200,
174 /** This style prevents user from moving the splitter.
176 wxPG_STATIC_SPLITTER
= 0x00000400,
178 /** Combination of other styles that make it impossible for user to modify
181 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
183 /** Disables wxTextCtrl based editors for properties which
184 can be edited in another way.
186 Equals calling wxPropertyGrid::LimitPropertyEditing for all added
189 wxPG_LIMITED_EDITING
= 0x00000800,
191 /** wxPropertyGridManager only: Show toolbar for mode and page selection. */
192 wxPG_TOOLBAR
= 0x00001000,
194 /** wxPropertyGridManager only: Show adjustable text box showing description
195 or help text, if available, for currently selected property.
197 wxPG_DESCRIPTION
= 0x00002000,
199 /** wxPropertyGridManager only: don't show an internal border around the
200 property grid. Recommended if you use a header.
202 wxPG_NO_INTERNAL_BORDER
= 0x00004000
205 #if wxPG_COMPATIBILITY_1_4
206 // In wxPG 1.4 this was used to enable now-default theme border support
207 // in wxPropertyGridManager.
208 #define wxPG_THEME_BORDER 0x00000000
212 enum wxPG_EX_WINDOW_STYLES
216 NOTE: wxPG_EX_xxx are extra window styles and must be set using
217 SetExtraStyle() member function.
219 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
220 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
221 not activated, and switching the mode first time becomes somewhat slower.
222 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
223 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
224 you don't plan to use categories at all, then using this style will result
225 in waste of resources.
228 wxPG_EX_INIT_NOCAT
= 0x00001000,
230 /** Extended window style that sets wxPropertyGridManager toolbar to not
233 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
235 /** Shows alphabetic/categoric mode buttons from toolbar.
237 wxPG_EX_MODE_BUTTONS
= 0x00008000,
239 /** Show property help strings as tool tips instead as text on the status bar.
240 You can set the help strings using SetPropertyHelpString member function.
242 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
244 /** Prevent TAB from focusing to wxButtons. This behavior was default
245 in version 1.2.0 and earlier.
246 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
247 atleast the button doesn't properly propagate key events (yes, I'm using
250 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
252 /** Allows relying on native double-buffering.
254 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
256 /** Set this style to let user have ability to set values of properties to
257 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
260 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
263 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
264 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
265 (thus they are not readable).
267 Note that this option is global, and applies to all wxPG property
270 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
272 /** Hides page selection buttons from toolbar.
274 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
276 /** Allows multiple properties to be selected by user (by pressing SHIFT
277 when clicking on a property, or by dragging with left mouse button
280 You can get array of selected properties with
281 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
282 mode wxPropertyGridInterface::GetSelection() returns
283 property which has editor active (usually the first one
284 selected). Other useful member functions are ClearSelection(),
285 AddToSelection() and RemoveFromSelection().
287 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000,
290 This enables top-level window tracking which allows wxPropertyGrid to
291 notify the application of last-minute property value changes by user.
293 This style is not enabled by default because it may cause crashes when
294 wxPropertyGrid is used in with wxAUI or similar system.
296 @remarks If you are not in fact using any system that may change
297 wxPropertyGrid's top-level parent window on its own, then you
298 are recommended to enable this style.
300 wxPG_EX_ENABLE_TLP_TRACKING
= 0x04000000,
302 /** Don't show divider above toolbar, on Windows.
304 wxPG_EX_NO_TOOLBAR_DIVIDER
= 0x08000000,
306 /** Show a separator below the toolbar.
308 wxPG_EX_TOOLBAR_SEPARATOR
= 0x10000000
312 #if wxPG_COMPATIBILITY_1_4
313 #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000
316 /** Combines various styles.
318 #define wxPG_DEFAULT_STYLE (0)
320 /** Combines various styles.
322 #define wxPGMAN_DEFAULT_STYLE (0)
327 // -----------------------------------------------------------------------
330 // Ids for sub-controls
331 // NB: It should not matter what these are.
332 #define wxPG_SUBID1 2
333 #define wxPG_SUBID2 3
334 #define wxPG_SUBID_TEMP1 4
336 // -----------------------------------------------------------------------
338 /** @class wxPGCommonValue
340 wxPropertyGrid stores information about common values in these
343 NB: Common value feature is not complete, and thus not mentioned in
346 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
350 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
353 m_renderer
= renderer
;
356 virtual ~wxPGCommonValue()
358 m_renderer
->DecRef();
361 virtual wxString
GetEditableText() const { return m_label
; }
362 const wxString
& GetLabel() const { return m_label
; }
363 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
367 wxPGCellRenderer
* m_renderer
;
370 // -----------------------------------------------------------------------
372 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
376 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
379 /** Prevents user from leaving property unless value is valid. If this
380 behavior flag is not used, then value change is instead cancelled.
382 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
384 /** Calls wxBell() on validation failure.
386 wxPG_VFB_BEEP
= 0x02,
388 /** Cell with invalid value will be marked (with red colour).
390 wxPG_VFB_MARK_CELL
= 0x04,
392 /** Display customizable text message explaining the situation.
394 wxPG_VFB_SHOW_MESSAGE
= 0x08,
397 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
399 /** Only used internally. */
400 wxPG_VFB_UNDEFINED
= 0x80
407 // Having this as define instead of wxByte typedef makes things easier for
408 // wxPython bindings (ignoring and redefining it in SWIG interface file
409 // seemed rather tricky)
410 #define wxPGVFBFlags unsigned char
415 Used to convey validation information to and from functions that
416 actually perform validation. Mostly used in custom property
419 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
421 friend class wxPropertyGrid
;
424 @return Returns failure behavior which is a combination of
425 @ref propgrid_vfbflags.
427 wxPGVFBFlags
GetFailureBehavior() const
428 { return m_failureBehavior
; }
431 Returns current failure message.
433 const wxString
& GetFailureMessage() const
434 { return m_failureMessage
; }
437 Returns reference to pending value.
439 wxVariant
& GetValue()
445 /** Set validation failure behavior
447 @param failureBehavior
448 Mixture of @ref propgrid_vfbflags.
450 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
451 { m_failureBehavior
= failureBehavior
; }
454 Set current failure message.
456 void SetFailureMessage(const wxString
& message
)
457 { m_failureMessage
= message
; }
460 /** Value to be validated.
464 /** Message displayed on validation failure.
466 wxString m_failureMessage
;
468 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
470 wxPGVFBFlags m_failureBehavior
;
473 // -----------------------------------------------------------------------
475 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
477 These are used with wxPropertyGrid::AddActionTrigger() and
478 wxPropertyGrid::ClearActionTriggers().
482 enum wxPG_KEYBOARD_ACTIONS
484 wxPG_ACTION_INVALID
= 0,
485 wxPG_ACTION_NEXT_PROPERTY
,
486 wxPG_ACTION_PREV_PROPERTY
,
487 wxPG_ACTION_EXPAND_PROPERTY
,
488 wxPG_ACTION_COLLAPSE_PROPERTY
,
489 wxPG_ACTION_CANCEL_EDIT
,
490 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
497 // -----------------------------------------------------------------------
500 // wxPropertyGrid::DoSelectProperty flags (selFlags)
502 // Focuses to created editor
503 #define wxPG_SEL_FOCUS 0x0001
504 // Forces deletion and recreation of editor
505 #define wxPG_SEL_FORCE 0x0002
506 // For example, doesn't cause EnsureVisible
507 #define wxPG_SEL_NONVISIBLE 0x0004
508 // Do not validate editor's value before selecting
509 #define wxPG_SEL_NOVALIDATE 0x0008
510 // Property being deselected is about to be deleted
511 #define wxPG_SEL_DELETING 0x0010
512 // Property's values was set to unspecified by the user
513 #define wxPG_SEL_SETUNSPEC 0x0020
514 // Property's event handler changed the value
515 #define wxPG_SEL_DIALOGVAL 0x0040
516 // Set to disable sending of wxEVT_PG_SELECTED event
517 #define wxPG_SEL_DONT_SEND_EVENT 0x0080
518 // Don't make any graphics updates
519 #define wxPG_SEL_NO_REFRESH 0x0100
521 // -----------------------------------------------------------------------
523 // DoSetSplitterPosition() flags
525 enum wxPG_SET_SPLITTER_POSITION_SPLITTER_FLAGS
527 wxPG_SPLITTER_REFRESH
= 0x0001,
528 wxPG_SPLITTER_ALL_PAGES
= 0x0002,
529 wxPG_SPLITTER_FROM_EVENT
= 0x0004,
530 wxPG_SPLITTER_FROM_AUTO_CENTER
= 0x0008
534 // -----------------------------------------------------------------------
537 #define wxPG_FL_INITIALIZED 0x0001
538 // Set when creating editor controls if it was clicked on.
539 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
540 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
541 #define wxPG_FL_FOCUSED 0x0008
542 #define wxPG_FL_MOUSE_CAPTURED 0x0010
543 #define wxPG_FL_MOUSE_INSIDE 0x0020
544 #define wxPG_FL_VALUE_MODIFIED 0x0040
545 // don't clear background of m_wndEditor
546 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
547 // currently active editor uses custom image
548 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
549 // cell colours override selection colours for selected cell
550 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
551 #define wxPG_FL_SCROLLED 0x0400
552 // set when all added/inserted properties get hideable flag
553 #define wxPG_FL_ADDING_HIDEABLES 0x0800
554 // Disables showing help strings on statusbar.
555 #define wxPG_FL_NOSTATUSBARHELP 0x1000
556 // Marks that we created the state, so we have to destroy it too.
557 #define wxPG_FL_CREATEDSTATE 0x2000
558 // Set if scrollbar's existence was detected in last onresize.
559 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
560 // Set if wxPGMan requires redrawing of description text box.
561 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
562 // Set if contained in wxPropertyGridManager
563 #define wxPG_FL_IN_MANAGER 0x00020000
564 // Set after wxPropertyGrid is shown in its initial good size
565 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
566 // Set when in SelectProperty.
567 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
568 // Set when help string is shown in status bar
569 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
570 // Auto sort is enabled (for categorized mode)
571 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
572 // Set after page has been inserted to manager
573 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
574 // Active editor control is abnormally large
575 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
576 // Recursion guard for HandleCustomEditorEvent
577 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
578 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
579 // Editor control width should not change on resize
580 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
581 // Width of panel can be different than width of grid
582 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
583 // Prevents RecalculateVirtualSize re-entrancy
584 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
586 #if !defined(__wxPG_SOURCE_FILE__)
587 // Reduce compile time, but still include in user app
588 #include "wx/propgrid/props.h"
591 // -----------------------------------------------------------------------
593 /** @class wxPropertyGrid
595 wxPropertyGrid is a specialized grid for editing properties
596 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
597 used to do the very same thing, but it hasn't been updated for a while
598 and it is currently deprecated.
600 Please note that most member functions are inherited and as such not
601 documented on this page. This means you will probably also want to read
602 wxPropertyGridInterface class reference.
604 See also @ref overview_propgrid.
606 @section propgrid_window_styles_ Window Styles
608 See @ref propgrid_window_styles.
610 @section propgrid_event_handling Event Handling
612 To process input from a propertygrid control, use these event handler
613 macros to direct input to member functions that take a wxPropertyGridEvent
616 @beginEventTable{wxPropertyGridEvent}
617 @event{EVT_PG_SELECTED (id, func)}
618 Respond to wxEVT_PG_SELECTED event, generated when a property selection
619 has been changed, either by user action or by indirect program
620 function. For instance, collapsing a parent property programmatically
621 causes any selected child property to become unselected, and may
622 therefore cause this event to be generated.
623 @event{EVT_PG_CHANGING(id, func)}
624 Respond to wxEVT_PG_CHANGING event, generated when property value
625 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
626 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
627 to prevent change from taking place, if necessary.
628 @event{EVT_PG_HIGHLIGHTED(id, func)}
629 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
630 moves over a property. Event's property is NULL if hovered area does
631 not belong to any property.
632 @event{EVT_PG_RIGHT_CLICK(id, func)}
633 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
634 clicked on with right mouse button.
635 @event{EVT_PG_DOUBLE_CLICK(id, func)}
636 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
637 double-clicked onwith left mouse button.
638 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
639 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
640 a property or category..
641 @event{EVT_PG_ITEM_EXPANDED(id, func)}
642 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
643 a property or category..
644 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
645 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
646 begin editing a property label. You can veto this event to prevent the
648 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
649 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
650 end editing of a property label. You can veto this event to prevent the
652 @event{EVT_PG_COL_BEGIN_DRAG(id, func)}
653 Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user
654 starts resizing a column - can be vetoed.
655 @event{EVT_PG_COL_DRAGGING,(id, func)}
656 Respond to wxEVT_PG_COL_DRAGGING, event, generated when a
657 column resize by user is in progress. This event is also generated
658 when user double-clicks the splitter in order to recenter
660 @event{EVT_PG_COL_END_DRAG(id, func)}
661 Respond to wxEVT_PG_COL_END_DRAG event, generated after column
662 resize by user has finished.
667 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
668 will also delay sorting etc. miscellaneous calculations to the last
674 class WXDLLIMPEXP_PROPGRID
675 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
677 friend class wxPropertyGridEvent
;
678 friend class wxPropertyGridPageState
;
679 friend class wxPropertyGridInterface
;
680 friend class wxPropertyGridManager
;
681 friend class wxPGHeaderCtrl
;
683 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
688 Two step constructor.
690 Call Create when this constructor is called to build up the
696 /** The default constructor. The styles to be used are styles valid for
697 the wxWindow and wxScrolledWindow.
699 @see @link wndflags Additional Window Styles @endlink
701 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
702 const wxPoint
& pos
= wxDefaultPosition
,
703 const wxSize
& size
= wxDefaultSize
,
704 long style
= wxPG_DEFAULT_STYLE
,
705 const wxString
& name
= wxPropertyGridNameStr
);
708 virtual ~wxPropertyGrid();
710 /** Adds given key combination to trigger given action.
712 Here is a sample code to make Enter key press move focus to
716 propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
718 propGrid->DedicateKey(WXK_RETURN);
722 Which action to trigger. See @link pgactions List of list of
723 wxPropertyGrid actions@endlink.
725 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
728 Dedicates a specific keycode to wxPropertyGrid. This means that such
729 key presses will not be redirected to editor controls.
731 Using this function allows, for example, navigation between
732 properties using arrow keys even when the focus is in the editor
735 void DedicateKey( int keycode
)
737 m_dedicatedKeys
.push_back(keycode
);
741 This static function enables or disables automatic use of
742 wxGetTranslation for following strings: wxEnumProperty list labels,
743 wxFlagsProperty sub-property labels.
747 static void AutoGetTranslation( bool enable
);
750 Changes value of a property, as if from an editor.
752 Use this instead of SetPropertyValue() if you need the value to run
753 through validation process, and also send the property change event.
756 Returns true if value was successfully changed.
758 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
761 Centers the splitter.
763 @param enableAutoResizing
764 If @true, automatic column resizing is enabled (only applicapple
765 if window style wxPG_SPLITTER_AUTO_CENTER is used).
767 void CenterSplitter( bool enableAutoResizing
= false );
769 /** Deletes all properties.
771 virtual void Clear();
773 /** Clears action triggers for given action.
775 Which action to trigger. See @link pgactions List of list of
776 wxPropertyGrid actions@endlink.
778 void ClearActionTriggers( int action
);
780 /** Forces updating the value of property from the editor control.
782 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
783 ProcessEvent, meaning your event handlers will be called immediately.
786 Returns true if anything was changed.
788 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
793 Whenever the control is created without any parameters, use Create to
794 actually create it. Don't access the control's public methods before
795 this is called @see @link wndflags Additional Window Styles@endlink
797 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
798 const wxPoint
& pos
= wxDefaultPosition
,
799 const wxSize
& size
= wxDefaultSize
,
800 long style
= wxPG_DEFAULT_STYLE
,
801 const wxString
& name
= wxPropertyGridNameStr
);
804 Call when editor widget's contents is modified.
806 For example, this is called when changes text in wxTextCtrl (used in
807 wxStringProperty and wxIntProperty).
810 This function should only be called by custom properties.
812 @see wxPGProperty::OnEvent()
814 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
816 /** Reverse of EditorsValueWasModified().
819 This function should only be called by custom properties.
821 void EditorsValueWasNotModified()
823 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
827 Enables or disables (shows/hides) categories according to parameter
830 bool EnableCategories( bool enable
);
832 /** Scrolls and/or expands items to ensure that the given item is visible.
833 Returns true if something was actually done.
835 bool EnsureVisible( wxPGPropArg id
);
838 Reduces column sizes to minimum possible that contents are still
839 visibly (naturally some margin space will be applied as well).
842 Minimum size for the grid to still display everything.
845 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
847 This function only works properly if grid size prior to call was already
850 Note that you can also get calculated column widths by calling
851 GetState->GetColumnWidth() immediately after this function returns.
855 wxSize sz
= m_pState
->DoFitColumns();
860 Returns wxWindow that the properties are painted on, and which should
861 be used as the parent for editor controls.
868 /** Returns current category caption background colour. */
869 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
871 wxFont
& GetCaptionFont() { return m_captionFont
; }
873 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
875 /** Returns current category caption text colour. */
876 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
878 /** Returns current cell background colour. */
879 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
881 /** Returns current cell text colour when disabled. */
882 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
884 /** Returns current cell text colour. */
885 wxColour
GetCellTextColour() const { return m_colPropFore
; }
888 Returns number of columns currently on grid.
890 unsigned int GetColumnCount() const
892 return (unsigned int) m_pState
->m_colWidths
.size();
895 /** Returns colour of empty space below properties. */
896 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
898 /** Returns height of highest characters of used font. */
899 int GetFontHeight() const { return m_fontHeight
; }
901 /** Returns pointer to itself. Dummy function that enables same kind
902 of code to use wxPropertyGrid and wxPropertyGridManager.
904 wxPropertyGrid
* GetGrid() { return this; }
906 /** Returns rectangle of custom paint image.
908 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
910 /** Returns size of the custom paint image in front of property.
911 If no argument is given, returns preferred size.
913 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
916 /** Returns last item which could be iterated using given flags.
918 See @ref propgrid_iterator_flags.
920 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
922 return m_pState
->GetLastItem(flags
);
925 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
927 return m_pState
->GetLastItem(flags
);
931 /** Returns colour of lines between cells. */
932 wxColour
GetLineColour() const { return m_colLine
; }
934 /** Returns background colour of margin. */
935 wxColour
GetMarginColour() const { return m_colMargin
; }
937 /** Returns margin width. */
938 int GetMarginWidth() const { return m_marginWidth
; }
941 Returns most up-to-date value of selected property. This will return
942 value different from GetSelectedProperty()->GetValue() only when text
943 editor is activate and string edited by user represents valid,
944 uncommitted property value.
946 wxVariant
GetUncommittedPropertyValue();
948 /** Returns "root property". It does not have name, etc. and it is not
949 visible. It is only useful for accessing its children.
951 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
953 /** Returns height of a single grid row (in pixels). */
954 int GetRowHeight() const { return m_lineHeight
; }
956 /** Returns currently selected property. */
957 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
959 /** Returns current selection background colour. */
960 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
962 /** Returns current selection text colour. */
963 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
966 Returns current splitter x position.
968 int GetSplitterPosition( unsigned int splitterIndex
= 0 ) const
970 return m_pState
->DoGetSplitterPosition(splitterIndex
);
973 /** Returns wxTextCtrl active in currently selected property, if any. Takes
974 into account wxOwnerDrawnComboBox.
976 wxTextCtrl
* GetEditorTextCtrl() const;
978 wxPGValidationInfo
& GetValidationInfo()
980 return m_validationInfo
;
983 /** Returns current vertical spacing. */
984 int GetVerticalSpacing() const { return (int)m_vspacing
; }
987 Returns @true if a property editor control has focus.
989 bool IsEditorFocused() const;
991 /** Returns true if editor's value was marked modified.
993 bool IsEditorsValueModified() const
994 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
997 Returns information about arbitrary position in the grid.
1000 Coordinates in the virtual grid space. You may need to use
1001 wxScrolledWindow::CalcScrolledPosition() for translating
1002 wxPropertyGrid client coordinates into something this member
1005 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
1007 /** Returns true if any property has been modified by the user. */
1008 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
1011 Returns true if updating is frozen (ie Freeze() called but not yet
1014 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
1017 It is recommended that you call this function any time your code causes
1018 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
1019 handler should be able to detect most changes, but it is not perfect.
1022 New top-level parent that is about to be set. Old top-level parent
1023 window should still exist as the current one.
1025 @remarks This function is automatically called from wxPropertyGrid::
1026 Reparent() and wxPropertyGridManager::Reparent(). You only
1027 need to use it if you reparent wxPropertyGrid indirectly.
1029 void OnTLPChanging( wxWindow
* newTLP
);
1031 /** Redraws given property.
1033 virtual void RefreshProperty( wxPGProperty
* p
);
1035 /** Registers a new editor class.
1037 Pointer to the editor class instance that should be used.
1039 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
1040 bool noDefCheck
= false )
1042 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
1045 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
1046 const wxString
& editorName
,
1047 bool noDefCheck
= false );
1049 /** Resets all colours to the original system values.
1051 void ResetColours();
1054 Resets column sizes and splitter positions, based on proportions.
1056 @param enableAutoResizing
1057 If @true, automatic column resizing is enabled (only applicapple
1058 if window style wxPG_SPLITTER_AUTO_CENTER is used).
1060 @see wxPropertyGridInterface::SetColumnProportion()
1062 void ResetColumnSizes( bool enableAutoResizing
= false );
1066 Editor widget is automatically created, but not focused unless focus is
1073 True if selection finished successfully. Usually only fails if
1074 current value in editor is not valid.
1076 @remarks In wxPropertyGrid 1.4, this member function used to generate
1077 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
1080 @remarks This clears any previous selection.
1082 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
1085 Set entire new selection from given list of properties.
1087 void SetSelection( const wxArrayPGProperty
& newSelection
)
1089 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
1093 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
1094 extra style is not used, then this has same effect as
1095 calling SelectProperty().
1097 @remarks Multiple selection is not supported for categories. This
1098 means that if you have properties selected, you cannot
1099 add category to selection, and also if you have category
1100 selected, you cannot add other properties to selection.
1101 This member function will fail silently in these cases,
1102 even returning true.
1104 bool AddToSelection( wxPGPropArg id
)
1106 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1107 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1111 Removes given property from selection. If property is not selected,
1112 an assertion failure will occur.
1114 bool RemoveFromSelection( wxPGPropArg id
)
1116 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1117 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1121 Makes given column editable by user.
1124 Using @false here will disable column from being editable.
1126 void MakeColumnEditable( unsigned int column
, bool editable
= true );
1129 Creates label editor wxTextCtrl for given column, for property
1130 that is currently selected. When multiple selection is
1131 enabled, this applies to whatever property GetSelection()
1135 Which column's label to edit. Note that you should not
1136 use value 1, which is reserved for property value
1139 @see EndLabelEdit(), MakeColumnEditable()
1141 void BeginLabelEdit( unsigned int column
= 0 )
1143 DoBeginLabelEdit(column
, wxPG_SEL_DONT_SEND_EVENT
);
1147 Destroys label editor wxTextCtrl, if any.
1150 Use @true (default) to store edited label text in
1153 @see BeginLabelEdit(), MakeColumnEditable()
1155 void EndLabelEdit( bool commit
= true )
1157 DoEndLabelEdit(commit
, wxPG_SEL_DONT_SEND_EVENT
);
1161 Returns currently active label editor, NULL if none.
1163 wxTextCtrl
* GetLabelEditor() const
1165 return m_labelEditor
;
1168 /** Sets category caption background colour. */
1169 void SetCaptionBackgroundColour(const wxColour
& col
);
1171 /** Sets category caption text colour. */
1172 void SetCaptionTextColour(const wxColour
& col
);
1174 /** Sets default cell background colour - applies to property cells.
1175 Note that appearance of editor widgets may not be affected.
1177 void SetCellBackgroundColour(const wxColour
& col
);
1179 /** Sets cell text colour for disabled properties.
1181 void SetCellDisabledTextColour(const wxColour
& col
);
1183 /** Sets default cell text colour - applies to property name and value text.
1184 Note that appearance of editor widgets may not be affected.
1186 void SetCellTextColour(const wxColour
& col
);
1188 /** Set number of columns (2 or more).
1190 void SetColumnCount( int colCount
)
1192 m_pState
->SetColumnCount(colCount
);
1197 Sets the 'current' category - Append will add non-category properties
1200 void SetCurrentCategory( wxPGPropArg id
)
1202 wxPG_PROP_ARG_CALL_PROLOG()
1203 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1205 m_pState
->m_currentCategory
= pc
;
1208 /** Sets colour of empty space below properties. */
1209 void SetEmptySpaceColour(const wxColour
& col
);
1211 /** Sets colour of lines between cells. */
1212 void SetLineColour(const wxColour
& col
);
1214 /** Sets background colour of margin. */
1215 void SetMarginColour(const wxColour
& col
);
1218 Sets selection background colour - applies to selected property name
1221 void SetSelectionBackgroundColour(const wxColour
& col
);
1224 Sets selection foreground colour - applies to selected property name
1227 void SetSelectionTextColour(const wxColour
& col
);
1229 /** Sets x coordinate of the splitter.
1231 Splitter position cannot exceed grid size, and therefore setting it
1232 during form creation may fail as initial grid size is often smaller
1233 than desired splitter position, especially when sizers are being used.
1235 void SetSplitterPosition( int newXPos
, int col
= 0 )
1237 DoSetSplitterPosition(newXPos
, col
, wxPG_SPLITTER_REFRESH
);
1241 Sets the property sorting function.
1244 The sorting function to be used. It should return a value greater
1245 than 0 if position of p1 is after p2. So, for instance, when
1246 comparing property names, you can use following implementation:
1249 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1253 return p1->GetBaseName().compare( p2->GetBaseName() );
1258 Default property sort function sorts properties by their labels
1259 (case-insensitively).
1261 @see GetSortFunction, wxPropertyGridInterface::Sort,
1262 wxPropertyGridInterface::SortChildren
1264 void SetSortFunction( wxPGSortCallback sortFunction
)
1266 m_sortFunction
= sortFunction
;
1270 Returns the property sort function (default is @NULL).
1272 @see SetSortFunction
1274 wxPGSortCallback
GetSortFunction() const
1276 return m_sortFunction
;
1280 Sets appearance of value cells representing an unspecified property
1281 value. Default appearance is blank.
1283 @remarks If you set the unspecified value to have any
1284 textual representation, then that will override
1285 "InlineHelp" attribute.
1287 @see wxPGProperty::SetValueToUnspecified(),
1288 wxPGProperty::IsValueUnspecified()
1290 void SetUnspecifiedValueAppearance( const wxPGCell
& cell
)
1292 m_unspecifiedAppearance
= m_propertyDefaultCell
;
1293 m_unspecifiedAppearance
.MergeFrom(cell
);
1297 Returns current appearance of unspecified value cells.
1299 @see SetUnspecifiedValueAppearance()
1301 const wxPGCell
& GetUnspecifiedValueAppearance() const
1303 return m_unspecifiedAppearance
;
1307 Returns (visual) text representation of the unspecified
1310 @param argFlags For internal use only.
1312 wxString
GetUnspecifiedValueText( int argFlags
= 0 ) const;
1314 /** Set virtual width for this particular page. Width -1 indicates that the
1315 virtual width should be disabled. */
1316 void SetVirtualWidth( int width
);
1319 Moves splitter as left as possible, while still allowing all
1320 labels to be shown in full.
1322 @param privateChildrenToo
1323 If @false, will still allow private children to be cropped.
1325 void SetSplitterLeft( bool privateChildrenToo
= false )
1327 m_pState
->SetSplitterLeft(privateChildrenToo
);
1330 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1331 height. Value of 2 should be default on most platforms.
1333 void SetVerticalSpacing( int vspacing
)
1335 m_vspacing
= (unsigned char)vspacing
;
1336 CalculateFontAndBitmapStuff( vspacing
);
1337 if ( !m_pState
->m_itemsAdded
) Refresh();
1340 /** Shows an brief error message that is related to a property. */
1341 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1343 wxPG_PROP_ARG_CALL_PROLOG()
1344 DoShowPropertyError(p
, msg
);
1347 /////////////////////////////////////////////////////////////////
1349 // Following methods do not need to be (currently) documented
1351 /////////////////////////////////////////////////////////////////
1353 bool HasVirtualWidth() const
1354 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1356 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1358 return (wxPGCommonValue
*) m_commonValues
[i
];
1361 /** Returns number of common values.
1363 unsigned int GetCommonValueCount() const
1365 return (unsigned int) m_commonValues
.size();
1368 /** Returns label of given common value.
1370 wxString
GetCommonValueLabel( unsigned int i
) const
1372 wxASSERT( GetCommonValue(i
) );
1373 return GetCommonValue(i
)->GetLabel();
1377 Returns index of common value that will truly change value to
1380 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1382 /** Set index of common value that will truly change value to unspecified.
1383 Using -1 will set none to have such effect.
1386 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1389 Shortcut for creating dialog-caller button. Used, for example, by
1392 This should only be called by properties.
1394 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1396 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1397 fits as one). Call after control has been created (but before
1400 void FixPosForTextCtrl( wxWindow
* ctrl
,
1401 unsigned int forColumn
= 1,
1402 const wxPoint
& offset
= wxPoint(0, 0) );
1404 /** Shortcut for creating text editor widget.
1406 Same as pos given for CreateEditor.
1408 Same as sz given for CreateEditor.
1410 Initial text for wxTextCtrl.
1412 If right-side control, such as button, also created, then create it
1413 first and pass it as this parameter.
1415 Extra style flags to pass for wxTextCtrl.
1417 Note that this should generally be called only by new classes derived
1420 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1422 const wxString
& value
,
1423 wxWindow
* secondary
,
1426 unsigned int forColumn
= 1 );
1428 /* Generates both textctrl and button.
1430 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1431 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1432 wxPGProperty
* property
);
1434 /** Generates position for a widget editor dialog box.
1436 Property for which dialog is positioned.
1438 Known or over-approximated size of the dialog.
1440 Position for dialog.
1442 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1445 // Converts escape sequences in src_str to newlines,
1446 // tabs, etc. and copies result to dst_str.
1447 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1448 wxString
& src_str
);
1450 // Converts newlines, tabs, etc. in src_str to escape
1451 // sequences, and copies result to dst_str.
1452 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1453 wxString
& src_str
);
1456 Returns rectangle that fully contains properties between and including
1457 p1 and p2. Rectangle is in virtual scrolled window coordinates.
1459 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1460 const wxPGProperty
* p2
) const;
1462 /** Returns pointer to current active primary editor control (NULL if none).
1464 wxWindow
* GetEditorControl() const;
1466 wxWindow
* GetPrimaryEditor() const
1468 return GetEditorControl();
1472 Returns pointer to current active secondary editor control (NULL if
1475 wxWindow
* GetEditorControlSecondary() const
1477 return m_wndEditor2
;
1481 Refreshes any active editor control.
1483 void RefreshEditor();
1485 // Events from editor controls are forward to this function
1486 void HandleCustomEditorEvent( wxEvent
&event
);
1489 Generates contents for string dst based on the contents of
1492 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1493 so on. Set flags to 1 inorder to convert backslashes to double-back-
1494 slashes and "(preDelims)"'s to "(preDelims)".
1496 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1497 wxChar preDelim
, wxChar postDelim
,
1500 // Mostly useful for page switching.
1501 void SwitchState( wxPropertyGridPageState
* pNewState
);
1503 long GetInternalFlags() const { return m_iFlags
; }
1504 bool HasInternalFlag( long flag
) const
1505 { return (m_iFlags
& flag
) ? true : false; }
1506 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1507 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1508 void IncFrozen() { m_frozen
++; }
1509 void DecFrozen() { m_frozen
--; }
1511 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1517 /** Standardized double-to-string conversion.
1519 static void DoubleToString( wxString
& target
,
1523 wxString
* precTemplate
);
1526 Call this from wxPGProperty::OnEvent() to cause property value to be
1527 changed after the function returns (with true as return value).
1528 ValueChangeInEvent() must be used if you wish the application to be
1529 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1531 void ValueChangeInEvent( wxVariant variant
)
1533 m_changeInEventValue
= variant
;
1534 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1538 You can use this member function, for instance, to detect in
1539 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1540 already called in wxPGEditor::OnEvent(). It really only detects
1541 if was value was changed using wxPGProperty::SetValueInEvent(), which
1542 is usually used when a 'picker' dialog is displayed. If value was
1543 written by "normal means" in wxPGProperty::StringToValue() or
1544 IntToValue(), then this function will return false (on the other hand,
1545 wxPGProperty::OnEvent() is not even called in those cases).
1547 bool WasValueChangedInEvent() const
1549 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1552 /** Returns true if given event is from first of an array of buttons
1553 (as can be in case when wxPGMultiButton is used).
1555 bool IsMainButtonEvent( const wxEvent
& event
)
1557 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1558 && (m_wndSecId
== event
.GetId());
1561 /** Pending value is expected to be passed in PerformValidation().
1563 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1564 unsigned int selFlags
= 0 );
1566 /** Called when validation for given property fails.
1568 Value which failed in validation.
1570 Return true if user is allowed to change to another property even
1571 if current has invalid value.
1573 To add your own validation failure behavior, override
1574 wxPropertyGrid::DoOnValidationFailure().
1576 bool OnValidationFailure( wxPGProperty
* property
,
1577 wxVariant
& invalidValue
);
1579 /** Called to indicate property and editor has valid value now.
1581 void OnValidationFailureReset( wxPGProperty
* property
)
1583 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1585 DoOnValidationFailureReset(property
);
1586 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1588 m_validationInfo
.m_failureMessage
.clear();
1591 /** Override in derived class to display error messages in custom manner
1592 (these message usually only result from validation failure).
1594 virtual void DoShowPropertyError( wxPGProperty
* property
,
1595 const wxString
& msg
);
1597 /** Override to customize property validation failure behavior.
1599 Value which failed in validation.
1601 Return true if user is allowed to change to another property even
1602 if current has invalid value.
1604 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1605 wxVariant
& invalidValue
);
1607 /** Override to customize resetting of property validation failure status.
1609 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1611 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1613 int GetSpacingY() const { return m_spacingy
; }
1616 Must be called in wxPGEditor::CreateControls() if primary editor window
1617 is wxTextCtrl, just before textctrl is created.
1619 Initial text value of created wxTextCtrl.
1621 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1624 Unfocuses or closes editor if one was open, but does not deselect
1627 bool UnfocusEditor();
1629 virtual void SetWindowStyleFlag( long style
);
1631 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1633 void DrawItem( wxPGProperty
* p
)
1638 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1641 Draws item, children, and consequtive parents as long as category is
1644 void DrawItemAndValueRelated( wxPGProperty
* p
);
1649 wxPropertyGridPageState used by the grid is created here.
1651 If grid is used in wxPropertyGridManager, there is no point overriding
1652 this - instead, set custom wxPropertyGridPage classes.
1654 virtual wxPropertyGridPageState
* CreateState() const;
1656 enum PerformValidationFlags
1658 SendEvtChanging
= 0x0001,
1659 IsStandaloneValidation
= 0x0002 // Not called in response to event
1663 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1664 Returns true if all tests passed. Implement in derived class to
1665 add additional validation behavior.
1667 virtual bool PerformValidation( wxPGProperty
* p
,
1668 wxVariant
& pendingValue
,
1669 int flags
= SendEvtChanging
);
1673 // Control font changer helper.
1674 void SetCurControlBoldFont();
1676 wxPGCell
& GetPropertyDefaultCell()
1678 return m_propertyDefaultCell
;
1681 wxPGCell
& GetCategoryDefaultCell()
1683 return m_categoryDefaultCell
;
1687 // Public methods for semi-public use
1689 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1691 // Overridden functions.
1692 virtual bool Destroy();
1693 // Returns property at given y coordinate (relative to grid's top left).
1694 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1696 virtual void Refresh( bool eraseBackground
= true,
1697 const wxRect
*rect
= (const wxRect
*) NULL
);
1698 virtual bool SetFont( const wxFont
& font
);
1699 #if wxPG_SUPPORT_TOOLTIPS
1700 void SetToolTip( const wxString
& tipString
);
1702 virtual void Freeze();
1703 virtual void SetExtraStyle( long exStyle
);
1704 virtual void Thaw();
1705 virtual bool Reparent( wxWindowBase
*newParent
);
1708 virtual wxSize
DoGetBestSize() const;
1710 #ifndef wxPG_ICON_WIDTH
1711 wxBitmap
*m_expandbmp
, *m_collbmp
;
1714 wxCursor
*m_cursorSizeWE
;
1716 /** wxWindow pointers to editor control(s). */
1717 wxWindow
*m_wndEditor
;
1718 wxWindow
*m_wndEditor2
;
1720 #if wxPG_DOUBLE_BUFFER
1721 wxBitmap
*m_doubleBuffer
;
1724 /** Local time ms when control was created. */
1725 wxLongLong m_timeCreated
;
1727 /** wxPGProperty::OnEvent can change value by setting this. */
1728 wxVariant m_changeInEventValue
;
1730 /** Id of m_wndEditor2, or its first child, if any. */
1733 /** Extra Y spacing between the items. */
1736 /** Control client area width; updated on resize. */
1739 /** Control client area height; updated on resize. */
1742 /** Current non-client width (needed when auto-centering). */
1745 /** Non-client width (auto-centering helper). */
1748 /** Previously recorded scroll start position. */
1752 The gutter spacing in front and back of the image.
1753 This determines the amount of spacing in front of each item
1757 /** Includes separator line. */
1760 /** Gutter*2 + image width. */
1763 // y spacing for expand/collapse button.
1764 int m_buttonSpacingY
;
1766 /** Extra margin for expanded sub-group items. */
1767 int m_subgroup_extramargin
;
1770 The image width of the [+] icon.
1772 This is also calculated in the gutter
1776 #ifndef wxPG_ICON_WIDTH
1779 The image height of the [+] icon.
1781 This is calculated as minimal size and to align
1786 /** Current cursor id. */
1790 This captionFont is made equal to the font of the wxScrolledWindow.
1792 As extra the bold face is set on it when this is wanted by the user
1795 wxFont m_captionFont
;
1797 int m_fontHeight
; // Height of the font.
1799 /** m_splitterx when drag began. */
1800 int m_startingSplitterX
;
1803 Index to splitter currently being dragged (0=one after the first
1806 int m_draggedSplitter
;
1808 /** Changed property, calculated in PerformValidation(). */
1809 wxPGProperty
* m_chgInfo_changedProperty
;
1812 Lowest property for which editing happened, but which does not have
1815 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1817 /** Changed property value, calculated in PerformValidation(). */
1818 wxVariant m_chgInfo_pendingValue
;
1820 /** Passed to SetValue. */
1821 wxVariant m_chgInfo_valueList
;
1823 /** Validation information. */
1824 wxPGValidationInfo m_validationInfo
;
1826 /** Actions and keys that trigger them. */
1827 wxPGHashMapI2I m_actionTriggers
;
1829 /** Appearance of currently active editor. */
1830 wxPGCell m_editorAppearance
;
1832 /** Appearance of a unspecified value cell. */
1833 wxPGCell m_unspecifiedAppearance
;
1835 /** List of properties to be deleted/removed in idle event handler. */
1836 wxArrayPGProperty m_deletedProperties
;
1837 wxArrayPGProperty m_removedProperties
;
1839 /** List of key codes that will not be handed over to editor controls. */
1840 // FIXME: Make this a hash set once there is template-based wxHashSet.
1841 wxVector
<int> m_dedicatedKeys
;
1847 /** Bits are used to indicate which colours are customized. */
1848 unsigned short m_coloursCustomized
;
1850 /** x - m_splitterx. */
1851 signed char m_dragOffset
;
1853 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1854 unsigned char m_dragStatus
;
1856 /** 0 = margin, 1 = label, 2 = value. */
1857 unsigned char m_mouseSide
;
1859 /** True when editor control is focused. */
1860 unsigned char m_editorFocused
;
1862 /** 1 if m_latsCaption is also the bottommost caption. */
1863 //unsigned char m_lastCaptionBottomnest;
1865 /** Set to 1 when graphics frozen. */
1866 unsigned char m_frozen
;
1868 unsigned char m_vspacing
;
1870 // Used to track when Alt/Ctrl+Key was consumed.
1871 unsigned char m_keyComboConsumed
;
1873 /** 1 if in DoPropertyChanged() */
1874 unsigned char m_inDoPropertyChanged
;
1876 /** 1 if in CommitChangesFromEditor() */
1877 unsigned char m_inCommitChangesFromEditor
;
1879 /** 1 if in DoSelectProperty() */
1880 unsigned char m_inDoSelectProperty
;
1882 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1884 // DoEditorValidate() recursion guard
1885 wxRecursionGuardFlag m_validatingEditor
;
1887 /** Internal flags - see wxPG_FL_XXX constants. */
1890 /** When drawing next time, clear this many item slots at the end. */
1891 int m_clearThisMany
;
1893 // Mouse is hovering over this column (index)
1894 unsigned int m_colHover
;
1896 // pointer to property that has mouse hovering
1897 wxPGProperty
* m_propHover
;
1899 // Active label editor
1900 wxTextCtrl
* m_labelEditor
;
1902 // For which property the label editor is active
1903 wxPGProperty
* m_labelEditorProperty
;
1905 // EventObject for wxPropertyGridEvents
1906 wxWindow
* m_eventObject
;
1908 // What (global) window is currently focused (needed to resolve event
1910 wxWindow
* m_curFocused
;
1912 // Event currently being sent - NULL if none at the moment
1913 wxPropertyGridEvent
* m_processedEvent
;
1915 // Last known top-level parent
1918 // Last closed top-level parent
1919 wxWindow
* m_tlpClosed
;
1921 // Local time ms when tlp was closed.
1922 wxLongLong m_tlpClosedTime
;
1925 wxPGSortCallback m_sortFunction
;
1927 // y coordinate of property that mouse hovering
1930 // Which column's editor is selected (usually 1)?
1931 unsigned int m_selColumn
;
1933 // x relative to splitter (needed for resize).
1936 // lines between cells
1938 // property labels and values are written in this colour
1939 wxColour m_colPropFore
;
1940 // or with this colour when disabled
1941 wxColour m_colDisPropFore
;
1942 // background for m_colPropFore
1943 wxColour m_colPropBack
;
1944 // text color for captions
1945 wxColour m_colCapFore
;
1946 // background color for captions
1947 wxColour m_colCapBack
;
1948 // foreground for selected property
1949 wxColour m_colSelFore
;
1950 // background for selected property (actually use background color when
1951 // control out-of-focus)
1952 wxColour m_colSelBack
;
1953 // background colour for margin
1954 wxColour m_colMargin
;
1955 // background colour for empty space below the grid
1956 wxColour m_colEmptySpace
;
1958 // Default property colours
1959 wxPGCell m_propertyDefaultCell
;
1961 // Default property category
1962 wxPGCell m_categoryDefaultCell
;
1964 // Backup of selected property's cells
1965 wxVector
<wxPGCell
> m_propCellsBackup
;
1967 // NB: These *cannot* be moved to globals.
1969 // labels when properties use common values
1970 wxVector
<wxPGCommonValue
*> m_commonValues
;
1972 // array of live events
1973 wxVector
<wxPropertyGridEvent
*> m_liveEvents
;
1975 // Which cv selection really sets value to unspecified?
1976 int m_cvUnspecified
;
1978 // Used to skip excess text editor events
1979 wxString m_prevTcValue
;
1983 // Sets some members to defaults (called constructors).
1986 // Initializes some members (called by Create and complex constructor).
1989 void OnPaint(wxPaintEvent
&event
);
1991 // main event receivers
1992 void OnMouseMove( wxMouseEvent
&event
);
1993 void OnMouseClick( wxMouseEvent
&event
);
1994 void OnMouseRightClick( wxMouseEvent
&event
);
1995 void OnMouseDoubleClick( wxMouseEvent
&event
);
1996 void OnMouseUp( wxMouseEvent
&event
);
1997 void OnKey( wxKeyEvent
&event
);
1998 void OnResize( wxSizeEvent
&event
);
2001 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
2002 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
2003 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
2004 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
2005 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
2006 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
2008 void OnMouseEntry( wxMouseEvent
&event
);
2010 void OnIdle( wxIdleEvent
&event
);
2011 void OnFocusEvent( wxFocusEvent
&event
);
2012 void OnChildFocusEvent( wxChildFocusEvent
& event
);
2014 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
2015 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
2017 // sub-control event handlers
2018 void OnMouseClickChild( wxMouseEvent
&event
);
2019 void OnMouseRightClickChild( wxMouseEvent
&event
);
2020 void OnMouseMoveChild( wxMouseEvent
&event
);
2021 void OnMouseUpChild( wxMouseEvent
&event
);
2022 void OnChildKeyDown( wxKeyEvent
&event
);
2024 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
2026 void OnScrollEvent( wxScrollWinEvent
&event
);
2028 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
2030 void OnTLPClose( wxCloseEvent
& event
);
2034 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
2035 unsigned int colIndex
,
2036 wxMouseEvent
* event
= NULL
,
2040 Adjust the centering of the bitmap icons (collapse / expand) when the
2041 caption font changes.
2043 They need to be centered in the middle of the font, so a bit of deltaY
2044 adjustment is needed. On entry, m_captionFont must be set to window
2045 font. It will be modified properly.
2047 void CalculateFontAndBitmapStuff( int vspacing
);
2049 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
2051 void CorrectEditorWidgetSizeX();
2053 /** Called in RecalculateVirtualSize() to reposition control
2054 on virtual height changes.
2056 void CorrectEditorWidgetPosY();
2058 int DoDrawItems( wxDC
& dc
,
2059 const wxRect
* drawRect
,
2060 bool isBuffered
) const;
2062 /** Draws an expand/collapse (ie. +/-) button.
2064 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
2065 wxPGProperty
* property
) const;
2067 /** Draws items from topitemy to bottomitemy */
2068 void DrawItems( wxDC
& dc
,
2069 unsigned int topItemY
,
2070 unsigned int bottomItemY
,
2071 const wxRect
* drawRect
= NULL
);
2073 // Translate wxKeyEvent to wxPG_ACTION_XXX
2074 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
2076 int KeyEventToAction(wxKeyEvent
&event
) const
2078 return KeyEventToActions(event
, NULL
);
2081 void ImprovedClientToScreen( int* px
, int* py
);
2083 // Called by focus event handlers. newFocused is the window that becomes
2085 void HandleFocusChange( wxWindow
* newFocused
);
2087 /** Reloads all non-customized colours from system settings. */
2088 void RegainColours();
2090 virtual bool DoEditorValidate();
2092 // Similar to DoSelectProperty() but also works on columns
2093 // other than 1. Does not active editor if column is not
2095 bool DoSelectAndEdit( wxPGProperty
* prop
,
2096 unsigned int colIndex
,
2097 unsigned int selFlags
);
2099 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
2102 void DoSetSplitterPosition( int newxpos
,
2103 int splitterIndex
= 0,
2104 int flags
= wxPG_SPLITTER_REFRESH
);
2106 bool DoAddToSelection( wxPGProperty
* prop
,
2109 bool DoRemoveFromSelection( wxPGProperty
* prop
,
2112 void DoBeginLabelEdit( unsigned int colIndex
, int selFlags
= 0 );
2113 void DoEndLabelEdit( bool commit
, int selFlags
= 0 );
2114 void OnLabelEditorEnterPress( wxCommandEvent
& event
);
2115 void OnLabelEditorKeyPress( wxKeyEvent
& event
);
2117 wxPGProperty
* DoGetItemAtY( int y
) const;
2119 void DestroyEditorWnd( wxWindow
* wnd
);
2122 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
2124 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
2126 // Returns nearest paint visible property (such that will be painted unless
2127 // window is scrolled or resized). If given property is paint visible, then
2128 // it itself will be returned.
2129 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
2131 static void RegisterDefaultEditors();
2133 // Sets up basic event handling for child control
2134 void SetupChildEventHandling( wxWindow
* wnd
);
2136 void CustomSetCursor( int type
, bool override
= false );
2139 Repositions scrollbar and underlying panel according to changed virtual
2142 void RecalculateVirtualSize( int forceXPos
= -1 );
2144 void SetEditorAppearance( const wxPGCell
& cell
,
2145 bool unspecified
= false );
2147 void ResetEditorAppearance()
2150 cell
.SetEmptyData();
2151 SetEditorAppearance(cell
, false);
2154 void PrepareAfterItemsAdded();
2157 Send event from the property grid.
2159 Omit the wxPG_SEL_NOVALIDATE flag to allow vetoing the event
2161 bool SendEvent( int eventType
, wxPGProperty
* p
,
2162 wxVariant
* pValue
= NULL
,
2163 unsigned int selFlags
= wxPG_SEL_NOVALIDATE
,
2164 unsigned int column
= 1 );
2166 void SetFocusOnCanvas();
2168 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
2172 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
2174 DECLARE_EVENT_TABLE()
2177 // -----------------------------------------------------------------------
2179 // Bunch of inlines that need to resolved after all classes have been defined.
2182 inline bool wxPropertyGridPageState::IsDisplayed() const
2184 return ( this == m_pPropGrid
->GetState() );
2187 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
2189 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
2192 inline wxString
wxPGProperty::GetHintText() const
2194 wxVariant vHintText
= GetAttribute(wxPGGlobalVars
->m_strHint
);
2196 #if wxPG_COMPATIBILITY_1_4
2197 // Try the old, deprecated "InlineHelp"
2198 if ( vHintText
.IsNull() )
2199 vHintText
= GetAttribute(wxPGGlobalVars
->m_strInlineHelp
);
2202 if ( !vHintText
.IsNull() )
2203 return vHintText
.GetString();
2205 return wxEmptyString
;
2208 inline int wxPGProperty::GetDisplayedCommonValueCount() const
2210 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
2212 wxPropertyGrid
* pg
= GetGrid();
2214 return (int) pg
->GetCommonValueCount();
2219 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
2221 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
2224 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
2226 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
2229 inline bool wxPGProperty::SetMaxLength( int maxLen
)
2231 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
2234 // -----------------------------------------------------------------------
2236 #define wxPG_BASE_EVT_PRE_ID 1775
2240 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
2241 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
2242 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
2243 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
2244 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
2245 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
2246 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
2247 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
2248 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
2249 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2250 wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
2251 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2252 wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
2253 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2254 wxEVT_PG_COL_BEGIN_DRAG
, wxPropertyGridEvent
);
2255 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2256 wxEVT_PG_COL_DRAGGING
, wxPropertyGridEvent
);
2257 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
,
2258 wxEVT_PG_COL_END_DRAG
, wxPropertyGridEvent
);
2262 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
2265 wxEVT_PG_HIGHLIGHTED
,
2266 wxEVT_PG_RIGHT_CLICK
,
2267 wxEVT_PG_PAGE_CHANGED
,
2268 wxEVT_PG_ITEM_COLLAPSED
,
2269 wxEVT_PG_ITEM_EXPANDED
,
2270 wxEVT_PG_DOUBLE_CLICK
,
2271 wxEVT_PG_LABEL_EDIT_BEGIN
,
2272 wxEVT_PG_LABEL_EDIT_ENDING
,
2273 wxEVT_PG_COL_BEGIN_DRAG
,
2274 wxEVT_PG_COL_DRAGGING
,
2275 wxEVT_PG_COL_END_DRAG
2280 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2281 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2285 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2287 #define EVT_PG_SELECTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2288 #define EVT_PG_CHANGING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2289 #define EVT_PG_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2290 #define EVT_PG_HIGHLIGHTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2291 #define EVT_PG_RIGHT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2292 #define EVT_PG_DOUBLE_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2293 #define EVT_PG_PAGE_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2294 #define EVT_PG_ITEM_COLLAPSED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2295 #define EVT_PG_ITEM_EXPANDED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2296 #define EVT_PG_LABEL_EDIT_BEGIN(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_BEGIN, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2297 #define EVT_PG_LABEL_EDIT_ENDING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_LABEL_EDIT_ENDING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2298 #define EVT_PG_COL_BEGIN_DRAG(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_BEGIN_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2299 #define EVT_PG_COL_DRAGGING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_DRAGGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2300 #define EVT_PG_COL_END_DRAG(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_COL_END_DRAG, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2302 #define wxPropertyGridEventHandler(fn) \
2303 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2308 /** @class wxPropertyGridEvent
2310 A propertygrid event holds information about events associated with
2311 wxPropertyGrid objects.
2313 @library{wxpropgrid}
2316 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2321 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2323 /** Copy constructor. */
2324 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2327 ~wxPropertyGridEvent();
2330 virtual wxEvent
* Clone() const;
2333 Returns the column index associated with this event.
2334 For the column dragging events, it is the column to the left
2335 of the splitter being dragged
2337 unsigned int GetColumn() const
2342 wxPGProperty
* GetMainParent() const
2344 wxASSERT(m_property
);
2345 return m_property
->GetMainParent();
2348 /** Returns id of associated property. */
2349 wxPGProperty
* GetProperty() const
2354 wxPGValidationInfo
& GetValidationInfo()
2356 wxASSERT(m_validationInfo
);
2357 return *m_validationInfo
;
2360 /** Returns true if you can veto the action that the event is signaling.
2362 bool CanVeto() const { return m_canVeto
; }
2365 Call this from your event handler to veto action that the event is
2368 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2371 Currently only wxEVT_PG_CHANGING supports vetoing.
2373 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2376 Returns name of the associated property.
2378 @remarks Property name is stored in event, so it remains
2379 accessible even after the associated property or
2380 the property grid has been deleted.
2382 wxString
GetPropertyName() const
2384 return m_propertyName
;
2388 Returns value of the associated property. Works for all event
2389 types, but for wxEVT_PG_CHANGING this member function returns
2390 the value that is pending, so you can call Veto() if the
2391 value is not satisfactory.
2393 @remarks Property value is stored in event, so it remains
2394 accessible even after the associated property or
2395 the property grid has been deleted.
2397 wxVariant
GetPropertyValue() const
2399 if ( m_validationInfo
)
2400 return m_validationInfo
->GetValue();
2405 Returns value of the associated property.
2407 @see GetPropertyValue
2409 wxVariant
GetValue() const
2411 return GetPropertyValue();
2415 Set override validation failure behavior.
2417 Only effective if Veto was also called, and only allowed if event type
2418 is wxEVT_PG_CHANGING.
2420 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2422 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2423 m_validationInfo
->SetFailureBehavior( flags
);
2426 /** Sets custom failure message for this time only. Only applies if
2427 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2429 void SetValidationFailureMessage( const wxString
& message
)
2431 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2432 m_validationInfo
->SetFailureMessage( message
);
2435 wxPGVFBFlags
GetValidationFailureBehavior() const
2437 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2438 return m_validationInfo
->GetFailureBehavior();
2441 void SetColumn( unsigned int column
)
2446 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2447 bool WasVetoed() const { return m_wasVetoed
; }
2449 /** Changes the associated property. */
2450 void SetProperty( wxPGProperty
* p
)
2454 m_propertyName
= p
->GetName();
2457 void SetPropertyValue( wxVariant value
)
2462 void SetPropertyGrid( wxPropertyGrid
* pg
)
2465 OnPropertyGridSet();
2468 void SetupValidationInfo()
2471 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2472 m_validationInfo
= &m_pg
->GetValidationInfo();
2473 m_value
= m_validationInfo
->GetValue();
2478 void OnPropertyGridSet();
2479 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2481 wxPGProperty
* m_property
;
2482 wxPropertyGrid
* m_pg
;
2483 wxPGValidationInfo
* m_validationInfo
;
2485 wxString m_propertyName
;
2488 unsigned int m_column
;
2495 // -----------------------------------------------------------------------
2497 /** @class wxPropertyGridPopulator
2499 Allows populating wxPropertyGrid from arbitrary text source.
2501 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2504 /** Default constructor.
2506 wxPropertyGridPopulator();
2509 virtual ~wxPropertyGridPopulator();
2511 void SetState( wxPropertyGridPageState
* state
);
2513 void SetGrid( wxPropertyGrid
* pg
);
2515 /** Appends a new property under bottommost parent.
2517 Property class as string.
2519 wxPGProperty
* Add( const wxString
& propClass
,
2520 const wxString
& propLabel
,
2521 const wxString
& propName
,
2522 const wxString
* propValue
,
2523 wxPGChoices
* pChoices
= NULL
);
2526 Pushes property to the back of parent array (ie it becomes bottommost
2527 parent), and starts scanning/adding children for it.
2529 When finished, parent array is returned to the original state.
2531 void AddChildren( wxPGProperty
* property
);
2533 /** Adds attribute to the bottommost property.
2535 Allowed values: "string", (same as string), "int", "bool". Empty string
2538 bool AddAttribute( const wxString
& name
,
2539 const wxString
& type
,
2540 const wxString
& value
);
2542 /** Called once in AddChildren.
2544 virtual void DoScanForChildren() = 0;
2547 Returns id of parent property for which children can currently be
2550 wxPGProperty
* GetCurParent() const
2552 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2555 wxPropertyGridPageState
* GetState() { return m_state
; }
2556 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2558 /** Like wxString::ToLong, except allows N% in addition of N.
2560 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2562 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2563 wxPGChoices. Registers parsed result using idString (if not empty).
2564 Also, if choices with given id already registered, then don't parse but
2565 return those choices instead.
2567 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2568 const wxString
& idString
);
2570 /** Implement in derived class to do custom process when an error occurs.
2571 Default implementation uses wxLogError.
2573 virtual void ProcessError( const wxString
& msg
);
2577 /** Used property grid. */
2578 wxPropertyGrid
* m_pg
;
2580 /** Used property grid state. */
2581 wxPropertyGridPageState
* m_state
;
2583 /** Tree-hierarchy of added properties (that can have children). */
2584 wxArrayPGProperty m_propHierarchy
;
2586 /** Hashmap for string-id to wxPGChoicesData mapping. */
2587 wxPGHashMapS2P m_dictIdChoices
;
2590 // -----------------------------------------------------------------------
2593 // Undefine macros that are not needed outside propertygrid sources
2595 #ifndef __wxPG_SOURCE_FILE__
2596 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2597 #undef wxPG_FL_SCROLLBAR_DETECTED
2598 #undef wxPG_FL_CREATEDSTATE
2599 #undef wxPG_FL_NOSTATUSBARHELP
2600 #undef wxPG_FL_SCROLLED
2601 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2602 #undef wxPG_FL_FOCUS_INSIDE
2603 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2604 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2605 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2606 #undef wxPG_FL_VALUE_MODIFIED
2607 #undef wxPG_FL_MOUSE_INSIDE
2608 #undef wxPG_FL_FOCUSED
2609 #undef wxPG_FL_MOUSE_CAPTURED
2610 #undef wxPG_FL_INITIALIZED
2611 #undef wxPG_FL_ACTIVATION_BY_CLICK
2612 #undef wxPG_SUPPORT_TOOLTIPS
2613 #undef wxPG_DOUBLE_BUFFER
2614 #undef wxPG_ICON_WIDTH
2615 #undef wxPG_USE_RENDERER_NATIVE
2616 // Following are needed by the manager headers
2617 // #undef const wxString&
2620 // -----------------------------------------------------------------------
2624 #endif // _WX_PROPGRID_PROPGRID_H_