From 8957008c2a3262ee5ea16e7e303d474e5bb2cbe5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 23 Aug 2018 11:59:37 +0100 Subject: [PATCH] Adjust grid cols for large fonts and/or long translations. Fixes: lp:1788495 * https://bugs.launchpad.net/kicad/+bug/1788495 --- common/widgets/wx_grid.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/widgets/wx_grid.cpp b/common/widgets/wx_grid.cpp index dc63d91660..5868cbb6be 100644 --- a/common/widgets/wx_grid.cpp +++ b/common/widgets/wx_grid.cpp @@ -26,6 +26,9 @@ #include "wx_grid.h" +#define MIN_GRIDCELL_MARGIN 3 + + void WX_GRID::SetTable( wxGridTableBase* aTable ) { // wxGrid::SetTable() messes up the column widths from wxFormBuilder so we have to save @@ -38,7 +41,12 @@ void WX_GRID::SetTable( wxGridTableBase* aTable ) wxGrid::SetTable( aTable ); for( int i = 0; i < GetNumberCols(); ++i ) - SetColSize( i, formBuilderColWidths[ i ] ); + { + // correct wxFormBuilder width for large fonts and/or long translations + int headingWidth = GetTextExtent( GetColLabelValue( i ) ).x + 2 * MIN_GRIDCELL_MARGIN; + + SetColSize( i, std::max( formBuilderColWidths[ i ], headingWidth ) ); + } delete[] formBuilderColWidths; }