SWT Composite最大尺寸

Cra*_*aig 5 size swt composite scrolledcomposite

我有一个ScrolledComposite,其内容被截断.我用谷歌搜索,并意识到它是Windows上的一个已知问题.

我能找到的唯一建议的解决方法是使用canvas.scroll功能.

鉴于问题的年龄,我想知道是否有更好的解决方法?

谢谢!

(编辑:在撰写本文时,链接是: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)

Dyl*_*lan 3

(您发布的链接出现了 400 错误)

不确定我的问题是否相同,但我也遇到了 ScrolledComposite 的截断问题。问题是,当我调整要滚动的 Composite 的大小并且滚动条变得可见时,控件没有考虑滚动条占用的空间。为了解决这个问题,我在滚动复合材料上的调整大小侦听器中添加了一种递归代码:

设置内容组合的大小后,检查scrolledComposite 的滚动条(例如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);
    }
}
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!

编辑:哇我没有注意到OP的日期。希望这最终能以任何方式帮助某人......