From: Jaakko Salli Date: Thu, 16 Apr 2009 19:28:39 +0000 (+0000) Subject: wxFlagsProperty now automatically relays wxBOOL_USE_CHECKBOX and wxBOOL_USE_DOUBLE_CL... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/16372f0d97cdd46f2bec3844877827ee9f8b2415?ds=sidebyside wxFlagsProperty now automatically relays wxBOOL_USE_CHECKBOX and wxBOOL_USE_DOUBLE_CLICK_CYCLING to child bool properties (closes #10690) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 334ec1351f..c850d2d43d 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -520,13 +520,23 @@ wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000 */ #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") -/** wxBoolProperty specific, int, default 0. When 1 sets bool property to - use checkbox instead of choice. +/** wxBoolProperty and wxFlagsProperty specific. Value type is bool. + Default value is False. + + When set to True, bool property will use check box instead of a + combo box as its editor control. If you set this attribute + for a wxFlagsProperty, it is automatically applied to child + bool properties. */ #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") -/** wxBoolProperty specific, int, default 0. When 1 sets bool property value - to cycle on double click (instead of showing the popup listbox). +/** wxBoolProperty and wxFlagsProperty specific. Value type is bool. + Default value is False. + + Set to True for the bool property to cycle value on double click + (instead of showing the popup listbox). If you set this attribute + for a wxFlagsProperty, it is automatically applied to child + bool properties. */ #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index ae426977ed..93f0ed542d 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -538,6 +538,7 @@ public: int childIndex, wxVariant& childValue ) const; virtual void RefreshChildren(); + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); // GetChoiceSelection needs to overridden since m_choices is // used and value is integer, but it is not index. diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index 2c4b99c16f..f553085577 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -51,13 +51,23 @@ */ #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") -/** wxBoolProperty specific, int, default 0. When 1 sets bool property to - use checkbox instead of choice. +/** wxBoolProperty and wxFlagsProperty specific. Value type is bool. + Default value is False. + + When set to True, bool property will use check box instead of a + combo box as its editor control. If you set this attribute + for a wxFlagsProperty, it is automatically applied to child + bool properties. */ #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") -/** wxBoolProperty specific, int, default 0. When 1 sets bool property value - to cycle on double click (instead of showing the popup listbox). +/** wxBoolProperty and wxFlagsProperty specific. Value type is bool. + Default value is False. + + Set to True for the bool property to cycle value on double click + (instead of showing the popup listbox). If you set this attribute + for a wxFlagsProperty, it is automatically applied to child + bool properties. */ #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") @@ -300,13 +310,16 @@ @subsection wxFlagsProperty - Represents a bit set that fits in a long integer. wxBoolProperty sub-properties - are created for editing individual bits. Textctrl is created to manually edit - the flags as a text; a continous sequence of spaces, commas and semicolons - is considered as a flag id separator. - Note: When changing "choices" (ie. flag labels) of wxFlagsProperty, you - will need to use wxPGProperty::SetChoices() - otherwise they will not get updated - properly. + Represents a bit set that fits in a long integer. wxBoolProperty sub- + properties are created for editing individual bits. Textctrl is created to + manually edit the flags as a text; a continous sequence of spaces, commas + and semicolons are considered as a flag id separator. + + Note: When changing "choices" (ie. flag labels) of wxFlagsProperty, + you will need to use wxPGProperty::SetChoices() - otherwise they will not + get updated properly. + + wxFlagsProperty supports the same attributes as wxBoolProperty. @subsection wxArrayStringProperty @@ -1454,7 +1467,7 @@ public: Helper class for managing choices of wxPropertyGrid properties. Each entry can have label, value, bitmap, text colour, and background colour. - + wxPGChoices uses reference counting, similar to other wxWidgets classes. This means that assignment operator and copy constructor only copy the reference and not the actual data. Use Copy() member function to create a diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 3558201abc..0bbf5605a1 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -1224,6 +1224,12 @@ void wxFlagsProperty::Init() m_children.clear(); + // Relay wxPG_BOOL_USE_CHECKBOX and wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING + // to child bool property controls. + long attrUseCheckBox = GetAttributeAsLong(wxPG_BOOL_USE_CHECKBOX, 0); + long attrUseDCC = GetAttributeAsLong(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING, + 0); + if ( m_choices.IsOk() ) { const wxPGChoices& choices = m_choices; @@ -1246,6 +1252,12 @@ void wxFlagsProperty::Init() { boolProp = new wxBoolProperty( label, label, child_val ); } + if ( attrUseCheckBox ) + boolProp->SetAttribute(wxPG_BOOL_USE_CHECKBOX, + true); + if ( attrUseDCC ) + boolProp->SetAttribute(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING, + true); AddPrivateChild(boolProp); } @@ -1494,6 +1506,22 @@ void wxFlagsProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVari thisValue = (long)(oldValue & ~(vi)); } +bool wxFlagsProperty::DoSetAttribute( const wxString& name, wxVariant& value ) +{ + if ( name == wxPG_BOOL_USE_CHECKBOX || + name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING ) + { + for ( size_t i=0; iSetAttribute(name, value); + } + // Must return false so that the attribute is stored in + // flag property's actual property storage + return false; + } + return false; +} + // ----------------------------------------------------------------------- // wxDirProperty // -----------------------------------------------------------------------