GTK3 / wxStaticText size

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

GTK3 / wxStaticText size

Post by stefan__o » Fri Oct 04, 2019 8:11 pm

Hello,

my application uses a lot of wxStaticText with custom fonts. All works fine in Windows, macOS and GTK2. Unfortunately in GTK3 all the wxStaticText are to small (text doesn't fit) and the problem is immediately resolved after resizing the main window. It can also be fixed by calling Layout() on the window at a later point (calling Layout() directly at the end of the function that creates all the wxStaticText does not make a difference).

A lot of people seemed to have similar issues and there was a bug related to that in wxWidgets that was fixed in 2016. I first used wxWidgets 3.0.4 (the one that comes with Ubuntu 18.04 LTS) but I figures out that the fix was not ported back to the 3.0 series. So I downloaded/build/installed wxWidgets 3.1.2 and compiled against that version: No difference

Any advice how to resolve that issue? I tried calling Layout and Refresh each and everywhere but nothing changes. I'm using the default GTK 3.22 that comes with Ubuntu 18.04 LTS

Best regards
Stefan

stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: GTK3 / wxStaticText size

Post by stefan__o » Sat Oct 05, 2019 12:19 pm

I did some further testing: The patch was later replaced by a much simpler solution according to the git logs.
I tried the last version with the original patch (9bb5d0435a4cce5bcb7b3956cb730f59c37ea5f6): problem is different: Sizes are still wrong, but text is not cut off, but painted over the borders.
Again, one simple resize of the window fixes everything. Any ideas?

DavidHart
Site Admin
Site Admin
Posts: 3896
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: GTK3 / wxStaticText size

Post by DavidHart » Sat Oct 05, 2019 1:03 pm

Hi,

As you say, this sounds very similar to https://trac.wxwidgets.org/ticket/17585. Did you test using the 'minimal' patch from comment 3?
I'm using the default GTK 3.22 that comes with Ubuntu 18.04 LTS
With which DE, and on X11 or Wayland?
but I figures out that the fix was not ported back to the 3.0 series.
It was, and would have been in wx3.0.4.
So I downloaded/build/installed wxWidgets 3.1.2
wx3.1.2 was released last December. There have been lots of commits since, so you need to test using wx3.1.3, git HEAD.

Failing that, your idea of calling Layout() is correct; if a resize works, so should a Layout(). Make sure you call it on the correct 'top-level' window though: if the parent of your statictexts is e.g. a wxPanel, do pPanel->Layout(). If that fails too, possible workarounds are to call Layout() after a delay from e.g. CallAfter(); or try wxWindow::PostSizeEvent. However these are all things that I tried for https://trac.wxwidgets.org/ticket/17585 so they probably won't work for you either :( .

Finally, if you can reproduce the failing behaviour with that comment 3 patch built against git HEAD, you should report this on wxTrac.

Regards,

David

stefan__o
Knows some wx things
Knows some wx things
Posts: 32
Joined: Mon Aug 04, 2014 12:55 am

Re: GTK3 / wxStaticText size

Post by stefan__o » Sat Oct 05, 2019 5:37 pm

With which DE, and on X11 or Wayland?
Cinnamon, X11
It was, and would have been in wx3.0.4.
The original patch was replaced, 3.0.4 already has the later version, that's why I thought it was not in there.

CallAfter does the trick, this add the end of the function that creates the static texts does not work:

Code: Select all

panel->Layout();
Layout();
But this does work:

Code: Select all

CallAfter([&] { panel->Layout(); Layout(); });

Post Reply