From f7e335c031e83874bf0ee64568ae72d5d0df73cf Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Mon, 30 Sep 2019 20:04:45 +0700 Subject: [PATCH] Fix recent regression in grid content autosizing Fix autosizing broken in 3c72396a3670326e6824d1605954920b351a76d2: we must add the extra margin to "extentMax". See https://github.com/wxWidgets/wxWidgets/pull/1559 Closes https://github.com/wxWidgets/wxWidgets/pull/1578 --- src/generic/grid.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index a7c5648aba..146d13689a 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -9378,11 +9378,16 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction) wxCoord w, h; dc.SetFont( GetLabelFont() ); + bool addMargin = true; + if ( column ) { if ( m_useNativeHeader ) { w = GetGridColHeader()->GetColumnTitleWidth(colOrRow); + + // GetColumnTitleWidth already adds margins internally. + addMargin = false; h = 0; } else @@ -9390,18 +9395,11 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction) dc.GetMultiLineTextExtent( GetColLabelValue(colOrRow), &w, &h ); if ( GetColLabelTextOrientation() == wxVERTICAL ) w = h; - - // leave some space around text - if ( w ) - w += 10; } } else { dc.GetMultiLineTextExtent( GetRowLabelValue(colOrRow), &w, &h ); - - if ( h ) - h += 6; } extent = column ? w : h; @@ -9414,6 +9412,14 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction) // than default extent but != 0, it's OK) extentMax = column ? m_defaultColWidth : m_defaultRowHeight; } + else if ( addMargin ) + { + // leave some space around text + if ( column ) + extentMax += 10; + else + extentMax += 6; + } if ( column ) {