From a2120bb6e12eecfeca8100c6217cde55d7682fb9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Dec 2023 02:27:37 +0100 Subject: [PATCH] Factor out wxAuiTabContainer::GetCloseButtonState() Extract the function for determining whether the close button should be shown for the given page in a reusable function. No real changes yet. --- include/wx/aui/auibook.h | 3 +++ src/aui/auibook.cpp | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 8f79f8f576..7caef20bbb 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -189,6 +189,9 @@ protected: wxRect m_rect; size_t m_tabOffset; unsigned int m_flags; + +private: + int GetCloseButtonState(const wxAuiNotebookPage& page) const; }; diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 035e763edb..570819219c 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -400,6 +400,15 @@ void wxAuiTabContainer::SetTabOffset(size_t offset) +int wxAuiTabContainer::GetCloseButtonState(const wxAuiNotebookPage& page) const +{ + // determine if a close button is on this tab + return ((m_flags & wxAUI_NB_CLOSE_ON_ALL_TABS) != 0 || + ((m_flags & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) != 0 && page.active)) + ? wxAUI_BUTTON_STATE_NORMAL + : wxAUI_BUTTON_STATE_HIDDEN; +} + // Render() renders the tab catalog to the specified DC // It is a virtual function and can be overridden to @@ -446,24 +455,13 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) { wxAuiNotebookPage& page = m_pages.Item(i); - // determine if a close button is on this tab - bool close_button = false; - if ((m_flags & wxAUI_NB_CLOSE_ON_ALL_TABS) != 0 || - ((m_flags & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) != 0 && page.active)) - { - close_button = true; - } - - int x_extent = 0; wxSize size = m_art->GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, - close_button ? - wxAUI_BUTTON_STATE_NORMAL : - wxAUI_BUTTON_STATE_HIDDEN, + GetCloseButtonState(page), &x_extent); if (i+1 < page_count)