From f7a094e1af0a07c278d61bd542c4be06aef5e3af Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Tue, 30 Sep 2008 17:23:27 +0000 Subject: [PATCH] Converted various wxArrayPtrVoids to wxVectors git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/manager.h | 4 +-- include/wx/propgrid/property.h | 19 ++++++------ include/wx/propgrid/propgrid.h | 8 +++-- include/wx/propgrid/propgriddefs.h | 1 + include/wx/propgrid/props.h | 2 +- src/propgrid/manager.cpp | 49 +++++++++++++++--------------- src/propgrid/property.cpp | 44 ++++++++++++++++----------- src/propgrid/propgrid.cpp | 28 ++++++----------- src/propgrid/propgridpagestate.cpp | 6 ++-- 9 files changed, 80 insertions(+), 81 deletions(-) diff --git a/include/wx/propgrid/manager.h b/include/wx/propgrid/manager.h index d3166bc3d6..3e1419f49f 100644 --- a/include/wx/propgrid/manager.h +++ b/include/wx/propgrid/manager.h @@ -432,7 +432,7 @@ public: */ wxPropertyGridPage* GetPage( unsigned int ind ) const { - return (wxPropertyGridPage*)m_arrPages.Item(ind); + return m_arrPages[ind]; } /** Returns page object for given page name. @@ -660,7 +660,7 @@ protected: wxPropertyGrid* m_pPropGrid; - wxArrayPtrVoid m_arrPages; + wxVector m_arrPages; #if wxUSE_TOOLBAR wxToolBar* m_pToolbar; diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 3dab662746..021d5a90a8 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -615,7 +615,7 @@ public: // Takes ownership of 'item' void Insert( int index, wxPGChoiceEntry* item ) { - wxArrayPtrVoid::iterator it; + wxVector::iterator it; if ( index == -1 ) { it = m_items.end(); @@ -642,7 +642,7 @@ public: { wxCHECK_MSG( i < GetCount(), NULL, "invalid index" ); - return (wxPGChoiceEntry*) m_items[i]; + return m_items[i]; } void DecRef() @@ -654,7 +654,7 @@ public: } private: - wxArrayPtrVoid m_items; + wxVector m_items; // So that multiple properties can use the same set int m_refCount; @@ -1888,19 +1888,18 @@ public: int GetChildrenHeight( int lh, int iMax = -1 ) const; /** Returns number of child properties */ - unsigned int GetChildCount() const { return m_children.GetCount(); } + unsigned int GetChildCount() const { return m_children.size(); } /** Returns sub-property at index i. */ wxPGProperty* Item( size_t i ) const - { return (wxPGProperty*)m_children.Item(i); } + { return m_children[i]; } /** Returns last sub-property. */ - wxPGProperty* Last() const { return (wxPGProperty*)m_children.Last(); } + wxPGProperty* Last() const { return m_children.back(); } - /** Returns index of given sub-property. */ - int Index( const wxPGProperty* p ) const - { return m_children.Index((wxPGProperty*)p); } + /** Returns index of given child property. */ + int Index( const wxPGProperty* p ) const; /** Deletes all sub-properties. */ void Empty(); @@ -2021,7 +2020,7 @@ protected: wxVariant m_value; wxPGAttributeStorage m_attributes; - wxArrayPtrVoid m_children; + wxArrayPGProperty m_children; // Extended cell information wxArrayPtrVoid m_cells; diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 9f82cfbe68..099c987088 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -49,7 +49,7 @@ public: wxPGHashMapS2P m_mapEditorClasses; #if wxUSE_VALIDATORS - wxArrayPtrVoid m_arrValidators; // These wxValidators need to be freed + wxVector m_arrValidators; // These wxValidators need to be freed #endif wxPGHashMapS2P m_dictPropertyClassInfo; // PropertyName -> ClassInfo @@ -1408,7 +1408,7 @@ protected: wxBitmap *m_doubleBuffer; #endif - wxArrayPtrVoid *m_windowsToDelete; + wxVector m_windowsToDelete; /** Local time ms when control was created. */ wxLongLong m_timeCreated; @@ -1627,11 +1627,13 @@ protected: // Array of background colour brushes. wxArrayPtrVoid m_arrBgBrushes; + // Array of foreground colours. wxArrayPtrVoid m_arrFgCols; // labels when properties use common values - wxArrayPtrVoid m_commonValues; + wxVector m_commonValues; + // Which cv selection really sets value to unspecified? int m_cvUnspecified; diff --git a/include/wx/propgrid/propgriddefs.h b/include/wx/propgrid/propgriddefs.h index 50937ec0f4..13cad628b6 100644 --- a/include/wx/propgrid/propgriddefs.h +++ b/include/wx/propgrid/propgriddefs.h @@ -15,6 +15,7 @@ #if wxUSE_PROPGRID #include "wx/dynarray.h" +#include "wx/vector.h" #include "wx/hashmap.h" #include "wx/variant.h" #include "wx/longlong.h" diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index d490473e98..48afe12fb1 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -213,7 +213,7 @@ WX_PG_IMPLEMENT_CUSTOM_COLOUR_PROPERTY_USES_WXCOLOUR2(CLASSNAME, \ // Common function exit #define WX_PG_DOGETVALIDATOR_EXIT(VALIDATOR) \ s_ptr = VALIDATOR; \ - wxPGGlobalVars->m_arrValidators.Add( (void*) VALIDATOR ); \ + wxPGGlobalVars->m_arrValidators.push_back( VALIDATOR ); \ return VALIDATOR; // ----------------------------------------------------------------------- diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 333a758b9d..a99a07de43 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -153,8 +153,6 @@ static const char* gs_xpm_defpage[] = { "................" }; -#define GETPAGESTATE(page) ((wxPropertyGridPage*)m_arrPages.Item(page))->GetStatePtr() - // ----------------------------------------------------------------------- // wxPropertyGridPage // ----------------------------------------------------------------------- @@ -360,7 +358,7 @@ void wxPropertyGridManager::Init2( int style ) pd->m_manager = this; wxPropertyGridPageState* state = pd->GetStatePtr(); state->m_pPropGrid = m_pPropGrid; - m_arrPages.Add( (void*)pd ); + m_arrPages.push_back( pd ); m_pPropGrid->m_pState = state; wxWindowID baseId = GetId(); @@ -422,9 +420,9 @@ wxPropertyGridManager::~wxPropertyGridManager() m_pPropGrid->m_pState = NULL; size_t i; - for ( i=0; i= 0 ) { - nextPage = (wxPropertyGridPage*)m_arrPages.Item(index); + nextPage = m_arrPages[index]; nextPage->OnShow(); } @@ -595,7 +593,7 @@ int wxPropertyGridManager::GetPageByName( const wxString& name ) const size_t i; for ( i=0; im_label == name ) + if ( m_arrPages[i]->m_label == name ) return i; } return wxNOT_FOUND; @@ -610,7 +608,7 @@ int wxPropertyGridManager::GetPageByState( const wxPropertyGridPageState* pState size_t i; for ( i=0; iGetStatePtr() ) + if ( pState == m_arrPages[i]->GetStatePtr() ) return i; } @@ -622,7 +620,7 @@ int wxPropertyGridManager::GetPageByState( const wxPropertyGridPageState* pState const wxString& wxPropertyGridManager::GetPageName( int index ) const { wxASSERT( index >= 0 && index < (int)GetPageCount() ); - return ((wxPropertyGridPage*)m_arrPages.Item(index))->m_label; + return m_arrPages[index]->m_label; } // ----------------------------------------------------------------------- @@ -636,7 +634,7 @@ wxPropertyGridPageState* wxPropertyGridManager::GetPageState( int page ) const if ( page == -1 ) return m_pState; - return GETPAGESTATE(page); + return m_arrPages[page]; } // ----------------------------------------------------------------------- @@ -664,7 +662,7 @@ void wxPropertyGridManager::ClearPage( int page ) if ( page >= 0 && page < (int)GetPageCount() ) { - wxPropertyGridPageState* state = GETPAGESTATE(page); + wxPropertyGridPageState* state = m_arrPages[page]; if ( state == m_pPropGrid->GetState() ) m_pPropGrid->Clear(); @@ -700,7 +698,7 @@ size_t wxPropertyGridManager::GetPageCount() const if ( !(m_iFlags & wxPG_MAN_FL_PAGE_INSERTED) ) return 0; - return m_arrPages.GetCount(); + return m_arrPages.size(); } // ----------------------------------------------------------------------- @@ -775,7 +773,7 @@ wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index, pageObj->m_id = m_nextTbInd; if ( isPageInserted ) - m_arrPages.Add( (void*)pageObj ); + m_arrPages.push_back( pageObj ); #if wxUSE_TOOLBAR if ( m_windowStyle & wxPG_TOOLBAR ) @@ -838,7 +836,7 @@ bool wxPropertyGridManager::IsAnyModified() const size_t i; for ( i=0; iGetStatePtr()->m_anyModified ) + if ( m_arrPages[i]->GetStatePtr()->m_anyModified ) return true; } return false; @@ -848,7 +846,7 @@ bool wxPropertyGridManager::IsAnyModified() const bool wxPropertyGridManager::IsPageModified( size_t index ) const { - if ( ((wxPropertyGridPage*)m_arrPages.Item(index))->GetStatePtr()->m_anyModified ) + if ( m_arrPages[index]->GetStatePtr()->m_anyModified ) return true; return false; } @@ -858,9 +856,9 @@ bool wxPropertyGridManager::IsPageModified( size_t index ) const wxPGProperty* wxPropertyGridManager::GetPageRoot( int index ) const { wxASSERT( index >= 0 ); - wxASSERT( index < (int)m_arrPages.GetCount() ); + wxASSERT( index < (int)m_arrPages.size() ); - return ((wxPropertyGridPage*)m_arrPages.Item(index))->GetStatePtr()->m_properties; + return m_arrPages[index]->GetStatePtr()->m_properties; } // ----------------------------------------------------------------------- @@ -871,9 +869,9 @@ bool wxPropertyGridManager::RemovePage( int page ) false, wxT("invalid page index") ); - wxPropertyGridPage* pd = (wxPropertyGridPage*)m_arrPages.Item(page); + wxPropertyGridPage* pd = m_arrPages[page]; - if ( m_arrPages.GetCount() == 1 ) + if ( m_arrPages.size() == 1 ) { // Last page: do not remove page entry m_pPropGrid->Clear(); @@ -881,6 +879,7 @@ bool wxPropertyGridManager::RemovePage( int page ) m_iFlags &= ~wxPG_MAN_FL_PAGE_INSERTED; pd->m_label.clear(); } + // Change selection if current is page else if ( page == m_selPage ) { @@ -913,9 +912,9 @@ bool wxPropertyGridManager::RemovePage( int page ) } #endif - if ( m_arrPages.GetCount() > 1 ) + if ( m_arrPages.size() > 1 ) { - m_arrPages.RemoveAt(page); + m_arrPages.erase(m_arrPages.begin() + page); delete pd; } @@ -1310,7 +1309,7 @@ wxPGProperty* wxPropertyGridManager::DoGetPropertyByName( const wxString& name ) size_t i; for ( i=0; iGetStatePtr(); + wxPropertyGridPageState* pState = m_arrPages[i]->GetStatePtr(); wxPGProperty* p = pState->BaseGetPropertyByName(name); if ( p ) { @@ -1369,7 +1368,7 @@ void wxPropertyGridManager::OnToolbarClick( wxCommandEvent &event ) // Find page with given id. for ( i=0; im_id == id ) { index = i; @@ -1451,7 +1450,7 @@ void wxPropertyGridManager::SetSplitterLeft( bool subProps, bool allPages ) for ( i=0; iGetColumnFitWidth(dc, GETPAGESTATE(i)->m_properties, 0, subProps ); + int maxW = m_pState->GetColumnFitWidth(dc, m_arrPages[i]->m_properties, 0, subProps ); maxW += m_pPropGrid->m_marginWidth; if ( maxW > highest ) highest = maxW; diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 2fc310ebdd..63fd9cac84 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -439,7 +439,7 @@ wxPGProperty::~wxPGProperty() unsigned int i; for ( i=0; iGetGrid(); } +int wxPGProperty::Index( const wxPGProperty* p ) const +{ + for ( unsigned int i = 0; i PWC_CHILD_SUMMARY_LIMIT && !(argFlags & wxPG_FULL_VALUE) ) @@ -1542,14 +1551,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 +1571,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*/ ) @@ -1792,12 +1801,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; diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index d33e9eec99..1e4850c31c 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -602,8 +602,6 @@ void wxPropertyGrid::Init1() m_doubleBuffer = (wxBitmap*) NULL; #endif - m_windowsToDelete = NULL; - #ifndef wxPG_ICON_WIDTH m_expandbmp = NULL; m_collbmp = NULL; @@ -761,8 +759,6 @@ wxPropertyGrid::~wxPropertyGrid() delete m_doubleBuffer; #endif - delete m_windowsToDelete; - //m_selected = (wxPGProperty*) NULL; if ( m_iFlags & wxPG_FL_CREATEDSTATE ) @@ -3448,19 +3444,16 @@ void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd ) void wxPropertyGrid::FreeEditors() { // Do not free editors immediately if processing events - if ( !m_windowsToDelete ) - m_windowsToDelete = new wxArrayPtrVoid; - if ( m_wndEditor2 ) { - m_windowsToDelete->push_back(m_wndEditor2); + m_windowsToDelete.push_back(m_wndEditor2); m_wndEditor2->Hide(); m_wndEditor2 = (wxWindow*) NULL; } if ( m_wndEditor ) { - m_windowsToDelete->push_back(m_wndEditor); + m_windowsToDelete.push_back(m_wndEditor); m_wndEditor->Hide(); m_wndEditor = (wxWindow*) NULL; } @@ -3488,14 +3481,14 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) // // Delete windows pending for deletion - if ( m_windowsToDelete && !m_inDoPropertyChanged && m_windowsToDelete->size() ) + if ( !m_inDoPropertyChanged && m_windowsToDelete.size() ) { unsigned int i; - for ( i=0; isize(); i++ ) - delete ((wxWindow*)((*m_windowsToDelete)[i])); + for ( i=0; iclear(); + m_windowsToDelete.clear(); } if ( !m_pState ) @@ -5627,11 +5620,7 @@ void wxPGChoicesData::Clear() delete Item(i); } -#if wxUSE_STL - m_items.resize(0); -#else - m_items.Empty(); -#endif + m_items.clear(); } void wxPGChoicesData::CopyDataFrom( wxPGChoicesData* data ) @@ -5776,7 +5765,8 @@ void wxPGChoices::RemoveAt(size_t nIndex, size_t count) unsigned int i; for ( i=nIndex; i<(nIndex+count); i++) delete m_data->Item(i); - m_data->m_items.RemoveAt(nIndex, count); + m_data->m_items.erase(m_data->m_items.begin()+nIndex, + m_data->m_items.begin()+nIndex+count-1); } // ----------------------------------------------------------------------- diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 693d339217..913321f78d 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -592,10 +592,10 @@ bool wxPropertyGridPageState::EnableCategories( bool enable ) // ----------------------------------------------------------------------- -static int wxPG_SortFunc(void **p1, void **p2) +static int wxPG_SortFunc(wxPGProperty **p1, wxPGProperty **p2) { - wxPGProperty *pp1 = *((wxPGProperty**)p1); - wxPGProperty *pp2 = *((wxPGProperty**)p2); + wxPGProperty *pp1 = *p1; + wxPGProperty *pp2 = *p2; return pp1->GetLabel().compare( pp2->GetLabel() ); } -- 2.45.2