Vadim Zeitlin
unread,Sep 1, 2025, 8:58:17 AM (6 days ago) Sep 1Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wx-...@googlegroups.com
On Mon, 1 Sep 2025 12:51:45 +0200 'Robert Roebling' via wx-dev wrote:
RR> I remember there have been discussions about line wrapping in the
RR> past, but I was just surprised that when I put a long wxStaticText
RR> into a wxBoxSizer( wxVERTICAL ), the text would not wrap and go past
RR> the window bounds. I then tried to call wxStaticText::Wrap() after
RR> every change of window size, but that seems to not work under GTK+ 3
RR> either, the text gets wrapped after every word over time (this is
RR> likely an unrelated bug).
Using Wrap() manually from wxEVT_SIZE handler does work for me (or at
least did when I tested it when I wrote this code...). One thing to note is
that you need to use wxST_NO_AUTORESIZE when using Wrap().
Of course, if we could make this work automatically, it would be much
better but I remember that this didn't seem especially simple to do when I
last looked at it...
RR> Looking at the GTK+ code of wxStaticText (to start with), in
RR> DoGetBestSize(), line wrapping is explicitly shut off and the control
RR> is supposed to return the unwrapped single line dimensions.
I think this is the only correct way to implement GetBestSize() semantics.
RR> I will look at why this actually works in wxWrapSizer (how does it
RR> know its horizontal constraints during DoGetBestSize()?), but maybe we
RR> need a DoGetBestSizeIfWidthIsLimitedTo(int width) which always just
RR> calls DoGetBestSize(), apart from wxStaticText where it would
RR> calculate the new height given fixed width.
We already have GetBest{Width,Height}() but they are only used by
wxBookCtrlBase currently and not for the generic layout.
Good luck,
VZ