From 4f6ddcf511e65ce4ee765ddcccbd6c29f69f238d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 4 Feb 2023 13:58:02 +0100 Subject: [PATCH] Hard code text control margins for GTK 2 Using GTKGetPreferredSize() doesn't always seem to return the correct values, resulting in making the control too big, so just hard code the smaller margins there. --- src/gtk/textctrl.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 861645ae8f..f65cfd6216 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -2150,8 +2150,16 @@ wxSize wxTextCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const { // default height tsize.y = GTKGetPreferredSize(m_widget).y; +#ifdef __WXGTK3__ // Add the margins we have previously set. tsize.IncBy( GTKGetEntryMargins(GetEntry()) ); +#else + // For GTK 2 these margins are too big, so hard code something more + // reasonable, this is not great but should be fine considering + // that it's very unlikely that GTK 2 is going to evolve, making + // this inappropriate. + tsize.IncBy(20, 0); +#endif } }