From 725c3d5608f6e1f81ee70e3efdd553b60d476e82 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 7 Nov 2021 16:06:55 +0000 Subject: [PATCH] Update images when DPI changes in wxBookCtrlBase-derived classes Just pretend that the images themselves have changed, this should be enough to recreate wxImageList from the bundle using the new scale factor in UpdateImageListIfNecessary(). --- include/wx/bookctrl.h | 4 ++++ src/common/bookctrl.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index f77f277ca6..1fc4d0edd6 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -360,6 +360,10 @@ private: // common part of all ctors void Init(); + // update the images if we use them on DPI change + void WXHandleDPIChanged(wxDPIChangedEvent& event); + + // internal border unsigned int m_internalBorder; diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index fe09f7e031..52cc3f4333 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -41,6 +41,8 @@ wxBEGIN_EVENT_TABLE(wxBookCtrlBase, wxControl) #if wxUSE_HELP EVT_HELP(wxID_ANY, wxBookCtrlBase::OnHelp) #endif // wxUSE_HELP + + EVT_DPI_CHANGED(wxBookCtrlBase::WXHandleDPIChanged) wxEND_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -291,6 +293,16 @@ wxSize wxBookCtrlBase::GetControllerSize() const // miscellaneous stuff // ---------------------------------------------------------------------------- +void wxBookCtrlBase::WXHandleDPIChanged(wxDPIChangedEvent& event) +{ + if ( HasImages() ) + { + OnImagesChanged(); + } + + event.Skip(); +} + #if wxUSE_HELP void wxBookCtrlBase::OnHelp(wxHelpEvent& event)