1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/propgrid/property.h
3 // Purpose: wxPGProperty and related support classes
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_PROPGRID_PROPERTY_H_
13 #define _WX_PROPGRID_PROPERTY_H_
17 #include "wx/propgrid/propgriddefs.h"
19 // -----------------------------------------------------------------------
21 #define wxNullProperty ((wxPGProperty*)NULL)
24 /** @class wxPGPaintData
26 Contains information relayed to property's OnCustomPaint.
30 /** wxPropertyGrid. */
31 const wxPropertyGrid
* m_parent
;
34 Normally -1, otherwise index to drop-down list item that has to be
39 /** Set to drawn width in OnCustomPaint (optional). */
43 In a measure item call, set this to the height of item at m_choiceItem
53 // space between vertical sides of a custom image
54 #define wxPG_CUSTOM_IMAGE_SPACINGY 1
56 // space between caption and selection rectangle,
57 #define wxPG_CAPRECTXMARGIN 2
59 // horizontally and vertically
60 #define wxPG_CAPRECTYMARGIN 1
63 /** @class wxPGCellRenderer
65 Base class for wxPropertyGrid cell renderers.
67 class WXDLLIMPEXP_PROPGRID wxPGCellRenderer
71 wxPGCellRenderer( unsigned int refCount
= 1 )
72 : m_refCount(refCount
) { }
73 virtual ~wxPGCellRenderer() { }
78 Selected
= 0x00010000,
82 virtual void Render( wxDC
& dc
,
84 const wxPropertyGrid
* propertyGrid
,
85 wxPGProperty
* property
,
88 int flags
) const = 0;
90 /** Returns size of the image in front of the editable area.
92 If property is NULL, then this call is for a custom value. In that case
93 the item is index to wxPropertyGrid's custom values.
95 virtual wxSize
GetImageSize( const wxPGProperty
* property
,
99 /** Paints property category selection rectangle.
101 virtual void DrawCaptionSelectionRect( wxDC
& dc
,
103 int w
, int h
) const;
105 /** Utility to draw vertically centered text.
107 void DrawText( wxDC
& dc
,
110 const wxString
& text
) const;
113 Utility to draw editor's value, or vertically aligned text if editor is
116 void DrawEditorValue( wxDC
& dc
, const wxRect
& rect
,
117 int xOffset
, const wxString
& text
,
118 wxPGProperty
* property
,
119 const wxPGEditor
* editor
) const;
121 /** Utility to render cell bitmap and set text colour plus bg brush colour.
123 Returns image width that, for instance, can be passed to DrawText.
125 int PreDrawCell( wxDC
& dc
,
127 const wxPGCell
& cell
,
144 unsigned int m_refCount
;
150 Base class for simple wxPropertyGrid cell information.
152 class WXDLLIMPEXP_PROPGRID wxPGCell
156 wxPGCell( const wxString
& text
,
157 const wxBitmap
& bitmap
= wxNullBitmap
,
158 const wxColour
& fgCol
= wxNullColour
,
159 const wxColour
& bgCol
= wxNullColour
);
161 virtual ~wxPGCell() { }
163 void SetText( const wxString
& text
) { m_text
= text
; }
164 void SetBitmap( const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
165 void SetFgCol( const wxColour
& col
) { m_fgCol
= col
; }
166 void SetBgCol( const wxColour
& col
) { m_bgCol
= col
; }
168 const wxString
& GetText() const { return m_text
; }
169 const wxBitmap
& GetBitmap() const { return m_bitmap
; }
170 const wxColour
& GetFgCol() const { return m_fgCol
; }
171 const wxColour
& GetBgCol() const { return m_bgCol
; }
181 /** @class wxPGDefaultRenderer
183 Default cell renderer, that can handles the common
186 class WXDLLIMPEXP_PROPGRID wxPGDefaultRenderer
: public wxPGCellRenderer
189 virtual void Render( wxDC
& dc
,
191 const wxPropertyGrid
* propertyGrid
,
192 wxPGProperty
* property
,
197 virtual wxSize
GetImageSize( const wxPGProperty
* property
,
204 // -----------------------------------------------------------------------
206 /** @class wxPGAttributeStorage
208 wxPGAttributeStorage is somewhat optimized storage for
209 key=variant pairs (ie. a map).
211 class WXDLLIMPEXP_PROPGRID wxPGAttributeStorage
214 wxPGAttributeStorage();
215 ~wxPGAttributeStorage();
217 void Set( const wxString
& name
, const wxVariant
& value
);
218 unsigned int GetCount() const { return (unsigned int) m_map
.size(); }
219 wxVariant
FindValue( const wxString
& name
) const
221 wxPGHashMapS2P::const_iterator it
= m_map
.find(name
);
222 if ( it
!= m_map
.end() )
224 wxVariantData
* data
= (wxVariantData
*) it
->second
;
226 return wxVariant(data
, it
->first
);
231 typedef wxPGHashMapS2P::const_iterator const_iterator
;
232 const_iterator
StartIteration() const
234 return m_map
.begin();
236 bool GetNext( const_iterator
& it
, wxVariant
& variant
) const
238 if ( it
== m_map
.end() )
241 wxVariantData
* data
= (wxVariantData
*) it
->second
;
243 variant
.SetData(data
);
244 variant
.SetName(it
->first
);
250 wxPGHashMapS2P m_map
;
255 // -----------------------------------------------------------------------
257 /** @section propgrid_propflags wxPGProperty Flags
261 enum wxPG_PROPERTY_FLAGS
264 /** Indicates bold font.
266 wxPG_PROP_MODIFIED
= 0x0001,
268 /** Disables ('greyed' text and editor does not activate) property.
270 wxPG_PROP_DISABLED
= 0x0002,
272 /** Hider button will hide this property.
274 wxPG_PROP_HIDDEN
= 0x0004,
276 /** This property has custom paint image just in front of its value.
277 If property only draws custom images into a popup list, then this
278 flag should not be set.
280 wxPG_PROP_CUSTOMIMAGE
= 0x0008,
282 /** Do not create text based editor for this property (but button-triggered
283 dialog and choice are ok).
285 wxPG_PROP_NOEDITOR
= 0x0010,
287 /** Property is collapsed, ie. it's children are hidden.
289 wxPG_PROP_COLLAPSED
= 0x0020,
292 If property is selected, then indicates that validation failed for pending
295 If property is not selected, then indicates that the the actual property
296 value has failed validation (NB: this behavior is not currently supported,
297 but may be used in future).
299 wxPG_PROP_INVALID_VALUE
= 0x0040,
303 /** Switched via SetWasModified(). Temporary flag - only used when
304 setting/changing property value.
306 wxPG_PROP_WAS_MODIFIED
= 0x0200,
309 If set, then child properties (if any) are private, and should be
310 "invisible" to the application.
312 wxPG_PROP_AGGREGATE
= 0x0400,
314 /** If set, then child properties (if any) are copies and should not
317 wxPG_PROP_CHILDREN_ARE_COPIES
= 0x0800,
320 Classifies this item as a non-category.
322 Used for faster item type identification.
324 wxPG_PROP_PROPERTY
= 0x1000,
327 Classifies this item as a category.
329 Used for faster item type identification.
331 wxPG_PROP_CATEGORY
= 0x2000,
333 /** Classifies this item as a property that has children, but is not aggregate
334 (ie children are not private).
336 wxPG_PROP_MISC_PARENT
= 0x4000,
338 /** Property is read-only. Editor is still created.
340 wxPG_PROP_READONLY
= 0x8000,
343 // NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS
346 /** Property's value is composed from values of child properties.
348 This flag cannot be used with property iterators.
350 wxPG_PROP_COMPOSED_VALUE
= 0x00010000,
352 /** Common value of property is selectable in editor.
354 This flag cannot be used with property iterators.
356 wxPG_PROP_USES_COMMON_VALUE
= 0x00020000,
358 /** Property can be set to unspecified value via editor.
359 Currently, this applies to following properties:
360 - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty:
364 This flag cannot be used with property iterators.
366 wxPG_PROP_AUTO_UNSPECIFIED
= 0x00040000,
368 /** Indicates the bit useable by derived properties.
370 wxPG_PROP_CLASS_SPECIFIC_1
= 0x00080000,
372 /** Indicates the bit useable by derived properties.
374 wxPG_PROP_CLASS_SPECIFIC_2
= 0x00100000
380 #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED
382 /** Property with children must have one of these set, otherwise iterators
383 will not work correctly.
384 Code should automatically take care of this, however.
386 #define wxPG_PROP_PARENTAL_FLAGS \
387 (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT)
392 // Combination of flags that can be stored by GetFlagsAsString
393 #define wxPG_STRING_STORED_FLAGS \
394 (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED)
396 // -----------------------------------------------------------------------
401 @section propgrid_property_attributes wxPropertyGrid Property Attribute
404 wxPGProperty::SetAttribute() and
405 wxPropertyGridInterface::SetPropertyAttribute() accept one of these as
406 attribute name argument.
408 You can use strings instead of constants. However, some of these
409 constants are redefined to use cached strings which may reduce
410 your binary size by some amount.
415 /** Set default value for property.
417 #define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue")
419 /** Universal, int or double. Minimum value for numeric properties.
421 #define wxPG_ATTR_MIN wxS("Min")
423 /** Universal, int or double. Maximum value for numeric properties.
425 #define wxPG_ATTR_MAX wxS("Max")
427 /** Universal, string. When set, will be shown as text after the displayed
428 text value. Alternatively, if third column is enabled, text will be shown
429 there (for any type of property).
431 #define wxPG_ATTR_UNITS wxS("Units")
433 /** Universal, string. When set, will be shown in property's value cell
434 when displayed value string is empty, or value is unspecified.
436 #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp")
438 /** wxBoolProperty specific, int, default 0. When 1 sets bool property to
439 use checkbox instead of choice.
441 #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox")
443 /** wxBoolProperty specific, int, default 0. When 1 sets bool property value
444 to cycle on double click (instead of showing the popup listbox).
446 #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling")
449 wxFloatProperty (and similar) specific, int, default -1.
451 Sets the (max) precision used when floating point value is rendered as
452 text. The default -1 means infinite precision.
454 #define wxPG_FLOAT_PRECISION wxS("Precision")
457 The text will be echoed as asterisks (wxTE_PASSWORD will be passed to
460 #define wxPG_STRING_PASSWORD wxS("Password")
462 /** Define base used by a wxUIntProperty. Valid constants are
463 wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL
464 (lowercase characters).
466 #define wxPG_UINT_BASE wxS("Base")
468 /** Define prefix rendered to wxUIntProperty. Accepted constants
469 wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN.
470 <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal
473 #define wxPG_UINT_PREFIX wxS("Prefix")
476 wxFileProperty/wxImageFileProperty specific, wxChar*, default is
478 Sets the wildcard used in the triggered wxFileDialog. Format is the same.
480 #define wxPG_FILE_WILDCARD wxS("Wildcard")
482 /** wxFileProperty/wxImageFileProperty specific, int, default 1.
483 When 0, only the file name is shown (i.e. drive and directory are hidden).
485 #define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath")
487 /** Specific to wxFileProperty and derived properties, wxString, default empty.
488 If set, then the filename is shown relative to the given path string.
490 #define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath")
493 Specific to wxFileProperty and derived properties, wxString, default is
496 Sets the initial path of where to look for files.
498 #define wxPG_FILE_INITIAL_PATH wxS("InitialPath")
500 /** Specific to wxFileProperty and derivatives, wxString, default is empty.
501 Sets a specific title for the dir dialog.
503 #define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle")
505 /** Specific to wxDirProperty, wxString, default is empty.
506 Sets a specific message for the dir dialog.
508 #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage")
510 /** Sets displayed date format for wxDateProperty.
512 #define wxPG_DATE_FORMAT wxS("DateFormat")
514 /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default
515 is wxDP_DEFAULT | wxDP_SHOWCENTURY.
517 #define wxPG_DATE_PICKER_STYLE wxS("PickerStyle")
519 /** SpinCtrl editor, int or double. How much number changes when button is
520 pressed (or up/down on keybard).
522 #define wxPG_ATTR_SPINCTRL_STEP wxS("Step")
524 /** SpinCtrl editor, bool. If true, value wraps at Min/Max.
526 #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap")
529 wxMultiChoiceProperty, int.
530 If 0, no user strings allowed. If 1, user strings appear before list
531 strings. If 2, user strings appear after list string.
533 #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
536 wxColourProperty and its kind, int, default 1.
538 Setting this attribute to 0 hides custom colour from property's list of
541 #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom")
546 // Redefine attribute macros to use cached strings
548 #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin
550 #define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax
551 #undef wxPG_ATTR_UNITS
552 #define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits
553 #undef wxPG_ATTR_INLINE_HELP
554 #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp
558 // -----------------------------------------------------------------------
562 /** @class wxPGChoiceEntry
563 Data of a single wxPGChoices choice.
565 class WXDLLIMPEXP_PROPGRID wxPGChoiceEntry
: public wxPGCell
569 wxPGChoiceEntry( const wxPGChoiceEntry
& entry
);
570 wxPGChoiceEntry( const wxString
& label
,
571 int value
= wxPG_INVALID_VALUE
)
572 : wxPGCell(), m_value(value
)
577 wxPGChoiceEntry( const wxString
& label
,
579 const wxBitmap
& bitmap
,
580 const wxColour
& fgCol
= wxNullColour
,
581 const wxColour
& bgCol
= wxNullColour
)
582 : wxPGCell(label
, bitmap
, fgCol
, bgCol
), m_value(value
)
586 virtual ~wxPGChoiceEntry()
590 void SetValue( int value
) { m_value
= value
; }
592 int GetValue() const { return m_value
; }
594 bool HasValue() const { return (m_value
!= wxPG_INVALID_VALUE
); }
601 typedef void* wxPGChoicesId
;
603 class WXDLLIMPEXP_PROPGRID wxPGChoicesData
605 friend class wxPGChoices
;
607 // Constructor sets m_refCount to 1.
610 void CopyDataFrom( wxPGChoicesData
* data
);
612 // Takes ownership of 'item'
613 void Insert( int index
, wxPGChoiceEntry
* item
)
615 wxVector
<wxPGChoiceEntry
*>::iterator it
;
619 index
= (int) m_items
.size();
623 it
= m_items
.begin() + index
;
626 // Need to fix value?
627 if ( item
->GetValue() == wxPG_INVALID_VALUE
)
628 item
->SetValue(index
);
630 m_items
.insert(it
, item
);
633 // Delete all entries
636 unsigned int GetCount() const
638 return (unsigned int) m_items
.size();
641 wxPGChoiceEntry
* Item( unsigned int i
) const
643 wxCHECK_MSG( i
< GetCount(), NULL
, "invalid index" );
651 wxASSERT( m_refCount
>= 0 );
652 if ( m_refCount
== 0 )
657 wxVector
<wxPGChoiceEntry
*> m_items
;
659 // So that multiple properties can use the same set
662 virtual ~wxPGChoicesData();
665 #define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL)
669 /** @class wxPGChoices
671 Helper class for managing choices of wxPropertyGrid properties.
672 Each entry can have label, value, bitmap, text colour, and background
678 class WXDLLIMPEXP_PROPGRID wxPGChoices
681 typedef long ValArrItem
;
683 /** Default constructor. */
689 /** Copy constructor. */
690 wxPGChoices( const wxPGChoices
& a
)
692 if ( a
.m_data
!= wxPGChoicesEmptyData
)
695 m_data
->m_refCount
++;
700 wxPGChoices( const wxChar
** labels
, const long* values
= NULL
)
707 wxPGChoices( const wxArrayString
& labels
,
708 const wxArrayInt
& values
= wxArrayInt() )
714 /** Simple interface constructor. */
715 wxPGChoices( wxPGChoicesData
* data
)
731 If did not have own copies, creates them now. If was empty, identical
732 to set except that creates copies.
734 void Add( const wxChar
** labels
, const ValArrItem
* values
= NULL
);
736 /** Version that works with wxArrayString. */
737 void Add( const wxArrayString
& arr
, const ValArrItem
* values
= NULL
);
739 /** Version that works with wxArrayString and wxArrayInt. */
740 void Add( const wxArrayString
& arr
, const wxArrayInt
& arrint
);
742 /** Adds single item. */
743 wxPGChoiceEntry
& Add( const wxString
& label
,
744 int value
= wxPG_INVALID_VALUE
);
746 /** Adds a single item, with bitmap. */
747 wxPGChoiceEntry
& Add( const wxString
& label
,
748 const wxBitmap
& bitmap
,
749 int value
= wxPG_INVALID_VALUE
);
751 /** Adds a single item with full entry information. */
752 wxPGChoiceEntry
& Add( const wxPGChoiceEntry
& entry
)
754 return Insert(entry
, -1);
757 /** Adds single item. */
758 wxPGChoiceEntry
& AddAsSorted( const wxString
& label
,
759 int value
= wxPG_INVALID_VALUE
);
761 void Assign( const wxPGChoices
& a
)
763 AssignData(a
.m_data
);
766 void AssignData( wxPGChoicesData
* data
);
768 /** Delete all choices. */
771 if ( m_data
!= wxPGChoicesEmptyData
)
777 if ( m_data
== wxPGChoicesEmptyData
)
778 m_data
= new wxPGChoicesData();
781 /** Gets a unsigned number identifying this list. */
782 wxPGChoicesId
GetId() const { return (wxPGChoicesId
) m_data
; };
784 const wxString
& GetLabel( unsigned int ind
) const
786 return Item(ind
).GetText();
789 unsigned int GetCount () const
794 return m_data
->GetCount();
797 int GetValue( unsigned int ind
) const { return Item(ind
).GetValue(); }
799 /** Returns array of values matching the given strings. Unmatching strings
800 result in wxPG_INVALID_VALUE entry in array.
802 wxArrayInt
GetValuesForStrings( const wxArrayString
& strings
) const;
804 /** Returns array of indices matching given strings. Unmatching strings
805 are added to 'unmatched', if not NULL.
807 wxArrayInt
GetIndicesForStrings( const wxArrayString
& strings
,
808 wxArrayString
* unmatched
= NULL
) const;
810 /** Returns true if choices in general are likely to have values
811 (depens on that all entries have values or none has)
813 bool HasValues() const;
815 bool HasValue( unsigned int i
) const
816 { return (i
< m_data
->GetCount()) && m_data
->Item(i
)->HasValue(); }
818 int Index( const wxString
& str
) const;
819 int Index( int val
) const;
821 /** Inserts single item. */
822 wxPGChoiceEntry
& Insert( const wxString
& label
,
824 int value
= wxPG_INVALID_VALUE
);
826 /** Inserts a single item with full entry information. */
827 wxPGChoiceEntry
& Insert( const wxPGChoiceEntry
& entry
, int index
);
829 /** Returns false if this is a constant empty set of choices,
830 which should not be modified.
834 return ( m_data
!= wxPGChoicesEmptyData
);
837 const wxPGChoiceEntry
& Item( unsigned int i
) const
840 return *m_data
->Item(i
);
843 wxPGChoiceEntry
& Item( unsigned int i
)
846 return *m_data
->Item(i
);
849 /** Removes count items starting at position nIndex. */
850 void RemoveAt(size_t nIndex
, size_t count
= 1);
853 /** Does not create copies for itself. */
854 void Set( const wxChar
** labels
, const long* values
= NULL
)
861 /** Version that works with wxArrayString and wxArrayInt. */
862 void Set( const wxArrayString
& labels
,
863 const wxArrayInt
& values
= wxArrayInt() )
872 // Creates exclusive copy of current choices
875 if ( m_data
->m_refCount
!= 1 )
877 wxPGChoicesData
* data
= new wxPGChoicesData();
878 data
->CopyDataFrom(m_data
);
884 // Returns data, increases refcount.
885 wxPGChoicesData
* GetData()
887 wxASSERT( m_data
->m_refCount
!= 0xFFFFFFF );
888 m_data
->m_refCount
++;
892 // Returns plain data ptr - no refcounting stuff is done.
893 wxPGChoicesData
* GetDataPtr() const { return m_data
; }
895 // Changes ownership of data to you.
896 wxPGChoicesData
* ExtractData()
898 wxPGChoicesData
* data
= m_data
;
899 m_data
= wxPGChoicesEmptyData
;
903 wxArrayString
GetLabels() const;
906 void operator= (const wxPGChoices
& a
)
908 AssignData(a
.m_data
);
911 wxPGChoiceEntry
& operator[](unsigned int i
)
916 const wxPGChoiceEntry
& operator[](unsigned int i
) const
922 wxPGChoicesData
* m_data
;
929 // -----------------------------------------------------------------------
931 /** @class wxPGProperty
933 wxPGProperty is base class for all wxPropertyGrid properties.
935 NB: Full class overview is now only present in
936 interface/wx/propgrid/property.h.
941 class WXDLLIMPEXP_PROPGRID wxPGProperty
: public wxObject
943 friend class wxPropertyGrid
;
944 friend class wxPropertyGridInterface
;
945 friend class wxPropertyGridPageState
;
946 friend class wxPropertyGridPopulator
;
947 friend class wxStringProperty
; // Proper "<composed>" support requires this
949 DECLARE_ABSTRACT_CLASS(wxPGProperty
)
952 typedef wxUint32 FlagType
;
954 /** Basic constructor.
959 Non-abstract property classes should have constructor of this style:
963 // If T is a class, then it should be a constant reference
964 // (e.g. const T& ) instead.
965 MyProperty( const wxString& label, const wxString& name, T value )
968 // Generally recommended way to set the initial value
969 // (as it should work in pretty much 100% of cases).
974 // If has private child properties then create them here. Also
975 // set flag that indicates presence of private children. E.g.:
977 // SetParentalType(wxPG_PROP_AGGREGATE);
979 // AddChild( new wxStringProperty( "Subprop 1",
981 // value.GetSubProp1() ) );
986 wxPGProperty( const wxString
& label
, const wxString
& name
);
990 It is customary for derived properties to implement this.
992 virtual ~wxPGProperty();
994 /** This virtual function is called after m_value has been set.
997 - If m_value was set to Null variant (ie. unspecified value),
998 OnSetValue() will not be called.
999 - m_value may be of any variant type. Typically properties internally
1000 support only one variant type, and as such OnSetValue() provides a
1001 good opportunity to convert
1002 supported values into internal type.
1003 - Default implementation does nothing.
1005 virtual void OnSetValue();
1007 /** Override this to return something else than m_value as the value.
1009 virtual wxVariant
DoGetValue() const { return m_value
; }
1011 #if !defined(SWIG) || defined(CREATE_VCW)
1012 /** Implement this function in derived class to check the value.
1013 Return true if it is ok. Returning false prevents property change events
1017 - Default implementation always returns true.
1019 virtual bool ValidateValue( wxVariant
& value
,
1020 wxPGValidationInfo
& validationInfo
) const;
1023 Converts text into wxVariant value appropriate for this property.
1026 On function entry this is the old value (should not be wxNullVariant
1027 in normal cases). Translated value must be assigned back to it.
1030 Text to be translated into variant.
1033 If wxPG_FULL_VALUE is set, returns complete, storable value instead
1034 of displayable one (they may be different).
1035 If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of
1036 composite property string value (as generated by GetValueAsString()
1037 called with this same flag).
1039 @return Returns @true if resulting wxVariant value was different.
1041 @remarks Default implementation converts semicolon delimited tokens into
1042 child values. Only works for properties with children.
1044 You might want to take into account that m_value is Null variant
1045 if property value is unspecified (which is usually only case if
1046 you explicitly enabled that sort behavior).
1048 virtual bool StringToValue( wxVariant
& variant
,
1049 const wxString
& text
,
1050 int argFlags
= 0 ) const;
1053 Converts integer (possibly a choice selection) into wxVariant value
1054 appropriate for this property.
1057 On function entry this is the old value (should not be wxNullVariant
1058 in normal cases). Translated value must be assigned back to it.
1061 Integer to be translated into variant.
1064 If wxPG_FULL_VALUE is set, returns complete, storable value instead
1067 @return Returns @true if resulting wxVariant value was different.
1070 - If property is not supposed to use choice or spinctrl or other editor
1071 with int-based value, it is not necessary to implement this method.
1072 - Default implementation simply assign given int to m_value.
1073 - If property uses choice control, and displays a dialog on some choice
1074 items, then it is preferred to display that dialog in IntToValue
1076 - You might want to take into account that m_value is Null variant if
1077 property value is unspecified (which is usually only case if you
1078 explicitly enabled that sort behavior).
1080 virtual bool IntToValue( wxVariant
& value
,
1082 int argFlags
= 0 ) const;
1083 #endif // !defined(SWIG) || defined(CREATE_VCW)
1086 /** Returns text representation of property's value.
1089 If wxPG_FULL_VALUE is set, returns complete, storable string value
1090 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
1091 string value that must be editable in textctrl. If
1092 wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
1093 display as a part of composite property string value.
1096 Default implementation returns string composed from text
1097 representations of child properties.
1099 virtual wxString
GetValueAsString( int argFlags
= 0 ) const;
1101 /** Converts string to a value, and if successful, calls SetValue() on it.
1102 Default behavior is to do nothing.
1104 String to get the value from.
1106 true if value was changed.
1108 bool SetValueFromString( const wxString
& text
, int flags
= 0 );
1110 /** Converts integer to a value, and if succesful, calls SetValue() on it.
1111 Default behavior is to do nothing.
1113 Int to get the value from.
1115 If has wxPG_FULL_VALUE, then the value given is a actual value and
1118 True if value was changed.
1120 bool SetValueFromInt( long value
, int flags
= 0 );
1123 Returns size of the custom painted image in front of property.
1125 This method must be overridden to return non-default value if
1126 OnCustomPaint is to be called.
1128 Normally -1, but can be an index to the property's list of items.
1130 - Default behavior is to return wxSize(0,0), which means no image.
1131 - Default image width or height is indicated with dimension -1.
1132 - You can also return wxPG_DEFAULT_IMAGE_SIZE, i.e. wxSize(-1, -1).
1134 virtual wxSize
OnMeasureImage( int item
= -1 ) const;
1137 Events received by editor widgets are processed here.
1139 Note that editor class usually processes most events. Some, such as
1140 button press events of TextCtrlAndButton class, can be handled here.
1141 Also, if custom handling for regular events is desired, then that can
1142 also be done (for example, wxSystemColourProperty custom handles
1143 wxEVT_COMMAND_CHOICE_SELECTED to display colour picker dialog when
1144 'custom' selection is made).
1146 If the event causes value to be changed, SetValueInEvent()
1147 should be called to set the new value.
1152 Should return true if any changes in value should be reported.
1154 If property uses choice control, and displays a dialog on some choice
1155 items, then it is preferred to display that dialog in IntToValue
1158 virtual bool OnEvent( wxPropertyGrid
* propgrid
,
1159 wxWindow
* wnd_primary
,
1163 Called after value of a child property has been altered.
1165 Note that this function is usually called at the time that value of
1166 this property, or given child property, is still pending for change.
1168 Sample pseudo-code implementation:
1171 void MyProperty::ChildChanged( wxVariant& thisValue,
1173 wxVariant& childValue ) const
1175 // Acquire reference to actual type of data stored in variant
1176 // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros
1177 // were used to create the variant class).
1178 T& data = TFromVariant(thisValue);
1180 // Copy childValue into data.
1181 switch ( childIndex )
1184 data.SetSubProp1( childvalue.GetLong() );
1187 data.SetSubProp2( childvalue.GetString() );
1195 Value of this property, that should be altered.
1197 Index of child changed (you can use Item(childIndex) to get).
1199 Value of the child property.
1201 virtual void ChildChanged( wxVariant
& thisValue
,
1203 wxVariant
& childValue
) const;
1205 /** Returns pointer to an instance of used editor.
1207 virtual const wxPGEditor
* DoGetEditorClass() const;
1209 /** Returns pointer to the wxValidator that should be used
1210 with the editor of this property (NULL for no validator).
1211 Setting validator explicitly via SetPropertyValidator
1214 In most situations, code like this should work well
1215 (macros are used to maintain one actual validator instance,
1216 so on the second call the function exits within the first
1221 wxValidator* wxMyPropertyClass::DoGetValidator () const
1223 WX_PG_DOGETVALIDATOR_ENTRY()
1225 wxMyValidator* validator = new wxMyValidator(...);
1227 ... prepare validator...
1229 WX_PG_DOGETVALIDATOR_EXIT(validator)
1235 You can get common filename validator by returning
1236 wxFileProperty::GetClassValidator(). wxDirProperty,
1237 for example, uses it.
1239 virtual wxValidator
* DoGetValidator () const;
1242 Override to paint an image in front of the property value text or
1243 drop-down list item (but only if wxPGProperty::OnMeasureImage is
1244 overridden as well).
1246 If property's OnMeasureImage() returns size that has height != 0 but
1247 less than row height ( < 0 has special meanings), wxPropertyGrid calls
1248 this method to draw a custom image in a limited area in front of the
1249 editor control or value text/graphics, and if control has drop-down
1250 list, then the image is drawn there as well (even in the case
1251 OnMeasureImage() returned higher height than row height).
1253 NOTE: Following applies when OnMeasureImage() returns a "flexible"
1254 height ( using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable
1255 height items: If rect.x is < 0, then this is a measure item call, which
1256 means that dc is invalid and only thing that should be done is to set
1257 paintdata.m_drawnHeight to the height of the image of item at index
1258 paintdata.m_choiceItem. This call may be done even as often as once
1259 every drop-down popup show.
1264 Box reserved for custom graphics. Includes surrounding rectangle,
1265 if any. If x is < 0, then this is a measure item call (see above).
1267 wxPGPaintData structure with much useful data.
1270 - You can actually exceed rect width, but if you do so then
1271 paintdata.m_drawnWidth must be set to the full width drawn in
1273 - Due to technical reasons, rect's height will be default even if
1274 custom height was reported during measure call.
1275 - Brush is guaranteed to be default background colour. It has been
1276 already used to clear the background of area being painted. It
1278 - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper
1279 colour) pen for drawing framing rectangle. It can be changed as
1282 @see GetValueAsString()
1284 virtual void OnCustomPaint( wxDC
& dc
,
1286 wxPGPaintData
& paintdata
);
1289 Returns used wxPGCellRenderer instance for given property column
1292 Default implementation returns editor's renderer for all columns.
1294 virtual wxPGCellRenderer
* GetCellRenderer( int column
) const;
1296 /** Returns which choice is currently selected. Only applies to properties
1299 Needs to reimplemented in derived class if property value does not
1300 map directly to a choice. Integer as index, bool, and string usually do.
1302 virtual int GetChoiceSelection() const;
1305 Refresh values of child properties.
1307 Automatically called after value is set.
1309 virtual void RefreshChildren();
1311 /** Special handling for attributes of this property.
1313 If returns false, then the attribute will be automatically stored in
1316 Default implementation simply returns false.
1318 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
1320 /** Returns value of an attribute.
1322 Override if custom handling of attributes is needed.
1324 Default implementation simply return NULL variant.
1326 virtual wxVariant
DoGetAttribute( const wxString
& name
) const;
1328 /** Returns instance of a new wxPGEditorDialogAdapter instance, which is
1329 used when user presses the (optional) button next to the editor control;
1331 Default implementation returns NULL (ie. no action is generated when
1334 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
1336 /** Returns wxPGCell of given column, NULL if none. If valid
1337 object is returned, caller will gain its ownership.
1339 wxPGCell
* AcquireCell( unsigned int column
)
1341 if ( column
>= m_cells
.size() )
1344 wxPGCell
* cell
= (wxPGCell
*) m_cells
[column
];
1345 m_cells
[column
] = NULL
;
1349 /** Append a new choice to property's list of choices.
1351 int AddChoice( const wxString
& label
, int value
= wxPG_INVALID_VALUE
)
1353 return InsertChoice(label
, wxNOT_FOUND
, value
);
1357 Returns true if children of this property are component values (for
1358 instance, points size, face name, and is_underlined are component
1361 bool AreChildrenComponents() const
1363 if ( m_flags
& (wxPG_PROP_COMPOSED_VALUE
|wxPG_PROP_AGGREGATE
) )
1370 Removes entry from property's wxPGChoices and editor control (if it is
1373 If selected item is deleted, then the value is set to unspecified.
1375 void DeleteChoice( int index
);
1378 Call to enable or disable usage of common value (integer value that can
1379 be selected for properties instead of their normal values) for this
1382 Common values are disabled by the default for all properties.
1384 void EnableCommonValue( bool enable
= true )
1386 if ( enable
) SetFlag( wxPG_PROP_USES_COMMON_VALUE
);
1387 else ClearFlag( wxPG_PROP_USES_COMMON_VALUE
);
1390 /** Composes text from values of child properties. */
1391 void GenerateComposedValue( wxString
& text
, int argFlags
= 0 ) const;
1393 /** Returns property's label. */
1394 const wxString
& GetLabel() const { return m_label
; }
1396 /** Returns property's name with all (non-category, non-root) parents. */
1397 wxString
GetName() const;
1400 Returns property's base name (ie parent's name is not added in any
1403 const wxString
& GetBaseName() const { return m_name
; }
1405 /** Returns read-only reference to property's list of choices.
1407 const wxPGChoices
& GetChoices() const
1412 /** Returns coordinate to the top y of the property. Note that the
1413 position of scrollbars is not taken into account.
1417 wxVariant
GetValue() const
1419 return DoGetValue();
1423 /** Returns reference to the internal stored value. GetValue is preferred
1424 way to get the actual value, since GetValueRef ignores DoGetValue,
1425 which may override stored value.
1427 wxVariant
& GetValueRef()
1432 const wxVariant
& GetValueRef() const
1438 /** To acquire property's value as string, you should use this
1439 function (instead of GetValueAsString()), as it may produce
1440 more accurate value in future versions.
1442 wxString
GetValueString( int argFlags
= 0 ) const;
1444 void UpdateControl( wxWindow
* primary
);
1446 /** Returns wxPGCell of given column, NULL if none. wxPGProperty
1447 will retain ownership of the cell object.
1449 wxPGCell
* GetCell( unsigned int column
) const
1451 if ( column
>= m_cells
.size() )
1454 return (wxPGCell
*) m_cells
[column
];
1457 /** Return number of displayed common values for this property.
1459 int GetDisplayedCommonValueCount() const;
1461 wxString
GetDisplayedString() const
1463 return GetValueString(0);
1466 /** Returns property grid where property lies. */
1467 wxPropertyGrid
* GetGrid() const;
1469 /** Returns owner wxPropertyGrid, but only if one is currently on a page
1470 displaying this property. */
1471 wxPropertyGrid
* GetGridIfDisplayed() const;
1473 /** Returns highest level non-category, non-root parent. Useful when you
1474 have nested wxCustomProperties/wxParentProperties.
1476 Thus, if immediate parent is root or category, this will return the
1479 wxPGProperty
* GetMainParent() const;
1481 /** Return parent of property */
1482 wxPGProperty
* GetParent() const { return m_parent
; }
1484 /** Returns true if property has editable wxTextCtrl when selected.
1487 Altough disabled properties do not displayed editor, they still
1488 return True here as being disabled is considered a temporary
1489 condition (unlike being read-only or having limited editing enabled).
1491 bool IsTextEditable() const;
1493 bool IsValueUnspecified() const
1495 return m_value
.IsNull();
1498 FlagType
HasFlag( FlagType flag
) const
1500 return ( m_flags
& flag
);
1503 /** Returns comma-delimited string of property attributes.
1505 const wxPGAttributeStorage
& GetAttributes() const
1507 return m_attributes
;
1510 /** Returns m_attributes as list wxVariant.
1512 wxVariant
GetAttributesAsList() const;
1514 FlagType
GetFlags() const
1519 const wxPGEditor
* GetEditorClass() const;
1521 wxString
GetValueType() const
1523 return m_value
.GetType();
1526 /** Returns editor used for given column. NULL for no editor.
1528 const wxPGEditor
* GetColumnEditor( int column
) const
1531 return GetEditorClass();
1536 /** Returns common value selected for this property. -1 for none.
1538 int GetCommonValue() const
1540 return m_commonValue
;
1543 /** Returns true if property has even one visible child.
1545 bool HasVisibleChildren() const;
1547 /** Inserts a new choice to property's list of choices.
1549 int InsertChoice( const wxString
& label
, int index
, int value
= wxPG_INVALID_VALUE
);
1552 Returns true if this property is actually a wxPropertyCategory.
1554 bool IsCategory() const { return HasFlag(wxPG_PROP_CATEGORY
)?true:false; }
1556 /** Returns true if this property is actually a wxRootProperty.
1558 bool IsRoot() const { return (m_parent
== NULL
); }
1560 /** Returns true if this is a sub-property. */
1561 bool IsSubProperty() const
1563 wxPGProperty
* parent
= (wxPGProperty
*)m_parent
;
1564 if ( parent
&& !parent
->IsCategory() )
1569 /** Returns last visible sub-property, recursively.
1571 const wxPGProperty
* GetLastVisibleSubItem() const;
1573 wxVariant
GetDefaultValue() const;
1575 int GetMaxLength() const
1577 return (int) m_maxLen
;
1581 Determines, recursively, if all children are not unspecified.
1584 Assumes members in this wxVariant list as pending
1587 bool AreAllChildrenSpecified( wxVariant
* pendingList
= NULL
) const;
1589 /** Updates composed values of parent non-category properties, recursively.
1590 Returns topmost property updated.
1593 - Must not call SetValue() (as can be called in it).
1595 wxPGProperty
* UpdateParentValues();
1597 /** Returns true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES.
1599 bool UsesAutoUnspecified() const
1601 return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED
)?true:false;
1604 wxBitmap
* GetValueImage() const
1606 return m_valueBitmap
;
1609 wxVariant
GetAttribute( const wxString
& name
) const;
1612 Returns named attribute, as string, if found.
1614 Otherwise defVal is returned.
1616 wxString
GetAttribute( const wxString
& name
, const wxString
& defVal
) const;
1619 Returns named attribute, as long, if found.
1621 Otherwise defVal is returned.
1623 long GetAttributeAsLong( const wxString
& name
, long defVal
) const;
1626 Returns named attribute, as double, if found.
1628 Otherwise defVal is returned.
1630 double GetAttributeAsDouble( const wxString
& name
, double defVal
) const;
1632 unsigned int GetDepth() const { return (unsigned int)m_depth
; }
1634 /** Gets flags as a'|' delimited string. Note that flag names are not
1635 prepended with 'wxPG_PROP_'.
1637 String will only be made to include flags combined by this parameter.
1639 wxString
GetFlagsAsString( FlagType flagsMask
) const;
1641 /** Returns position in parent's array. */
1642 unsigned int GetIndexInParent() const
1644 return (unsigned int)m_arrIndex
;
1647 /** Hides or reveals the property.
1649 true for hide, false for reveal.
1651 By default changes are applied recursively. Set this paramter
1652 wxPG_DONT_RECURSE to prevent this.
1654 inline bool Hide( bool hide
, int flags
= wxPG_RECURSE
);
1656 bool IsExpanded() const
1657 { return (!(m_flags
& wxPG_PROP_COLLAPSED
) && GetChildCount()); }
1659 /** Returns true if all parents expanded.
1661 bool IsVisible() const;
1663 bool IsEnabled() const { return !(m_flags
& wxPG_PROP_DISABLED
); }
1665 /** If property's editor is created this forces its recreation.
1666 Useful in SetAttribute etc. Returns true if actually did anything.
1668 bool RecreateEditor();
1670 /** If property's editor is active, then update it's value.
1672 void RefreshEditor();
1674 /** Sets an attribute for this property.
1676 Text identifier of attribute. See @ref propgrid_property_attributes.
1680 void SetAttribute( const wxString
& name
, wxVariant value
);
1682 void SetAttributes( const wxPGAttributeStorage
& attributes
);
1685 /** Sets editor for a property.
1688 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1689 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
1692 For custom editors, use pointer you received from
1693 wxPropertyGrid::RegisterEditorClass().
1695 void SetEditor( const wxPGEditor
* editor
)
1697 m_customEditor
= editor
;
1701 /** Sets editor for a property.
1703 inline void SetEditor( const wxString
& editorName
);
1705 /** Sets cell information for given column.
1707 Note that the property takes ownership of given wxPGCell instance.
1709 void SetCell( int column
, wxPGCell
* cellObj
);
1711 /** Sets common value selected for this property. -1 for none.
1713 void SetCommonValue( int commonValue
)
1715 m_commonValue
= commonValue
;
1718 /** Sets flags from a '|' delimited string. Note that flag names are not
1719 prepended with 'wxPG_PROP_'.
1721 void SetFlagsFromString( const wxString
& str
);
1723 /** Sets property's "is it modified?" flag. Affects children recursively.
1725 void SetModifiedStatus( bool modified
)
1727 SetFlagRecursively(wxPG_PROP_MODIFIED
, modified
);
1730 /** Call in OnEvent(), OnButtonClick() etc. to change the property value
1731 based on user input.
1734 This method is const since it doesn't actually modify value, but posts
1735 given variant as pending value, stored in wxPropertyGrid.
1737 void SetValueInEvent( wxVariant value
) const;
1740 Call this to set value of the property.
1742 Unlike methods in wxPropertyGrid, this does not automatically update
1746 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run
1747 through validation process and send property change event.
1749 If you need to change property value in event, based on user input, use
1750 SetValueInEvent() instead.
1753 Pointer to list variant that contains child values. Used to indicate
1754 which children should be marked as modified.
1756 Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR).
1758 void SetValue( wxVariant value
, wxVariant
* pList
= NULL
, int flags
= 0 );
1760 /** Set wxBitmap in front of the value. This bitmap may be ignored
1761 by custom cell renderers.
1763 void SetValueImage( wxBitmap
& bmp
);
1765 /** If property has choices and they are not yet exclusive, new such copy
1766 of them will be created.
1768 void SetChoicesExclusive()
1770 m_choices
.SetExclusive();
1773 /** Sets selected choice and changes property value.
1775 Tries to retain value type, although currently if it is not string,
1776 then it is forced to integer.
1778 void SetChoiceSelection( int newValue
);
1780 void SetExpanded( bool expanded
)
1782 if ( !expanded
) m_flags
|= wxPG_PROP_COLLAPSED
;
1783 else m_flags
&= ~wxPG_PROP_COLLAPSED
;
1786 void SetFlag( FlagType flag
) { m_flags
|= flag
; }
1788 void SetFlagRecursively( FlagType flag
, bool set
);
1790 void SetHelpString( const wxString
& helpString
)
1792 m_helpString
= helpString
;
1795 void SetLabel( const wxString
& label
) { m_label
= label
; }
1797 inline void SetName( const wxString
& newName
);
1800 Changes what sort of parent this property is for its children.
1803 Use one of the following values: wxPG_PROP_MISC_PARENT (for generic
1804 parents), wxPG_PROP_CATEGORY (for categories), or
1805 wxPG_PROP_AGGREGATE (for derived property classes with private
1808 @remarks You only need to call this if you use AddChild() to add
1809 child properties. Adding properties with
1810 wxPropertyGridInterface::Insert() or
1811 wxPropertyGridInterface::AppendIn() will automatically set
1812 property to use wxPG_PROP_MISC_PARENT style.
1814 void SetParentalType( int flag
)
1816 m_flags
&= ~(wxPG_PROP_PROPERTY
|wxPG_PROP_PARENTAL_FLAGS
);
1820 void SetValueToUnspecified()
1822 wxVariant val
; // Create NULL variant
1826 #if wxUSE_VALIDATORS
1827 /** Sets wxValidator for a property*/
1828 void SetValidator( const wxValidator
& validator
)
1830 m_validator
= wxDynamicCast(validator
.Clone(),wxValidator
);
1833 /** Gets assignable version of property's validator. */
1834 wxValidator
* GetValidator() const
1838 return DoGetValidator();
1840 #endif // #if wxUSE_VALIDATORS
1843 /** Returns client data (void*) of a property.
1845 void* GetClientData() const
1847 return m_clientData
;
1850 /** Sets client data (void*) of a property.
1852 This untyped client data has to be deleted manually.
1854 void SetClientData( void* clientData
)
1856 m_clientData
= clientData
;
1859 /** Returns client object of a property.
1861 void SetClientObject(wxClientData
* clientObject
)
1863 delete m_clientObject
;
1864 m_clientObject
= clientObject
;
1867 /** Sets managed client object of a property.
1869 wxClientData
*GetClientObject() const { return m_clientObject
; }
1872 /** Sets new set of choices for property.
1875 This operation clears the property value.
1877 bool SetChoices( wxPGChoices
& choices
);
1879 /** Set max length of text in text editor.
1881 inline bool SetMaxLength( int maxLen
);
1883 /** Call with 'false' in OnSetValue to cancel value changes after all
1884 (ie. cancel 'true' returned by StringToValue() or IntToValue()).
1886 void SetWasModified( bool set
= true )
1888 if ( set
) m_flags
|= wxPG_PROP_WAS_MODIFIED
;
1889 else m_flags
&= ~wxPG_PROP_WAS_MODIFIED
;
1892 const wxString
& GetHelpString() const
1894 return m_helpString
;
1897 void ClearFlag( FlagType flag
) { m_flags
&= ~(flag
); }
1899 // Use, for example, to detect if item is inside collapsed section.
1900 bool IsSomeParent( wxPGProperty
* candidate_parent
) const;
1903 Adapts list variant into proper value using consecutive
1906 void AdaptListToValue( wxVariant
& list
, wxVariant
* value
) const;
1909 Adds a child property. If you use this instead of
1910 wxPropertyGridInterface::Insert() or
1911 wxPropertyGridInterface::AppendIn(), then you must set up
1912 property's parental type before making the call. To do this,
1913 call property's SetParentalType() function with either
1914 wxPG_PROP_MISC_PARENT (normal, public children) or with
1915 wxPG_PROP_AGGREGATE (private children for subclassed property).
1919 wxPGProperty* prop = new wxStringProperty(wxS("Property"));
1920 prop->SetParentalType(wxPG_PROP_MISC_PARENT);
1921 wxPGProperty* prop2 = new wxStringProperty(wxS("Property2"));
1922 prop->AddChild(prop2);
1925 void AddChild( wxPGProperty
* prop
);
1927 /** Returns height of children, recursively, and
1928 by taking expanded/collapsed status into account.
1930 iMax is used when finding property y-positions.
1932 int GetChildrenHeight( int lh
, int iMax
= -1 ) const;
1934 /** Returns number of child properties */
1935 unsigned int GetChildCount() const
1937 return (unsigned int) m_children
.size();
1940 /** Returns sub-property at index i. */
1941 wxPGProperty
* Item( unsigned int i
) const
1942 { return m_children
[i
]; }
1944 /** Returns last sub-property.
1946 wxPGProperty
* Last() const { return m_children
.back(); }
1948 /** Returns index of given child property. */
1949 int Index( const wxPGProperty
* p
) const;
1951 /** Deletes all sub-properties. */
1954 // Puts correct indexes to children
1955 void FixIndicesOfChildren( unsigned int starthere
= 0 );
1958 // Returns wxPropertyGridPageState in which this property resides.
1959 wxPropertyGridPageState
* GetParentState() const { return m_parentState
; }
1962 wxPGProperty
* GetItemAtY( unsigned int y
,
1964 unsigned int* nextItemY
) const;
1966 /** Returns (direct) child property with given name (or NULL if not found).
1968 wxPGProperty
* GetPropertyByName( const wxString
& name
) const;
1972 DocStr(GetClientData
,
1973 "Returns the client data object for a property", "");
1974 PyObject
* GetClientData() {
1975 wxPyClientData
* data
= (wxPyClientData
*)self
->GetClientObject();
1977 Py_INCREF(data
->m_obj
);
1985 DocStr(SetClientData
,
1986 "Associate the given client data.", "");
1987 void SetClientData(PyObject
* clientData
) {
1988 wxPyClientData
* data
= new wxPyClientData(clientData
);
1989 self
->SetClientObject(data
);
1993 GetClientObject
= GetClientData
1994 SetClientObject
= SetClientData
2000 static wxString
* sm_wxPG_LABEL
;
2002 /** This member is public so scripting language bindings
2003 wrapper code can access it freely.
2008 /** Returns text for given column.
2010 wxString
GetColumnText( unsigned int col
) const;
2012 /** Returns (direct) child property with given name (or NULL if not found),
2016 Start looking for the child at this index.
2019 Does not support scope (ie. Parent.Child notation).
2021 wxPGProperty
* GetPropertyByNameWH( const wxString
& name
,
2022 unsigned int hintIndex
) const;
2024 /** This is used by Insert etc. */
2025 void AddChild2( wxPGProperty
* prop
,
2027 bool correct_mode
= true );
2029 void DoSetName(const wxString
& str
) { m_name
= str
; }
2031 void InitAfterAdded( wxPropertyGridPageState
* pageState
,
2032 wxPropertyGrid
* propgrid
);
2034 // Removes child property with given pointer. Does not delete it.
2035 void RemoveChild( wxPGProperty
* p
);
2037 void SetParentState( wxPropertyGridPageState
* pstate
)
2038 { m_parentState
= pstate
; }
2040 // Call after fixed sub-properties added/removed after creation.
2041 // if oldSelInd >= 0 and < new max items, then selection is
2043 void SubPropsChanged( int oldSelInd
= -1 );
2045 int GetY2( int lh
) const;
2049 wxPGProperty
* m_parent
;
2050 wxPropertyGridPageState
* m_parentState
;
2052 wxClientData
* m_clientObject
;
2054 // Overrides editor returned by property class
2055 const wxPGEditor
* m_customEditor
;
2056 #if wxUSE_VALIDATORS
2057 // Editor is going to get this validator
2058 wxValidator
* m_validator
;
2060 // Show this in front of the value
2062 // TODO: Can bitmap be implemented with wxPGCell?
2063 wxBitmap
* m_valueBitmap
;
2066 wxPGAttributeStorage m_attributes
;
2067 wxArrayPGProperty m_children
;
2069 // Extended cell information
2070 wxArrayPtrVoid m_cells
;
2072 // Choices shown in drop-down list of editor control.
2073 wxPGChoices m_choices
;
2075 // Help shown in statusbar or help box.
2076 wxString m_helpString
;
2078 // Index in parent's property array.
2079 unsigned int m_arrIndex
;
2081 // If not -1, then overrides m_value
2086 // Maximum length (mainly for string properties). Could be in some sort of
2087 // wxBaseStringProperty, but currently, for maximum flexibility and
2088 // compatibility, we'll stick it here. Anyway, we had 3 excess bytes to use
2089 // so short int will fit in just fine.
2092 // Root has 0, categories etc. at that level 1, etc.
2093 unsigned char m_depth
;
2095 // m_depthBgCol indicates width of background colour between margin and item
2096 // (essentially this is category's depth, if none then equals m_depth).
2097 unsigned char m_depthBgCol
;
2099 unsigned char m_bgColIndex
; // Background brush index.
2100 unsigned char m_fgColIndex
; // Foreground colour index.
2103 // Called in constructors.
2105 void Init( const wxString
& label
, const wxString
& name
);
2106 #endif // #ifndef SWIG
2109 // -----------------------------------------------------------------------
2112 // Property class declaration helper macros
2113 // (wxPGRootPropertyClass and wxPropertyCategory require this).
2116 #define WX_PG_DECLARE_DOGETEDITORCLASS \
2117 virtual const wxPGEditor* DoGetEditorClass() const;
2120 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
2122 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
2123 WX_PG_DECLARE_DOGETEDITORCLASS \
2126 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME)
2129 // Implements sans constructor function. Also, first arg is class name, not
2131 #define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \
2132 const wxPGEditor* PROPNAME::DoGetEditorClass() const \
2134 return wxPGEditor_##EDITOR; \
2137 // -----------------------------------------------------------------------
2141 /** @class wxPGRootProperty
2143 Root parent property.
2145 class WXDLLIMPEXP_PROPGRID wxPGRootProperty
: public wxPGProperty
2148 WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty
)
2153 virtual ~wxPGRootProperty();
2155 virtual bool StringToValue( wxVariant
&, const wxString
&, int ) const
2163 // -----------------------------------------------------------------------
2165 /** @class wxPropertyCategory
2167 Category (caption) property.
2169 class WXDLLIMPEXP_PROPGRID wxPropertyCategory
: public wxPGProperty
2171 friend class wxPropertyGrid
;
2172 friend class wxPropertyGridPageState
;
2173 WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory
)
2176 /** Default constructor is only used in special cases. */
2177 wxPropertyCategory();
2179 wxPropertyCategory( const wxString
& label
,
2180 const wxString
& name
= wxPG_LABEL
);
2181 ~wxPropertyCategory();
2183 int GetTextExtent( const wxWindow
* wnd
, const wxFont
& font
) const;
2186 virtual wxString
GetValueAsString( int argFlags
) const;
2188 void SetTextColIndex( unsigned int colInd
)
2189 { m_capFgColIndex
= (wxByte
) colInd
; }
2190 unsigned int GetTextColIndex() const
2191 { return (unsigned int) m_capFgColIndex
; }
2193 void CalculateTextExtent( wxWindow
* wnd
, const wxFont
& font
);
2195 int m_textExtent
; // pre-calculated length of text
2196 wxByte m_capFgColIndex
; // caption text colour index
2204 // -----------------------------------------------------------------------
2206 #endif // wxUSE_PROPGRID
2208 #endif // _WX_PROPGRID_PROPERTY_H_