首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SWT复合材料最大尺寸

SWT复合材料最大尺寸
EN

Stack Overflow用户
提问于 2010-09-27 13:49:40
回答 1查看 4.2K关注 0票数 5

我有一个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)

EN

回答 1

Stack Overflow用户

发布于 2011-02-22 17:18:21

(您发布的链接给出了一个400错误)

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

在设置了内容组合的大小之后,请检查scrolled复合材料的滚动条(例如getVerticalBar())是否刚刚变得可见。如果是,请向侦听器发送新的调整大小事件。这是我的代码片段..。

代码语言:javascript
复制
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);
    }
}

希望这能有所帮助!

编辑:,哇,我没有注意到OP的日期。希望这最终能帮到别人.

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3804433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档