X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b7bc9d806b57f20e1d3135025ba0e6f603e7450e..55410bb4f67febe1ca20654f078ea4fb9a6223ae:/src/propgrid/props.cpp?ds=sidebyside diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index df7efa118a..9014519cee 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -632,7 +632,7 @@ wxString wxFloatProperty::ValueToString( wxVariant& value, value, m_precision, !(argFlags & wxPG_FULL_VALUE), - (wxString*) NULL); + NULL); } return text; } @@ -963,6 +963,7 @@ wxEnumProperty::~wxEnumProperty () } int wxEnumProperty::ms_nextIndex = -2; +int wxEnumProperty::ms_prevIndex = -1; void wxEnumProperty::OnSetValue() { @@ -1053,7 +1054,7 @@ bool wxEnumProperty::ValueFromString_( wxVariant& value, const wxString& text, i setAsNextIndex = -1; value = text; } - else if ( m_index != useIndex ) + else if ( useIndex != GetIndex() ) { if ( useIndex != -1 ) { @@ -1094,7 +1095,7 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags } else { - if ( m_index != intVal ) + if ( intVal != GetIndex() ) { ms_nextIndex = intVal; } @@ -1113,16 +1114,29 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags return false; } +void +wxEnumProperty::OnValidationFailure( wxVariant& WXUNUSED(pendingValue) ) +{ + // Revert index + m_index = ms_prevIndex; + ResetNextIndex(); +} + void wxEnumProperty::SetIndex( int index ) { + ms_prevIndex = m_index; ms_nextIndex = -2; m_index = index; } int wxEnumProperty::GetIndex() const { + if ( m_value.IsNull() ) + return -1; + if ( ms_nextIndex != -2 ) return ms_nextIndex; + return m_index; } @@ -1252,7 +1266,7 @@ void wxFlagsProperty::Init() wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, const wxChar** labels, const long* values, long value ) : wxPGProperty(label,name) { - m_oldChoicesData = (wxPGChoicesData*) NULL; + m_oldChoicesData = NULL; if ( labels ) { @@ -1272,7 +1286,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, const wxArrayString& labels, const wxArrayInt& values, int value ) : wxPGProperty(label,name) { - m_oldChoicesData = (wxPGChoicesData*) NULL; + m_oldChoicesData = NULL; if ( &labels && labels.size() ) { @@ -1292,7 +1306,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, wxPGChoices& choices, long value ) : wxPGProperty(label,name) { - m_oldChoicesData = (wxPGChoicesData*) NULL; + m_oldChoicesData = NULL; if ( choices.IsOk() ) { @@ -2118,7 +2132,7 @@ bool wxArrayEditorDialog::Create( wxWindow *parent, // Manipulator buttons wxBoxSizer* colsizer = new wxBoxSizer( wxVERTICAL ); - m_butCustom = (wxButton*) NULL; + m_butCustom = NULL; if ( m_custBtText ) { m_butCustom = new wxButton(this,28,::wxGetTranslation(m_custBtText)); @@ -2328,7 +2342,7 @@ wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog() void wxPGArrayStringEditorDialog::Init() { - m_pCallingClass = (wxArrayStringProperty*) NULL; + m_pCallingClass = NULL; } void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& )