1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/propgrid.h
3 // Purpose: wxPropertyGrid
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPGRID_H_
13 #define _WX_PROPGRID_PROPGRID_H_
17 #include "wx/dcclient.h"
18 #include "wx/scrolwin.h"
19 #include "wx/tooltip.h"
20 #include "wx/datetime.h"
22 #include "wx/propgrid/property.h"
23 #include "wx/propgrid/propgridiface.h"
27 extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr
[];
32 // -----------------------------------------------------------------------
34 // -----------------------------------------------------------------------
38 // This is required for sharing common global variables.
39 class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
43 wxPGGlobalVarsClass();
44 ~wxPGGlobalVarsClass();
46 // Used by advprops, but here to make things easier.
47 wxString m_pDefaultImageWildcard
;
49 // Map of editor class instances (keys are name string).
50 wxPGHashMapS2P m_mapEditorClasses
;
53 wxVector
<wxValidator
*> m_arrValidators
; // These wxValidators need to be freed
56 wxPGHashMapS2P m_dictPropertyClassInfo
; // PropertyName -> ClassInfo
58 wxPGChoices
* m_fontFamilyChoices
;
60 // Replace with your own to affect all properties using default renderer.
61 wxPGCellRenderer
* m_defaultRenderer
;
63 wxPGChoices m_boolChoices
;
65 wxVariant m_vEmptyString
;
67 wxVariant m_vMinusOne
;
71 // Cached constant strings
72 wxPGCachedString m_strstring
;
73 wxPGCachedString m_strlong
;
74 wxPGCachedString m_strbool
;
75 wxPGCachedString m_strlist
;
77 wxPGCachedString m_strDefaultValue
;
78 wxPGCachedString m_strMin
;
79 wxPGCachedString m_strMax
;
80 wxPGCachedString m_strUnits
;
81 wxPGCachedString m_strInlineHelp
;
83 // If true then some things are automatically translated
84 bool m_autoGetTranslation
;
86 // > 0 if errors cannot or should not be shown in statusbar etc.
89 int m_extraStyle
; // global extra style
93 int HasExtraStyle( int style
) const { return (m_extraStyle
& style
); }
96 extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
* wxPGGlobalVars
;
98 #define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
99 #define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
100 #define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
101 #define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
102 #define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
104 #define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
106 // When wxPG is loaded dynamically after the application is already running
107 // then the built-in module system won't pick this one up. Add it manually.
108 WXDLLIMPEXP_PROPGRID
void wxPGInitResourceModule();
112 // -----------------------------------------------------------------------
114 /** @section propgrid_window_styles wxPropertyGrid Window Styles
116 SetWindowStyleFlag method can be used to modify some of these at run-time.
119 enum wxPG_WINDOW_STYLES
122 /** This will cause Sort() automatically after an item is added.
123 When inserting a lot of items in this mode, it may make sense to
124 use Freeze() before operations and Thaw() afterwards to increase
127 wxPG_AUTO_SORT
= 0x00000010,
129 /** Categories are not initially shown (even if added).
130 IMPORTANT NOTE: If you do not plan to use categories, then this
131 style will waste resources.
132 This flag can also be changed using wxPropertyGrid::EnableCategories method.
134 wxPG_HIDE_CATEGORIES
= 0x00000020,
136 /* This style combines non-categoric mode and automatic sorting.
138 wxPG_ALPHABETIC_MODE
= (wxPG_HIDE_CATEGORIES
|wxPG_AUTO_SORT
),
140 /** Modified values are shown in bold font. Changing this requires Refresh()
143 wxPG_BOLD_MODIFIED
= 0x00000040,
145 /** When wxPropertyGrid is resized, splitter moves to the center. This
146 behavior stops once the user manually moves the splitter.
148 wxPG_SPLITTER_AUTO_CENTER
= 0x00000080,
150 /** Display tooltips for cell text that cannot be shown completely. If
151 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
153 wxPG_TOOLTIPS
= 0x00000100,
155 /** Disables margin and hides all expand/collapse buttons that would appear
156 outside the margin (for sub-properties). Toggling this style automatically
157 expands all collapsed items.
159 wxPG_HIDE_MARGIN
= 0x00000200,
161 /** This style prevents user from moving the splitter.
163 wxPG_STATIC_SPLITTER
= 0x00000400,
165 /** Combination of other styles that make it impossible for user to modify
168 wxPG_STATIC_LAYOUT
= (wxPG_HIDE_MARGIN
|wxPG_STATIC_SPLITTER
),
170 /** Disables wxTextCtrl based editors for properties which
171 can be edited in another way.
173 Equals calling wxPropertyGrid::LimitPropertyEditing for all added
176 wxPG_LIMITED_EDITING
= 0x00000800,
178 /** wxPropertyGridManager only: Show toolbar for mode and page selection. */
179 wxPG_TOOLBAR
= 0x00001000,
181 /** wxPropertyGridManager only: Show adjustable text box showing description
182 or help text, if available, for currently selected property.
184 wxPG_DESCRIPTION
= 0x00002000
188 enum wxPG_EX_WINDOW_STYLES
192 NOTE: wxPG_EX_xxx are extra window styles and must be set using
193 SetExtraStyle() member function.
195 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
196 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
197 not activated, and switching the mode first time becomes somewhat slower.
198 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
199 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
200 you don't plan to use categories at all, then using this style will result
201 in waste of resources.
204 wxPG_EX_INIT_NOCAT
= 0x00001000,
206 /** Extended window style that sets wxPropertyGridManager toolbar to not
209 wxPG_EX_NO_FLAT_TOOLBAR
= 0x00002000,
211 /** Shows alphabetic/categoric mode buttons from toolbar.
213 wxPG_EX_MODE_BUTTONS
= 0x00008000,
215 /** Show property help strings as tool tips instead as text on the status bar.
216 You can set the help strings using SetPropertyHelpString member function.
218 wxPG_EX_HELP_AS_TOOLTIPS
= 0x00010000,
220 /** Prevent TAB from focusing to wxButtons. This behavior was default
221 in version 1.2.0 and earlier.
222 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
223 atleast the button doesn't properly propagate key events (yes, I'm using
226 //wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
228 /** Allows relying on native double-buffering.
230 wxPG_EX_NATIVE_DOUBLE_BUFFERING
= 0x00080000,
232 /** Set this style to let user have ability to set values of properties to
233 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
236 wxPG_EX_AUTO_UNSPECIFIED_VALUES
= 0x00200000,
239 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
240 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
241 (thus they are not readable).
243 Note that this option is global, and applies to all wxPG property
246 wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES
= 0x00400000,
248 /** Hides page selection buttons from toolbar.
250 wxPG_EX_HIDE_PAGE_BUTTONS
= 0x01000000,
252 /** Allows multiple properties to be selected by user (by pressing SHIFT
253 when clicking on a property, or by dragging with left mouse button
256 You can get array of selected properties with
257 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
258 mode wxPropertyGridInterface::GetSelection() returns
259 property which has editor active (usually the first one
260 selected). Other useful member functions are ClearSelection(),
261 AddToSelection() and RemoveFromSelection().
263 wxPG_EX_MULTIPLE_SELECTION
= 0x02000000
267 /** Combines various styles.
269 #define wxPG_DEFAULT_STYLE (0)
271 /** Combines various styles.
273 #define wxPGMAN_DEFAULT_STYLE (0)
278 // -----------------------------------------------------------------------
281 // Ids for sub-controls
282 // NB: It should not matter what these are.
283 #define wxPG_SUBID1 2
284 #define wxPG_SUBID2 3
285 #define wxPG_SUBID_TEMP1 4
287 // -----------------------------------------------------------------------
289 /** @class wxPGCommonValue
291 wxPropertyGrid stores information about common values in these
294 NB: Common value feature is not complete, and thus not mentioned in
297 class WXDLLIMPEXP_PROPGRID wxPGCommonValue
301 wxPGCommonValue( const wxString
& label
, wxPGCellRenderer
* renderer
)
304 m_renderer
= renderer
;
307 virtual ~wxPGCommonValue()
309 m_renderer
->DecRef();
312 virtual wxString
GetEditableText() const { return m_label
; }
313 const wxString
& GetLabel() const { return m_label
; }
314 wxPGCellRenderer
* GetRenderer() const { return m_renderer
; }
318 wxPGCellRenderer
* m_renderer
;
321 // -----------------------------------------------------------------------
323 /** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
327 enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
330 /** Prevents user from leaving property unless value is valid. If this
331 behavior flag is not used, then value change is instead cancelled.
333 wxPG_VFB_STAY_IN_PROPERTY
= 0x01,
335 /** Calls wxBell() on validation failure.
337 wxPG_VFB_BEEP
= 0x02,
339 /** Cell with invalid value will be marked (with red colour).
341 wxPG_VFB_MARK_CELL
= 0x04,
343 /** Display customizable text message explaining the situation.
345 wxPG_VFB_SHOW_MESSAGE
= 0x08,
348 wxPG_VFB_DEFAULT
= wxPG_VFB_STAY_IN_PROPERTY
|wxPG_VFB_BEEP
,
350 /** Only used internally. */
351 wxPG_VFB_UNDEFINED
= 0x80
358 typedef wxByte wxPGVFBFlags
;
363 Used to convey validation information to and from functions that
364 actually perform validation. Mostly used in custom property
367 class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
369 friend class wxPropertyGrid
;
372 @return Returns failure behavior which is a combination of
373 @ref propgrid_vfbflags.
375 wxPGVFBFlags
GetFailureBehavior() const
376 { return m_failureBehavior
; }
379 Returns current failure message.
381 const wxString
& GetFailureMessage() const
382 { return m_failureMessage
; }
385 Returns reference to pending value.
387 const wxVariant
& GetValue() const
393 /** Set validation failure behavior
395 @param failureBehavior
396 Mixture of @ref propgrid_vfbflags.
398 void SetFailureBehavior(wxPGVFBFlags failureBehavior
)
399 { m_failureBehavior
= failureBehavior
; }
402 Set current failure message.
404 void SetFailureMessage(const wxString
& message
)
405 { m_failureMessage
= message
; }
408 /** Value to be validated.
412 /** Message displayed on validation failure.
414 wxString m_failureMessage
;
416 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
418 wxPGVFBFlags m_failureBehavior
;
421 // -----------------------------------------------------------------------
423 /** @section propgrid_pgactions wxPropertyGrid Action Identifiers
425 These are used with wxPropertyGrid::AddActionTrigger() and
426 wxPropertyGrid::ClearActionTriggers().
430 enum wxPG_KEYBOARD_ACTIONS
432 wxPG_ACTION_INVALID
= 0,
433 wxPG_ACTION_NEXT_PROPERTY
,
434 wxPG_ACTION_PREV_PROPERTY
,
435 wxPG_ACTION_EXPAND_PROPERTY
,
436 wxPG_ACTION_COLLAPSE_PROPERTY
,
437 wxPG_ACTION_CANCEL_EDIT
,
438 wxPG_ACTION_PRESS_BUTTON
, // Causes editor button (if any) to be pressed
445 // -----------------------------------------------------------------------
448 // wxPropertyGrid::DoSelectProperty flags (selFlags)
450 // Focuses to created editor
451 #define wxPG_SEL_FOCUS 0x01
452 // Forces deletion and recreation of editor
453 #define wxPG_SEL_FORCE 0x02
454 // For example, doesn't cause EnsureVisible
455 #define wxPG_SEL_NONVISIBLE 0x04
456 // Do not validate editor's value before selecting
457 #define wxPG_SEL_NOVALIDATE 0x08
458 // Property being deselected is about to be deleted
459 #define wxPG_SEL_DELETING 0x10
460 // Property's values was set to unspecified by the user
461 #define wxPG_SEL_SETUNSPEC 0x20
462 // Property's event handler changed the value
463 #define wxPG_SEL_DIALOGVAL 0x40
464 // Set to disable sending of wxEVT_PG_SELECTED event
465 #define wxPG_SEL_DONT_SEND_EVENT 0x80
468 // -----------------------------------------------------------------------
473 #define wxPG_FL_INITIALIZED 0x0001
474 // Set when creating editor controls if it was clicked on.
475 #define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
476 #define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
477 #define wxPG_FL_FOCUSED 0x0008
478 #define wxPG_FL_MOUSE_CAPTURED 0x0010
479 #define wxPG_FL_MOUSE_INSIDE 0x0020
480 #define wxPG_FL_VALUE_MODIFIED 0x0040
481 // don't clear background of m_wndEditor
482 #define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
483 // currently active editor uses custom image
484 #define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
485 // cell colours override selection colours for selected cell
486 #define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
487 #define wxPG_FL_SCROLLED 0x0400
488 // set when all added/inserted properties get hideable flag
489 #define wxPG_FL_ADDING_HIDEABLES 0x0800
490 // Disables showing help strings on statusbar.
491 #define wxPG_FL_NOSTATUSBARHELP 0x1000
492 // Marks that we created the state, so we have to destroy it too.
493 #define wxPG_FL_CREATEDSTATE 0x2000
494 // Set if scrollbar's existence was detected in last onresize.
495 #define wxPG_FL_SCROLLBAR_DETECTED 0x4000
496 // Set if wxPGMan requires redrawing of description text box.
497 #define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
498 // Set if contained in wxPropertyGridManager
499 #define wxPG_FL_IN_MANAGER 0x00020000
500 // Set after wxPropertyGrid is shown in its initial good size
501 #define wxPG_FL_GOOD_SIZE_SET 0x00040000
502 // Set when in SelectProperty.
503 #define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
504 // Set when help string is shown in status bar
505 #define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
506 // Splitter position has been custom-set by the user
507 #define wxPG_FL_SPLITTER_PRE_SET 0x00400000
508 // Validation failed. Clear on modify event.
509 #define wxPG_FL_VALIDATION_FAILED 0x00800000
510 // Auto sort is enabled (for categorized mode)
511 #define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
512 // Set after page has been inserted to manager
513 #define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
514 // Active editor control is abnormally large
515 #define wxPG_FL_ABNORMAL_EDITOR 0x04000000
516 // Recursion guard for HandleCustomEditorEvent
517 #define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
518 #define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
519 // Editor control width should not change on resize
520 #define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
521 // Width of panel can be different than width of grid
522 #define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
523 // Prevents RecalculateVirtualSize re-entrancy
524 #define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
526 #endif // #ifndef SWIG
528 #if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
529 // Reduce compile time, but still include in user app
530 #include "wx/propgrid/props.h"
533 // -----------------------------------------------------------------------
535 /** @class wxPropertyGrid
537 wxPropertyGrid is a specialized grid for editing properties
538 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
539 used to do the very same thing, but it hasn't been updated for a while
540 and it is currently deprecated.
542 Please note that most member functions are inherited and as such not
543 documented on this page. This means you will probably also want to read
544 wxPropertyGridInterface class reference.
546 See also @ref overview_propgrid.
548 @section propgrid_window_styles_ Window Styles
550 See @ref propgrid_window_styles.
552 @section propgrid_event_handling Event Handling
554 To process input from a propertygrid control, use these event handler
555 macros to direct input to member functions that take a wxPropertyGridEvent
558 @beginEventTable{wxPropertyGridEvent}
559 @event{EVT_PG_SELECTED (id, func)}
560 Respond to wxEVT_PG_SELECTED event, generated when a property selection
561 has been changed, either by user action or by indirect program
562 function. For instance, collapsing a parent property programmatically
563 causes any selected child property to become unselected, and may
564 therefore cause this event to be generated.
565 @event{EVT_PG_CHANGING(id, func)}
566 Respond to wxEVT_PG_CHANGING event, generated when property value
567 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
568 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
569 to prevent change from taking place, if necessary.
570 @event{EVT_PG_HIGHLIGHTED(id, func)}
571 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
572 moves over a property. Event's property is NULL if hovered area does
573 not belong to any property.
574 @event{EVT_PG_RIGHT_CLICK(id, func)}
575 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
576 clicked on with right mouse button.
577 @event{EVT_PG_DOUBLE_CLICK(id, func)}
578 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
579 double-clicked onwith left mouse button.
580 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
581 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
582 a property or category..
583 @event{EVT_PG_ITEM_EXPANDED(id, func)}
584 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
585 a property or category..
590 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
591 will also delay sorting etc. miscellaneous calculations to the last
597 class WXDLLIMPEXP_PROPGRID
598 wxPropertyGrid
: public wxScrolledWindow
, public wxPropertyGridInterface
600 friend class wxPropertyGridPageState
;
601 friend class wxPropertyGridInterface
;
602 friend class wxPropertyGridManager
;
603 friend class wxPGCanvas
;
605 DECLARE_DYNAMIC_CLASS(wxPropertyGrid
)
610 Two step constructor.
612 Call Create when this constructor is called to build up the
618 /** The default constructor. The styles to be used are styles valid for
619 the wxWindow and wxScrolledWindow.
621 @see @link wndflags Additional Window Styles @endlink
623 wxPropertyGrid( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
624 const wxPoint
& pos
= wxDefaultPosition
,
625 const wxSize
& size
= wxDefaultSize
,
626 long style
= wxPG_DEFAULT_STYLE
,
627 const wxString
& name
= wxPropertyGridNameStr
);
630 virtual ~wxPropertyGrid();
632 /** Adds given key combination to trigger given action.
635 Which action to trigger. See @link pgactions List of list of
636 wxPropertyGrid actions@endlink.
638 void AddActionTrigger( int action
, int keycode
, int modifiers
= 0 );
641 This static function enables or disables automatic use of
642 wxGetTranslation for following strings: wxEnumProperty list labels,
643 wxFlagsProperty sub-property labels.
647 static void AutoGetTranslation( bool enable
);
650 Changes value of a property, as if from an editor.
652 Use this instead of SetPropertyValue() if you need the value to run
653 through validation process, and also send the property change event.
656 Returns true if value was successfully changed.
658 bool ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
);
661 Centers the splitter.
663 If argument is true, automatic splitter centering is enabled (only
664 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
666 void CenterSplitter( bool enable_auto_centering
= false );
668 /** Deletes all properties.
670 virtual void Clear();
672 /** Clears action triggers for given action.
674 Which action to trigger. See @link pgactions List of list of
675 wxPropertyGrid actions@endlink.
677 void ClearActionTriggers( int action
);
679 /** Forces updating the value of property from the editor control.
681 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
682 ProcessEvent, meaning your event handlers will be called immediately.
685 Returns true if anything was changed.
687 virtual bool CommitChangesFromEditor( wxUint32 flags
= 0 );
692 Whenever the control is created without any parameters, use Create to
693 actually create it. Don't access the control's public methods before
694 this is called @see @link wndflags Additional Window Styles@endlink
696 bool Create( wxWindow
*parent
, wxWindowID id
= wxID_ANY
,
697 const wxPoint
& pos
= wxDefaultPosition
,
698 const wxSize
& size
= wxDefaultSize
,
699 long style
= wxPG_DEFAULT_STYLE
,
700 const wxString
& name
= wxPropertyGridNameStr
);
703 Call when editor widget's contents is modified.
705 For example, this is called when changes text in wxTextCtrl (used in
706 wxStringProperty and wxIntProperty).
709 This function should only be called by custom properties.
711 @see wxPGProperty::OnEvent()
713 void EditorsValueWasModified() { m_iFlags
|= wxPG_FL_VALUE_MODIFIED
; }
715 /** Reverse of EditorsValueWasModified().
718 This function should only be called by custom properties.
720 void EditorsValueWasNotModified()
722 m_iFlags
&= ~(wxPG_FL_VALUE_MODIFIED
);
726 Enables or disables (shows/hides) categories according to parameter
729 bool EnableCategories( bool enable
);
731 /** Scrolls and/or expands items to ensure that the given item is visible.
732 Returns true if something was actually done.
734 bool EnsureVisible( wxPGPropArg id
);
737 Reduces column sizes to minimum possible that contents are still
738 visibly (naturally some margin space will be applied as well).
741 Minimum size for the grid to still display everything.
744 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
746 This function only works properly if grid size prior to call was already
749 Note that you can also get calculated column widths by calling
750 GetState->GetColumnWidth() immediately after this function returns.
754 wxSize sz
= m_pState
->DoFitColumns();
759 Returns wxWindow that the properties are painted on, and which should
760 be used as the parent for editor controls.
762 wxPanel
* GetPanel() const
767 /** Returns current category caption background colour. */
768 wxColour
GetCaptionBackgroundColour() const { return m_colCapBack
; }
770 wxFont
& GetCaptionFont() { return m_captionFont
; }
772 const wxFont
& GetCaptionFont() const { return m_captionFont
; }
774 /** Returns current category caption text colour. */
775 wxColour
GetCaptionForegroundColour() const { return m_colCapFore
; }
777 /** Returns current cell background colour. */
778 wxColour
GetCellBackgroundColour() const { return m_colPropBack
; }
780 /** Returns current cell text colour when disabled. */
781 wxColour
GetCellDisabledTextColour() const { return m_colDisPropFore
; }
783 /** Returns current cell text colour. */
784 wxColour
GetCellTextColour() const { return m_colPropFore
; }
787 Returns number of columns currently on grid.
789 unsigned int GetColumnCount() const
791 return (unsigned int) m_pState
->m_colWidths
.size();
794 /** Returns colour of empty space below properties. */
795 wxColour
GetEmptySpaceColour() const { return m_colEmptySpace
; }
797 /** Returns height of highest characters of used font. */
798 int GetFontHeight() const { return m_fontHeight
; }
800 /** Returns pointer to itself. Dummy function that enables same kind
801 of code to use wxPropertyGrid and wxPropertyGridManager.
803 wxPropertyGrid
* GetGrid() { return this; }
805 /** Returns rectangle of custom paint image.
807 wxRect
GetImageRect( wxPGProperty
* p
, int item
) const;
809 /** Returns size of the custom paint image in front of property.
810 If no argument is given, returns preferred size.
812 wxSize
GetImageSize( wxPGProperty
* p
= NULL
, int item
= -1 ) const;
815 /** Returns last item which could be iterated using given flags.
817 See @ref propgrid_iterator_flags.
819 wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
)
821 return m_pState
->GetLastItem(flags
);
824 const wxPGProperty
* GetLastItem( int flags
= wxPG_ITERATE_DEFAULT
) const
826 return m_pState
->GetLastItem(flags
);
830 /** Returns colour of lines between cells. */
831 wxColour
GetLineColour() const { return m_colLine
; }
833 /** Returns background colour of margin. */
834 wxColour
GetMarginColour() const { return m_colMargin
; }
837 Returns most up-to-date value of selected property. This will return
838 value different from GetSelectedProperty()->GetValue() only when text
839 editor is activate and string edited by user represents valid,
840 uncommitted property value.
842 wxVariant
GetUncommittedPropertyValue();
844 /** Returns "root property". It does not have name, etc. and it is not
845 visible. It is only useful for accessing its children.
847 wxPGProperty
* GetRoot() const { return m_pState
->m_properties
; }
849 /** Returns height of a single grid row (in pixels). */
850 int GetRowHeight() const { return m_lineHeight
; }
852 /** Returns currently selected property. */
853 wxPGProperty
* GetSelectedProperty() const { return GetSelection(); }
855 /** Returns current selection background colour. */
856 wxColour
GetSelectionBackgroundColour() const { return m_colSelBack
; }
858 /** Returns current selection text colour. */
859 wxColour
GetSelectionForegroundColour() const { return m_colSelFore
; }
861 /** Returns current splitter x position. */
862 int GetSplitterPosition() const
863 { return m_pState
->DoGetSplitterPosition(0); }
865 /** Returns wxTextCtrl active in currently selected property, if any. Takes
866 into account wxOwnerDrawnComboBox.
868 wxTextCtrl
* GetEditorTextCtrl() const;
870 wxPGValidationInfo
& GetValidationInfo()
872 return m_validationInfo
;
875 /** Returns current vertical spacing. */
876 int GetVerticalSpacing() const { return (int)m_vspacing
; }
879 Returns @true if a property editor control has focus.
881 bool IsEditorFocused() const;
883 /** Returns true if editor's value was marked modified.
885 bool IsEditorsValueModified() const
886 { return ( m_iFlags
& wxPG_FL_VALUE_MODIFIED
) ? true : false; }
889 Returns information about arbitrary position in the grid.
892 Coordinates in the virtual grid space. You may need to use
893 wxScrolledWindow::CalcScrolledPosition() for translating
894 wxPropertyGrid client coordinates into something this member
897 wxPropertyGridHitTestResult
HitTest( const wxPoint
& pt
) const;
899 /** Returns true if any property has been modified by the user. */
900 bool IsAnyModified() const { return (m_pState
->m_anyModified
>0); }
903 Returns true if updating is frozen (ie Freeze() called but not yet
906 bool IsFrozen() const { return (m_frozen
>0)?true:false; }
909 It is recommended that you call this function any time your code causes
910 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
911 handler should be able to detect most changes, but it is not perfect.
914 New top-level parent that is about to be set. Old top-level parent
915 window should still exist as the current one.
917 @remarks This function is automatically called from wxPropertyGrid::
918 Reparent() and wxPropertyGridManager::Reparent(). You only
919 need to use it if you reparent wxPropertyGrid indirectly.
921 void OnTLPChanging( wxWindow
* newTLP
);
923 /** Redraws given property.
925 virtual void RefreshProperty( wxPGProperty
* p
);
928 /** Registers a new editor class.
930 Pointer to the editor class instance that should be used.
932 static wxPGEditor
* RegisterEditorClass( wxPGEditor
* editor
,
933 bool noDefCheck
= false )
935 return DoRegisterEditorClass(editor
, wxEmptyString
, noDefCheck
);
938 static wxPGEditor
* DoRegisterEditorClass( wxPGEditor
* editorClass
,
939 const wxString
& editorName
,
940 bool noDefCheck
= false );
943 /** Resets all colours to the original system values.
949 Editor widget is automatically created, but not focused unless focus is
956 True if selection finished successfully. Usually only fails if
957 current value in editor is not valid.
959 @remarks In wxPropertyGrid 1.4, this member function used to generate
960 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
963 @remarks This clears any previous selection.
965 bool SelectProperty( wxPGPropArg id
, bool focus
= false );
968 Set entire new selection from given list of properties.
970 void SetSelection( const wxArrayPGProperty
& newSelection
)
972 DoSetSelection( newSelection
, wxPG_SEL_DONT_SEND_EVENT
);
976 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
977 extra style is not used, then this has same effect as
978 calling SelectProperty().
980 @remarks Multiple selection is not supported for categories. This
981 means that if you have properties selected, you cannot
982 add category to selection, and also if you have category
983 selected, you cannot add other properties to selection.
984 This member function will fail silently in these cases,
987 bool AddToSelection( wxPGPropArg id
)
989 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
990 return DoAddToSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
994 Removes given property from selection. If property is not selected,
995 an assertion failure will occur.
997 bool RemoveFromSelection( wxPGPropArg id
)
999 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1000 return DoRemoveFromSelection(p
, wxPG_SEL_DONT_SEND_EVENT
);
1003 /** Sets category caption background colour. */
1004 void SetCaptionBackgroundColour(const wxColour
& col
);
1006 /** Sets category caption text colour. */
1007 void SetCaptionTextColour(const wxColour
& col
);
1009 /** Sets default cell background colour - applies to property cells.
1010 Note that appearance of editor widgets may not be affected.
1012 void SetCellBackgroundColour(const wxColour
& col
);
1014 /** Sets cell text colour for disabled properties.
1016 void SetCellDisabledTextColour(const wxColour
& col
);
1018 /** Sets default cell text colour - applies to property name and value text.
1019 Note that appearance of editor widgets may not be affected.
1021 void SetCellTextColour(const wxColour
& col
);
1023 /** Set number of columns (2 or more).
1025 void SetColumnCount( int colCount
)
1027 m_pState
->SetColumnCount(colCount
);
1032 Sets the 'current' category - Append will add non-category properties
1035 void SetCurrentCategory( wxPGPropArg id
)
1037 wxPG_PROP_ARG_CALL_PROLOG()
1038 wxPropertyCategory
* pc
= wxDynamicCast(p
, wxPropertyCategory
);
1040 m_pState
->m_currentCategory
= pc
;
1043 /** Sets colour of empty space below properties. */
1044 void SetEmptySpaceColour(const wxColour
& col
);
1046 /** Sets colour of lines between cells. */
1047 void SetLineColour(const wxColour
& col
);
1049 /** Sets background colour of margin. */
1050 void SetMarginColour(const wxColour
& col
);
1053 Sets selection background colour - applies to selected property name
1056 void SetSelectionBackgroundColour(const wxColour
& col
);
1059 Sets selection foreground colour - applies to selected property name
1062 void SetSelectionTextColour(const wxColour
& col
);
1064 /** Sets x coordinate of the splitter.
1066 Splitter position cannot exceed grid size, and therefore setting it
1067 during form creation may fail as initial grid size is often smaller
1068 than desired splitter position, especially when sizers are being used.
1070 void SetSplitterPosition( int newxpos
, int col
= 0 )
1072 DoSetSplitterPosition_(newxpos
, true, col
);
1073 m_iFlags
|= wxPG_FL_SPLITTER_PRE_SET
;
1077 Sets the property sorting function.
1080 The sorting function to be used. It should return a value greater
1081 than 0 if position of p1 is after p2. So, for instance, when
1082 comparing property names, you can use following implementation:
1085 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1089 return p1->GetBaseName().compare( p2->GetBaseName() );
1094 Default property sort function sorts properties by their labels
1095 (case-insensitively).
1097 @see GetSortFunction, wxPropertyGridInterface::Sort,
1098 wxPropertyGridInterface::SortChildren
1100 void SetSortFunction( wxPGSortCallback sortFunction
)
1102 m_sortFunction
= sortFunction
;
1106 Returns the property sort function (default is @NULL).
1108 @see SetSortFunction
1110 wxPGSortCallback
GetSortFunction() const
1112 return m_sortFunction
;
1115 /** Set virtual width for this particular page. Width -1 indicates that the
1116 virtual width should be disabled. */
1117 void SetVirtualWidth( int width
);
1120 Moves splitter as left as possible, while still allowing all
1121 labels to be shown in full.
1123 @param privateChildrenToo
1124 If @false, will still allow private children to be cropped.
1126 void SetSplitterLeft( bool privateChildrenToo
= false )
1128 m_pState
->SetSplitterLeft(privateChildrenToo
);
1131 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1132 height. Value of 2 should be default on most platforms.
1134 void SetVerticalSpacing( int vspacing
)
1136 m_vspacing
= (unsigned char)vspacing
;
1137 CalculateFontAndBitmapStuff( vspacing
);
1138 if ( !m_pState
->m_itemsAdded
) Refresh();
1141 /** Shows an brief error message that is related to a property. */
1142 void ShowPropertyError( wxPGPropArg id
, const wxString
& msg
)
1144 wxPG_PROP_ARG_CALL_PROLOG()
1145 DoShowPropertyError(p
, msg
);
1148 /////////////////////////////////////////////////////////////////
1150 // Following methods do not need to be (currently) documented
1152 /////////////////////////////////////////////////////////////////
1154 bool HasVirtualWidth() const
1155 { return (m_iFlags
& wxPG_FL_HAS_VIRTUAL_WIDTH
) ? true : false; }
1157 const wxPGCommonValue
* GetCommonValue( unsigned int i
) const
1159 return (wxPGCommonValue
*) m_commonValues
[i
];
1162 /** Returns number of common values.
1164 unsigned int GetCommonValueCount() const
1166 return (unsigned int) m_commonValues
.size();
1169 /** Returns label of given common value.
1171 wxString
GetCommonValueLabel( unsigned int i
) const
1173 wxASSERT( GetCommonValue(i
) );
1174 return GetCommonValue(i
)->GetLabel();
1178 Returns index of common value that will truly change value to
1181 int GetUnspecifiedCommonValue() const { return m_cvUnspecified
; }
1183 /** Set index of common value that will truly change value to unspecified.
1184 Using -1 will set none to have such effect.
1187 void SetUnspecifiedCommonValue( int index
) { m_cvUnspecified
= index
; }
1190 Shortcut for creating dialog-caller button. Used, for example, by
1193 This should only be called by properties.
1195 wxWindow
* GenerateEditorButton( const wxPoint
& pos
, const wxSize
& sz
);
1197 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1198 fits as one). Call after control has been created (but before
1201 void FixPosForTextCtrl( wxWindow
* ctrl
,
1202 const wxPoint
& offset
= wxPoint(0, 0) );
1204 /** Shortcut for creating text editor widget.
1206 Same as pos given for CreateEditor.
1208 Same as sz given for CreateEditor.
1210 Initial text for wxTextCtrl.
1212 If right-side control, such as button, also created, then create it
1213 first and pass it as this parameter.
1215 Extra style flags to pass for wxTextCtrl.
1217 Note that this should generally be called only by new classes derived
1220 wxWindow
* GenerateEditorTextCtrl( const wxPoint
& pos
,
1222 const wxString
& value
,
1223 wxWindow
* secondary
,
1227 /* Generates both textctrl and button.
1229 wxWindow
* GenerateEditorTextCtrlAndButton( const wxPoint
& pos
,
1230 const wxSize
& sz
, wxWindow
** psecondary
, int limited_editing
,
1231 wxPGProperty
* property
);
1233 /** Generates position for a widget editor dialog box.
1235 Property for which dialog is positioned.
1237 Known or over-approximated size of the dialog.
1239 Position for dialog.
1241 wxPoint
GetGoodEditorDialogPosition( wxPGProperty
* p
,
1244 // Converts escape sequences in src_str to newlines,
1245 // tabs, etc. and copies result to dst_str.
1246 static wxString
& ExpandEscapeSequences( wxString
& dst_str
,
1247 wxString
& src_str
);
1249 // Converts newlines, tabs, etc. in src_str to escape
1250 // sequences, and copies result to dst_str.
1251 static wxString
& CreateEscapeSequences( wxString
& dst_str
,
1252 wxString
& src_str
);
1255 Returns rectangle that fully contains properties between and including
1258 wxRect
GetPropertyRect( const wxPGProperty
* p1
,
1259 const wxPGProperty
* p2
) const;
1261 /** Returns pointer to current active primary editor control (NULL if none).
1263 wxWindow
* GetEditorControl() const;
1265 wxWindow
* GetPrimaryEditor() const
1267 return GetEditorControl();
1271 Returns pointer to current active secondary editor control (NULL if
1274 wxWindow
* GetEditorControlSecondary() const
1276 return m_wndEditor2
;
1280 Refreshes any active editor control.
1282 void RefreshEditor();
1284 // Events from editor controls are forward to this function
1285 void HandleCustomEditorEvent( wxEvent
&event
);
1290 Generates contents for string dst based on the contents of
1293 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1294 so on. Set flags to 1 inorder to convert backslashes to double-back-
1295 slashes and "(preDelims)"'s to "(preDelims)".
1297 static void ArrayStringToString( wxString
& dst
, const wxArrayString
& src
,
1298 wxChar preDelim
, wxChar postDelim
,
1301 // Mostly useful for page switching.
1302 void SwitchState( wxPropertyGridPageState
* pNewState
);
1304 long GetInternalFlags() const { return m_iFlags
; }
1305 bool HasInternalFlag( long flag
) const
1306 { return (m_iFlags
& flag
) ? true : false; }
1307 void SetInternalFlag( long flag
) { m_iFlags
|= flag
; }
1308 void ClearInternalFlag( long flag
) { m_iFlags
&= ~(flag
); }
1309 void IncFrozen() { m_frozen
++; }
1310 void DecFrozen() { m_frozen
--; }
1312 void OnComboItemPaint( const wxPGComboBox
* pCb
,
1318 /** Standardized double-to-string conversion.
1320 static void DoubleToString( wxString
& target
,
1324 wxString
* precTemplate
);
1327 Call this from wxPGProperty::OnEvent() to cause property value to be
1328 changed after the function returns (with true as return value).
1329 ValueChangeInEvent() must be used if you wish the application to be
1330 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1332 void ValueChangeInEvent( wxVariant variant
)
1334 m_changeInEventValue
= variant
;
1335 m_iFlags
|= wxPG_FL_VALUE_CHANGE_IN_EVENT
;
1339 You can use this member function, for instance, to detect in
1340 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1341 already called in wxPGEditor::OnEvent(). It really only detects
1342 if was value was changed using wxPGProperty::SetValueInEvent(), which
1343 is usually used when a 'picker' dialog is displayed. If value was
1344 written by "normal means" in wxPGProperty::StringToValue() or
1345 IntToValue(), then this function will return false (on the other hand,
1346 wxPGProperty::OnEvent() is not even called in those cases).
1348 bool WasValueChangedInEvent() const
1350 return (m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
) ? true : false;
1353 /** Returns true if given event is from first of an array of buttons
1354 (as can be in case when wxPGMultiButton is used).
1356 bool IsMainButtonEvent( const wxEvent
& event
)
1358 return (event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
1359 && (m_wndSecId
== event
.GetId());
1362 /** Pending value is expected to be passed in PerformValidation().
1364 virtual bool DoPropertyChanged( wxPGProperty
* p
,
1365 unsigned int selFlags
= 0 );
1367 /** Called when validation for given property fails.
1369 Value which failed in validation.
1371 Return true if user is allowed to change to another property even
1372 if current has invalid value.
1374 To add your own validation failure behavior, override
1375 wxPropertyGrid::DoOnValidationFailure().
1377 bool OnValidationFailure( wxPGProperty
* property
,
1378 wxVariant
& invalidValue
);
1380 /** Called to indicate property and editor has valid value now.
1382 void OnValidationFailureReset( wxPGProperty
* property
)
1384 if ( property
&& property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
1386 DoOnValidationFailureReset(property
);
1387 property
->ClearFlag(wxPG_PROP_INVALID_VALUE
);
1389 m_validationInfo
.m_failureMessage
.clear();
1392 /** Override in derived class to display error messages in custom manner
1393 (these message usually only result from validation failure).
1395 virtual void DoShowPropertyError( wxPGProperty
* property
,
1396 const wxString
& msg
);
1398 /** Override to customize property validation failure behavior.
1400 Value which failed in validation.
1402 Return true if user is allowed to change to another property even
1403 if current has invalid value.
1405 virtual bool DoOnValidationFailure( wxPGProperty
* property
,
1406 wxVariant
& invalidValue
);
1408 /** Override to customize resetting of property validation failure status.
1410 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1412 virtual void DoOnValidationFailureReset( wxPGProperty
* property
);
1414 int GetSpacingY() const { return m_spacingy
; }
1417 Must be called in wxPGEditor::CreateControls() if primary editor window
1418 is wxTextCtrl, just before textctrl is created.
1420 Initial text value of created wxTextCtrl.
1422 void SetupTextCtrlValue( const wxString text
) { m_prevTcValue
= text
; }
1425 Unfocuses or closes editor if one was open, but does not deselect
1428 bool UnfocusEditor();
1430 virtual void SetWindowStyleFlag( long style
);
1432 void DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
);
1434 void DrawItem( wxPGProperty
* p
)
1439 virtual void DrawItemAndChildren( wxPGProperty
* p
);
1442 Draws item, children, and consequtive parents as long as category is
1445 void DrawItemAndValueRelated( wxPGProperty
* p
);
1450 wxPropertyGridPageState used by the grid is created here.
1452 If grid is used in wxPropertyGridManager, there is no point overriding
1453 this - instead, set custom wxPropertyGridPage classes.
1455 virtual wxPropertyGridPageState
* CreateState() const;
1457 enum PerformValidationFlags
1459 SendEvtChanging
= 0x0001,
1460 IsStandaloneValidation
= 0x0002 // Not called in response to event
1464 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1465 Returns true if all tests passed. Implement in derived class to
1466 add additional validation behavior.
1468 virtual bool PerformValidation( wxPGProperty
* p
,
1469 wxVariant
& pendingValue
,
1470 int flags
= SendEvtChanging
);
1474 // Control font changer helper.
1475 void SetCurControlBoldFont();
1477 wxPGCell
& GetPropertyDefaultCell()
1479 return m_propertyDefaultCell
;
1482 wxPGCell
& GetCategoryDefaultCell()
1484 return m_categoryDefaultCell
;
1488 // Public methods for semi-public use
1490 bool DoSelectProperty( wxPGProperty
* p
, unsigned int flags
= 0 );
1492 // Overridden functions.
1493 virtual bool Destroy();
1494 // Returns property at given y coordinate (relative to grid's top left).
1495 wxPGProperty
* GetItemAtY( int y
) const { return DoGetItemAtY(y
); }
1497 virtual void Refresh( bool eraseBackground
= true,
1498 const wxRect
*rect
= (const wxRect
*) NULL
);
1499 virtual bool SetFont( const wxFont
& font
);
1500 #if wxPG_SUPPORT_TOOLTIPS
1501 void SetToolTip( const wxString
& tipString
);
1503 virtual void Freeze();
1504 virtual void SetExtraStyle( long exStyle
);
1505 virtual void Thaw();
1506 virtual bool Reparent( wxWindowBase
*newParent
);
1509 virtual wxSize
DoGetBestSize() const;
1511 #ifndef wxPG_ICON_WIDTH
1512 wxBitmap
*m_expandbmp
, *m_collbmp
;
1515 wxCursor
*m_cursorSizeWE
;
1517 /** wxWindow pointers to editor control(s). */
1518 wxWindow
*m_wndEditor
;
1519 wxWindow
*m_wndEditor2
;
1521 /** wxPGCanvas instance. */
1524 #if wxPG_DOUBLE_BUFFER
1525 wxBitmap
*m_doubleBuffer
;
1528 /** Local time ms when control was created. */
1529 wxLongLong m_timeCreated
;
1531 /** wxPGProperty::OnEvent can change value by setting this. */
1532 wxVariant m_changeInEventValue
;
1534 /** Id of m_wndEditor2, or its first child, if any. */
1537 /** Extra Y spacing between the items. */
1540 /** Control client area width; updated on resize. */
1543 /** Control client area height; updated on resize. */
1546 /** Current non-client width (needed when auto-centering). */
1549 /** Non-client width (auto-centering helper). */
1552 /** Previously recorded scroll start position. */
1556 The gutter spacing in front and back of the image.
1557 This determines the amount of spacing in front of each item
1561 /** Includes separator line. */
1564 /** Gutter*2 + image width. */
1567 // y spacing for expand/collapse button.
1568 int m_buttonSpacingY
;
1570 /** Extra margin for expanded sub-group items. */
1571 int m_subgroup_extramargin
;
1574 The image width of the [+] icon.
1576 This is also calculated in the gutter
1580 #ifndef wxPG_ICON_WIDTH
1583 The image height of the [+] icon.
1585 This is calculated as minimal size and to align
1590 /** Current cursor id. */
1594 This captionFont is made equal to the font of the wxScrolledWindow.
1596 As extra the bold face is set on it when this is wanted by the user
1599 wxFont m_captionFont
;
1601 int m_fontHeight
; // Height of the font.
1603 /** m_splitterx when drag began. */
1604 int m_startingSplitterX
;
1607 Index to splitter currently being dragged (0=one after the first
1610 int m_draggedSplitter
;
1612 /** Changed property, calculated in PerformValidation(). */
1613 wxPGProperty
* m_chgInfo_changedProperty
;
1616 Lowest property for which editing happened, but which does not have
1619 wxPGProperty
* m_chgInfo_baseChangedProperty
;
1621 /** Changed property value, calculated in PerformValidation(). */
1622 wxVariant m_chgInfo_pendingValue
;
1624 /** Passed to SetValue. */
1625 wxVariant m_chgInfo_valueList
;
1627 /** Validation information. */
1628 wxPGValidationInfo m_validationInfo
;
1630 /** Actions and keys that trigger them. */
1631 wxPGHashMapI2I m_actionTriggers
;
1637 /** Bits are used to indicate which colours are customized. */
1638 unsigned short m_coloursCustomized
;
1640 /** x - m_splitterx. */
1641 signed char m_dragOffset
;
1643 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1644 unsigned char m_dragStatus
;
1646 /** 0 = margin, 1 = label, 2 = value. */
1647 unsigned char m_mouseSide
;
1649 /** True when editor control is focused. */
1650 unsigned char m_editorFocused
;
1652 /** 1 if m_latsCaption is also the bottommost caption. */
1653 //unsigned char m_lastCaptionBottomnest;
1655 /** Set to 1 when graphics frozen. */
1656 unsigned char m_frozen
;
1658 unsigned char m_vspacing
;
1660 // Used to track when Alt/Ctrl+Key was consumed.
1661 unsigned char m_keyComboConsumed
;
1663 /** 1 if in DoPropertyChanged() */
1664 unsigned char m_inDoPropertyChanged
;
1666 /** 1 if in CommitChangesFromEditor() */
1667 unsigned char m_inCommitChangesFromEditor
;
1669 /** 1 if in DoSelectProperty() */
1670 unsigned char m_inDoSelectProperty
;
1672 wxPGVFBFlags m_permanentValidationFailureBehavior
; // Set by app
1674 /** Internal flags - see wxPG_FL_XXX constants. */
1677 /** When drawing next time, clear this many item slots at the end. */
1678 int m_clearThisMany
;
1680 // pointer to property that has mouse hovering
1681 wxPGProperty
* m_propHover
;
1683 // EventObject for wxPropertyGridEvents
1684 wxWindow
* m_eventObject
;
1686 // What (global) window is currently focused (needed to resolve event
1688 wxWindow
* m_curFocused
;
1690 // Last known top-level parent
1693 // Last closed top-level parent
1694 wxWindow
* m_tlpClosed
;
1696 // Local time ms when tlp was closed.
1697 wxLongLong m_tlpClosedTime
;
1700 wxPGSortCallback m_sortFunction
;
1702 // y coordinate of property that mouse hovering
1704 // Which column's editor is selected (usually 1)?
1707 // x relative to splitter (needed for resize).
1710 // lines between cells
1712 // property labels and values are written in this colour
1713 wxColour m_colPropFore
;
1714 // or with this colour when disabled
1715 wxColour m_colDisPropFore
;
1716 // background for m_colPropFore
1717 wxColour m_colPropBack
;
1718 // text color for captions
1719 wxColour m_colCapFore
;
1720 // background color for captions
1721 wxColour m_colCapBack
;
1722 // foreground for selected property
1723 wxColour m_colSelFore
;
1724 // background for selected property (actually use background color when
1725 // control out-of-focus)
1726 wxColour m_colSelBack
;
1727 // background colour for margin
1728 wxColour m_colMargin
;
1729 // background colour for empty space below the grid
1730 wxColour m_colEmptySpace
;
1732 // Default property colours
1733 wxPGCell m_propertyDefaultCell
;
1735 // Default property category
1736 wxPGCell m_categoryDefaultCell
;
1738 // Backup of selected property's cells
1739 wxVector
<wxPGCell
> m_propCellsBackup
;
1741 // NB: These *cannot* be moved to globals.
1743 // labels when properties use common values
1744 wxVector
<wxPGCommonValue
*> m_commonValues
;
1746 // Which cv selection really sets value to unspecified?
1747 int m_cvUnspecified
;
1749 // Used to skip excess text editor events
1750 wxString m_prevTcValue
;
1754 // Sets some members to defaults (called constructors).
1757 // Initializes some members (called by Create and complex constructor).
1760 void OnPaint(wxPaintEvent
&event
);
1762 // main event receivers
1763 void OnMouseMove( wxMouseEvent
&event
);
1764 void OnMouseMoveBottom( wxMouseEvent
&event
);
1765 void OnMouseClick( wxMouseEvent
&event
);
1766 void OnMouseRightClick( wxMouseEvent
&event
);
1767 void OnMouseDoubleClick( wxMouseEvent
&event
);
1768 void OnMouseUp( wxMouseEvent
&event
);
1769 void OnKey( wxKeyEvent
&event
);
1770 void OnResize( wxSizeEvent
&event
);
1773 bool HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
);
1774 bool HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1775 bool HandleMouseRightClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1776 bool HandleMouseDoubleClick( int x
, unsigned int y
, wxMouseEvent
&event
);
1777 bool HandleMouseUp( int x
, unsigned int y
, wxMouseEvent
&event
);
1778 void HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
);
1780 void OnMouseEntry( wxMouseEvent
&event
);
1782 void OnIdle( wxIdleEvent
&event
);
1783 void OnFocusEvent( wxFocusEvent
&event
);
1784 void OnChildFocusEvent( wxChildFocusEvent
& event
);
1786 bool OnMouseCommon( wxMouseEvent
&event
, int* px
, int *py
);
1787 bool OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
);
1789 // sub-control event handlers
1790 void OnMouseClickChild( wxMouseEvent
&event
);
1791 void OnMouseRightClickChild( wxMouseEvent
&event
);
1792 void OnMouseMoveChild( wxMouseEvent
&event
);
1793 void OnMouseUpChild( wxMouseEvent
&event
);
1794 void OnChildKeyDown( wxKeyEvent
&event
);
1796 void OnCaptureChange( wxMouseCaptureChangedEvent
&event
);
1798 void OnScrollEvent( wxScrollWinEvent
&event
);
1800 void OnSysColourChanged( wxSysColourChangedEvent
&event
);
1802 void OnTLPClose( wxCloseEvent
& event
);
1806 bool AddToSelectionFromInputEvent( wxPGProperty
* prop
,
1807 wxMouseEvent
* event
= NULL
,
1811 Adjust the centering of the bitmap icons (collapse / expand) when the
1812 caption font changes.
1814 They need to be centered in the middle of the font, so a bit of deltaY
1815 adjustment is needed. On entry, m_captionFont must be set to window
1816 font. It will be modified properly.
1818 void CalculateFontAndBitmapStuff( int vspacing
);
1820 wxRect
GetEditorWidgetRect( wxPGProperty
* p
, int column
) const;
1822 void CorrectEditorWidgetSizeX();
1824 /** Called in RecalculateVirtualSize() to reposition control
1825 on virtual height changes.
1827 void CorrectEditorWidgetPosY();
1829 int DoDrawItems( wxDC
& dc
,
1830 const wxRect
* clipRect
,
1831 bool isBuffered
) const;
1833 /** Draws an expand/collapse (ie. +/-) button.
1835 virtual void DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1836 wxPGProperty
* property
) const;
1838 /** Draws items from topitemy to bottomitemy */
1839 void DrawItems( wxDC
& dc
, unsigned int topitemy
, unsigned int bottomitemy
,
1840 const wxRect
* clip_rect
= (const wxRect
*) NULL
);
1842 // Translate wxKeyEvent to wxPG_ACTION_XXX
1843 int KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const;
1845 int KeyEventToAction(wxKeyEvent
&event
) const
1847 return KeyEventToActions(event
, NULL
);
1850 void ImprovedClientToScreen( int* px
, int* py
);
1852 // Called by focus event handlers. newFocused is the window that becomes
1854 void HandleFocusChange( wxWindow
* newFocused
);
1856 /** Reloads all non-customized colours from system settings. */
1857 void RegainColours();
1859 bool DoEditorValidate();
1861 void DoSetSelection( const wxArrayPGProperty
& newSelection
,
1864 bool DoAddToSelection( wxPGProperty
* prop
,
1867 bool DoRemoveFromSelection( wxPGProperty
* prop
,
1870 wxPGProperty
* DoGetItemAtY( int y
) const;
1872 void DoSetSplitterPosition_( int newxpos
,
1873 bool refresh
= true,
1874 int splitterIndex
= 0,
1875 bool allPages
= false );
1879 virtual bool DoExpand( wxPGProperty
* p
, bool sendEvent
= false );
1881 virtual bool DoCollapse( wxPGProperty
* p
, bool sendEvent
= false );
1883 // Returns nearest paint visible property (such that will be painted unless
1884 // window is scrolled or resized). If given property is paint visible, then
1885 // it itself will be returned.
1886 wxPGProperty
* GetNearestPaintVisible( wxPGProperty
* p
) const;
1888 static void RegisterDefaultEditors();
1890 // Sets up basic event handling for child control
1891 void SetupChildEventHandling( wxWindow
* wnd
);
1893 void CustomSetCursor( int type
, bool override
= false );
1896 Repositions scrollbar and underlying panel according to changed virtual
1899 void RecalculateVirtualSize( int forceXPos
= -1 );
1901 void PrepareAfterItemsAdded();
1903 bool SendEvent( int eventType
,
1905 wxVariant
* pValue
= NULL
,
1906 unsigned int selFlags
= 0 );
1908 void SetFocusOnCanvas();
1910 bool DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
);
1914 bool ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
);
1916 DECLARE_EVENT_TABLE()
1917 #endif // #ifndef SWIG
1920 // -----------------------------------------------------------------------
1922 // Bunch of inlines that need to resolved after all classes have been defined.
1926 inline bool wxPropertyGridPageState::IsDisplayed() const
1928 return ( this == m_pPropGrid
->GetState() );
1931 inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
1933 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
1937 inline int wxPGProperty::GetDisplayedCommonValueCount() const
1939 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE
) )
1941 wxPropertyGrid
* pg
= GetGrid();
1943 return (int) pg
->GetCommonValueCount();
1948 inline void wxPGProperty::SetDefaultValue( wxVariant
& value
)
1950 SetAttribute(wxPG_ATTR_DEFAULT_VALUE
, value
);
1953 inline void wxPGProperty::SetEditor( const wxString
& editorName
)
1955 m_customEditor
= wxPropertyGridInterface::GetEditorByName(editorName
);
1958 inline bool wxPGProperty::Hide( bool hide
, int flags
)
1960 return GetGrid()->HideProperty(this, hide
, flags
);
1963 inline bool wxPGProperty::SetMaxLength( int maxLen
)
1965 return GetGrid()->SetPropertyMaxLength(this,maxLen
);
1968 // -----------------------------------------------------------------------
1970 #define wxPG_BASE_EVT_PRE_ID 1775
1974 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
1975 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
1976 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
1977 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
1978 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
1979 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
1980 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
1981 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
1982 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID
, wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
1986 wxEVT_PG_SELECTED
= wxPG_BASE_EVT_PRE_ID
,
1989 wxEVT_PG_HIGHLIGHTED
,
1990 wxEVT_PG_RIGHT_CLICK
,
1991 wxEVT_PG_PAGE_CHANGED
,
1992 wxEVT_PG_ITEM_COLLAPSED
,
1993 wxEVT_PG_ITEM_EXPANDED
,
1994 wxEVT_PG_DOUBLE_CLICK
1999 #define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2000 #define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2004 typedef void (wxEvtHandler::*wxPropertyGridEventFunction
)(wxPropertyGridEvent
&);
2006 #define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2007 #define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2008 #define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2009 #define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2010 #define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2011 #define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2012 #define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2013 #define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2014 #define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2016 #define wxPropertyGridEventHandler(fn) \
2017 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
2022 /** @class wxPropertyGridEvent
2024 A propertygrid event holds information about events associated with
2025 wxPropertyGrid objects.
2027 @library{wxpropgrid}
2030 class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent
: public wxCommandEvent
2035 wxPropertyGridEvent(wxEventType commandType
=0, int id
=0);
2037 /** Copy constructor. */
2038 wxPropertyGridEvent(const wxPropertyGridEvent
& event
);
2041 ~wxPropertyGridEvent();
2044 virtual wxEvent
* Clone() const;
2046 wxPGProperty
* GetMainParent() const
2048 wxASSERT(m_property
);
2049 return m_property
->GetMainParent();
2052 /** Returns id of associated property. */
2053 wxPGProperty
* GetProperty() const
2058 wxPGValidationInfo
& GetValidationInfo()
2060 wxASSERT(m_validationInfo
);
2061 return *m_validationInfo
;
2064 /** Returns true if you can veto the action that the event is signaling.
2066 bool CanVeto() const { return m_canVeto
; }
2069 Call this from your event handler to veto action that the event is
2072 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2075 Currently only wxEVT_PG_CHANGING supports vetoing.
2077 void Veto( bool veto
= true ) { m_wasVetoed
= veto
; }
2079 /** Returns value that is about to be set for wxEVT_PG_CHANGING.
2081 const wxVariant
& GetValue() const
2083 wxASSERT_MSG( m_validationInfo
,
2084 "Only call GetValue from a handler "
2085 "of event type that supports it" );
2086 return m_validationInfo
->GetValue();
2090 Set override validation failure behavior.
2092 Only effective if Veto was also called, and only allowed if event type
2093 is wxEVT_PG_CHANGING.
2095 void SetValidationFailureBehavior( wxPGVFBFlags flags
)
2097 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2098 m_validationInfo
->SetFailureBehavior( flags
);
2101 /** Sets custom failure message for this time only. Only applies if
2102 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2104 void SetValidationFailureMessage( const wxString
& message
)
2106 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2107 m_validationInfo
->SetFailureMessage( message
);
2111 wxPGVFBFlags
GetValidationFailureBehavior() const
2113 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2114 return m_validationInfo
->GetFailureBehavior();
2117 void SetCanVeto( bool canVeto
) { m_canVeto
= canVeto
; }
2118 bool WasVetoed() const { return m_wasVetoed
; }
2120 /** Changes the associated property. */
2121 void SetProperty( wxPGProperty
* p
) { m_property
= p
; }
2123 void SetPropertyGrid( wxPropertyGrid
* pg
) { m_pg
= pg
; }
2125 void SetupValidationInfo()
2128 wxASSERT( GetEventType() == wxEVT_PG_CHANGING
);
2129 m_validationInfo
= &m_pg
->GetValidationInfo();
2134 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent
)
2136 wxPGProperty
* m_property
;
2137 wxPropertyGrid
* m_pg
;
2138 wxPGValidationInfo
* m_validationInfo
;
2147 // -----------------------------------------------------------------------
2149 /** @class wxPropertyGridPopulator
2151 Allows populating wxPropertyGrid from arbitrary text source.
2153 class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2156 /** Default constructor.
2158 wxPropertyGridPopulator();
2161 virtual ~wxPropertyGridPopulator();
2163 void SetState( wxPropertyGridPageState
* state
);
2165 void SetGrid( wxPropertyGrid
* pg
);
2167 /** Appends a new property under bottommost parent.
2169 Property class as string.
2171 wxPGProperty
* Add( const wxString
& propClass
,
2172 const wxString
& propLabel
,
2173 const wxString
& propName
,
2174 const wxString
* propValue
,
2175 wxPGChoices
* pChoices
= NULL
);
2178 Pushes property to the back of parent array (ie it becomes bottommost
2179 parent), and starts scanning/adding children for it.
2181 When finished, parent array is returned to the original state.
2183 void AddChildren( wxPGProperty
* property
);
2185 /** Adds attribute to the bottommost property.
2187 Allowed values: "string", (same as string), "int", "bool". Empty string
2190 bool AddAttribute( const wxString
& name
,
2191 const wxString
& type
,
2192 const wxString
& value
);
2194 /** Called once in AddChildren.
2196 virtual void DoScanForChildren() = 0;
2199 Returns id of parent property for which children can currently be
2202 wxPGProperty
* GetCurParent() const
2204 return (wxPGProperty
*) m_propHierarchy
[m_propHierarchy
.size()-1];
2207 wxPropertyGridPageState
* GetState() { return m_state
; }
2208 const wxPropertyGridPageState
* GetState() const { return m_state
; }
2210 /** Like wxString::ToLong, except allows N% in addition of N.
2212 static bool ToLongPCT( const wxString
& s
, long* pval
, long max
);
2214 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2215 wxPGChoices. Registers parsed result using idString (if not empty).
2216 Also, if choices with given id already registered, then don't parse but
2217 return those choices instead.
2219 wxPGChoices
ParseChoices( const wxString
& choicesString
,
2220 const wxString
& idString
);
2222 /** Implement in derived class to do custom process when an error occurs.
2223 Default implementation uses wxLogError.
2225 virtual void ProcessError( const wxString
& msg
);
2229 /** Used property grid. */
2230 wxPropertyGrid
* m_pg
;
2232 /** Used property grid state. */
2233 wxPropertyGridPageState
* m_state
;
2235 /** Tree-hierarchy of added properties (that can have children). */
2236 wxArrayPGProperty m_propHierarchy
;
2238 /** Hashmap for string-id to wxPGChoicesData mapping. */
2239 wxPGHashMapS2P m_dictIdChoices
;
2242 // -----------------------------------------------------------------------
2245 // Undefine macros that are not needed outside propertygrid sources
2247 #ifndef __wxPG_SOURCE_FILE__
2248 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2249 #undef wxPG_FL_SCROLLBAR_DETECTED
2250 #undef wxPG_FL_CREATEDSTATE
2251 #undef wxPG_FL_NOSTATUSBARHELP
2252 #undef wxPG_FL_SCROLLED
2253 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2254 #undef wxPG_FL_FOCUS_INSIDE
2255 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2256 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2257 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2258 #undef wxPG_FL_VALUE_MODIFIED
2259 #undef wxPG_FL_MOUSE_INSIDE
2260 #undef wxPG_FL_FOCUSED
2261 #undef wxPG_FL_MOUSE_CAPTURED
2262 #undef wxPG_FL_INITIALIZED
2263 #undef wxPG_FL_ACTIVATION_BY_CLICK
2264 #undef wxPG_FL_DONT_CENTER_SPLITTER
2265 #undef wxPG_SUPPORT_TOOLTIPS
2266 #undef wxPG_DOUBLE_BUFFER
2267 #undef wxPG_ICON_WIDTH
2268 #undef wxPG_USE_RENDERER_NATIVE
2269 // Following are needed by the manager headers
2270 // #undef const wxString&
2273 // -----------------------------------------------------------------------
2277 #endif // _WX_PROPGRID_PROPGRID_H_