From 6ed0443d2f515587d0c75f2237840c18daf4a18f Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Tue, 1 Oct 2019 12:31:01 +0700 Subject: [PATCH] Fix wxGrid::SetColSize for the native header In case of the width of -1 for the native header the title width must be calculated by the native header itself. --- src/generic/grid.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 146d13689a..06462eeb2e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -9128,16 +9128,23 @@ void wxGrid::SetColSize( int col, int width ) // show the column back using its old size. if ( width == -1 && GetColWidth(col) != 0 ) { - long w, h; - wxArrayString lines; - wxClientDC dc(m_colLabelWin); - dc.SetFont(GetLabelFont()); - StringToLines(GetColLabelValue(col), lines); - if ( GetColLabelTextOrientation() == wxHORIZONTAL ) - GetTextBoxSize( dc, lines, &w, &h ); + if ( m_useNativeHeader ) + { + width = GetGridColHeader()->GetColumnTitleWidth(col); + } else - GetTextBoxSize( dc, lines, &h, &w ); - width = w + 6; + { + long w, h; + wxArrayString lines; + wxClientDC dc(m_colLabelWin); + dc.SetFont(GetLabelFont()); + StringToLines(GetColLabelValue(col), lines); + if ( GetColLabelTextOrientation() == wxHORIZONTAL ) + GetTextBoxSize( dc, lines, &w, &h ); + else + GetTextBoxSize( dc, lines, &h, &w ); + width = w + 6; + } // Check that it is not less than the minimal width and do use the // possibly greater than minimal-acceptable-width minimal-width itself