*/
wxPropertyGridPage* GetPage( unsigned int ind ) const
{
- return (wxPropertyGridPage*)m_arrPages.Item(ind);
+ return m_arrPages[ind];
}
/** Returns page object for given page name.
wxPropertyGrid* m_pPropGrid;
- wxArrayPtrVoid m_arrPages;
+ wxVector<wxPropertyGridPage*> m_arrPages;
#if wxUSE_TOOLBAR
wxToolBar* m_pToolbar;
// Takes ownership of 'item'
void Insert( int index, wxPGChoiceEntry* item )
{
- wxArrayPtrVoid::iterator it;
+ wxVector<wxPGChoiceEntry*>::iterator it;
if ( index == -1 )
{
it = m_items.end();
{
wxCHECK_MSG( i < GetCount(), NULL, "invalid index" );
- return (wxPGChoiceEntry*) m_items[i];
+ return m_items[i];
}
void DecRef()
}
private:
- wxArrayPtrVoid m_items;
+ wxVector<wxPGChoiceEntry*> m_items;
// So that multiple properties can use the same set
int m_refCount;
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();
wxVariant m_value;
wxPGAttributeStorage m_attributes;
- wxArrayPtrVoid m_children;
+ wxArrayPGProperty m_children;
// Extended cell information
wxArrayPtrVoid m_cells;
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
wxBitmap *m_doubleBuffer;
#endif
- wxArrayPtrVoid *m_windowsToDelete;
+ wxVector<wxWindow*> m_windowsToDelete;
/** Local time ms when control was created. */
wxLongLong m_timeCreated;
// 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;
#if wxUSE_PROPGRID
#include "wx/dynarray.h"
+#include "wx/vector.h"
#include "wx/hashmap.h"
#include "wx/variant.h"
#include "wx/longlong.h"
// 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;
// -----------------------------------------------------------------------
"................"
};
-#define GETPAGESTATE(page) ((wxPropertyGridPage*)m_arrPages.Item(page))->GetStatePtr()
-
// -----------------------------------------------------------------------
// wxPropertyGridPage
// -----------------------------------------------------------------------
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();
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;
// 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);
if ( index >= 0 )
{
- nextPage = (wxPropertyGridPage*)m_arrPages.Item(index);
+ nextPage = m_arrPages[index];
nextPage->OnShow();
}
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;
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;
}
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;
}
// -----------------------------------------------------------------------
if ( page == -1 )
return m_pState;
- return GETPAGESTATE(page);
+ return m_arrPages[page];
}
// -----------------------------------------------------------------------
if ( page >= 0 && page < (int)GetPageCount() )
{
- wxPropertyGridPageState* state = GETPAGESTATE(page);
+ wxPropertyGridPageState* state = m_arrPages[page];
if ( state == m_pPropGrid->GetState() )
m_pPropGrid->Clear();
if ( !(m_iFlags & wxPG_MAN_FL_PAGE_INSERTED) )
return 0;
- return m_arrPages.GetCount();
+ return m_arrPages.size();
}
// -----------------------------------------------------------------------
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 )
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;
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;
}
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;
}
// -----------------------------------------------------------------------
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();
m_iFlags &= ~wxPG_MAN_FL_PAGE_INSERTED;
pd->m_label.clear();
}
+
// Change selection if current is page
else if ( page == m_selPage )
{
}
#endif
- if ( m_arrPages.GetCount() > 1 )
+ if ( m_arrPages.size() > 1 )
{
- m_arrPages.RemoveAt(page);
+ m_arrPages.erase(m_arrPages.begin() + page);
delete pd;
}
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 )
{
// 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;
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;
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;
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 )
{
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 )
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++ )
{
text += wxS(" ");
}
- curChild = (wxPGProperty*) m_children.Item(i+1);
+ curChild = m_children[i+1];
}
}
if ( text.EndsWith(wxS("; "), &rest) )
text = rest;
- if ( (unsigned int)i < m_children.GetCount() )
+ if ( (unsigned int)i < m_children.size() )
text += wxS("; ...");
}
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) )
// 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 );
}
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*/ )
{
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),
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;
m_doubleBuffer = (wxBitmap*) NULL;
#endif
- m_windowsToDelete = NULL;
-
#ifndef wxPG_ICON_WIDTH
m_expandbmp = NULL;
m_collbmp = NULL;
delete m_doubleBuffer;
#endif
- delete m_windowsToDelete;
-
//m_selected = (wxPGProperty*) NULL;
if ( m_iFlags & wxPG_FL_CREATEDSTATE )
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;
}
//
// 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 )
delete Item(i);
}
-#if wxUSE_STL
- m_items.resize(0);
-#else
- m_items.Empty();
-#endif
+ m_items.clear();
}
void wxPGChoicesData::CopyDataFrom( wxPGChoicesData* data )
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);
}
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
-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() );
}