Converted various wxArrayPtrVoids to wxVectors

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli 2008-09-30 17:23:27 +00:00
parent 7eaed395dd
commit f7a094e1af
9 changed files with 80 additions and 81 deletions

View File

@ -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<wxPropertyGridPage*> m_arrPages;
#if wxUSE_TOOLBAR
wxToolBar* m_pToolbar;

View File

@ -615,7 +615,7 @@ public:
// Takes ownership of 'item'
void Insert( int index, wxPGChoiceEntry* item )
{
wxArrayPtrVoid::iterator it;
wxVector<wxPGChoiceEntry*>::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<wxPGChoiceEntry*> 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;

View File

@ -49,7 +49,7 @@ public:
wxPGHashMapS2P m_mapEditorClasses;
#if wxUSE_VALIDATORS
wxArrayPtrVoid m_arrValidators; // These wxValidators need to be freed
wxVector<wxValidator*> 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<wxWindow*> 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<wxPGCommonValue*> m_commonValues;
// Which cv selection really sets value to unspecified?
int m_cvUnspecified;

View File

@ -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"

View File

@ -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;
// -----------------------------------------------------------------------

View File

@ -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<m_arrPages.GetCount(); i++ )
for ( i=0; i<m_arrPages.size(); i++ )
{
delete (wxPropertyGridPage*)m_arrPages.Item(i);
delete m_arrPages[i];
}
delete m_emptyPage;
@ -464,7 +462,7 @@ bool wxPropertyGridManager::SetFont( const wxFont& font )
// TODO: Need to do caption recacalculations for other pages as well.
unsigned int i;
for ( i=0; i<m_arrPages.GetCount(); i++ )
for ( i=0; i<m_arrPages.size(); i++ )
{
wxPropertyGridPage* page = GetPage(i);
@ -544,7 +542,7 @@ bool wxPropertyGridManager::DoSelectPage( int index )
if ( index >= 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; i<GetPageCount(); i++ )
{
if ( ((wxPropertyGridPage*)m_arrPages.Item(i))->m_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; i<GetPageCount(); i++ )
{
if ( pState == ((wxPropertyGridPage*)m_arrPages.Item(i))->GetStatePtr() )
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; i<GetPageCount(); i++ )
{
if ( ((wxPropertyGridPage*)m_arrPages.Item(i))->GetStatePtr()->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; i<GetPageCount(); i++ )
{
wxPropertyGridPageState* pState = ((wxPropertyGridPage*)m_arrPages.Item(i))->GetStatePtr();
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; i<GetPageCount(); i++ )
{
pdc = (wxPropertyGridPage*)m_arrPages.Item(i);
pdc = m_arrPages[i];
if ( pdc->m_id == id )
{
index = i;
@ -1451,7 +1450,7 @@ void wxPropertyGridManager::SetSplitterLeft( bool subProps, bool allPages )
for ( i=0; i<GetPageCount(); i++ )
{
int maxW = m_pState->GetColumnFitWidth(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;

View File

@ -439,7 +439,7 @@ wxPGProperty::~wxPGProperty()
unsigned int i;
for ( i=0; i<m_cells.size(); i++ )
delete (wxPGCell*) m_cells[i];
delete m_cells[i];
// This makes it easier for us to detect dangling pointers
m_parent = NULL;
@ -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<m_children.size(); i++ )
{
if ( p == m_children[i] )
return i;
}
return wxNOT_FOUND;
}
void wxPGProperty::UpdateControl( wxWindow* primary )
{
@ -519,7 +528,7 @@ wxString wxPGProperty::GetColumnText( unsigned int col ) const
void wxPGProperty::GenerateComposedValue( wxString& text, int argFlags ) const
{
int i;
int iMax = m_children.GetCount();
int iMax = m_children.size();
text.clear();
if ( iMax == 0 )
@ -534,7 +543,7 @@ void wxPGProperty::GenerateComposedValue( wxString& text, int argFlags ) const
if ( !IsTextEditable() )
argFlags |= wxPG_UNEDITABLE_COMPOSITE_FRAGMENT;
wxPGProperty* curChild = (wxPGProperty*) m_children.Item(0);
wxPGProperty* curChild = m_children[0];
for ( i = 0; i < iMax; i++ )
{
@ -566,7 +575,7 @@ void wxPGProperty::GenerateComposedValue( wxString& text, int argFlags ) const
text += wxS(" ");
}
curChild = (wxPGProperty*) m_children.Item(i+1);
curChild = m_children[i+1];
}
}
@ -575,7 +584,7 @@ void wxPGProperty::GenerateComposedValue( wxString& text, int argFlags ) const
if ( text.EndsWith(wxS("; "), &rest) )
text = rest;
if ( (unsigned int)i < m_children.GetCount() )
if ( (unsigned int)i < m_children.size() )
text += wxS("; ...");
}
@ -631,7 +640,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
unsigned int curChild = 0;
unsigned int iMax = m_children.GetCount();
unsigned int iMax = m_children.size();
if ( iMax > 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<GetChildCount(); i++ )
{
wxPGProperty* p = (wxPGProperty*) Item(i);
delete p;
delete m_children[i];
}
}
m_children.Empty();
m_children.clear();
}
void wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
@ -1971,11 +1979,11 @@ void wxPGProperty::SubPropsChanged( int oldSelInd )
PrepareSubProperties();
wxPGProperty* sel = (wxPGProperty*) NULL;
if ( oldSelInd >= (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;

View File

@ -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; i<m_windowsToDelete->size(); i++ )
delete ((wxWindow*)((*m_windowsToDelete)[i]));
for ( i=0; i<m_windowsToDelete.size(); i++ )
delete m_windowsToDelete[i];
m_windowsToDelete->clear();
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);
}
// -----------------------------------------------------------------------

View File

@ -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() );
}