Moved wxPGChoices m_choices member from various property classes to base wxPGProperty. This allows any property to have choices without subclassing and therefore work with Choice and ComboBox editors. Also removed redundant choice manipulation functions from wxPropertyGridinterface (ie. now use ones in wxPGProperty).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55740 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -10,13 +10,6 @@
|
||||
#define wxNullProperty ((wxPGProperty*)NULL)
|
||||
|
||||
|
||||
// Structure for relaying choice/list info.
|
||||
struct wxPGChoiceInfo
|
||||
{
|
||||
wxPGChoices* m_choices;
|
||||
};
|
||||
|
||||
|
||||
/** @section propgrid_property_attributes wxPropertyGrid Property Attribute Identifiers
|
||||
|
||||
wxPGProperty::SetAttribute() and
|
||||
@@ -257,7 +250,8 @@ struct wxPGChoiceInfo
|
||||
the flags as a text; a continous sequence of spaces, commas and semicolons
|
||||
is considered as a flag id separator.
|
||||
<b>Note: </b> When changing "choices" (ie. flag labels) of wxFlagsProperty, you
|
||||
will need to use SetPropertyChoices - otherwise they will not get updated properly.
|
||||
will need to use wxPGProperty::SetChoices() - otherwise they will not get updated
|
||||
properly.
|
||||
|
||||
@subsection wxArrayStringProperty
|
||||
|
||||
@@ -634,17 +628,6 @@ public:
|
||||
*/
|
||||
virtual wxValidator* DoGetValidator () const;
|
||||
|
||||
/** 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 wxPGEditor_Choice or similar.
|
||||
@remarks
|
||||
- If returns NULL in choiceinfo.m_choices, then this class must be
|
||||
derived from wxBaseEnumProperty.
|
||||
- Must be able to cope situation where property's set of choices is
|
||||
uninitialized.
|
||||
*/
|
||||
virtual int GetChoiceInfo( wxPGChoiceInfo* choiceinfo );
|
||||
|
||||
/** 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).
|
||||
|
||||
@@ -682,7 +665,7 @@ public:
|
||||
int m_drawnWidth;
|
||||
|
||||
// In a measure item call, set this to the height of item at m_choiceItem index
|
||||
int m_drawnHeight;
|
||||
int m_drawnHeight;
|
||||
};
|
||||
@endcode
|
||||
|
||||
@@ -706,6 +689,14 @@ public:
|
||||
*/
|
||||
virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
|
||||
|
||||
/** Returns which choice is currently selected. Only applies to properties
|
||||
which have choices.
|
||||
|
||||
Needs to reimplemented in derived class if property value does not
|
||||
map directly to a choice. Integer as index, bool, and string usually do.
|
||||
*/
|
||||
virtual int GetChoiceSelection() const;
|
||||
|
||||
/** Refresh values of child properties. Automatically called after value is set.
|
||||
*/
|
||||
virtual void RefreshChildren();
|
||||
@@ -735,14 +726,6 @@ public:
|
||||
*/
|
||||
virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
|
||||
|
||||
/** Adds entry to property's wxPGChoices and editor control (if it is active).
|
||||
Returns index of item added.
|
||||
*/
|
||||
int AppendChoice( const wxString& label, int value = wxPG_INVALID_VALUE )
|
||||
{
|
||||
return InsertChoice(label,-1,value);
|
||||
}
|
||||
|
||||
/** Returns wxPGCell of given column, NULL if none. If valid
|
||||
object is returned, caller will gain its ownership.
|
||||
*/
|
||||
@@ -756,6 +739,20 @@ public:
|
||||
return cell;
|
||||
}
|
||||
|
||||
/** Append a new choice to property's list of choices.
|
||||
|
||||
@param label
|
||||
Label for added choice.
|
||||
|
||||
@param value
|
||||
Value for new choice. Do not specify if you wish this
|
||||
to equal choice index.
|
||||
|
||||
@return
|
||||
Index to added choice.
|
||||
*/
|
||||
int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE );
|
||||
|
||||
/** Returns true if children of this property are component values (for instance,
|
||||
points size, face name, and is_underlined are component values of a font).
|
||||
*/
|
||||
@@ -796,12 +793,10 @@ public:
|
||||
/** Returns property's base name (ie. parent's name is not added in any case) */
|
||||
const wxString& GetBaseName() const { return m_name; }
|
||||
|
||||
wxPGChoices& GetChoices();
|
||||
|
||||
/** Returns read-only reference to property's list of choices.
|
||||
*/
|
||||
const wxPGChoices& GetChoices() const;
|
||||
|
||||
const wxPGChoiceEntry* GetCurrentChoice() const;
|
||||
|
||||
/** Returns coordinate to the top y of the property. Note that the
|
||||
position of scrollbars is not taken into account.
|
||||
*/
|
||||
@@ -843,10 +838,6 @@ public:
|
||||
return (wxPGCell*) m_cells[column];
|
||||
}
|
||||
|
||||
unsigned int GetChoiceCount() const;
|
||||
|
||||
wxString GetChoiceString( unsigned int index );
|
||||
|
||||
/** Return number of displayed common values for this property.
|
||||
*/
|
||||
int GetDisplayedCommonValueCount() const;
|
||||
@@ -937,8 +928,17 @@ public:
|
||||
*/
|
||||
bool HasVisibleChildren() const;
|
||||
|
||||
/** Adds entry to property's wxPGChoices and editor control (if it is active).
|
||||
Returns index of item added.
|
||||
/** Inserts a new choice to property's list of choices.
|
||||
|
||||
@param label
|
||||
Text for new choice
|
||||
|
||||
@param index
|
||||
Insertion position. Use wxNOT_FOUND to append.
|
||||
|
||||
@param value
|
||||
Value for new choice. Do not specify if you wish this
|
||||
to equal choice index.
|
||||
*/
|
||||
int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
|
||||
|
||||
@@ -1086,9 +1086,17 @@ public:
|
||||
*/
|
||||
void SetCell( int column, wxPGCell* cellObj );
|
||||
|
||||
/** Changes value of a property with choices, but only
|
||||
works if the value type is long or string. */
|
||||
void SetChoiceSelection( int newValue, const wxPGChoiceInfo& choiceInfo );
|
||||
/** If property has choices and they are not yet exclusive, new such copy
|
||||
of them will be created.
|
||||
*/
|
||||
void SetChoicesExclusive();
|
||||
|
||||
/** Sets selected choice and changes property value.
|
||||
|
||||
Tries to retain value type, although currently if it is not string,
|
||||
then it is forced to integer.
|
||||
*/
|
||||
void SetChoiceSelection( int newValue );
|
||||
|
||||
/** Sets common value selected for this property. -1 for none.
|
||||
*/
|
||||
@@ -1141,11 +1149,6 @@ public:
|
||||
*/
|
||||
void SetValueImage( wxBitmap& bmp );
|
||||
|
||||
/** If property has choices and they are not yet exclusive, new such copy
|
||||
of them will be created.
|
||||
*/
|
||||
void SetChoicesExclusive();
|
||||
|
||||
void SetExpanded( bool expanded )
|
||||
{
|
||||
if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED;
|
||||
@@ -1280,7 +1283,7 @@ public:
|
||||
|
||||
/** Returns height of children, recursively, and
|
||||
by taking expanded/collapsed status into account.
|
||||
|
||||
|
||||
iMax is used when finding property y-positions.
|
||||
*/
|
||||
int GetChildrenHeight( int lh, int iMax = -1 ) const;
|
||||
|
@@ -26,16 +26,6 @@ public:
|
||||
/** Destructor */
|
||||
virtual ~wxPropertyGridInterface() { }
|
||||
|
||||
/** Adds choice to a property that can accept one.
|
||||
@remarks
|
||||
- If you need to make sure that you modify only the set of choices of
|
||||
a single property (and not also choices of other properties with initially
|
||||
identical set), call wxPropertyGrid::SetPropertyChoicesPrivate.
|
||||
- This usually only works for wxEnumProperty and derivatives (wxFlagsProperty
|
||||
can get accept new items but its items may not get updated).
|
||||
*/
|
||||
void AddPropertyChoice( wxPGPropArg id, const wxString& label, int value = wxPG_INVALID_VALUE );
|
||||
|
||||
/** Appends property to the list. wxPropertyGrid assumes ownership of the object.
|
||||
Becomes child of most recently added category.
|
||||
@remarks
|
||||
@@ -106,14 +96,6 @@ public:
|
||||
/** Deletes a property by id. If category is deleted, all children are automatically deleted as well. */
|
||||
void DeleteProperty( wxPGPropArg id );
|
||||
|
||||
/** Deletes choice from a property.
|
||||
|
||||
If selected item is deleted, then the value is set to unspecified.
|
||||
|
||||
See AddPropertyChoice for more details.
|
||||
*/
|
||||
void DeletePropertyChoice( wxPGPropArg id, int index );
|
||||
|
||||
/** Disables property. */
|
||||
bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
|
||||
|
||||
@@ -286,12 +268,6 @@ public:
|
||||
*/
|
||||
wxPGProperty* GetPropertyByName( const wxString& name, const wxString& subname ) const;
|
||||
|
||||
/** Returns writable reference to property's list of choices (and relevant
|
||||
values). If property does not have any choices, will return reference
|
||||
to an invalid set of choices that will return false on IsOk call.
|
||||
*/
|
||||
wxPGChoices& GetPropertyChoices( wxPGPropArg id );
|
||||
|
||||
/** Returns property's editor. */
|
||||
const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const
|
||||
{
|
||||
@@ -534,12 +510,6 @@ public:
|
||||
return p->IsCategory();
|
||||
}
|
||||
|
||||
/** Inserts choice to a property that can accept one.
|
||||
|
||||
See AddPropertyChoice for more details.
|
||||
*/
|
||||
void InsertPropertyChoice( wxPGPropArg id, const wxString& label, int index, int value = wxPG_INVALID_VALUE );
|
||||
|
||||
/** Returns true if property is enabled. */
|
||||
bool IsPropertyEnabled( wxPGPropArg id ) const
|
||||
{
|
||||
@@ -707,27 +677,6 @@ public:
|
||||
p->SetCell( column, new wxPGCell(text, bitmap, fgCol, bgCol) );
|
||||
}
|
||||
|
||||
/** Set choices of a property to specified set of labels and values.
|
||||
|
||||
@remarks
|
||||
This operation clears the property value.
|
||||
*/
|
||||
void SetPropertyChoices( wxPGPropArg id, wxPGChoices& choices)
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetChoices(choices);
|
||||
}
|
||||
|
||||
|
||||
/** If property's set of choices is shared, then calling this method converts
|
||||
it to private.
|
||||
*/
|
||||
void SetPropertyChoicesExclusive( wxPGPropArg id )
|
||||
{
|
||||
wxPG_PROP_ARG_CALL_PROLOG()
|
||||
p->SetChoicesExclusive();
|
||||
}
|
||||
|
||||
/** Sets client data (void*) of a property.
|
||||
@remarks
|
||||
This untyped client data has to be deleted manually.
|
||||
|
Reference in New Issue
Block a user