X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b0f0eda8ce631577cf4176d2d17785daddc9b5bc..5bf3b6fe48580853044132c381d3548535ca7ad1:/src/propgrid/props.cpp diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index bb9d18a7a0..3558201abc 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -200,7 +200,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int int firstNonZeroPos = 0; - for ( ; i != iMax; i++ ) + for ( ; i != iMax; ++i ) { wxChar c = *i; if ( c != wxS('0') && c != wxS(' ') ) @@ -606,7 +606,7 @@ void wxPropertyGrid::DoubleToString(wxString& target, wxString::const_iterator i = target.end() - 1; size_t new_len = target.length() - 1; - for ( ; i != target.begin(); i-- ) + for ( ; i != target.begin(); --i ) { if ( *i != wxS('0') ) break; @@ -632,7 +632,7 @@ wxString wxFloatProperty::ValueToString( wxVariant& value, value, m_precision, !(argFlags & wxPG_FULL_VALUE), - (wxString*) NULL); + NULL); } return text; } @@ -973,7 +973,7 @@ void wxEnumProperty::OnSetValue() else if ( variantType == wxPG_VARIANT_TYPE_STRING ) ValueFromString_( m_value, m_value.GetString(), 0 ); else - wxASSERT( false ); + wxFAIL; if ( ms_nextIndex != -2 ) { @@ -1053,7 +1053,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 +1094,7 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags } else { - if ( m_index != intVal ) + if ( intVal != GetIndex() ) { ms_nextIndex = intVal; } @@ -1113,6 +1113,13 @@ bool wxEnumProperty::ValueFromInt_( wxVariant& variant, int intVal, int argFlags return false; } +void +wxEnumProperty::OnValidationFailure( wxVariant& WXUNUSED(pendingValue) ) +{ + // Revert index + ResetNextIndex(); +} + void wxEnumProperty::SetIndex( int index ) { ms_nextIndex = -2; @@ -1121,8 +1128,12 @@ void wxEnumProperty::SetIndex( int index ) int wxEnumProperty::GetIndex() const { + if ( m_value.IsNull() ) + return -1; + if ( ms_nextIndex != -2 ) return ms_nextIndex; + return m_index; } @@ -1176,8 +1187,6 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(wxFlagsProperty,long,TextCtrl) void wxFlagsProperty::Init() { - SetParentalType(wxPG_PROP_AGGREGATE); - long value = m_value; // @@ -1237,7 +1246,7 @@ void wxFlagsProperty::Init() { boolProp = new wxBoolProperty( label, label, child_val ); } - AddChild(boolProp); + AddPrivateChild(boolProp); } m_oldChoicesData = m_choices.GetDataPtr(); @@ -1252,7 +1261,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 +1281,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 +1301,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 +2127,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 +2337,7 @@ wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog() void wxPGArrayStringEditorDialog::Init() { - m_pCallingClass = (wxArrayStringProperty*) NULL; + m_pCallingClass = NULL; } void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& ) @@ -2400,16 +2409,13 @@ void wxPropertyGrid::ArrayStringToString( wxString& dst, const wxArrayString& sr unsigned int i; unsigned int itemCount = src.size(); - wxChar preas[2]; + wxChar preas[2] = { 0, 0 }; dst.Empty(); - if ( !preDelim ) - preas[0] = 0; - else if ( (flags & 1) ) + if ( flags & 1 ) { preas[0] = preDelim; - preas[1] = 0; pdr = wxS("\\"); pdr += preDelim; }