Use wxVector<> in wxTreebookPage implementation
No real changes, just replace the use of a macro-based array with wxVector<>.
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "wx/bookctrl.h"
|
#include "wx/bookctrl.h"
|
||||||
#include "wx/containr.h"
|
#include "wx/containr.h"
|
||||||
#include "wx/treebase.h" // for wxTreeItemId
|
#include "wx/treebase.h" // for wxTreeItemId
|
||||||
|
#include "wx/vector.h"
|
||||||
|
|
||||||
typedef wxWindow wxTreebookPage;
|
typedef wxWindow wxTreebookPage;
|
||||||
|
|
||||||
@@ -150,7 +151,7 @@ protected:
|
|||||||
void OnTreeNodeExpandedCollapsed(wxTreeEvent& event);
|
void OnTreeNodeExpandedCollapsed(wxTreeEvent& event);
|
||||||
|
|
||||||
// array of page ids and page windows
|
// array of page ids and page windows
|
||||||
wxArrayTreeItemIds m_treeIds;
|
wxVector<wxTreeItemId> m_treeIds;
|
||||||
|
|
||||||
// in the situation when m_selection page is not wxNOT_FOUND but page is
|
// in the situation when m_selection page is not wxNOT_FOUND but page is
|
||||||
// NULL this is the first (sub)child that has a non-NULL page
|
// NULL this is the first (sub)child that has a non-NULL page
|
||||||
@@ -217,7 +218,7 @@ private:
|
|||||||
|
|
||||||
// Returns internal number of pages which can be different from
|
// Returns internal number of pages which can be different from
|
||||||
// GetPageCount() while performing a page insertion or removal.
|
// GetPageCount() while performing a page insertion or removal.
|
||||||
size_t DoInternalGetPageCount() const { return m_treeIds.GetCount(); }
|
size_t DoInternalGetPageCount() const { return m_treeIds.size(); }
|
||||||
|
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/imaglist.h"
|
#include "wx/imaglist.h"
|
||||||
|
#include "wx/treectrl.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// various wxWidgets macros
|
// various wxWidgets macros
|
||||||
@@ -140,7 +141,7 @@ bool wxTreebook::InsertSubPage(size_t pagePos,
|
|||||||
bool wxTreebook::AddPage(wxWindow *page, const wxString& text, bool bSelect,
|
bool wxTreebook::AddPage(wxWindow *page, const wxString& text, bool bSelect,
|
||||||
int imageId)
|
int imageId)
|
||||||
{
|
{
|
||||||
return DoInsertPage(m_treeIds.GetCount(), page, text, bSelect, imageId);
|
return DoInsertPage(m_treeIds.size(), page, text, bSelect, imageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertion time is linear to the number of top-pages
|
// insertion time is linear to the number of top-pages
|
||||||
@@ -312,7 +313,7 @@ wxTreebookPage *wxTreebook::DoRemovePage(size_t pagePos)
|
|||||||
bool wxTreebook::DeleteAllPages()
|
bool wxTreebook::DeleteAllPages()
|
||||||
{
|
{
|
||||||
wxBookCtrlBase::DeleteAllPages();
|
wxBookCtrlBase::DeleteAllPages();
|
||||||
m_treeIds.Clear();
|
m_treeIds.clear();
|
||||||
m_selection =
|
m_selection =
|
||||||
m_actualSelection = wxNOT_FOUND;
|
m_actualSelection = wxNOT_FOUND;
|
||||||
|
|
||||||
@@ -326,20 +327,20 @@ void wxTreebook::DoInternalAddPage(size_t newPos,
|
|||||||
wxTreebookPage *page,
|
wxTreebookPage *page,
|
||||||
wxTreeItemId pageId)
|
wxTreeItemId pageId)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( newPos <= m_treeIds.GetCount(), wxT("Ivalid index passed to wxTreebook::DoInternalAddPage") );
|
wxASSERT_MSG( newPos <= m_treeIds.size(), wxT("Ivalid index passed to wxTreebook::DoInternalAddPage") );
|
||||||
|
|
||||||
// hide newly inserted page initially (it will be shown when selected)
|
// hide newly inserted page initially (it will be shown when selected)
|
||||||
if ( page )
|
if ( page )
|
||||||
page->Hide();
|
page->Hide();
|
||||||
|
|
||||||
if ( newPos == m_treeIds.GetCount() )
|
if ( newPos == m_treeIds.size() )
|
||||||
{
|
{
|
||||||
// append
|
// append
|
||||||
m_treeIds.Add(pageId);
|
m_treeIds.push_back(pageId);
|
||||||
}
|
}
|
||||||
else // insert
|
else // insert
|
||||||
{
|
{
|
||||||
m_treeIds.Insert(pageId, newPos);
|
m_treeIds.insert(m_treeIds.begin() + newPos, pageId);
|
||||||
|
|
||||||
if ( m_selection != wxNOT_FOUND && newPos <= (size_t)m_selection )
|
if ( m_selection != wxNOT_FOUND && newPos <= (size_t)m_selection )
|
||||||
{
|
{
|
||||||
@@ -361,12 +362,13 @@ void wxTreebook::DoInternalRemovePageRange(size_t pagePos, size_t subCount)
|
|||||||
// Attention: this function is only for a situation when we delete a node
|
// Attention: this function is only for a situation when we delete a node
|
||||||
// with all its children so pagePos is the node's index and subCount is the
|
// with all its children so pagePos is the node's index and subCount is the
|
||||||
// node children count
|
// node children count
|
||||||
wxASSERT_MSG( pagePos + subCount < m_treeIds.GetCount(),
|
wxASSERT_MSG( pagePos + subCount < m_treeIds.size(),
|
||||||
wxT("Ivalid page index") );
|
wxT("Ivalid page index") );
|
||||||
|
|
||||||
wxTreeItemId pageId = m_treeIds[pagePos];
|
wxTreeItemId pageId = m_treeIds[pagePos];
|
||||||
|
|
||||||
m_treeIds.RemoveAt(pagePos, subCount + 1);
|
wxVector<wxTreeItemId>::iterator itPos = m_treeIds.begin() + pagePos;
|
||||||
|
m_treeIds.erase(itPos, itPos + subCount + 1);
|
||||||
|
|
||||||
if ( m_selection != wxNOT_FOUND )
|
if ( m_selection != wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
@@ -454,7 +456,7 @@ void wxTreebook::DoUpdateSelection(bool bSelect, int newPos)
|
|||||||
|
|
||||||
wxTreeItemId wxTreebook::DoInternalGetPage(size_t pagePos) const
|
wxTreeItemId wxTreebook::DoInternalGetPage(size_t pagePos) const
|
||||||
{
|
{
|
||||||
if ( pagePos >= m_treeIds.GetCount() )
|
if ( pagePos >= m_treeIds.size() )
|
||||||
{
|
{
|
||||||
// invalid position but ok here, in this internal function, don't assert
|
// invalid position but ok here, in this internal function, don't assert
|
||||||
// (the caller will do it)
|
// (the caller will do it)
|
||||||
@@ -466,7 +468,7 @@ wxTreeItemId wxTreebook::DoInternalGetPage(size_t pagePos) const
|
|||||||
|
|
||||||
int wxTreebook::DoInternalFindPageById(wxTreeItemId pageId) const
|
int wxTreebook::DoInternalFindPageById(wxTreeItemId pageId) const
|
||||||
{
|
{
|
||||||
const size_t count = m_treeIds.GetCount();
|
const size_t count = m_treeIds.size();
|
||||||
for ( size_t i = 0; i < count; ++i )
|
for ( size_t i = 0; i < count; ++i )
|
||||||
{
|
{
|
||||||
if ( m_treeIds[i] == pageId )
|
if ( m_treeIds[i] == pageId )
|
||||||
|
Reference in New Issue
Block a user