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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user