From 8ac0543a5ec3f5abf12618312459d0e7fa0d5ed2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 17 Jan 2023 13:24:49 +0000 Subject: [PATCH] Try a bigger hammer to keep wxFormBuilder from messing up grid fonts. Fixes https://gitlab.com/kicad/code/kicad/issues/13547 --- common/widgets/wx_grid.cpp | 17 ++++++++++++++++- include/widgets/wx_grid.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index 35e21f5d6b..e6a0684b19 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -103,6 +103,7 @@ WX_GRID::WX_GRID( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxS // Make sure the GUI font scales properly SetDefaultCellFont( KIUI::GetControlFont( this ) ); + SetLabelFont( KIUI::GetControlFont( this ) ); if( GetColLabelSize() > 0 ) SetColLabelSize( GetColLabelSize() + 4 ); @@ -191,6 +192,20 @@ void WX_GRID::SetTable( wxGridTableBase* aTable, bool aTakeOwnership ) } +bool WX_GRID::Show( bool aShow ) +{ + // Don't let wxFormBuilder override the fonts. It's always the wrong answer as it will set + // a fixed-size, non-scaling, non-HiDPI-aware font. + if( aShow ) + { + SetDefaultCellFont( KIUI::GetControlFont( this ) ); + SetLabelFont( KIUI::GetControlFont( this ) ); + } + + return wxGrid::Show( aShow ); +} + + void WX_GRID::onGridCellSelect( wxGridEvent& aEvent ) { // Highlight the selected cell. diff --git a/include/widgets/wx_grid.h b/include/widgets/wx_grid.h index cd062d95da..a577b0966c 100644 --- a/include/widgets/wx_grid.h +++ b/include/widgets/wx_grid.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -136,6 +136,8 @@ public: DeleteRows( 0, GetNumberRows() ); } + bool Show( bool aShow ) override; + protected: /** * A re-implementation of wxGrid::DrawColLabel which left-aligns the first column and draws