Bug 118164 - [StyledText] Ability to disable scrolling
Summary: [StyledText] Ability to disable scrolling
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2005-11-27 16:42 EST by Florian Priester CLA
Modified: 2017-07-28 11:29 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Priester CLA 2005-11-27 16:42:50 EST
SWT N20051127-0010

In my application I use StyledTexts (SWT.MULTI | SWT.WRAP) whose size
is set dynamically to always fit the text contained in the widget.
In other words, if text is set or entered for which there is not enough
room, the bounds of the StyledText will be changed to make it bigger.
Scrolling, if needed, happens at the level of the parent composite
(a kind of scrolled composite), moving the StyledText itself along with
other controls.

In order for this scenario to work, it is important that the StyledText
never attempt to scroll "inside itself" like it does when used as a
regular editor. Instead, the top/horizontal pixel must always be (0,0).

To achieve this, I found that in previous versions of StyledText
it was sufficient to create a subclass that overrode the method
Canvas#scroll and set it to do nothing. Due to the recent rewrite
of StyledText.java, this no longer works. After some failed attempts
to solve the problem by calling setTopPixel(0) and setRedraw(false/true)
in the right places, I'm currently using a subclass that also overrides
StyledText#scrollVertical as a new workaround.

This approach has a few problems:
  - As before, StyledText needs to be subclassed, something which
    is discouraged and which I would rather avoid
  - Since scrollVertical is package-private, I can only override it
    by moving my subclass into the org.eclipse.swt.custom package
    where it does not really belong because it is not part of SWT
  - Most importantly, the workaround relies on internal details
    that may change at any time. The method scrollVertical might be
    renamed or made private, and code that invokes scrolling could
    also appear in other methods anywhere in the StyledText

For this reason it would be extremely helpful if the StyledText widget
directly supported a static, non-scrolling mode. In Swing terms, the
behaviour would be like that of a JEditorPane that has not been put
inside a JViewport/JScrollPane.

The desired option could be controlled by a simple parameter, perhaps
something like setScrollable(boolean). If set to false, this would
prevent the StyledText from ever changing the viewport origin
(that is, the top/horizontal pixel) or calling Canvas#scroll.

Thanks in advance for considering this request. (And also thanks for
continuing to improve StyledText, as in bug 83405!)
Comment 1 Steve Northover CLA 2005-12-07 16:26:51 EST
FH won't be able to look into this until well after M4.
Comment 2 Florian Priester CLA 2006-02-13 03:58:29 EST
Since this report was filed, the StyledText instances in the code
I am working on have been replaced with a specialized editor widget.
As this removes the original need for additional StyledText API as
described above, I no longer uphold this enhancement request.

If you feel that there may be other developers for whom an option to
switch off StyledText's integrated viewport would be useful, you might
want to keep this bug open, otherwise please feel free to close it.
Comment 3 Felipe Heidrich CLA 2009-08-19 16:00:26 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.