From 9463415998435b4116e5797810e80558feecd727 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 1 Apr 2020 22:39:45 +0200 Subject: [PATCH] Fix check mark size in wxGrid after DPI change Moving wxGrid window to a monitor with different DPI now correctly changes the check mark size as expected. --- src/generic/gridctrl.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/generic/gridctrl.cpp b/src/generic/gridctrl.cpp index 96d13b9f15..baf5937796 100644 --- a/src/generic/gridctrl.cpp +++ b/src/generic/gridctrl.cpp @@ -32,6 +32,7 @@ #include "wx/renderer.h" #include "wx/generic/private/grid.h" +#include "wx/private/window.h" // ---------------------------------------------------------------------------- // wxGridCellRenderer @@ -926,16 +927,19 @@ wxSize wxGridCellBoolRenderer::GetBestSize(wxGrid& grid, int WXUNUSED(row), int WXUNUSED(col)) { - static wxSize s_sizeCheckMark; + static wxPrivate::DpiDependentValue s_sizeCheckMark; - // compute it only once (no locks for MT safeness in GUI thread...) - if ( !s_sizeCheckMark.x ) + // Get the check mark size in pixels if it hadn't been done yet or if the + // DPI has changed. + if ( s_sizeCheckMark.HasChanged(&grid) ) { - s_sizeCheckMark = - wxRendererNative::Get().GetCheckBoxSize(&grid, wxCONTROL_CELL); + s_sizeCheckMark.SetAtNewDPI + ( + wxRendererNative::Get().GetCheckBoxSize(&grid, wxCONTROL_CELL) + ); } - return s_sizeCheckMark; + return s_sizeCheckMark.Get(); } void wxGridCellBoolRenderer::Draw(wxGrid& grid,