// If has private child properties then create them here. Also
// set flag that indicates presence of private children. E.g.:
//
- // SetParentalType(wxPG_PROP_AGGREGATE);
- //
- // AddChild( new wxStringProperty( "Subprop 1",
- // wxPG_LABEL,
- // value.GetSubProp1() ) );
+ // AddPrivateChild( new wxStringProperty("Subprop 1",
+ // wxPG_LABEL,
+ // value.GetSubProp1() ) );
}
@endcode
*/
bool HasVisibleChildren() const;
+ /**
+ Use this member function to add independent (ie. regular) children to
+ a property.
+
+ @return Inserted childProperty.
+
+ @remarks wxPropertyGrid is not automatically refreshed by this
+ function.
+
+ @see AddPrivateChild()
+ */
+ wxPGProperty* InsertChild( int index, wxPGProperty* childProperty );
+
/** Inserts a new choice to property's list of choices.
*/
int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
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
+ 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.
+ @remarks You generally do not need to call this function.
*/
void SetParentalType( int flag )
{
*/
void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
+#if wxPG_COMPATIBILITY_1_4
+ /**
+ Adds a private child property.
+
+ @deprecated Use AddPrivateChild() instead.
+
+ @see AddPrivateChild()
+ */
+ wxDEPRECATED( void AddChild( wxPGProperty* prop ) );
+#endif
+
/**
- Adds a child property. If you use this instead of
+ Adds a private 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:
+ wxPropertyGridInterface::AppendIn(), then property's parental
+ type will automatically be set up to wxPG_PROP_AGGREGATE. In other
+ words, all properties of this property will become private.
+ */
+ void AddPrivateChild( wxPGProperty* prop );
- @code
- wxPGProperty* prop = new wxStringProperty(wxS("Property"));
- prop->SetParentalType(wxPG_PROP_MISC_PARENT);
- wxPGProperty* prop2 = new wxStringProperty(wxS("Property2"));
- prop->AddChild(prop2);
- @endcode
+ /**
+ Appends a new child property.
*/
- void AddChild( wxPGProperty* prop );
+ wxPGProperty* AppendChild( wxPGProperty* prop )
+ {
+ return InsertChild(-1, prop);
+ }
/** Returns height of children, recursively, and
by taking expanded/collapsed status into account.
unsigned int hintIndex ) const;
/** This is used by Insert etc. */
- void AddChild2( wxPGProperty* prop,
- int index = -1,
- bool correct_mode = true );
+ void DoAddChild( wxPGProperty* prop,
+ int index = -1,
+ bool correct_mode = true );
void DoGenerateComposedValue( wxString& text,
int argFlags = wxPG_VALUE_IS_CURRENT,
// Removes child property with given pointer. Does not delete it.
void RemoveChild( wxPGProperty* p );
+ void DoPreAddChild( int index, wxPGProperty* prop );
+
void SetParentState( wxPropertyGridPageState* pstate )
{ m_parentState = pstate; }
variant << value;
SetValue(variant);
- // If has private child properties then create them here. For example:
- // AddChild( new wxStringProperty( "Subprop 1", wxPG_LABEL, value.GetSubProp1() ) );
+ // If has private child properties then create them here.
+ // For example:
+ // AddPrivateChild( new wxStringProperty("Subprop 1",
+ // wxPG_LABEL,
+ // value.GetSubProp1()));
}
@endcode
int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE );
/**
- 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:
+ Adds a private child property.
- @code
- wxPGProperty* prop = new wxStringProperty(wxS("Property"));
- prop->SetParentalType(wxPG_PROP_MISC_PARENT);
- wxPGProperty* prop2 = new wxStringProperty(wxS("Property2"));
- prop->AddChild(prop2);
- @endcode
+ @deprecated Use AddPrivateChild() instead.
+
+ @see AddPrivateChild()
+ */
+ wxDEPRECATED( void AddChild( wxPGProperty* prop ) );
+
+ /**
+ Adds a private child property. If you use this instead of
+ wxPropertyGridInterface::Insert() or
+ wxPropertyGridInterface::AppendIn(), then property's parental
+ type will automatically be set up to wxPG_PROP_AGGREGATE. In other
+ words, all properties of this property will become private.
*/
- void AddChild( wxPGProperty* property );
+ void AddPrivateChild( wxPGProperty* prop );
/**
Adapts list variant into proper value using consecutive
*/
void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
+ /**
+ Use this member function to add independent (ie. regular) children to
+ a property.
+
+ @return Appended childProperty.
+
+ @remarks wxPropertyGrid is not automatically refreshed by this
+ function.
+
+ @see InsertChild(), AddPrivateChild()
+ */
+ wxPGProperty* AppendChild( wxPGProperty* childProperty );
+
/**
Determines, recursively, if all children are not unspecified.
*/
int Index( const wxPGProperty* p ) const;
+ /**
+ Use this member function to add independent (ie. regular) children to
+ a property.
+
+ @return Inserted childProperty.
+
+ @remarks wxPropertyGrid is not automatically refreshed by this
+ function.
+
+ @see AppendChild(), AddPrivateChild()
+ */
+ wxPGProperty* InsertChild( int index, wxPGProperty* childProperty );
+
/**
Inserts a new choice to property's list of choices.
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.
+ @remarks You generally do not need to call this function.
*/
void SetParentalType( int flag );
: wxPGProperty(label,name)
{
SetValue( WXVARIANT(value) );
- SetParentalType(wxPG_PROP_AGGREGATE);
- AddChild( new wxFloatProperty(wxT("X"),wxPG_LABEL,value.x) );
- AddChild( new wxFloatProperty(wxT("Y"),wxPG_LABEL,value.y) );
- AddChild( new wxFloatProperty(wxT("Z"),wxPG_LABEL,value.z) );
+ AddPrivateChild( new wxFloatProperty(wxT("X"),wxPG_LABEL,value.x) );
+ AddPrivateChild( new wxFloatProperty(wxT("Y"),wxPG_LABEL,value.y) );
+ AddPrivateChild( new wxFloatProperty(wxT("Z"),wxPG_LABEL,value.z) );
}
wxVectorProperty::~wxVectorProperty() { }
: wxPGProperty(label,name)
{
SetValue( WXVARIANT(value) );
- SetParentalType(wxPG_PROP_AGGREGATE);
- AddChild( new wxVectorProperty(wxT("A"),wxPG_LABEL,value.a) );
- AddChild( new wxVectorProperty(wxT("B"),wxPG_LABEL,value.b) );
- AddChild( new wxVectorProperty(wxT("C"),wxPG_LABEL,value.c) );
+ AddPrivateChild( new wxVectorProperty(wxT("A"),wxPG_LABEL,value.a) );
+ AddPrivateChild( new wxVectorProperty(wxT("B"),wxPG_LABEL,value.b) );
+ AddPrivateChild( new wxVectorProperty(wxT("C"),wxPG_LABEL,value.c) );
}
wxTriangleProperty::~wxTriangleProperty() { }
// For testing purposes, combine two methods of adding children
//
- // AddChild() requires that we call this
- pid->SetParentalType(wxPG_PROP_MISC_PARENT);
-
- pid->AddChild( new wxStringProperty(wxT("Latest Release"), wxPG_LABEL, wxT("2.8.8")));
- pid->AddChild( new wxBoolProperty(wxT("Win API"), wxPG_LABEL, true) );
+ pid->AppendChild( new wxStringProperty(wxT("Latest Release"),
+ wxPG_LABEL,
+ wxT("2.8.10")));
+ pid->AppendChild( new wxBoolProperty(wxT("Win API"),
+ wxPG_LABEL,
+ true) );
pg->Append( pid );
// (instead of calling SetValue) in derived (wxObject) properties.
m_value_wxFontData << value;
- SetParentalType(wxPG_PROP_AGGREGATE);
-
// Add extra children.
- AddChild( new wxColourProperty(_("Colour"), wxPG_LABEL,
- fontData.GetColour() ) );
+ AddPrivateChild( new wxColourProperty(_("Colour"), wxPG_LABEL,
+ fontData.GetColour() ) );
}
wxFontDataProperty::~wxFontDataProperty () { }
const wxSize& value) : wxPGProperty(label,name)
{
SetValueI(value);
- SetParentalType(wxPG_PROP_AGGREGATE);
- AddChild( new wxIntProperty(wxT("Width"),wxPG_LABEL,value.x) );
- AddChild( new wxIntProperty(wxT("Height"),wxPG_LABEL,value.y) );
+ AddPrivateChild( new wxIntProperty(wxT("Width"),wxPG_LABEL,value.x) );
+ AddPrivateChild( new wxIntProperty(wxT("Height"),wxPG_LABEL,value.y) );
}
wxSizeProperty::~wxSizeProperty() { }
const wxPoint& value) : wxPGProperty(label,name)
{
SetValueI(value);
- SetParentalType(wxPG_PROP_AGGREGATE);
- AddChild( new wxIntProperty(wxT("X"),wxPG_LABEL,value.x) );
- AddChild( new wxIntProperty(wxT("Y"),wxPG_LABEL,value.y) );
+ AddPrivateChild( new wxIntProperty(wxT("X"),wxPG_LABEL,value.x) );
+ AddPrivateChild( new wxIntProperty(wxT("Y"),wxPG_LABEL,value.y) );
}
wxPointProperty::~wxPointProperty() { }
wxFont font;
font << m_value;
- SetParentalType(wxPG_PROP_AGGREGATE);
+ AddPrivateChild( new wxIntProperty( _("Point Size"),
+ wxS("Point Size"),(long)font.GetPointSize() ) );
- AddChild( new wxIntProperty( _("Point Size"), wxS("Point Size"),(long)font.GetPointSize() ) );
-
- AddChild( new wxEnumProperty(_("Family"), wxS("PointSize"),
- gs_fp_es_family_labels,gs_fp_es_family_values,
- font.GetFamily()) );
+ AddPrivateChild( new wxEnumProperty(_("Family"), wxS("PointSize"),
+ gs_fp_es_family_labels,gs_fp_es_family_values,
+ font.GetFamily()) );
wxString faceName = font.GetFaceName();
// If font was not in there, add it now
p->SetValueFromString(faceName, wxPG_FULL_VALUE);
- AddChild( p );
+ AddPrivateChild( p );
- AddChild( new wxEnumProperty(_("Style"), wxS("Style"),
- gs_fp_es_style_labels,gs_fp_es_style_values,font.GetStyle()) );
+ AddPrivateChild( new wxEnumProperty(_("Style"), wxS("Style"),
+ gs_fp_es_style_labels,gs_fp_es_style_values,
+ font.GetStyle()) );
- AddChild( new wxEnumProperty(_("Weight"), wxS("Weight"),
- gs_fp_es_weight_labels,gs_fp_es_weight_values,font.GetWeight()) );
+ AddPrivateChild( new wxEnumProperty(_("Weight"), wxS("Weight"),
+ gs_fp_es_weight_labels,gs_fp_es_weight_values,
+ font.GetWeight()) );
- AddChild( new wxBoolProperty(_("Underlined"), wxS("Underlined"),
- font.GetUnderlined()) );
+ AddPrivateChild( new wxBoolProperty(_("Underlined"), wxS("Underlined"),
+ font.GetUnderlined()) );
}
wxFontProperty::~wxFontProperty() { }
if ( GetChildCount() )
{
// Check parental flags
- wxASSERT_MSG( (m_flags & wxPG_PROP_PARENTAL_FLAGS),
- "Call SetFlag(wxPG_PROP_MISC_PARENT) or"
- "SetFlag(wxPG_PROP_AGGREGATE) before calling"
- "wxPGProperty::AddChild()." );
+ wxASSERT_MSG( ((m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_AGGREGATE) ||
+ ((m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_MISC_PARENT),
+ "wxPGProperty parental flags set incorrectly at "
+ "this time" );
if ( HasFlag(wxPG_PROP_AGGREGATE) )
{
}
// This is used by Insert etc.
-void wxPGProperty::AddChild2( wxPGProperty* prop, int index, bool correct_mode )
+void wxPGProperty::DoAddChild( wxPGProperty* prop, int index,
+ bool correct_mode )
{
if ( index < 0 || (size_t)index >= m_children.size() )
{
prop->m_parent = this;
}
-// This is used by properties that have fixed sub-properties
-void wxPGProperty::AddChild( wxPGProperty* prop )
+void wxPGProperty::DoPreAddChild( int index, wxPGProperty* prop )
{
wxASSERT_MSG( prop->GetBaseName().length(),
- "Property's children must have unique, non-empty names within their scope" );
+ "Property's children must have unique, non-empty "
+ "names within their scope" );
- prop->m_arrIndex = m_children.size();
- m_children.push_back( prop );
+ prop->m_arrIndex = index;
+ m_children.insert( m_children.begin()+index,
+ prop );
int custImgHeight = prop->OnMeasureImage().y;
if ( custImgHeight < 0 /*|| custImgHeight > 1*/ )
prop->m_parent = this;
}
+void wxPGProperty::AddPrivateChild( wxPGProperty* prop )
+{
+ if ( !(m_flags & wxPG_PROP_PARENTAL_FLAGS) )
+ SetParentalType(wxPG_PROP_AGGREGATE);
+
+ wxASSERT_MSG( (m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_AGGREGATE,
+ "Do not mix up AddPrivateChild() calls with other "
+ "property adders." );
+
+ DoPreAddChild( m_children.size(), prop );
+}
+
+#if wxPG_COMPATIBILITY_1_4
+void wxPGProperty::AddChild( wxPGProperty* prop )
+{
+ AddPrivateChild(prop);
+}
+#endif
+
+wxPGProperty* wxPGProperty::InsertChild( int index,
+ wxPGProperty* childProperty )
+{
+ if ( index < 0 )
+ index = m_children.size();
+
+ if ( m_parentState )
+ {
+ m_parentState->DoInsert(this, index, childProperty);
+ }
+ else
+ {
+ if ( !(m_flags & wxPG_PROP_PARENTAL_FLAGS) )
+ SetParentalType(wxPG_PROP_MISC_PARENT);
+
+ wxASSERT_MSG( (m_flags & wxPG_PROP_PARENTAL_FLAGS) ==
+ wxPG_PROP_MISC_PARENT,
+ "Do not mix up AddPrivateChild() calls with other "
+ "property adders." );
+
+ DoPreAddChild( index, childProperty );
+ }
+
+ return childProperty;
+}
+
void wxPGProperty::RemoveChild( wxPGProperty* p )
{
wxArrayPGProperty::iterator it;
wxPGProperty* parent = p->GetParent();
if ( parent->IsCategory() || parent->IsRoot() )
{
- m_abcArray->AddChild2(p);
+ m_abcArray->DoAddChild(p);
p->m_parent = &m_regularArray;
}
}
if ( m_abcArray && !property->IsCategory() &&
(parentIsCategory || parentIsRoot) )
{
- m_abcArray->AddChild2( property, -1, false );
+ m_abcArray->DoAddChild( property, -1, false );
}
// Add to current mode.
- parent->AddChild2( property, index, true );
+ parent->DoAddChild( property, index, true );
}
else
{
if ( parentIsCategory )
// Parent is category.
- parent->AddChild2( property, index, false );
+ parent->DoAddChild( property, index, false );
else if ( parentIsRoot )
// Parent is root.
- m_regularArray.AddChild2( property, -1, false );
+ m_regularArray.DoAddChild( property, -1, false );
// Add to current mode
if ( !property->IsCategory() )
- m_abcArray->AddChild2( property, index, true );
+ m_abcArray->DoAddChild( property, index, true );
}
// category stuff
void wxFlagsProperty::Init()
{
- SetParentalType(wxPG_PROP_AGGREGATE);
-
long value = m_value;
//
{
boolProp = new wxBoolProperty( label, label, child_val );
}
- AddChild(boolProp);
+ AddPrivateChild(boolProp);
}
m_oldChoicesData = m_choices.GetDataPtr();