1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPGProperty
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define wxNullProperty ((wxPGProperty*)NULL)
14 @section propgrid_property_attributes wxPropertyGrid Property Attribute Identifiers
16 wxPGProperty::SetAttribute() and wxPropertyGridInterface::SetPropertyAttribute()
17 accept one of these as attribute name argument.
19 You can use strings instead of constants.
20 However, some of these constants are redefined to use cached strings which
21 may reduce your binary size by some amount.
26 /** Set default value for property.
28 #define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue")
30 /** Universal, int or double. Minimum value for numeric properties.
32 #define wxPG_ATTR_MIN wxS("Min")
34 /** Universal, int or double. Maximum value for numeric properties.
36 #define wxPG_ATTR_MAX wxS("Max")
38 /** Universal, string. When set, will be shown as text after the displayed
39 text value. Alternatively, if third column is enabled, text will be shown
40 there (for any type of property).
42 #define wxPG_ATTR_UNITS wxS("Units")
44 /** When set, will be shown as 'greyed' text in property's value cell when
45 the actual displayed value is blank.
47 #define wxPG_ATTR_HINT wxS("Hint")
50 @deprecated Use "Hint" (wxPG_ATTR_HINT) instead.
52 #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp")
54 /** Universal, wxArrayString. Set to enable auto-completion in any
55 wxTextCtrl-based property editor.
57 #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete")
59 /** wxBoolProperty and wxFlagsProperty specific. Value type is bool.
60 Default value is False.
62 When set to True, bool property will use check box instead of a
63 combo box as its editor control. If you set this attribute
64 for a wxFlagsProperty, it is automatically applied to child
67 #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox")
69 /** wxBoolProperty and wxFlagsProperty specific. Value type is bool.
70 Default value is False.
72 Set to True for the bool property to cycle value on double click
73 (instead of showing the popup listbox). If you set this attribute
74 for a wxFlagsProperty, it is automatically applied to child
77 #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling")
79 /** wxFloatProperty (and similar) specific, int, default -1. Sets the (max) precision
80 used when floating point value is rendered as text. The default -1 means infinite
83 #define wxPG_FLOAT_PRECISION wxS("Precision")
85 /** The text will be echoed as asterisks (wxTE_PASSWORD will be passed to textctrl etc).
87 #define wxPG_STRING_PASSWORD wxS("Password")
89 /** Define base used by a wxUIntProperty. Valid constants are
90 wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL
91 (lowercase characters).
93 #define wxPG_UINT_BASE wxS("Base")
95 /** Define prefix rendered to wxUIntProperty. Accepted constants
96 wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN.
97 <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal
100 #define wxPG_UINT_PREFIX wxS("Prefix")
102 /** wxFileProperty/wxImageFileProperty specific, wxChar*, default is detected/varies.
103 Sets the wildcard used in the triggered wxFileDialog. Format is the
106 #define wxPG_FILE_WILDCARD wxS("Wildcard")
108 /** wxFileProperty/wxImageFileProperty specific, int, default 1.
109 When 0, only the file name is shown (i.e. drive and directory are hidden).
111 #define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath")
113 /** Specific to wxFileProperty and derived properties, wxString, default empty.
114 If set, then the filename is shown relative to the given path string.
116 #define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath")
118 /** Specific to wxFileProperty and derived properties, wxString, default is empty.
119 Sets the initial path of where to look for files.
121 #define wxPG_FILE_INITIAL_PATH wxS("InitialPath")
123 /** Specific to wxFileProperty and derivatives, wxString, default is empty.
124 Sets a specific title for the dir dialog.
126 #define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle")
128 /** Specific to wxDirProperty, wxString, default is empty.
129 Sets a specific message for the dir dialog.
131 #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage")
134 wxArrayStringProperty's string delimiter character. If this is aquotation
135 mark or hyphen, then strings will be quoted instead (with given
138 Default delimiter is quotation mark.
140 #define wxPG_ARRAY_DELIMITER wxS("Delimiter")
142 /** Sets displayed date format for wxDateProperty.
144 #define wxPG_DATE_FORMAT wxS("DateFormat")
146 /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default
147 is wxDP_DEFAULT | wxDP_SHOWCENTURY. Using wxDP_ALLOWNONE will enable
148 better unspecified value support in the editor.
150 #define wxPG_DATE_PICKER_STYLE wxS("PickerStyle")
152 /** SpinCtrl editor, int or double. How much number changes when button is
153 pressed (or up/down on keybard).
155 #define wxPG_ATTR_SPINCTRL_STEP wxS("Step")
157 /** SpinCtrl editor, bool. If @true, value wraps at Min/Max.
159 #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap")
161 /** SpinCtrl editor, bool. If @true, value can also by changed by moving
162 mouse when left mouse button is being pressed.
164 #define wxPG_ATTR_SPINCTRL_MOTIONSPIN wxS("MotionSpin")
166 /** wxMultiChoiceProperty, int. If 0, no user strings allowed. If 1, user strings
167 appear before list strings. If 2, user strings appear after list string.
169 #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
171 /** wxColourProperty and its kind, int, default 1. Setting this attribute to 0 hides custom
172 colour from property's list of choices.
174 #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom")
180 /** @section propgrid_propflags wxPGProperty Flags
184 enum wxPGPropertyFlags
187 /** Indicates bold font.
189 wxPG_PROP_MODIFIED
= 0x0001,
191 /** Disables ('greyed' text and editor does not activate) property.
193 wxPG_PROP_DISABLED
= 0x0002,
195 /** Hider button will hide this property.
197 wxPG_PROP_HIDDEN
= 0x0004,
199 /** This property has custom paint image just in front of its value.
200 If property only draws custom images into a popup list, then this
201 flag should not be set.
203 wxPG_PROP_CUSTOMIMAGE
= 0x0008,
205 /** Do not create text based editor for this property (but button-triggered
206 dialog and choice are ok).
208 wxPG_PROP_NOEDITOR
= 0x0010,
210 /** Property is collapsed, ie. it's children are hidden.
212 wxPG_PROP_COLLAPSED
= 0x0020,
215 If property is selected, then indicates that validation failed for pending
218 If property is not selected, then indicates that the the actual property
219 value has failed validation (NB: this behavior is not currently supported,
220 but may be used in future).
222 wxPG_PROP_INVALID_VALUE
= 0x0040,
226 /** Switched via SetWasModified(). Temporary flag - only used when
227 setting/changing property value.
229 wxPG_PROP_WAS_MODIFIED
= 0x0200,
232 If set, then child properties (if any) are private, and should be
233 "invisible" to the application.
235 wxPG_PROP_AGGREGATE
= 0x0400,
237 /** If set, then child properties (if any) are copies and should not
240 wxPG_PROP_CHILDREN_ARE_COPIES
= 0x0800,
243 Classifies this item as a non-category.
245 Used for faster item type identification.
247 wxPG_PROP_PROPERTY
= 0x1000,
250 Classifies this item as a category.
252 Used for faster item type identification.
254 wxPG_PROP_CATEGORY
= 0x2000,
256 /** Classifies this item as a property that has children, but is not aggregate
257 (ie children are not private).
259 wxPG_PROP_MISC_PARENT
= 0x4000,
261 /** Property is read-only. Editor is still created for wxTextCtrl-based
262 property editors. For others, editor is not usually created because
263 they do implement wxTE_READONLY style or equivalent.
265 wxPG_PROP_READONLY
= 0x8000,
268 // NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS
271 /** Property's value is composed from values of child properties.
273 This flag cannot be used with property iterators.
275 wxPG_PROP_COMPOSED_VALUE
= 0x00010000,
277 /** Common value of property is selectable in editor.
279 This flag cannot be used with property iterators.
281 wxPG_PROP_USES_COMMON_VALUE
= 0x00020000,
283 /** Property can be set to unspecified value via editor.
284 Currently, this applies to following properties:
285 - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty:
289 This flag cannot be used with property iterators.
291 @see wxPGProperty::SetAutoUnspecified()
293 wxPG_PROP_AUTO_UNSPECIFIED
= 0x00040000,
295 /** Indicates the bit useable by derived properties.
297 wxPG_PROP_CLASS_SPECIFIC_1
= 0x00080000,
299 /** Indicates the bit useable by derived properties.
301 wxPG_PROP_CLASS_SPECIFIC_2
= 0x00100000,
303 /** Indicates that the property is being deleted and should be ignored.
305 wxPG_PROP_BEING_DELETED
= 0x00200000
311 #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED
313 /** Property with children must have one of these set, otherwise iterators
314 will not work correctly.
315 Code should automatically take care of this, however.
317 #define wxPG_PROP_PARENTAL_FLAGS \
318 ((wxPGPropertyFlags)(wxPG_PROP_AGGREGATE | \
319 wxPG_PROP_CATEGORY | \
320 wxPG_PROP_MISC_PARENT))
329 wxPGProperty is base class for all wxPropertyGrid properties. In
330 sections below we cover few related topics.
332 @li @ref pgproperty_properties
333 @li @ref pgproperty_creating
335 @section pgproperty_properties Supplied Ready-to-use Property Classes
337 Here is a list and short description of supplied fully-functional
338 property classes. They are located in either props.h or advprops.h.
340 @li @ref wxArrayStringProperty
341 @li @ref wxBoolProperty
342 @li @ref wxColourProperty
343 @li @ref wxCursorProperty
344 @li @ref wxDateProperty
345 @li @ref wxDirProperty
346 @li @ref wxEditEnumProperty
347 @li @ref wxEnumProperty
348 @li @ref wxFileProperty
349 @li @ref wxFlagsProperty
350 @li @ref wxFloatProperty
351 @li @ref wxFontProperty
352 @li @ref wxImageFileProperty
353 @li @ref wxIntProperty
354 @li @ref wxLongStringProperty
355 @li @ref wxMultiChoiceProperty
356 @li @ref wxPropertyCategory
357 @li @ref wxStringProperty
358 @li @ref wxSystemColourProperty
359 @li @ref wxUIntProperty
361 @subsection wxPropertyCategory
363 Not an actual property per se, but a header for a group of properties.
364 Regardless inherits from wxPGProperty, and supports displaying 'labels'
365 for columns other than the first one. Easiest way to set category's
366 label for second column is to call wxPGProperty::SetValue() with string
369 @subsection wxStringProperty
371 Simple string property. wxPG_STRING_PASSWORD attribute may be used
372 to echo value as asterisks and use wxTE_PASSWORD for wxTextCtrl.
373 wxPG_ATTR_AUTOCOMPLETE attribute may be used to enable auto-completion
374 (use a wxArrayString value), and is also supported by any property that
375 happens to use a wxTextCtrl-based editor.
377 @remarks wxStringProperty has a special trait: if it has value of
378 "<composed>", and also has child properties, then its displayed
379 value becomes composition of child property values, similar as
380 with wxFontProperty, for instance.
382 @subsection wxIntProperty
384 Like wxStringProperty, but converts text to a signed long integer.
385 wxIntProperty seamlessly supports 64-bit integers (ie. wxLongLong).
386 To safely convert variant to integer, use code like this:
390 ll << property->GetValue();
393 wxLongLong ll = propertyGrid->GetPropertyValueAsLong(property);
396 @subsection wxUIntProperty
398 Like wxIntProperty, but displays value as unsigned int. To set
399 the prefix used globally, manipulate wxPG_UINT_PREFIX string attribute.
400 To set the globally used base, manipulate wxPG_UINT_BASE int
401 attribute. Regardless of current prefix, understands (hex) values starting
402 with both "0x" and "$".
403 Like wxIntProperty, wxUIntProperty seamlessly supports 64-bit unsigned
404 integers (ie. wxULongLong). Same wxVariant safety rules apply.
406 @subsection wxFloatProperty
408 Like wxStringProperty, but converts text to a double-precision floating point.
409 Default float-to-text precision is 6 decimals, but this can be changed
410 by modifying wxPG_FLOAT_PRECISION attribute.
412 @subsection wxBoolProperty
414 Represents a boolean value. wxChoice is used as editor control, by the
415 default. wxPG_BOOL_USE_CHECKBOX attribute can be set to true inorder to use
418 @subsection wxLongStringProperty
420 Like wxStringProperty, but has a button that triggers a small text editor
421 dialog. Note that in long string values, tabs are represented by "\t" and
424 To display custom dialog on button press, you can subclass
425 wxLongStringProperty and implement OnButtonClick, like this:
428 virtual bool OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
430 wxSize dialogSize(...size of your dialog...);
432 wxPoint dlgPos = propGrid->GetGoodEditorDialogPosition(this,
435 // Create dialog dlg at dlgPos. Use value as initial string
439 if ( dlg.ShowModal() == wxID_OK )
441 value = dlg.GetStringValue);
448 Also, if you wish not to have line breaks and tabs translated to
449 escape sequences, then do following in constructor of your subclass:
452 m_flags |= wxPG_PROP_NO_ESCAPE;
455 @subsection wxDirProperty
457 Like wxLongStringProperty, but the button triggers dir selector instead.
458 Supported properties (all with string value): wxPG_DIR_DIALOG_MESSAGE.
460 @subsection wxFileProperty
462 Like wxLongStringProperty, but the button triggers file selector instead.
463 Default wildcard is "All files..." but this can be changed by setting
464 wxPG_FILE_WILDCARD attribute (see wxFileDialog for format details).
465 Attribute wxPG_FILE_SHOW_FULL_PATH can be set to @false inorder to show
466 only the filename, not the entire path.
468 @subsection wxEnumProperty
470 Represents a single selection from a list of choices -
471 wxOwnerDrawnComboBox is used to edit the value.
473 @subsection wxFlagsProperty
475 Represents a bit set that fits in a long integer. wxBoolProperty sub-
476 properties are created for editing individual bits. Textctrl is created to
477 manually edit the flags as a text; a continous sequence of spaces, commas
478 and semicolons are considered as a flag id separator.
480 <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty,
481 you will need to use wxPGProperty::SetChoices() - otherwise they will not
482 get updated properly.
484 wxFlagsProperty supports the same attributes as wxBoolProperty.
486 @subsection wxArrayStringProperty
488 Allows editing of a list of strings in wxTextCtrl and in a separate
489 dialog. Supports "Delimiter" attribute, which defaults to comma (',').
491 @subsection wxDateProperty
493 wxDateTime property. Default editor is DatePickerCtrl, altough TextCtrl
494 should work as well. wxPG_DATE_FORMAT attribute can be used to change
495 string wxDateTime::Format uses (altough default is recommended as it is
496 locale-dependant), and wxPG_DATE_PICKER_STYLE allows changing window
497 style given to DatePickerCtrl (default is wxDP_DEFAULT|wxDP_SHOWCENTURY).
498 Using wxDP_ALLOWNONE will enable better unspecified value support.
500 @subsection wxEditEnumProperty
502 Represents a string that can be freely edited or selected from list of choices -
503 custom combobox control is used to edit the value.
505 @subsection wxMultiChoiceProperty
507 Allows editing a multiple selection from a list of strings. This is
508 property is pretty much built around concept of wxMultiChoiceDialog.
509 It uses wxArrayString value.
511 @subsection wxImageFileProperty
513 Like wxFileProperty, but has thumbnail of the image in front of
514 the filename and autogenerates wildcard from available image handlers.
516 @subsection wxColourProperty
518 <b>Useful alternate editor:</b> Choice.
520 Represents wxColour. wxButton is used to trigger a colour picker dialog.
521 There are various sub-classing opportunities with this class. See
522 below in wxSystemColourProperty section for details.
524 @subsection wxFontProperty
526 Represents wxFont. Various sub-properties are used to edit individual
529 @subsection wxSystemColourProperty
531 Represents wxColour and a system colour index. wxChoice is used to edit
532 the value. Drop-down list has color images. Note that value type
533 is wxColourPropertyValue instead of wxColour (which wxColourProperty
537 class wxColourPropertyValue : public wxObject
540 // An integer value relating to the colour, and which exact
541 // meaning depends on the property with which it is used.
543 // For wxSystemColourProperty:
544 // Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR
545 // macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM.
548 // Resulting colour. Should be correct regardless of type.
553 in wxSystemColourProperty, and its derived class wxColourProperty, there
554 are various sub-classing features. To set basic list list of colour
555 names, call wxPGProperty::SetChoices().
558 // Override in derived class to customize how colours are translated
560 virtual wxString ColourToString( const wxColour& col, int index ) const;
562 // Returns index of entry that triggers colour picker dialog
563 // (default is last).
564 virtual int GetCustomColourIndex() const;
566 // Helper function to show the colour dialog
567 bool QueryColourFromUser( wxVariant& variant ) const;
569 // Returns colour for given choice.
570 // Default function returns wxSystemSettings::GetColour(index).
571 virtual wxColour GetColour( int index ) const;
574 @subsection wxCursorProperty
576 Represents a wxCursor. wxChoice is used to edit the value.
577 Drop-down list has cursor images under some (wxMSW) platforms.
580 @section pgproperty_creating Creating Custom Properties
582 New properties can be created by subclassing wxPGProperty or one
583 of the provided property classes, and (re)implementing necessary
584 member functions. Below, each virtual member function has ample
585 documentation about its purpose and any odd details which to keep
588 Here is a very simple 'template' code:
591 class MyProperty : public wxPGProperty
594 // Default constructor
597 // All arguments of this ctor must have a default value -
598 // use wxPG_LABEL for label and name
599 MyProperty( const wxString& label = wxPG_LABEL,
600 const wxString& name = wxPG_LABEL,
601 const wxString& value = wxEmptyString )
602 : wxPGProperty(label, name)
604 // m_value is wxVariant
608 virtual ~MyProperty() { }
610 const wxPGEditor* DoGetEditorClass() const
612 // Determines editor used by property.
613 // You can replace 'TextCtrl' below with any of these
614 // builtin-in property editor identifiers: Choice, ComboBox,
615 // TextCtrlAndButton, ChoiceAndButton, CheckBox, SpinCtrl,
617 return wxPGEditor_TextCtrl;
620 virtual wxString ValueToString( wxVariant& value,
623 // TODO: Convert given property value to a string
626 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags )
628 // TODO: Adapt string to property value.
635 Since wxPGProperty derives from wxObject, you can use standard
636 wxDECLARE_DYNAMIC_CLASS and wxIMPLEMENT_DYNAMIC_CLASS macros. From the
637 above example they were omitted for sake of simplicity, and besides,
638 they are only really needed if you need to use wxRTTI with your
641 You can change the 'value type' of a property by simply assigning different
642 type of variant with SetValue. <b>It is mandatory to implement
643 wxVariantData class for all data types used as property values.</b>
644 You can use macros declared in wxPropertyGrid headers. For instance:
648 // (If you need to have export declaration, use version of macros
649 // with _EXPORTED postfix)
650 WX_PG_DECLARE_VARIANT_DATA(MyDataClass)
653 WX_PG_IMPLEMENT_VARIANT_DATA(MyDataClass)
655 // Or, if you don't have valid == operator:
656 WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(MyDataClass)
662 class wxPGProperty
: public wxObject
665 typedef wxUint32 FlagType
;
674 Non-abstract property classes should have constructor of this style:
678 MyProperty( const wxString& label, const wxString& name, const T& value )
679 : wxPGProperty(label, name)
681 // Generally recommended way to set the initial value
682 // (as it should work in pretty much 100% of cases).
687 // If has private child properties then create them here.
689 // AddPrivateChild( new wxStringProperty("Subprop 1",
691 // value.GetSubProp1()));
696 wxPGProperty( const wxString
& label
, const wxString
& name
);
699 Virtual destructor. It is customary for derived properties to implement this.
701 virtual ~wxPGProperty();
704 This virtual function is called after m_value has been set.
707 - If m_value was set to Null variant (ie. unspecified value), OnSetValue()
709 - m_value may be of any variant type. Typically properties internally support only
710 one variant type, and as such OnSetValue() provides a good opportunity to convert
711 supported values into internal type.
712 - Default implementation does nothing.
714 virtual void OnSetValue();
717 Override this to return something else than m_value as the value.
719 virtual wxVariant
DoGetValue() const;
722 Implement this function in derived class to check the value.
723 Return @true if it is ok. Returning @false prevents property change events
727 - Default implementation always returns @true.
729 virtual bool ValidateValue( wxVariant
& value
, wxPGValidationInfo
& validationInfo
) const;
732 Converts text into wxVariant value appropriate for this property.
735 On function entry this is the old value (should not be wxNullVariant
736 in normal cases). Translated value must be assigned back to it.
739 Text to be translated into variant.
742 If wxPG_FULL_VALUE is set, returns complete, storable value instead
743 of displayable one (they may be different).
744 If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of
745 composite property string value (as generated by ValueToString()
746 called with this same flag).
748 @return Returns @true if resulting wxVariant value was different.
750 @remarks Default implementation converts semicolon delimited tokens into
751 child values. Only works for properties with children.
753 You might want to take into account that m_value is Null variant
754 if property value is unspecified (which is usually only case if
755 you explicitly enabled that sort behavior).
757 virtual bool StringToValue( wxVariant
& variant
, const wxString
& text
, int argFlags
= 0 ) const;
760 Converts integer (possibly a choice selection) into wxVariant value
761 appropriate for this property.
764 On function entry this is the old value (should not be wxNullVariant
765 in normal cases). Translated value must be assigned back to it.
767 Integer to be translated into variant.
769 If wxPG_FULL_VALUE is set, returns complete, storable value instead
772 @return Returns @true if resulting wxVariant value was different.
775 - If property is not supposed to use choice or spinctrl or other editor
776 with int-based value, it is not necessary to implement this method.
777 - Default implementation simply assign given int to m_value.
778 - If property uses choice control, and displays a dialog on some choice
779 items, then it is preferred to display that dialog in IntToValue
781 - You might want to take into account that m_value is Mull variant if
782 property value is unspecified (which is usually only case if you
783 explicitly enabled that sort behavior).
785 virtual bool IntToValue( wxVariant
& variant
, int number
, int argFlags
= 0 ) const;
788 Converts property value into a text representation.
791 Value to be converted.
793 If 0 (default value), then displayed string is returned.
794 If wxPG_FULL_VALUE is set, returns complete, storable string value
795 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
796 string value that must be editable in textctrl.
797 If wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
798 display as a part of string property's composite text representation.
800 @remarks Default implementation calls GenerateComposedValue().
802 virtual wxString
ValueToString( wxVariant
& value
, int argFlags
= 0 ) const;
805 Converts string to a value, and if successful, calls SetValue() on it.
806 Default behavior is to do nothing.
809 String to get the value from.
813 @return @true if value was changed.
815 bool SetValueFromString( const wxString
& text
, int flags
= 0 );
818 Converts integer to a value, and if succesful, calls SetValue() on it.
819 Default behavior is to do nothing.
822 Int to get the value from.
824 If has wxPG_FULL_VALUE, then the value given is a actual value and not an index.
826 @return @true if value was changed.
828 bool SetValueFromInt( long value
, int flags
= 0 );
831 Returns size of the custom painted image in front of property. This method
832 must be overridden to return non-default value if OnCustomPaint is to be
836 Normally -1, but can be an index to the property's list of items.
839 - Default behavior is to return wxSize(0,0), which means no image.
840 - Default image width or height is indicated with dimension -1.
841 - You can also return wxPG_DEFAULT_IMAGE_SIZE which equals wxSize(-1, -1).
843 virtual wxSize
OnMeasureImage( int item
= -1 ) const;
846 Events received by editor widgets are processed here. Note that editor class
847 usually processes most events. Some, such as button press events of
848 TextCtrlAndButton class, can be handled here. Also, if custom handling
849 for regular events is desired, then that can also be done (for example,
850 wxSystemColourProperty custom handles wxEVT_COMMAND_CHOICE_SELECTED
851 to display colour picker dialog when 'custom' selection is made).
853 If the event causes value to be changed, SetValueInEvent() should be called
854 to set the new value.
856 The parameter @a event is the associated wxEvent.
859 Should return @true if any changes in value should be reported.
862 - If property uses choice control, and displays a dialog on some choice items,
863 then it is preferred to display that dialog in IntToValue instead of OnEvent.
865 virtual bool OnEvent( wxPropertyGrid
* propgrid
, wxWindow
* wnd_primary
, wxEvent
& event
);
868 Called after value of a child property has been altered. Must return
869 new value of the whole property (after any alterations warrented by
872 Note that this function is usually called at the time that value of
873 this property, or given child property, is still pending for change,
874 and as such, result of GetValue() or m_value should not be relied
877 Sample pseudo-code implementation:
880 wxVariant MyProperty::ChildChanged( wxVariant& thisValue,
882 wxVariant& childValue ) const
884 // Acquire reference to actual type of data stored in variant
885 // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros
886 // were used to create the variant class).
887 T& data = TFromVariant(thisValue);
889 // Copy childValue into data.
890 switch ( childIndex )
893 data.SetSubProp1( childvalue.GetLong() );
896 data.SetSubProp2( childvalue.GetString() );
901 // Return altered data
907 Value of this property. Changed value should be returned (in
908 previous versions of wxPropertyGrid it was only necessary to
909 write value back to this argument).
911 Index of child changed (you can use Item(childIndex) to get
914 (Pending) value of the child property.
917 Modified value of the whole property.
919 virtual wxVariant
ChildChanged( wxVariant
& thisValue
,
921 wxVariant
& childValue
) const;
924 Returns pointer to an instance of used editor.
926 virtual const wxPGEditor
* DoGetEditorClass() const;
929 Returns pointer to the wxValidator that should be used
930 with the editor of this property (@NULL for no validator).
931 Setting validator explicitly via SetPropertyValidator
934 In most situations, code like this should work well
935 (macros are used to maintain one actual validator instance,
936 so on the second call the function exits within the first
941 wxValidator* wxMyPropertyClass::DoGetValidator () const
943 WX_PG_DOGETVALIDATOR_ENTRY()
945 wxMyValidator* validator = new wxMyValidator(...);
947 ... prepare validator...
949 WX_PG_DOGETVALIDATOR_EXIT(validator)
955 You can get common filename validator by returning
956 wxFileProperty::GetClassValidator(). wxDirProperty,
957 for example, uses it.
959 virtual wxValidator
* DoGetValidator () const;
962 Override to paint an image in front of the property value text or drop-down
963 list item (but only if wxPGProperty::OnMeasureImage is overridden as well).
965 If property's OnMeasureImage() returns size that has height != 0 but less than
966 row height ( < 0 has special meanings), wxPropertyGrid calls this method to
967 draw a custom image in a limited area in front of the editor control or
968 value text/graphics, and if control has drop-down list, then the image is
969 drawn there as well (even in the case OnMeasureImage() returned higher height
972 NOTE: Following applies when OnMeasureImage() returns a "flexible" height (
973 using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items:
974 If rect.x is < 0, then this is a measure item call, which means that
975 dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight
976 to the height of the image of item at index paintdata.m_choiceItem. This call
977 may be done even as often as once every drop-down popup show.
982 Box reserved for custom graphics. Includes surrounding rectangle, if any.
983 If x is < 0, then this is a measure item call (see above).
985 wxPGPaintData structure with much useful data about painted item.
990 const wxPropertyGrid* m_parent;
992 // Normally -1, otherwise index to drop-down list item that has to be drawn.
995 // Set to drawn width in OnCustomPaint (optional).
998 // In a measure item call, set this to the height of item at m_choiceItem index
1004 - You can actually exceed rect width, but if you do so then paintdata.m_drawnWidth
1005 must be set to the full width drawn in pixels.
1006 - Due to technical reasons, rect's height will be default even if custom height
1007 was reported during measure call.
1008 - Brush is guaranteed to be default background colour. It has been already used to
1009 clear the background of area being painted. It can be modified.
1010 - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper colour) pen for
1011 drawing framing rectangle. It can be changed as well.
1013 @see ValueToString()
1015 virtual void OnCustomPaint( wxDC
& dc
, const wxRect
& rect
, wxPGPaintData
& paintdata
);
1018 Returns used wxPGCellRenderer instance for given property column (label=0, value=1).
1020 Default implementation returns editor's renderer for all columns.
1022 virtual wxPGCellRenderer
* GetCellRenderer( int column
) const;
1025 Returns which choice is currently selected. Only applies to properties
1028 Needs to reimplemented in derived class if property value does not
1029 map directly to a choice. Integer as index, bool, and string usually do.
1031 virtual int GetChoiceSelection() const;
1034 Refresh values of child properties. Automatically called after value is set.
1036 virtual void RefreshChildren();
1039 Reimplement this member function to add special handling for
1040 attributes of this property.
1042 @return Return @false to have the attribute automatically stored in
1043 m_attributes. Default implementation simply does that and
1046 @remarks To actually set property attribute values from the
1047 application, use wxPGProperty::SetAttribute() instead.
1049 virtual bool DoSetAttribute( const wxString
& name
, wxVariant
& value
);
1052 Returns value of an attribute.
1054 Override if custom handling of attributes is needed.
1056 Default implementation simply return @NULL variant.
1058 virtual wxVariant
DoGetAttribute( const wxString
& name
) const;
1061 Returns instance of a new wxPGEditorDialogAdapter instance, which is
1062 used when user presses the (optional) button next to the editor control;
1064 Default implementation returns @NULL (ie. no action is generated when
1067 virtual wxPGEditorDialogAdapter
* GetEditorDialog() const;
1070 Called whenever validation has failed with given pending value.
1072 @remarks If you implement this in your custom property class, please
1073 remember to call the baser implementation as well, since they
1074 may use it to revert property into pre-change state.
1076 virtual void OnValidationFailure( wxVariant
& pendingValue
);
1079 Append a new choice to property's list of choices.
1082 Label for added choice.
1085 Value for new choice. Do not specify if you wish this
1086 to equal choice index.
1089 Index to added choice.
1091 int AddChoice( const wxString
& label
, int value
= wxPG_INVALID_VALUE
);
1094 Adds a private child property.
1096 @deprecated Use AddPrivateChild() instead.
1098 @see AddPrivateChild()
1100 wxDEPRECATED( void AddChild( wxPGProperty
* prop
) );
1103 Adds a private child property. If you use this instead of
1104 wxPropertyGridInterface::Insert() or
1105 wxPropertyGridInterface::AppendIn(), then property's parental
1106 type will automatically be set up to wxPG_PROP_AGGREGATE. In other
1107 words, all properties of this property will become private.
1109 void AddPrivateChild( wxPGProperty
* prop
);
1112 Adapts list variant into proper value using consecutive
1113 ChildChanged() calls.
1115 void AdaptListToValue( wxVariant
& list
, wxVariant
* value
) const;
1118 Use this member function to add independent (ie. regular) children to
1121 @return Appended childProperty.
1123 @remarks wxPropertyGrid is not automatically refreshed by this
1126 @see InsertChild(), AddPrivateChild()
1128 wxPGProperty
* AppendChild( wxPGProperty
* childProperty
);
1131 Determines, recursively, if all children are not unspecified.
1134 Assumes members in this wxVariant list as pending
1137 bool AreAllChildrenSpecified( wxVariant
* pendingList
= NULL
) const;
1140 Returns @true if children of this property are component values (for instance,
1141 points size, face name, and is_underlined are component values of a font).
1143 bool AreChildrenComponents() const;
1146 Sets or clears given property flag. Mainly for internal use.
1148 @remarks Setting a property flag never has any side-effect, and is
1149 intended almost exclusively for internal use. So, for
1150 example, if you want to disable a property, call
1151 Enable(false) instead of setting wxPG_PROP_DISABLED flag.
1153 @see HasFlag(), GetFlags()
1155 void ChangeFlag( wxPGPropertyFlags flag
, bool set
);
1158 Deletes children of the property.
1160 void DeleteChildren();
1163 Removes entry from property's wxPGChoices and editor control (if it is active).
1165 If selected item is deleted, then the value is set to unspecified.
1167 void DeleteChoice( int index
);
1169 /** Deletes all child properties. */
1173 Enables or disables the property. Disabled property usually appears
1174 as having grey text.
1177 If @false, property is disabled instead.
1179 @see wxPropertyGridInterface::EnableProperty()
1181 void Enable( bool enable
= true );
1184 Composes text from values of child properties.
1186 wxString
GenerateComposedValue() const;
1189 Returns property attribute value, null variant if not found.
1191 wxVariant
GetAttribute( const wxString
& name
) const;
1193 /** Returns named attribute, as string, if found. Otherwise defVal is returned.
1195 wxString
GetAttribute( const wxString
& name
, const wxString
& defVal
) const;
1197 /** Returns named attribute, as long, if found. Otherwise defVal is returned.
1199 long GetAttributeAsLong( const wxString
& name
, long defVal
) const;
1201 /** Returns named attribute, as double, if found. Otherwise defVal is returned.
1203 double GetAttributeAsDouble( const wxString
& name
, double defVal
) const;
1206 Returns attributes as list wxVariant.
1208 wxVariant
GetAttributesAsList() const;
1211 Returns editor used for given column. @NULL for no editor.
1213 const wxPGEditor
* GetColumnEditor( int column
) const;
1215 /** Returns property's base name (ie. parent's name is not added in any case) */
1216 const wxString
& GetBaseName() const;
1219 Returns wxPGCell of given column.
1221 @remarks const version of this member function returns 'default'
1222 wxPGCell object if the property itself didn't hold
1225 const wxPGCell
& GetCell( unsigned int column
) const;
1228 Returns wxPGCell of given column, creating one if necessary.
1230 wxPGCell
& GetCell( unsigned int column
);
1233 Returns wxPGCell of given column, creating one if necessary.
1235 wxPGCell
& GetOrCreateCell( unsigned int column
);
1238 Returns number of child properties.
1240 unsigned int GetChildCount() const;
1243 Returns height of children, recursively, and
1244 by taking expanded/collapsed status into account.
1247 Line height. Pass result of GetGrid()->GetRowHeight() here.
1250 Only used (internally) when finding property y-positions.
1252 int GetChildrenHeight( int lh
, int iMax
= -1 ) const;
1255 Returns read-only reference to property's list of choices.
1257 const wxPGChoices
& GetChoices() const;
1260 Returns client data (void*) of a property.
1262 void* GetClientData() const;
1264 /** Sets managed client object of a property.
1266 wxClientData
*GetClientObject() const;
1269 Returns property's default value. If property's value type is not
1270 a built-in one, and "DefaultValue" attribute is not defined, then
1271 this function usually returns Null variant.
1273 wxVariant
GetDefaultValue() const;
1275 /** Returns property's displayed text.
1277 wxString
GetDisplayedString() const;
1280 Returns wxPGEditor that will be used and created when
1281 property becomes selected. Returns more accurate value
1282 than DoGetEditorClass().
1284 const wxPGEditor
* GetEditorClass() const;
1287 Returns property flags.
1289 FlagType
GetFlags() const;
1291 /** Returns property grid where property lies. */
1292 wxPropertyGrid
* GetGrid() const;
1295 Returns owner wxPropertyGrid, but only if one is currently on a page
1296 displaying this property.
1298 wxPropertyGrid
* GetGridIfDisplayed() const;
1301 Returns property's help or description text.
1303 @see SetHelpString()
1305 const wxString
& GetHelpString() const;
1308 Returns position in parent's array.
1310 unsigned int GetIndexInParent() const;
1312 /** Returns property's label. */
1313 const wxString
& GetLabel() const;
1316 Returns last visible child property, recursively.
1318 const wxPGProperty
* GetLastVisibleSubItem() const;
1321 Returns highest level non-category, non-root parent. Useful when you
1322 have nested properties with children.
1324 @remarks If immediate parent is root or category, this will return the
1327 wxPGProperty
* GetMainParent() const;
1329 /** Returns maximum allowed length of property's text value.
1331 int GetMaxLength() const;
1333 /** Returns property's name with all (non-category, non-root) parents. */
1334 wxString
GetName() const;
1336 /** Return parent of property */
1337 wxPGProperty
* GetParent() const;
1340 Returns (direct) child property with given name (or @NULL if not found).
1342 wxPGProperty
* GetPropertyByName( const wxString
& name
) const;
1344 /** Gets assignable version of property's validator. */
1345 wxValidator
* GetValidator() const;
1348 Returns property's value.
1350 wxVariant
GetValue() const;
1353 Returns bitmap that appears next to value text. Only returns non-@NULL
1354 bitmap if one was set with SetValueImage().
1356 wxBitmap
* GetValueImage() const;
1358 /** Returns text representation of property's value.
1361 If 0 (default value), then displayed string is returned.
1362 If wxPG_FULL_VALUE is set, returns complete, storable string value
1363 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
1364 string value that must be editable in textctrl. If
1365 wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
1366 display as a part of string property's composite text
1369 @remarks In older versions, this function used to be overridden to convert
1370 property's value into a string representation. This function is
1371 now handled by ValueToString(), and overriding this function now
1372 will result in run-time assertion failure.
1374 virtual wxString
GetValueAsString( int argFlags
= 0 ) const;
1376 /** Synonymous to GetValueAsString().
1378 @deprecated Use GetValueAsString() instead.
1380 @see GetValueAsString()
1382 wxDEPRECATED( wxString
GetValueString( int argFlags
= 0 ) const );
1385 Returns value type used by this property.
1387 wxString
GetValueType() const;
1390 Returns coordinate to the top y of the property. Note that the
1391 position of scrollbars is not taken into account.
1396 Returns non-zero if property has given flag set.
1398 @see propgrid_propflags
1400 FlagType
HasFlag( wxPGPropertyFlags flag
) const;
1403 Returns @true if property has even one visible child.
1405 bool HasVisibleChildren() const;
1408 Hides or reveals the property.
1411 @true for hide, @false for reveal.
1414 By default changes are applied recursively. Set this parameter wxPG_DONT_RECURSE to prevent this.
1416 bool Hide( bool hide
, int flags
= wxPG_RECURSE
);
1419 Returns index of given child property. wxNOT_FOUND if
1420 given property is not child of this.
1422 int Index( const wxPGProperty
* p
) const;
1425 Use this member function to add independent (ie. regular) children to
1428 @return Inserted childProperty.
1430 @remarks wxPropertyGrid is not automatically refreshed by this
1433 @see AppendChild(), AddPrivateChild()
1435 wxPGProperty
* InsertChild( int index
, wxPGProperty
* childProperty
);
1438 Inserts a new choice to property's list of choices.
1444 Insertion position. Use wxNOT_FOUND to append.
1447 Value for new choice. Do not specify if you wish this
1448 to equal choice index.
1450 int InsertChoice( const wxString
& label
, int index
, int value
= wxPG_INVALID_VALUE
);
1453 Returns @true if this property is actually a wxPropertyCategory.
1455 bool IsCategory() const;
1458 Returns @true if property is enabled.
1460 bool IsEnabled() const;
1463 Returns @true if property has visible children.
1465 bool IsExpanded() const;
1468 Returns @true if this property is actually a wxRootProperty.
1470 bool IsRoot() const;
1473 Returns @true if candidateParent is some parent of this property.
1475 bool IsSomeParent( wxPGProperty
* candidateParent
) const;
1478 Returns true if property has editable wxTextCtrl when selected.
1480 @remarks Altough disabled properties do not displayed editor, they still
1481 return @true here as being disabled is considered a temporary
1482 condition (unlike being read-only or having limited editing enabled).
1484 bool IsTextEditable() const;
1487 Returns @true if property's value is considered unspecified. This
1488 usually means that value is Null variant.
1490 bool IsValueUnspecified() const;
1493 Returns true if all parents expanded.
1495 bool IsVisible() const;
1498 Returns child property at index i.
1500 wxPGProperty
* Item( unsigned int i
) const;
1503 If property's editor is active, then update it's value.
1505 void RefreshEditor();
1508 Sets an attribute for this property.
1511 Text identifier of attribute. See @ref propgrid_property_attributes.
1516 @remarks Setting attribute's value to Null variant will simply remove it
1517 from property's set of attributes.
1519 void SetAttribute( const wxString
& name
, wxVariant value
);
1522 Set if user can change the property's value to unspecified by
1523 modifying the value of the editor control (usually by clearing
1524 it). Currently, this can work with following properties:
1525 wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty.
1528 Whether to enable or disable this behavior (it is disabled by
1531 void SetAutoUnspecified( bool enable
= true );
1534 Sets property's background colour.
1537 Background colour to use.
1540 Default is wxPG_RECURSE which causes colour to be set recursively.
1541 Omit this flag to only set colour for the property in question
1542 and not any of its children.
1544 void SetBackgroundColour( const wxColour
& colour
,
1545 int flags
= wxPG_RECURSE
);
1548 Sets editor for a property.
1551 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1552 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list).
1554 For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass().
1556 void SetEditor( const wxPGEditor
* editor
);
1559 Sets editor for a property, by editor name.
1561 void SetEditor( const wxString
& editorName
);
1564 Sets cell information for given column.
1566 void SetCell( int column
, const wxPGCell
& cell
);
1569 Sets new set of choices for the property.
1571 @remarks This operation deselects the property and clears its
1574 bool SetChoices( wxPGChoices
& choices
);
1577 Sets client data (void*) of a property.
1579 @remarks This untyped client data has to be deleted manually.
1581 void SetClientData( void* clientData
);
1583 /** Returns client object of a property.
1585 void SetClientObject(wxClientData
* clientObject
);
1588 Sets selected choice and changes property value.
1590 Tries to retain value type, although currently if it is not string,
1591 then it is forced to integer.
1593 void SetChoiceSelection( int newValue
);
1595 /** Set default value of a property. Synonymous to
1598 SetAttribute("DefaultValue", value);
1601 void SetDefaultValue( wxVariant
& value
);
1604 Sets or clears given property flag, recursively. This function is
1605 primarily intended for internal use.
1609 void SetFlagRecursively( wxPGPropertyFlags flag
, bool set
);
1612 Sets property's help string, which is shown, for example, in
1613 wxPropertyGridManager's description text box.
1615 void SetHelpString( const wxString
& helpString
);
1618 Sets property's label.
1620 @remarks Properties under same parent may have same labels. However,
1621 property names must still remain unique.
1623 void SetLabel( const wxString
& label
);
1626 Set max length of text in text editor.
1628 bool SetMaxLength( int maxLen
);
1631 Sets property's "is it modified?" flag. Affects children recursively.
1633 void SetModifiedStatus( bool modified
);
1636 Sets new (base) name for property.
1638 void SetName( const wxString
& newName
);
1641 Changes what sort of parent this property is for its children.
1644 Use one of the following values: wxPG_PROP_MISC_PARENT (for generic
1645 parents), wxPG_PROP_CATEGORY (for categories), or
1646 wxPG_PROP_AGGREGATE (for derived property classes with private
1649 @remarks You generally do not need to call this function.
1651 void SetParentalType( int flag
);
1654 Sets property's text colour.
1660 Default is wxPG_RECURSE which causes colour to be set recursively.
1661 Omit this flag to only set colour for the property in question
1662 and not any of its children.
1664 void SetTextColour( const wxColour
& colour
,
1665 int flags
= wxPG_RECURSE
);
1667 /** Sets wxValidator for a property */
1668 void SetValidator( const wxValidator
& validator
);
1671 Call this to set value of the property. Unlike methods in wxPropertyGrid,
1672 this does not automatically update the display.
1675 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
1676 validation process and send property change event.
1678 If you need to change property value in event, based on user input, use
1679 SetValueInEvent() instead.
1684 Pointer to list variant that contains child values. Used to indicate
1685 which children should be marked as modified. Usually you just use @NULL.
1687 wxPG_SETVAL_REFRESH_EDITOR is set by default, to refresh editor
1688 and redraw properties.
1690 void SetValue( wxVariant value
, wxVariant
* pList
= NULL
,
1691 int flags
= wxPG_SETVAL_REFRESH_EDITOR
);
1694 Set wxBitmap in front of the value. This bitmap may be ignored
1695 by custom cell renderers.
1697 void SetValueImage( wxBitmap
& bmp
);
1700 Call this function in OnEvent(), OnButtonClick() etc. to change the
1701 property value based on user input.
1703 @remarks This method is const since it doesn't actually modify value, but posts
1704 given variant as pending value, stored in wxPropertyGrid.
1706 void SetValueInEvent( wxVariant value
) const;
1709 Sets property's value to unspecified (ie. Null variant).
1711 void SetValueToUnspecified();
1714 Call with @false in OnSetValue() to cancel value changes after all
1715 (ie. cancel @true returned by StringToValue() or IntToValue()).
1717 void SetWasModified( bool set
= true );
1720 Updates composed values of parent non-category properties, recursively.
1721 Returns topmost property updated.
1723 wxPGProperty
* UpdateParentValues();
1726 Returns @true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES.
1728 bool UsesAutoUnspecified() const;
1735 Base class for wxPropertyGrid cell information.
1737 @library{wxpropgrid}
1740 class wxPGCell
: public wxObject
1744 wxPGCell(const wxPGCell
& other
);
1745 wxPGCell( const wxString
& text
,
1746 const wxBitmap
& bitmap
= wxNullBitmap
,
1747 const wxColour
& fgCol
= wxNullColour
,
1748 const wxColour
& bgCol
= wxNullColour
);
1750 virtual ~wxPGCell();
1752 const wxPGCellData
* GetData() const;
1755 Returns @true if this cell has custom text stored within.
1757 bool HasText() const;
1760 Merges valid data from srcCell into this.
1762 void MergeFrom( const wxPGCell
& srcCell
);
1764 void SetText( const wxString
& text
);
1765 void SetBitmap( const wxBitmap
& bitmap
);
1766 void SetFgCol( const wxColour
& col
);
1769 Sets font of the cell.
1771 @remarks Because wxPropertyGrid does not support rows of
1772 different height, it makes little sense to change
1773 size of the font. Therefore it is recommended
1774 to use return value of wxPropertyGrid::GetFont()
1775 or wxPropertyGrid::GetCaptionFont() as a basis
1776 for the font that, after modifications, is passed
1777 to this member function.
1779 void SetFont( const wxFont
& font
);
1781 void SetBgCol( const wxColour
& col
);
1783 const wxString
& GetText() const;
1784 const wxBitmap
& GetBitmap() const;
1785 const wxColour
& GetFgCol() const;
1788 Returns font of the cell. If no specific font is set for this
1789 cell, then the font will be invalid.
1791 const wxFont
& GetFont() const;
1793 const wxColour
& GetBgCol() const;
1795 wxPGCell
& operator=( const wxPGCell
& other
);
1802 Helper class for managing choices of wxPropertyGrid properties.
1803 Each entry can have label, value, bitmap, text colour, and background
1806 wxPGChoices uses reference counting, similar to other wxWidgets classes.
1807 This means that assignment operator and copy constructor only copy the
1808 reference and not the actual data. Use Copy() member function to create a
1811 @remarks If you do not specify value for entry, index is used.
1813 @library{wxpropgrid}
1819 typedef long ValArrItem
;
1822 Default constructor.
1827 Copy constructor, uses reference counting. To create a real copy,
1828 use Copy() member function instead.
1830 wxPGChoices( const wxPGChoices
& a
);
1833 wxPGChoices( const wxChar
** labels
, const long* values
= NULL
);
1836 wxPGChoices( const wxArrayString
& labels
, const wxArrayInt
& values
= wxArrayInt() );
1839 wxPGChoices( wxPGChoicesData
* data
);
1845 Adds to current. If did not have own copies, creates them now. If was empty,
1846 identical to set except that creates copies.
1848 void Add( const wxChar
** labels
, const ValArrItem
* values
= NULL
);
1850 /** Version that works with wxArrayString. */
1851 void Add( const wxArrayString
& arr
, const ValArrItem
* values
= NULL
);
1853 /** Version that works with wxArrayString and wxArrayInt. */
1854 void Add( const wxArrayString
& arr
, const wxArrayInt
& arrint
);
1856 /** Adds single item. */
1857 wxPGChoiceEntry
& Add( const wxString
& label
, int value
= wxPG_INVALID_VALUE
);
1859 /** Adds a single item, with bitmap. */
1860 wxPGChoiceEntry
& Add( const wxString
& label
, const wxBitmap
& bitmap
,
1861 int value
= wxPG_INVALID_VALUE
);
1863 /** Adds a single item with full entry information. */
1864 wxPGChoiceEntry
& Add( const wxPGChoiceEntry
& entry
);
1866 /** Adds single item, sorted. */
1867 wxPGChoiceEntry
& AddAsSorted( const wxString
& label
, int value
= wxPG_INVALID_VALUE
);
1870 Assigns choices data, using reference counting. To create a real copy,
1871 use Copy() member function instead.
1873 void Assign( const wxPGChoices
& a
);
1876 Assigns data from another set of choices.
1878 void AssignData( wxPGChoicesData
* data
);
1886 Returns a real copy of the choices.
1888 wxPGChoices
Copy() const;
1891 Returns labe of item.
1893 const wxString
& GetLabel( unsigned int ind
) const;
1896 Returns number of items.
1898 unsigned int GetCount() const;
1901 Returns value of item;
1903 int GetValue( unsigned int ind
) const;
1906 Returns array of values matching the given strings. Unmatching strings
1907 result in wxPG_INVALID_VALUE entry in array.
1909 wxArrayInt
GetValuesForStrings( const wxArrayString
& strings
) const;
1912 Returns array of indices matching given strings. Unmatching strings
1913 are added to 'unmatched', if not @NULL.
1915 wxArrayInt
GetIndicesForStrings( const wxArrayString
& strings
,
1916 wxArrayString
* unmatched
= NULL
) const;
1918 /** Returns property at given virtual y coordinate.
1920 wxPGProperty
* GetItemAtY( unsigned int y
) const;
1923 Returns @true if item at given index has a valid value;
1925 bool HasValue( unsigned int i
) const;
1928 Returns index of item with given label.
1930 int Index( const wxString
& label
) const;
1933 Returns index of item with given value.
1935 int Index( int val
) const;
1938 Inserts single item.
1940 wxPGChoiceEntry
& Insert( const wxString
& label
, int index
, int value
= wxPG_INVALID_VALUE
);
1943 Inserts a single item with full entry information.
1945 wxPGChoiceEntry
& Insert( const wxPGChoiceEntry
& entry
, int index
);
1948 Returns @false if this is a constant empty set of choices,
1949 which should not be modified.
1954 Returns item at given index.
1956 const wxPGChoiceEntry
& Item( unsigned int i
) const;
1959 Returns item at given index.
1961 wxPGChoiceEntry
& Item( unsigned int i
);
1964 Removes count items starting at position nIndex.
1966 void RemoveAt(size_t nIndex
, size_t count
= 1);
1969 Sets contents from lists of strings and values.
1971 void Set( const wxChar
** labels
, const long* values
= NULL
);
1974 Sets contents from lists of strings and values.
1976 void Set( const wxArrayString
& labels
, const wxArrayInt
& values
= wxArrayInt() );
1979 Creates exclusive copy of current choices.
1981 void AllocExclusive();
1984 Returns array of choice labels.
1986 wxArrayString
GetLabels() const;
1988 void operator= (const wxPGChoices
& a
);
1990 wxPGChoiceEntry
& operator[](unsigned int i
);
1991 const wxPGChoiceEntry
& operator[](unsigned int i
) const;
1994 // -----------------------------------------------------------------------