Make wxPG_BOOL_USE_CHECKBOX and wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING built-in attributes
Both attributes are used only in wxBoolProperty and wxFlagsProperty to set respective internal flags and don't have to be stored in the property's attribute store.
This commit is contained in:
@@ -316,7 +316,6 @@ public:
|
|||||||
virtual bool IntToValue( wxVariant& variant,
|
virtual bool IntToValue( wxVariant& variant,
|
||||||
int number, int argFlags = 0 ) const wxOVERRIDE;
|
int number, int argFlags = 0 ) const wxOVERRIDE;
|
||||||
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||||
virtual wxVariant DoGetAttribute( const wxString& name ) const wxOVERRIDE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -664,7 +663,7 @@ protected:
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
// wxBoolProperty specific flags
|
// wxBoolProperty, wxFlagsProperty specific flags
|
||||||
#define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
|
#define wxPG_PROP_USE_CHECKBOX wxPG_PROP_CLASS_SPECIFIC_1
|
||||||
// DCC = Double Click Cycles
|
// DCC = Double Click Cycles
|
||||||
#define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
|
#define wxPG_PROP_USE_DCC wxPG_PROP_CLASS_SPECIFIC_2
|
||||||
|
@@ -74,20 +74,20 @@ struct wxPGPaintData
|
|||||||
*/
|
*/
|
||||||
#define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete")
|
#define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete")
|
||||||
|
|
||||||
/** wxBoolProperty and wxFlagsProperty specific. Value type is bool.
|
/** wxBoolProperty and wxFlagsProperty specific built-in attribute.
|
||||||
Default value is False.
|
Value type is @c bool. Default value is @false.
|
||||||
|
|
||||||
When set to True, bool property will use check box instead of a
|
When set to @true, bool property will use check box instead of a
|
||||||
combo box as its editor control. If you set this attribute
|
combo box as its editor control. If you set this attribute
|
||||||
for a wxFlagsProperty, it is automatically applied to child
|
for a wxFlagsProperty, it is automatically applied to child
|
||||||
bool properties.
|
bool properties.
|
||||||
*/
|
*/
|
||||||
#define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox")
|
#define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox")
|
||||||
|
|
||||||
/** wxBoolProperty and wxFlagsProperty specific. Value type is bool.
|
/** wxBoolProperty and wxFlagsProperty specific built-in attribute.
|
||||||
Default value is False.
|
Value type is @c bool. Default value is @true.
|
||||||
|
|
||||||
Set to True for the bool property to cycle value on double click
|
Set to @true for the bool property to cycle value on double click
|
||||||
(instead of showing the popup listbox). If you set this attribute
|
(instead of showing the popup listbox). If you set this attribute
|
||||||
for a wxFlagsProperty, it is automatically applied to child
|
for a wxFlagsProperty, it is automatically applied to child
|
||||||
bool properties.
|
bool properties.
|
||||||
|
@@ -1184,23 +1184,6 @@ bool wxBoolProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVariant wxBoolProperty::DoGetAttribute( const wxString& name ) const
|
|
||||||
{
|
|
||||||
wxVariant value;
|
|
||||||
#if wxPG_INCLUDE_CHECKBOX
|
|
||||||
if ( name == wxPG_BOOL_USE_CHECKBOX )
|
|
||||||
{
|
|
||||||
value = (bool)((m_flags & wxPG_PROP_USE_CHECKBOX) != 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if ( name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING )
|
|
||||||
{
|
|
||||||
value = (bool)((m_flags & wxPG_PROP_USE_DCC) != 0);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// wxEnumProperty
|
// wxEnumProperty
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -1569,9 +1552,8 @@ void wxFlagsProperty::Init()
|
|||||||
|
|
||||||
// Relay wxPG_BOOL_USE_CHECKBOX and wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING
|
// Relay wxPG_BOOL_USE_CHECKBOX and wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING
|
||||||
// to child bool property controls.
|
// to child bool property controls.
|
||||||
long attrUseCheckBox = GetAttributeAsLong(wxPG_BOOL_USE_CHECKBOX, 0);
|
bool attrUseCheckBox = (m_flags & wxPG_PROP_USE_CHECKBOX) != 0;
|
||||||
long attrUseDCC = GetAttributeAsLong(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING,
|
bool attrUseDCC = (m_flags & wxPG_PROP_USE_DCC) != 0;
|
||||||
0);
|
|
||||||
|
|
||||||
if ( m_choices.IsOk() )
|
if ( m_choices.IsOk() )
|
||||||
{
|
{
|
||||||
@@ -1595,12 +1577,8 @@ void wxFlagsProperty::Init()
|
|||||||
{
|
{
|
||||||
boolProp = new wxBoolProperty( label, label, child_val );
|
boolProp = new wxBoolProperty( label, label, child_val );
|
||||||
}
|
}
|
||||||
if ( attrUseCheckBox )
|
boolProp->SetAttribute(wxPG_BOOL_USE_CHECKBOX, attrUseCheckBox);
|
||||||
boolProp->SetAttribute(wxPG_BOOL_USE_CHECKBOX,
|
boolProp->SetAttribute(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING, attrUseDCC);
|
||||||
true);
|
|
||||||
if ( attrUseDCC )
|
|
||||||
boolProp->SetAttribute(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING,
|
|
||||||
true);
|
|
||||||
AddPrivateChild(boolProp);
|
AddPrivateChild(boolProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1617,6 +1595,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name,
|
|||||||
const wxChar* const* labels, const long* values, long value ) : wxPGProperty(label,name)
|
const wxChar* const* labels, const long* values, long value ) : wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
m_oldChoicesData = NULL;
|
m_oldChoicesData = NULL;
|
||||||
|
m_flags |= wxPG_PROP_USE_DCC; // same default like wxBoolProperty
|
||||||
|
|
||||||
if ( labels )
|
if ( labels )
|
||||||
{
|
{
|
||||||
@@ -1637,6 +1616,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name,
|
|||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
m_oldChoicesData = NULL;
|
m_oldChoicesData = NULL;
|
||||||
|
m_flags |= wxPG_PROP_USE_DCC; // same default like wxBoolProperty
|
||||||
|
|
||||||
if ( !labels.empty() )
|
if ( !labels.empty() )
|
||||||
{
|
{
|
||||||
@@ -1657,6 +1637,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name,
|
|||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
m_oldChoicesData = NULL;
|
m_oldChoicesData = NULL;
|
||||||
|
m_flags |= wxPG_PROP_USE_DCC; // same default like wxBoolProperty
|
||||||
|
|
||||||
if ( choices.IsOk() )
|
if ( choices.IsOk() )
|
||||||
{
|
{
|
||||||
@@ -1847,16 +1828,31 @@ wxVariant wxFlagsProperty::ChildChanged( wxVariant& thisValue,
|
|||||||
|
|
||||||
bool wxFlagsProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
bool wxFlagsProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||||
{
|
{
|
||||||
if ( name == wxPG_BOOL_USE_CHECKBOX ||
|
if ( name == wxPG_BOOL_USE_CHECKBOX )
|
||||||
name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING )
|
|
||||||
{
|
{
|
||||||
for ( size_t i=0; i<GetChildCount(); i++ )
|
if ( value.GetBool() )
|
||||||
|
m_flags |= wxPG_PROP_USE_CHECKBOX;
|
||||||
|
else
|
||||||
|
m_flags &= ~(wxPG_PROP_USE_CHECKBOX);
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < GetChildCount(); i++ )
|
||||||
{
|
{
|
||||||
Item(i)->SetAttribute(name, value);
|
Item(i)->SetAttribute(name, value);
|
||||||
}
|
}
|
||||||
// Must return false so that the attribute is stored in
|
return true;
|
||||||
// flag property's actual property storage
|
}
|
||||||
return false;
|
else if ( name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING )
|
||||||
|
{
|
||||||
|
if ( value.GetBool() )
|
||||||
|
m_flags |= wxPG_PROP_USE_DCC;
|
||||||
|
else
|
||||||
|
m_flags &= ~(wxPG_PROP_USE_DCC);
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < GetChildCount(); i++ )
|
||||||
|
{
|
||||||
|
Item(i)->SetAttribute(name, value);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user