From 33ead6fb6aabdcd675356f8e3e84edb4ca2d1a28 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 8 Dec 2024 00:19:22 +0100 Subject: [PATCH] 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. --- include/wx/aui/auibook.h | 19 ++++++++++++++++--- interface/wx/aui/auibook.h | 4 ++-- src/aui/auibook.cpp | 25 ++++++++++--------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 0fb57561a6..09a4181af3 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -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); diff --git a/interface/wx/aui/auibook.h b/interface/wx/aui/auibook.h index 5b453b8d76..109f2d31f3 100644 --- a/interface/wx/aui/auibook.h +++ b/interface/wx/aui/auibook.h @@ -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); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 1984fe8373..90876d3104 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -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) {