[wxPython-users] TextCtrl Scrollbar detection
Robin Dunn
robin at alldunn.com
Sat May 19 22:29:39 PDT 2007
Bob Robison wrote:
> I have a multi-line TextCtrl, that I am writing some fixed-width font
> data into. I want to calculate the number of characters in each line
> in EVT_SIZE handler. (yes, I've asked about this before) I was
> directed to use GetSize and divide by GetCharWidth to figure this
> out. This works OK, but I'm having an issue with fudge factors....
>
>
> First off, the GetCharWidth is returning 8, but a new char is
> appearing (on each line) only after increasing the size of the window
> (horizontally) by 10. Is there a one pixel space on each side?
It's possible. It's also possible that this can also vary by platform
or even style options.
>
> Also, the useable space in the window is sometimes encroached upon by
> a scrollbar --- however, when I call the HasScrollbar() method of the
> text control, it is always returning 0, whether the scrollbar is
> visible or not.... Any advice here?
That is only for the scrollbars provided by wxWidgets. The TextCtrl's
scrollbar is provided by the native widget. We don't have access to it
or any way to detect it.
> I am fine to force the
> scrollbar to be there all the time, but I couldn't find the proper
> way to do that either.
>
That depends on platform and other styles being used. On Windows XP you
should get an inactive (until it is needed) scrollbar by default for
multi-line controls. But if you used the wx.TE_RICH style that can
change things. Try wx.TE_RICH2 instead.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list