Not-scrolling wxRichTextCtrl

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Not-scrolling wxRichTextCtrl

Marvin Gülker
Hi everyone,

I am trying to figure out how I can make a wxRichTextCtrl that doesn't
scroll, but instead requests more size from the containing sizer. The
widget is set to read-only and it gets text inserted based on user input
received over the network.

It is possible to use SetMinSize() as with any other widget to have it
request more size, but that leaves me with the problem of how to
calculate the size required. GetVirtualSize(), which I would have
expected to return the extends of the scrollable area inside the
wxRichTextCtrl, only returns the size of the wxRichTextCtrl itself

I have already tried hacky things like drawing the text I want to insert
on a DC first and then measuring the extent it covers[1] (using the
result as input for SetMinSize()), but that only roughly works when
there are newlines in the text. If there are no newlines,
i.e. wxRichTextCtrl needs to do linebreaking itself, I am unable to even
remotely determine the size the display of the entire text may require
since there appearently is no way to find out how many characters fit in
a line (which would be difficult with non-monospaced fonts
anyway). Finally, once more complex markup is involved, this approach
is going to fail anyway since it would require me to effectively
reimplement wxRichTextCtrl.

So, how do I either tell wxRichTextCtrl to not scroll, but enlarge, or
how do I precalculate the size it would require? Actually, I'm only
interested in the height it would need, but I guess the question is more

WX      : 3.0.2
OS      : Gentoo Linux, 64 bit (wxGTK2)


[1]: Courtesy of this SO post:


Please read before posting.

To unsubscribe, send email to [hidden email]
or visit