From e211a451fedd540d382fda9f7324c8ff5328b0d8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 12 Dec 2021 23:16:28 +0000 Subject: [PATCH] Re-realize wxAuiToolBar on DPI change to fix its layout The layout of the toolbar depends on the size of its bitmaps, which changes when the DPI does, so call Realize() again when this happens. This fixes the layout of the toolbars in the aui sample when moving it between screens using different DPI. --- include/wx/aui/auibar.h | 1 + src/aui/auibar.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/wx/aui/auibar.h b/include/wx/aui/auibar.h index 434ed8fc8f..c8abbcebd6 100644 --- a/include/wx/aui/auibar.h +++ b/include/wx/aui/auibar.h @@ -642,6 +642,7 @@ protected: // handlers void OnSize(wxSizeEvent& evt); void OnIdle(wxIdleEvent& evt); + void OnDPIChanged(wxDPIChangedEvent& evt); void OnPaint(wxPaintEvent& evt); void OnEraseBackground(wxEraseEvent& evt); void OnLeftDown(wxMouseEvent& evt); diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index 66a7073396..3705d8b776 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -825,6 +825,7 @@ static wxOrientation GetOrientation(long style) wxBEGIN_EVENT_TABLE(wxAuiToolBar, wxControl) EVT_SIZE(wxAuiToolBar::OnSize) EVT_IDLE(wxAuiToolBar::OnIdle) + EVT_DPI_CHANGED(wxAuiToolBar::OnDPIChanged) EVT_ERASE_BACKGROUND(wxAuiToolBar::OnEraseBackground) EVT_PAINT(wxAuiToolBar::OnPaint) EVT_LEFT_DOWN(wxAuiToolBar::OnLeftDown) @@ -2383,6 +2384,11 @@ void wxAuiToolBar::OnIdle(wxIdleEvent& evt) evt.Skip(); } +void wxAuiToolBar::OnDPIChanged(wxDPIChangedEvent& WXUNUSED(event)) +{ + Realize(); +} + void wxAuiToolBar::UpdateWindowUI(long flags) { if ( flags & wxUPDATE_UI_FROMIDLE )