diff --git a/include/wx/propgrid/advprops.h b/include/wx/propgrid/advprops.h index 342d42e816..555d4ded3d 100644 --- a/include/wx/propgrid/advprops.h +++ b/include/wx/propgrid/advprops.h @@ -344,6 +344,7 @@ public: int argFlags = 0) const wxOVERRIDE; virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event ) wxOVERRIDE; + virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE; wxArrayInt GetValueAsArrayInt() const { @@ -361,6 +362,8 @@ protected: // Cache displayed text since generating it is relatively complicated. wxString m_display; + // How to handle user strings + int m_userStringMode; }; #endif // wxUSE_CHOICEDLG diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index 841d2615ce..ad98d42629 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -197,9 +197,9 @@ struct wxPGPaintData */ #define wxPG_ATTR_SPINCTRL_MOTION wxS("MotionSpin") -/** wxMultiChoiceProperty, @c int. If 0, no user strings allowed. If 1, user - strings appear before list strings. If 2, user strings appear after list - string. +/** Built-in attribute of wxMultiChoiceProperty, @c int type. Default value + is 0. If set to 0, no user strings allowed. If 1, user strings appear + before list strings. If 2, user strings appear after list string. */ #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode") diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index ef87b33060..71fb64cc13 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -2042,6 +2042,7 @@ wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label, const wxArrayString& value) : wxPGProperty(label,name) { + m_userStringMode = 0; m_choices.Assign(choices); SetValue(value); } @@ -2052,6 +2053,7 @@ wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label, const wxArrayString& value) : wxPGProperty(label,name) { + m_userStringMode = 0; m_choices.Set(strings); SetValue(value); } @@ -2061,6 +2063,7 @@ wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label, const wxArrayString& value) : wxPGProperty(label,name) { + m_userStringMode = 0; wxArrayString strings; m_choices.Set(strings); SetValue(value); @@ -2174,8 +2177,6 @@ bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid, if ( dlg.ShowModal() == wxID_OK && choiceCount ) { - int userStringMode = GetAttributeAsLong(wxPG_ATTR_MULTICHOICE_USERSTRINGMODE, 0); - wxArrayInt arrInt = dlg.GetSelections(); wxVariant variant; @@ -2186,7 +2187,7 @@ bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid, // Translate string indices to strings unsigned int n; - if ( userStringMode == 1 ) + if ( m_userStringMode == 1 ) { for (n=0;n 0 || (m_choices.IsOk() && m_choices.Index( token ) != wxNOT_FOUND) ) + if ( m_userStringMode > 0 || (m_choices.IsOk() && m_choices.Index( token ) != wxNOT_FOUND) ) arr.Add(token); WX_PG_TOKENIZER2_END() @@ -2228,6 +2227,16 @@ bool wxMultiChoiceProperty::StringToValue( wxVariant& variant, const wxString& t return true; } +bool wxMultiChoiceProperty::DoSetAttribute( const wxString& name, wxVariant& value ) +{ + if ( name == wxPG_ATTR_MULTICHOICE_USERSTRINGMODE ) + { + m_userStringMode = (int)value.GetLong(); + return true; + } + return false; +} + #endif // wxUSE_CHOICEDLG