Compute wxStaticText best size ourselves if GTK does it wrongly

GTK doesn't take into account changes to the font of a hidden
wxStaticText and returns wrong preferred (i.e. best) size for it which
still uses the old font in this case, which results in all sorts of
problems when this wrong best size is used for the layout.

Work around it by computing the best size ourselves in this case using
the correct font. This seems to return exactly the same results as GTK
returns as long as the font is not changed, but also works correctly
when it is.

This commit is best viewed ignoring whitespace-only changes.

See #16088.
This commit is contained in:
Vadim Zeitlin
2024-08-24 15:39:29 +02:00
parent 7e14fda22c
commit e6500a4e31
2 changed files with 67 additions and 22 deletions
+3
View File
@@ -61,6 +61,9 @@ private:
void GTKDoSetLabel(GTKLabelSetter setter, const wxString& label);
// If our font has been changed, we compute the best size ourselves because
// GTK doesn't always do it correctly, see DoGetBestSize().
bool m_computeOurOwnBestSize = false;
wxDECLARE_DYNAMIC_CLASS(wxStaticText);
};