wxPropertyGrid
|
This is a somewhat inefficient but versatile property class. More...
#include <props.h>
Public Member Functions | |
virtual void | ChildChanged (wxVariant &a1, int a2, wxVariant &a3) const |
Called after value of a child property has been altered. | |
virtual bool | DoSetAttribute (const wxString &name, wxVariant &value) |
Special handling for attributes of this property. | |
virtual int | GetChoiceInfo (wxPGChoiceInfo *choiceinfo) |
Returns current value's index to the choice control. | |
virtual wxString | GetValueAsString (int argFlags) const |
Returns text representation of property's value. | |
virtual bool | IntToValue (wxVariant &variant, int number, int argFlags) const |
Converts 'number' (including choice selection) into proper value 'variant'. | |
virtual void | OnCustomPaint (wxDC &dc, const wxRect &rect, wxPGPaintData &paintdata) |
Override to paint an image in front of the property value text or drop-down list item (but only if wxPGProperty::OnMeasureImage is overridden as well). | |
virtual wxSize | OnMeasureImage (int item) const |
Returns size of the custom painted image in front of property. | |
virtual bool | StringToValue (wxVariant &variant, const wxString &text, int argFlags=0) const |
Converts 'text' into proper value 'variant'. | |
wxCustomProperty (const wxString &label=wxPG_LABEL, const wxString &name=wxPG_LABEL) | |
Protected Attributes | |
wxPGChoices | m_choices |
wxPGPaintCallback | m_paintCallback |
This is a somewhat inefficient but versatile property class.
Base class offers the following:
virtual void wxCustomProperty::ChildChanged | ( | wxVariant & | thisValue, |
int | childIndex, | ||
wxVariant & | childValue | ||
) | const [virtual] |
Called after value of a child property has been altered.
Note that this function is usually called at the time that value of this property, or given child property, is still pending for change.
Sample pseudo-code implementation:
void MyProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const { // Acquire reference to actual type of data stored in variant // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros were used to create // the variant class). T& data = TFromVariant(thisValue); // Copy childValue into data. switch ( childIndex ) { case 0: data.SetSubProp1( childvalue.GetLong() ); break; case 1: data.SetSubProp2( childvalue.GetString() ); break; ... } }
thisValue | Value of this property, that should be altered. |
childIndex | Index of child changed (you can use Item(childIndex) to get). |
childValue | Value of the child property. |
Reimplemented from wxPGProperty.
virtual bool wxCustomProperty::DoSetAttribute | ( | const wxString & | name, |
wxVariant & | value | ||
) | [virtual] |
Special handling for attributes of this property.
If returns false, then the attribute will be automatically stored in m_attributes.
Default implementation simply returns false.
Reimplemented from wxPGProperty.
virtual int wxCustomProperty::GetChoiceInfo | ( | wxPGChoiceInfo * | choiceinfo | ) | [virtual] |
Returns current value's index to the choice control.
May also return, through pointer arguments, strings that should be inserted to that control. Irrelevant to classes which do not employ wxPG_EDITOR(Choice) or similar.
Reimplemented from wxPGProperty.
virtual wxString wxCustomProperty::GetValueAsString | ( | int | argFlags | ) | const [virtual] |
Returns text representation of property's value.
Generally this function should not be called from the application code. Instead, call GetValueString().
argFlags | If wxPG_FULL_VALUE is set, returns complete, storable string value instead of displayable. If wxPG_EDITABLE_VALUE is set, returns string value that must be editable in textctrl. If wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to display as a part of composite property string value. |
Reimplemented from wxPGProperty.
virtual bool wxCustomProperty::IntToValue | ( | wxVariant & | value, |
int | number, | ||
int | argFlags | ||
) | const [virtual] |
Converts 'number' (including choice selection) into proper value 'variant'.
Returns true if new (different than m_value) value could be interpreted from the integer.
argFlags | If wxPG_FULL_VALUE is set, returns complete, storable value instead of displayable |
Reimplemented from wxPGProperty.
virtual void wxCustomProperty::OnCustomPaint | ( | wxDC & | dc, |
const wxRect & | rect, | ||
wxPGPaintData & | paintdata | ||
) | [virtual] |
Override to paint an image in front of the property value text or drop-down list item (but only if wxPGProperty::OnMeasureImage is overridden as well).
If property's OnMeasureImage() returns size that has height != 0 but less than row height ( < 0 has special meanings), wxPropertyGrid calls this method to draw a custom image in a limited area in front of the editor control or value text/graphics, and if control has drop-down list, then the image is drawn there as well (even in the case OnMeasureImage() returned higher height than row height).
NOTE: Following applies when OnMeasureImage() returns a "flexible" height ( using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items: If rect.x is < 0, then this is a measure item call, which means that dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight to the height of the image of item at index paintdata.m_choiceItem. This call may be done even as often as once every drop-down popup show.
dc | wxDC to paint on. |
rect | Box reserved for custom graphics. Includes surrounding rectangle, if any. If x is < 0, then this is a measure item call (see above). |
paintdata | wxPGPaintData structure with much useful data. |
Reimplemented from wxPGProperty.
virtual wxSize wxCustomProperty::OnMeasureImage | ( | int | item | ) | const [virtual] |
Returns size of the custom painted image in front of property.
This method must be overridden to return non-default value if OnCustomPaint is to be called.
item | Normally -1, but can be an index to the property's list of items. |
Reimplemented from wxPGProperty.
virtual bool wxCustomProperty::StringToValue | ( | wxVariant & | variant, |
const wxString & | text, | ||
int | argFlags = 0 |
||
) | const [virtual] |
Converts 'text' into proper value 'variant'.
Returns true if new (different than m_value) value could be interpreted from the text.
argFlags | If wxPG_FULL_VALUE is set, returns complete, storable value instead of displayable one (they may be different). If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of composite property string value (as generated by GetValueAsString() called with this same flag). |
Reimplemented from wxPGProperty.