Use wxVector<> for wxBookCtrlBase::m_pages array

Get rid of another macro-based array in favour of wxVector<>.

No real changes.
This commit is contained in:
Vadim Zeitlin 2018-03-25 00:38:16 +01:00
parent 3d37b8c72a
commit bee28c2730
8 changed files with 22 additions and 24 deletions

View File

@ -20,11 +20,9 @@
#if wxUSE_BOOKCTRL
#include "wx/control.h"
#include "wx/dynarray.h"
#include "wx/vector.h"
#include "wx/withimages.h"
WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages);
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent;
@ -94,7 +92,7 @@ public:
virtual size_t GetPageCount() const { return m_pages.size(); }
// get the panel which represents the given page
virtual wxWindow *GetPage(size_t n) const { return m_pages[n]; }
virtual wxWindow *GetPage(size_t n) const { return m_pages.at(n); }
// get the current page or NULL if none
wxWindow *GetCurrentPage() const
@ -331,7 +329,7 @@ protected:
// the array of all pages of this control
wxArrayPages m_pages;
wxVector<wxWindow*> m_pages;
// get the page area
virtual wxRect GetPageRect() const;

View File

@ -241,8 +241,8 @@ void wxBookCtrlBase::DoSize()
// resize all pages to fit the new control size
const wxRect pageRect = GetPageRect();
const unsigned pagesCount = m_pages.GetCount();
for ( unsigned int i = 0; i < pagesCount; ++i )
const size_t pagesCount = m_pages.size();
for ( size_t i = 0; i < pagesCount; ++i )
{
wxWindow * const page = m_pages[i];
if ( !page )
@ -310,7 +310,7 @@ void wxBookCtrlBase::OnHelp(wxHelpEvent& event)
source = source->GetParent();
}
if ( source && m_pages.Index(source) == wxNOT_FOUND )
if ( source && FindPage(source) == wxNOT_FOUND )
{
// this event is for the book control itself, redirect it to the
// corresponding page
@ -368,7 +368,7 @@ wxBookCtrlBase::InsertPage(size_t nPage,
wxCHECK_MSG( nPage <= m_pages.size(), false,
wxT("invalid page index in wxBookCtrlBase::InsertPage()") );
m_pages.Insert(page, nPage);
m_pages.insert(m_pages.begin() + nPage, page);
if ( page )
page->SetSize(GetPageRect());
@ -395,7 +395,7 @@ wxWindow *wxBookCtrlBase::DoRemovePage(size_t nPage)
wxT("invalid page index in wxBookCtrlBase::DoRemovePage()") );
wxWindow *pageRemoved = m_pages[nPage];
m_pages.RemoveAt(nPage);
m_pages.erase(m_pages.begin() + nPage);
DoInvalidateBestSize();
return pageRemoved;

View File

@ -418,7 +418,7 @@ bool wxNotebook::InsertPage( size_t position,
wxGtkNotebookPage* pageData = new wxGtkNotebookPage;
m_pages.Insert(win, position);
m_pages.insert(m_pages.begin() + position, win);
m_pagesData.Insert(position, pageData);
// set the label image and text

View File

@ -660,7 +660,7 @@ bool wxNotebook::InsertPage( size_t position,
else
m_pagesData.Insert( position, nb_page );
m_pages.Insert(win, position);
m_pages.insert(m_pages.begin() + position, win);
nb_page->m_box = gtk_hbox_new( FALSE, 1 );
gtk_container_border_width( GTK_CONTAINER(nb_page->m_box), 2 );

View File

@ -309,9 +309,9 @@ wxNotebook::~wxNotebook()
size_t wxNotebook::GetPageCount() const
{
// consistency check
wxASSERT( (int)m_pages.Count() == TabCtrl_GetItemCount(GetHwnd()) );
wxASSERT( (int)m_pages.size() == TabCtrl_GetItemCount(GetHwnd()) );
return m_pages.Count();
return m_pages.size();
}
int wxNotebook::GetRowCount() const
@ -404,7 +404,7 @@ bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
if ( ret && rows != GetRowCount() )
{
const wxRect r = GetPageSize();
const size_t count = m_pages.Count();
const size_t count = m_pages.size();
for ( size_t page = 0; page < count; page++ )
m_pages[page]->SetSize(r);
}
@ -578,7 +578,7 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
if ( !TabCtrl_DeleteItem(GetHwnd(), nPage) )
wxLogLastError(wxS("TabCtrl_DeleteItem()"));
if ( m_pages.IsEmpty() )
if ( m_pages.empty() )
{
// no selection any more, the notebook becamse empty
m_selection = wxNOT_FOUND;
@ -693,13 +693,13 @@ bool wxNotebook::InsertPage(size_t nPage,
}
// succeeded: save the pointer to the page
m_pages.Insert(pPage, nPage);
m_pages.insert(m_pages.begin() + nPage, pPage);
// we may need to adjust the size again if the notebook size changed:
// normally this only happens for the first page we add (the tabs which
// hadn't been there before are now shown) but for a multiline notebook it
// can happen for any page at all as a new row could have been started
if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) )
if ( m_pages.size() == 1 || HasFlag(wxNB_MULTILINE) )
{
AdjustPageSize(pPage);
@ -959,7 +959,7 @@ void wxNotebook::OnSize(wxSizeEvent& event)
int width = rc.right - rc.left,
height = rc.bottom - rc.top;
size_t nCount = m_pages.Count();
size_t nCount = m_pages.size();
for ( size_t nPage = 0; nPage < nCount; nPage++ ) {
wxNotebookPage *pPage = m_pages[nPage];
pPage->SetSize(rc.left, rc.top, width, height);

View File

@ -173,7 +173,7 @@ wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
wxT("DoRemovePage: invalid notebook page") );
wxNotebookPage* page = m_pages[nPage] ;
m_pages.RemoveAt(nPage);
m_pages.erase(m_pages.begin() + nPage);
m_images.RemoveAt(nPage);
MacSetupTabs();
@ -285,7 +285,7 @@ wxRect wxNotebook::GetPageRect() const
// time because doing it in ::Create() doesn't work (for unknown reasons)
void wxNotebook::OnSize(wxSizeEvent& event)
{
unsigned int nCount = m_pages.Count();
unsigned int nCount = m_pages.size();
wxRect rect = GetPageRect() ;
for ( unsigned int nPage = 0; nPage < nCount; nPage++ )

View File

@ -150,7 +150,7 @@ bool wxNotebook::InsertPage(size_t n, wxWindow *page, const wxString& text,
m_qtTabWidget->insertTab( n, page->GetHandle(), wxQtConvertString( text ));
}
m_pages.Insert(page, n);
m_pages.insert(m_pages.begin() + n, page);
m_images.insert(m_images.begin() + n, imageId);
// reenable firing qt signals as internal wx initialization was completed

View File

@ -304,7 +304,7 @@ bool wxNotebook::InsertPage(size_t nPage,
wxT("invalid notebook page in InsertPage()") );
// modify the data
m_pages.Insert(pPage, nPage);
m_pages.insert(m_pages.begin() + nPage, pPage);
wxString label;
m_accels.Insert(FindAccelIndex(strText, &label), nPage);
@ -378,7 +378,7 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL, wxT("invalid notebook page") );
wxNotebookPage *page = m_pages[nPage];
m_pages.RemoveAt(nPage);
m_pages.erase(m_pages.begin() + nPage);
m_titles.RemoveAt(nPage);
m_accels.RemoveAt(nPage);
m_widths.RemoveAt(nPage);