Make wxPG_ATTR_MULTICHOICE_USERSTRINGMODE a built-in attribute
This attribute is used only internally in wxArrayStringProperty and thus can be considered as a built-in attribute which value can be stored in the local data member and not in the property's attribute store.
This commit is contained in:
@@ -344,6 +344,7 @@ public:
|
|||||||
int argFlags = 0) const wxOVERRIDE;
|
int argFlags = 0) const wxOVERRIDE;
|
||||||
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
virtual bool OnEvent( wxPropertyGrid* propgrid,
|
||||||
wxWindow* primary, wxEvent& event ) wxOVERRIDE;
|
wxWindow* primary, wxEvent& event ) wxOVERRIDE;
|
||||||
|
virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE;
|
||||||
|
|
||||||
wxArrayInt GetValueAsArrayInt() const
|
wxArrayInt GetValueAsArrayInt() const
|
||||||
{
|
{
|
||||||
@@ -361,6 +362,8 @@ protected:
|
|||||||
|
|
||||||
// Cache displayed text since generating it is relatively complicated.
|
// Cache displayed text since generating it is relatively complicated.
|
||||||
wxString m_display;
|
wxString m_display;
|
||||||
|
// How to handle user strings
|
||||||
|
int m_userStringMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // wxUSE_CHOICEDLG
|
#endif // wxUSE_CHOICEDLG
|
||||||
|
|||||||
@@ -197,9 +197,9 @@ struct wxPGPaintData
|
|||||||
*/
|
*/
|
||||||
#define wxPG_ATTR_SPINCTRL_MOTION wxS("MotionSpin")
|
#define wxPG_ATTR_SPINCTRL_MOTION wxS("MotionSpin")
|
||||||
|
|
||||||
/** wxMultiChoiceProperty, @c int. If 0, no user strings allowed. If 1, user
|
/** Built-in attribute of wxMultiChoiceProperty, @c int type. Default value
|
||||||
strings appear before list strings. If 2, user strings appear after list
|
is 0. If set to 0, no user strings allowed. If 1, user strings appear
|
||||||
string.
|
before list strings. If 2, user strings appear after list string.
|
||||||
*/
|
*/
|
||||||
#define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
|
#define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
|
||||||
|
|
||||||
|
|||||||
@@ -2042,6 +2042,7 @@ wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label,
|
|||||||
const wxArrayString& value)
|
const wxArrayString& value)
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
|
m_userStringMode = 0;
|
||||||
m_choices.Assign(choices);
|
m_choices.Assign(choices);
|
||||||
SetValue(value);
|
SetValue(value);
|
||||||
}
|
}
|
||||||
@@ -2052,6 +2053,7 @@ wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label,
|
|||||||
const wxArrayString& value)
|
const wxArrayString& value)
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
|
m_userStringMode = 0;
|
||||||
m_choices.Set(strings);
|
m_choices.Set(strings);
|
||||||
SetValue(value);
|
SetValue(value);
|
||||||
}
|
}
|
||||||
@@ -2061,6 +2063,7 @@ wxMultiChoiceProperty::wxMultiChoiceProperty( const wxString& label,
|
|||||||
const wxArrayString& value)
|
const wxArrayString& value)
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
|
m_userStringMode = 0;
|
||||||
wxArrayString strings;
|
wxArrayString strings;
|
||||||
m_choices.Set(strings);
|
m_choices.Set(strings);
|
||||||
SetValue(value);
|
SetValue(value);
|
||||||
@@ -2174,8 +2177,6 @@ bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
|
|
||||||
if ( dlg.ShowModal() == wxID_OK && choiceCount )
|
if ( dlg.ShowModal() == wxID_OK && choiceCount )
|
||||||
{
|
{
|
||||||
int userStringMode = GetAttributeAsLong(wxPG_ATTR_MULTICHOICE_USERSTRINGMODE, 0);
|
|
||||||
|
|
||||||
wxArrayInt arrInt = dlg.GetSelections();
|
wxArrayInt arrInt = dlg.GetSelections();
|
||||||
|
|
||||||
wxVariant variant;
|
wxVariant variant;
|
||||||
@@ -2186,7 +2187,7 @@ bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
// Translate string indices to strings
|
// Translate string indices to strings
|
||||||
|
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
if ( userStringMode == 1 )
|
if ( m_userStringMode == 1 )
|
||||||
{
|
{
|
||||||
for (n=0;n<extraStrings.size();n++)
|
for (n=0;n<extraStrings.size();n++)
|
||||||
value.push_back(extraStrings[n]);
|
value.push_back(extraStrings[n]);
|
||||||
@@ -2195,7 +2196,7 @@ bool wxMultiChoiceProperty::OnEvent( wxPropertyGrid* propgrid,
|
|||||||
for ( size_t i = 0; i < arrInt.size(); i++ )
|
for ( size_t i = 0; i < arrInt.size(); i++ )
|
||||||
value.Add(m_choices.GetLabel(arrInt.Item(i)));
|
value.Add(m_choices.GetLabel(arrInt.Item(i)));
|
||||||
|
|
||||||
if ( userStringMode == 2 )
|
if ( m_userStringMode == 2 )
|
||||||
{
|
{
|
||||||
for (n=0;n<extraStrings.size();n++)
|
for (n=0;n<extraStrings.size();n++)
|
||||||
value.push_back(extraStrings[n]);
|
value.push_back(extraStrings[n]);
|
||||||
@@ -2215,10 +2216,8 @@ bool wxMultiChoiceProperty::StringToValue( wxVariant& variant, const wxString& t
|
|||||||
{
|
{
|
||||||
wxArrayString arr;
|
wxArrayString arr;
|
||||||
|
|
||||||
int userStringMode = GetAttributeAsLong(wxPG_ATTR_MULTICHOICE_USERSTRINGMODE, 0);
|
|
||||||
|
|
||||||
WX_PG_TOKENIZER2_BEGIN(text,wxT('"'))
|
WX_PG_TOKENIZER2_BEGIN(text,wxT('"'))
|
||||||
if ( userStringMode > 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);
|
arr.Add(token);
|
||||||
WX_PG_TOKENIZER2_END()
|
WX_PG_TOKENIZER2_END()
|
||||||
|
|
||||||
@@ -2228,6 +2227,16 @@ bool wxMultiChoiceProperty::StringToValue( wxVariant& variant, const wxString& t
|
|||||||
return true;
|
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
|
#endif // wxUSE_CHOICEDLG
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user