From baa2ea0273d9dd629fe27f18116bb2ae225c57e2 Mon Sep 17 00:00:00 2001 From: Kumazuma Date: Thu, 30 Mar 2023 09:19:36 +0900 Subject: [PATCH] Fix AUI tab close button size after DPI change in wxMSW Reset close button size on DPI change to ensure that its size is recomputed correctly using the new DPI when the tab is redrawn the next time. Closes #23400. --- include/wx/aui/auibook.h | 1 + include/wx/aui/tabart.h | 1 + include/wx/aui/tabartmsw.h | 2 ++ src/aui/auibook.cpp | 7 +++++++ src/aui/tabartmsw.cpp | 4 ++++ 5 files changed, 15 insertions(+) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 29e0cf3a74..02af6173ee 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -223,6 +223,7 @@ protected: void OnChar(wxKeyEvent& event); void OnCaptureLost(wxMouseCaptureLostEvent& evt); void OnSysColourChanged(wxSysColourChangedEvent& event); + void OnDpiChanged(wxDPIChangedEvent& event); protected: diff --git a/include/wx/aui/tabart.h b/include/wx/aui/tabart.h index e37638a25c..068b97200a 100644 --- a/include/wx/aui/tabart.h +++ b/include/wx/aui/tabart.h @@ -113,6 +113,7 @@ public: // Provide opportunity for subclasses to recalculate colours virtual void UpdateColoursFromSystem() {} + virtual void UpdateDpi() {} }; diff --git a/include/wx/aui/tabartmsw.h b/include/wx/aui/tabartmsw.h index 8a6b15ba11..132d87e558 100644 --- a/include/wx/aui/tabartmsw.h +++ b/include/wx/aui/tabartmsw.h @@ -74,6 +74,8 @@ public: const wxAuiNotebookPageArray& pages, const wxSize& requiredBmpSize) override; + void UpdateDpi() override; + private: bool m_themed; wxSize m_closeBtnSize; diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 25051b8e79..f355542892 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -1003,6 +1003,7 @@ wxBEGIN_EVENT_TABLE(wxAuiTabCtrl, wxControl) EVT_CHAR(wxAuiTabCtrl::OnChar) EVT_MOUSE_CAPTURE_LOST(wxAuiTabCtrl::OnCaptureLost) EVT_SYS_COLOUR_CHANGED(wxAuiTabCtrl::OnSysColourChanged) + EVT_DPI_CHANGED(wxAuiTabCtrl::OnDpiChanged) wxEND_EVENT_TABLE() @@ -1505,6 +1506,12 @@ void wxAuiTabCtrl::OnChar(wxKeyEvent& event) event.Skip(); } +void wxAuiTabCtrl::OnDpiChanged(wxDPIChangedEvent& event) +{ + m_art->UpdateDpi(); + event.Skip(); +} + // wxTabFrame is an interesting case. It's important that all child pages // of the multi-notebook control are all actually children of that control // (and not grandchildren). wxTabFrame facilitates this. There is one diff --git a/src/aui/tabartmsw.cpp b/src/aui/tabartmsw.cpp index 4c8f27a5d7..f56b8d1593 100644 --- a/src/aui/tabartmsw.cpp +++ b/src/aui/tabartmsw.cpp @@ -458,5 +458,9 @@ bool wxAuiMSWTabArt::IsThemed() const !(m_flags & wxAUI_NB_BOTTOM); // Native theme does not support bottom tabs } +void wxAuiMSWTabArt::UpdateDpi() +{ + m_closeBtnSize = wxDefaultSize; +} #endif // wxUSE_AUI && wxUSE_UXTHEME && !defined(__WXUNIVERSAL__)