Hello,
I am having a weird difficulty with StaticText and BoxSizer.
I'm creating a dialog with a vertical sizer. The first, topmost item
in the sizer is a StaticText with a paragraph of text, and below
that there's a bunch of other widgets, doesn't matter which. (At the
bottom there are the buttons, of course.)
Now, since the text is a full paragraph and not just one line, it
needs to wrap to several lines. And the sizer needs to take into
account the height that the StaticText will require because of this
wrapping, so no text will be hidden.
How do I do this? I tried and haven't been successful.
Is the text already wrapped (with \n's inserted in the text) or do you
do something like calling staticText.Wrap(width)? If so then the best
size calculation should include enough vertical space to show all the
lines. If you are relying on the static text to automatically wrap to
the available width, don't. First, not all platforms do that. Second,
the best size calculation has no idea how it will be auto-wrapped and so
it can't provide an accurate size for the sizer.
In a later message, cool-RR wrote:
But how can I know the width number? I want it to fit inside the
parent dialog, but that might have an unknown size.
And there's the paradox... Something I've done in the past is to catch
the parent's EVT_SIZE, Freeze() the parent, reset the label on the
static text to the unwrapped version of the text, call Wrap again with
the new width, call Thaw(), and call evt.Skip() so the default handler
will still do the layout as normal.
···
On 11/10/10 8:24 AM, cool-RR wrote:
--
Robin Dunn
Software Craftsman