SWT Maximum Composite Size

I have a ScrolledComposite whose contents are truncated. I have Googled, and I know that this is a known issue in Windows.

The only recommended solution I can find is to use the canvas.scroll function .

Given the age of the problem, I was wondering if there is a more suitable solution?

Thank!

(EDIT: At the time of this writing, the link was: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java?view = markup & content-type = text% 2Fvnd.viewcvs-markup & revision = HEAD )

+5
source share
1 answer

(, , 400)

, , ScrolledComposite. , Composite, , , . , Resize :

, , , (getVerticalBar()). , Resize . ...

public void handleEvent(Event event)
{
    int newWidth = scrolledComposite.getSize().x;
    boolean hasScroll = false;
    ScrollBar scrollBar = scrolledComposite.getVerticalBar();
    if (scrollBar.isVisible())
    {
        hasScroll = true;
        newWidth -= scrolledComposite.getVerticalBar().getSize().x;
    }
    newWidth -= 8;
    Point size = contentComposite.computeSize(newWidth, SWT.DEFAULT);
    contentComposite.setSize(size);

    int scroll_multiplier = size.y / 50;
    scrollBar.setIncrement(scroll_multiplier);

    /**
     * If the scroll bar became visible because of the resize, then
     * we actually need to resize it again, because of the scroll
     * bar taking up some extra space.
     */
    if (scrollBar.isVisible() && !hasScroll)
    {
        scrolledComposite.notifyListeners(SWT.Resize, null);
    }
}

, !

: wow OP. , - ...

+3

All Articles