From 3de89b2710b6a1724323246067db9ba59fffef13 Mon Sep 17 00:00:00 2001 From: skruse Date: Sun, 24 Dec 2017 15:20:23 +0100 Subject: [PATCH] Fix auto-sizing multiline wxGrid column labels with empty lines Account for the empty lines explicitly by reserving enough vertical space for them, as wxDC::GetTextExtent() wouldn't do it as it simply returns 0 for empty strings. Closes #18028. --- src/generic/grid.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 64b2113ebf..ddc158258a 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6139,9 +6139,18 @@ void wxGrid::GetTextBoxSize( const wxDC& dc, size_t i; for ( i = 0; i < lines.GetCount(); i++ ) { - dc.GetTextExtent( lines[i], &lineW, &lineH ); - w = wxMax( w, lineW ); - h += lineH; + if ( lines[i].empty() ) + { + // GetTextExtent() would return 0 for empty lines, but we still + // need to account for their height. + h += dc.GetCharHeight(); + } + else + { + dc.GetTextExtent( lines[i], &lineW, &lineH ); + w = wxMax( w, lineW ); + h += lineH; + } } *width = w;