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.
This commit is contained in:
skruse
2017-12-24 15:20:23 +01:00
committed by Vadim Zeitlin
parent 4f7fb24ef4
commit 3de89b2710

View File

@@ -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;