Stop passing window to insert separately to wxAuiTabContainer

It's already part of wxAuiNotebookPage also passed to its AddPage() and
InsertPage() functions and there is no need to pass it as a separate
parameter.

This changes these functions in a backwards-incompatible way, and even
though they were never really supposed to be public, provide
backwards-compatible overloads for them just in case somebody used them.

No real changes, just simplify the code.
This commit is contained in:
Vadim Zeitlin
2024-12-09 21:33:14 +01:00
parent bfa27c2bb0
commit 33ead6fb6a
3 changed files with 28 additions and 20 deletions
+16 -3
View File
@@ -138,8 +138,8 @@ public:
void SetFlags(unsigned int flags);
unsigned int GetFlags() const;
bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
bool AddPage(const wxAuiNotebookPage& info);
bool InsertPage(const wxAuiNotebookPage& info, size_t idx);
bool MovePage(wxWindow* page, size_t newIdx);
bool RemovePage(wxWindow* page);
void RemovePageAt(size_t idx);
@@ -178,7 +178,20 @@ public:
// Make the tab visible if it wasn't already
void MakeTabVisible(int tabPage, wxWindow* win);
// Compatibility only, don't use.
// Backwards compatible variants of internal functions, which shouldn't be
// used anyhow.
bool AddPage(wxWindow* page, wxAuiNotebookPage info)
{
info.window = page;
return AddPage(info);
}
bool InsertPage(wxWindow* page, wxAuiNotebookPage info, size_t idx)
{
info.window = page;
return InsertPage(info, idx);
}
bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const
{
auto* const button = ButtonHitTest(x, y);
+2 -2
View File
@@ -636,8 +636,8 @@ public:
void SetFlags(unsigned int flags);
unsigned int GetFlags() const;
bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
bool AddPage(const wxAuiNotebookPage& info);
bool InsertPage(const wxAuiNotebookPage& info, size_t idx);
bool MovePage(wxWindow* page, size_t newIdx);
bool RemovePage(wxWindow* page);
void RemovePageAt(size_t idx);
+10 -15
View File
@@ -177,26 +177,20 @@ void wxAuiTabContainer::SetRect(const wxRect& rect, wxWindow* wnd)
}
}
bool wxAuiTabContainer::AddPage(wxWindow* page,
const wxAuiNotebookPage& info)
bool wxAuiTabContainer::AddPage(const wxAuiNotebookPage& info)
{
return InsertPage(page, info, m_pages.GetCount());
return InsertPage(info, m_pages.GetCount());
}
bool wxAuiTabContainer::InsertPage(wxWindow* page,
const wxAuiNotebookPage& info,
bool wxAuiTabContainer::InsertPage(const wxAuiNotebookPage& info,
size_t idx)
{
wxAuiNotebookPage page_info = info;
page_info.window = page;
page_info.hover = false;
m_pages.insert(m_pages.begin() + idx, page_info);
m_pages.insert(m_pages.begin() + idx, info);
// let the art provider know how many pages we have
if (m_art)
{
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount(), page);
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount(), info.window);
}
return true;
@@ -2051,11 +2045,11 @@ void wxAuiNotebook::InsertPageAt(wxAuiNotebookPage& info,
select = true;
}
m_tabs.InsertPage(page, info, page_idx);
m_tabs.InsertPage(info, page_idx);
if ( tab_page_idx == -1 )
tab_page_idx = tabctrl->GetPageCount();
tabctrl->InsertPage(page, info, tab_page_idx);
tabctrl->InsertPage(info, tab_page_idx);
// Note that we don't need to call DoSizing() if the height has changed, as
// it's already called from UpdateTabCtrlHeight() itself in this case.
@@ -2489,7 +2483,7 @@ void wxAuiNotebook::Split(size_t page, int direction)
// add the page to the destination tabs
dest_tabs->InsertPage(page_info.window, page_info, 0);
dest_tabs->InsertPage(page_info, 0);
if (src_tabs->GetPageCount() == 0)
{
@@ -2751,6 +2745,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt)
// make a copy of the page info
wxAuiNotebookPage page_info = m_tabs.GetPage(main_idx);
page_info.hover = false;
// remove the page from the source notebook
RemovePage(main_idx);
@@ -2854,7 +2849,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt)
// add the page to the destination tabs
if (insert_idx == -1)
insert_idx = dest_tabs->GetPageCount();
dest_tabs->InsertPage(page_info.window, page_info, insert_idx);
dest_tabs->InsertPage(page_info, insert_idx);
if (src_tabs->GetPageCount() == 0)
{