newbie query re wx.TextCtrl and scrollbar behaviour

background: I am implementing a report viewer using a multi-line TextCtrl
(if this is bad then please point me in the right direction! :-)). Turns out
that such an animal is limited to holding/displaying (something like) 32K
characters - but my report text can be much bigger than this, so presumably
I have to implement a "window" into the report text using a multi-line
TextCtrl and then manipulate its scrollbars to take me through the report
data i.e. I perform a SetScrollbar using arguments that indicate that the
TextCtrl is displaying (say) 16 lines but the scrollbar range is actually
5000 lines (even though the TextCtrl instance can only display 16 lines).

I have hooked to the wx.EVT_SCROLLWIN_THUMBTRACK event (using
wx.lib.evtmgr.eventManager) to be notified of movements of the scroll bar.
However, I have noticed that when the scroll bar is released by the mouse
(THUMBRELEASE) that it appears to being "resized" automatically to the
proportion of text actually in the TextCtrl rather than the range that I set
using the SetScrollbar method. This would appear (from a certain perspective
at least :-)) to be natural i.e. the TextCtrl instance is looking after
itself and adjusting the scroll bar for what it contains rather than what I
have told it to indicate to the user.

My question is: should I have to issue a new SetScrollbar call each time I
change the text in the "window" I have created to "restore" the original
scrollbar range or is this a "bug" and the TextCtrl instance shouldn't be
modifying the size of the scroll bar?

I guess this then (possibly) leads to the question: if this is "correct"
behaviour (which I suspect it is), is my best option to create a modified
TextCtrl and override the behaviour of the scrollbars? Or is there some
other way of achieving what I need to do?

Any help would be appreciated on this one :slight_smile:

Thanks
Peter

Peter Milliken
Software Engineer
ResMed
Phone: +61 2 9886-5059
Fax: +61 2 9878-5564

Warning: Copyright ResMed. Where the contents of this email and/or attachment includes materials prepared by ResMed, the use of those materials is subject exclusively to the conditions of engagement between ResMed and the intended recipient.

This communication is confidential and may contain legally privileged information. By the use of email over the Internet or other communication systems, ResMed is not waiving either confidentiality of, or legal privilege in,the content of the email and of any attachments.
If the recipient of this message is not the intended addressee, please call ResMed immediately on +61 2 9886 5000 Sydney, Australia.

Peter Milliken wrote:

background: I am implementing a report viewer using a multi-line TextCtrl
(if this is bad then please point me in the right direction! :-)). Turns out
that such an animal is limited to holding/displaying (something like) 32K
characters -

This is a limitation of the default native control used on MSW. To switch to a different native control that can (in theory) have 4G characters use the wxTE_RICH2 style.

but my report text can be much bigger than this, so presumably
I have to implement a "window" into the report text using a multi-line
TextCtrl and then manipulate its scrollbars to take me through the report
data i.e. I perform a SetScrollbar using arguments that indicate that the
TextCtrl is displaying (say) 16 lines but the scrollbar range is actually
5000 lines (even though the TextCtrl instance can only display 16 lines).

I have hooked to the wx.EVT_SCROLLWIN_THUMBTRACK event (using
wx.lib.evtmgr.eventManager) to be notified of movements of the scroll bar.
However, I have noticed that when the scroll bar is released by the mouse
(THUMBRELEASE) that it appears to being "resized" automatically to the
proportion of text actually in the TextCtrl rather than the range that I set
using the SetScrollbar method. This would appear (from a certain perspective
at least :-)) to be natural i.e. the TextCtrl instance is looking after
itself and adjusting the scroll bar for what it contains rather than what I
have told it to indicate to the user.

As you've discovered you really can't use the native widgets in ways that they were not designed to be used. Each of them has quirks that vary on different platforms and versions and wxWindows can't pound all of them into the wxWindow shape all the time.

If you just need this for read-only use then probably the best way to do what you want is to derive a class from wxScrolledWindow and draw the text yourself. Another possibility is to use a virtual wxListCtrl with just a single column.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!