X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b96a14e3340e6f516d2d1b82ba09be1cacdb5ee2..5a45dd6fd9870de6b68eff437fd5fe4ea5895c3c:/src/propgrid/property.cpp?ds=sidebyside diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 2fc310ebdd..1022055d36 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -4,7 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: 2008-08-23 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) Jaakko Salli // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -35,7 +35,7 @@ #include "wx/intl.h" #endif -#include +#include "wx/propgrid/propgrid.h" #define PWC_CHILD_SUMMARY_LIMIT 16 // Maximum number of children summarized in a parent property's @@ -476,6 +476,15 @@ wxPropertyGrid* wxPGProperty::GetGrid() const return m_parentState->GetGrid(); } +int wxPGProperty::Index( const wxPGProperty* p ) const +{ + for ( unsigned int i = 0; i PWC_CHILD_SUMMARY_LIMIT && !(argFlags & wxPG_FULL_VALUE) ) @@ -871,7 +880,7 @@ void wxPGProperty::OnCustomPaint( wxDC& dc, const wxPGEditor* wxPGProperty::DoGetEditorClass() const { - return wxPG_EDITOR(TextCtrl); + return wxPGEditor_TextCtrl; } // Default extra property event handling - that is, none at all. @@ -883,6 +892,14 @@ bool wxPGProperty::OnEvent( wxPropertyGrid*, wxWindow*, wxEvent& ) void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) { + // If auto unspecified values are not wanted (via window or property style), + // then get default value instead of wxNullVariant. + if ( value.IsNull() && (flags & wxPG_SETVAL_BY_USER) && + !UsesAutoUnspecified() ) + { + value = GetDefaultValue(); + } + if ( !value.IsNull() ) { wxVariant tempListVariant; @@ -1370,11 +1387,11 @@ const wxPGEditor* wxPGProperty::GetEditorClass() const { // TextCtrlAndButton -> ComboBoxAndButton if ( editor->IsKindOf(CLASSINFO(wxPGTextCtrlAndButtonEditor)) ) - editor = wxPG_EDITOR(ChoiceAndButton); + editor = wxPGEditor_ChoiceAndButton; // TextCtrl -> ComboBox else if ( editor->IsKindOf(CLASSINFO(wxPGTextCtrlEditor)) ) - editor = wxPG_EDITOR(ComboBox); + editor = wxPGEditor_ComboBox; } return editor; @@ -1542,14 +1559,14 @@ int wxPGProperty::GetY() const // This is used by Insert etc. void wxPGProperty::AddChild2( wxPGProperty* prop, int index, bool correct_mode ) { - if ( index < 0 || (size_t)index >= m_children.GetCount() ) + if ( index < 0 || (size_t)index >= m_children.size() ) { - if ( correct_mode ) prop->m_arrIndex = m_children.GetCount(); - m_children.Add( prop ); + if ( correct_mode ) prop->m_arrIndex = m_children.size(); + m_children.push_back( prop ); } else { - m_children.Insert( prop, index ); + m_children.insert( m_children.begin()+index, prop); if ( correct_mode ) FixIndexesOfChildren( index ); } @@ -1562,8 +1579,8 @@ void wxPGProperty::AddChild( wxPGProperty* prop ) wxASSERT_MSG( prop->GetBaseName().length(), "Property's children must have unique, non-empty names within their scope" ); - prop->m_arrIndex = m_children.GetCount(); - m_children.Add( prop ); + prop->m_arrIndex = m_children.size(); + m_children.push_back( prop ); int custImgHeight = prop->OnMeasureImage().y; if ( custImgHeight < 0 /*|| custImgHeight > 1*/ ) @@ -1572,6 +1589,20 @@ void wxPGProperty::AddChild( wxPGProperty* prop ) prop->m_parent = this; } +void wxPGProperty::RemoveChild( wxPGProperty* p ) +{ + wxArrayPGProperty::iterator it; + wxArrayPGProperty& children = m_children; + + for ( it=children.begin(); it != children.end(); it++ ) + { + if ( *it == p ) + { + m_children.erase(it); + break; + } + } +} void wxPGProperty::AdaptListToValue( wxVariant& list, wxVariant* value ) const { @@ -1792,12 +1823,11 @@ void wxPGProperty::Empty() { for ( i=0; i= (int)m_children.GetCount() ) - oldSelInd = (int)m_children.GetCount() - 1; + if ( oldSelInd >= (int)m_children.size() ) + oldSelInd = (int)m_children.size() - 1; if ( oldSelInd >= 0 ) - sel = (wxPGProperty*) m_children[oldSelInd]; + sel = m_children[oldSelInd]; else if ( oldSelInd == -2 ) sel = this;