@code
virtual bool OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
{
- // Update property value from editor, if necessary
- PrepareValueForDialogEditing(propGrid);
-
wxSize dialogSize(...size of your dialog...);
wxPoint dlgPos = propGrid->GetGoodEditorDialogPosition(this,
<b>Useful alternate editor:</b> Choice.
Represents wxColour. wxButton is used to trigger a colour picker dialog.
+ There are various sub-classing opportunities with this class. See
+ below in wxSystemColourProperty section for details.
@subsection wxFontProperty
Represents wxColour and a system colour index. wxChoice is used to edit
the value. Drop-down list has color images. Note that value type
- is wxColourPropertyValue instead of wxColour.
+ is wxColourPropertyValue instead of wxColour (which wxColourProperty
+ uses).
+
@code
class wxColourPropertyValue : public wxObject
{
wxColour m_colour;
};
@endcode
+
+ in wxSystemColourProperty, and its derived class wxColourProperty, there
+ are various sub-classing features. To set basic list list of colour
+ names, call wxPGProperty::SetChoices().
+
+ @code
+ // Override in derived class to customize how colours are translated
+ // to strings.
+ virtual wxString ColourToString( const wxColour& col, int index ) const;
+
+ // Returns index of entry that triggers colour picker dialog
+ // (default is last).
+ virtual int GetCustomColourIndex() const;
+
+ // Helper function to show the colour dialog
+ bool QueryColourFromUser( wxVariant& variant ) const;
+
+ // Returns colour for given choice.
+ // Default function returns wxSystemSettings::GetColour(index).
+ virtual wxColour GetColour( int index ) const;
+ @endcode
@subsection wxCursorProperty
int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE );
/**
- Properties which have private child properties should add them
- with this function, called in their constructor.
+ Adds a child property. If you use this instead of
+ wxPropertyGridInterface::Insert() or
+ wxPropertyGridInterface::AppendIn(), then you must set up
+ property's parental type before making the call. To do this,
+ call property's SetParentalType() function with either
+ wxPG_PROP_MISC_PARENT (normal, public children) or with
+ wxPG_PROP_AGGREGATE (private children for subclassed property).
+ For instance:
+
+ @code
+ wxPGProperty* prop = new wxStringProperty(wxS("Property"));
+ prop->SetParentalType(wxPG_PROP_MISC_PARENT);
+ wxPGProperty* prop2 = new wxStringProperty(wxS("Property2"));
+ prop->AddChild(prop2);
+ @endcode
*/
void AddChild( wxPGProperty* property );
/**
Returns child property at index i.
*/
- wxPGProperty* Item( size_t i ) const;
-
- /**
- Updates property value in case there were last minute
- changes. If value was unspecified, it will be set to default.
- Use only for properties that have TextCtrl-based editor.
-
- @remarks If you have code similar to
- @code
- // Update the value in case of last minute changes
- if ( primary && propgrid->IsEditorsValueModified() )
- GetEditorClass()->CopyValueFromControl( this, primary );
- @endcode
- in wxPGProperty::OnEvent wxEVT_COMMAND_BUTTON_CLICKED handler,
- then replace it with call to this method.
-
- @return Returns @true if value changed.
- */
- bool PrepareValueForDialogEditing( wxPropertyGrid* propgrid );
+ wxPGProperty* Item( unsigned int i ) const;
/**
If property's editor is active, then update it's value.
*/
void SetName( const wxString& newName );
+ /**
+ Changes what sort of parent this property is for its children.
+
+ @param flag
+ Use one of the following values: wxPG_PROP_MISC_PARENT (for generic
+ parents), wxPG_PROP_CATEGORY (for categories), or
+ wxPG_PROP_AGGREGATE (for derived property classes with private
+ children).
+
+ @remarks You only need to call this if you use AddChild() to add
+ child properties. Adding properties with
+ wxPropertyGridInterface::Insert() or
+ wxPropertyGridInterface::AppendIn() will automatically set
+ property to use wxPG_PROP_MISC_PARENT style.
+ */
+ void SetParentalType( int flag );
+
/** Sets wxValidator for a property */
void SetValidator( const wxValidator& validator );
/**
Returns labe of item.
*/
- const wxString& GetLabel( size_t ind ) const;
+ const wxString& GetLabel( unsigned int ind ) const;
/**
Returns number of items.
*/
- size_t GetCount () const;
+ unsigned int GetCount() const;
/**
Returns value of item;
*/
- int GetValue( size_t ind ) const;
+ int GetValue( unsigned int ind ) const;
/**
Returns array of values matching the given strings. Unmatching strings