Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] Allow TVS_NOSCROLL to be set for a Tree


The following wad hides the scroll bar of the tree.  Might be helpful.  When you run it, it looks like there is a bug in tree scrolling.

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;

public class Test {
public static void main (String [] args) {
        Display display = new Display ();
        Shell shell = new Shell (display);
        shell.setLayout (new FillLayout ());

        final Composite composite = new Composite (shell, SWT.V_SCROLL);
        final Tree tree = new Tree (composite, SWT.BORDER | SWT.SINGLE);
        for (int i=0; i< 12; i++) {
                TreeItem item0 = new TreeItem (tree, SWT.NONE);
                item0.setText ("Item " + i);
                for (int j=0; j<12; j++) {
                        TreeItem item1 = new TreeItem (item0, SWT.NONE);
                        item1.setText ("Item " + j);
                }
        }
        composite.addListener (SWT.Resize, new Listener () {
                public void handleEvent (Event event) {
                        Rectangle rect = composite.getClientArea ();
                        tree.setBounds (tree.computeTrim (0, 0, rect.width, rect.height));
                }
        });
       
        shell.pack ();
        shell.open ();
        while (!shell.isDisposed ()) {
                if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
}
}



"Olivier Modica" <omodica@xxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

06/16/2003 07:13 PM
Please respond to platform-swt-dev

       
        To:        <platform-swt-dev@xxxxxxxxxxx>
        cc:        
        Subject:        RE: [platform-swt-dev] Allow TVS_NOSCROLL to be set for a Tree



Thanks for your comments Steve.

>The comment from the code refers to the fact that when no scroll
>bars are specified and more items than are visible are added to
>the tree, then using the arrow keys to move around the items will
>not scroll to show the selection (at least it did not at the time
>the comment was written).
Actually after implementing additional tests, it does appear that
with TVS_NOSCROLL or without TVS_NOSCROLL set the scrollbars will
appear for the tree widget, although arrow keys may not scroll the
tree (it will if the tree is added to ScrolledComposite/method1).
So it appears I'm out of luck here.

>Why is the native scrolling insufficient?
I'm evaluating porting a tool (from Swing) that requires trees
to have a specific layout, specifically with a scrollbar on the left
side while displaying left-to-right text.
Since setting the orientation to right-to-left will mirror both the
text and the scrollbar, it still wouldn't answer my requirement.

I decided to go with an approach that uses a ScrolledComposite that
wraps the tree, the ScrolledComposite does take care of selection
and resizing.
This does work, however I have cases where the tree will display its
scrollbars until the code intercepts the change and adjust the
ScrolledComposite (usually milliseconds).

I understand the TVS_NOSCROLL set would be unsupported, however I
couldn't find a way to either set the tree provided scrollbars
invisible,
or to adjust the right-to-left settings so only the text, not the
scrollbars, is mirrored.

Are there any ways to achieve this using the SWT API, would it be
outside of the SWT scope or planned for a later release?

Best regards,
Olivier Modica.

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top