SWT StyledText是否具有高度限制? [英] Does SWT StyledText have a height limit?

查看:198
本文介绍了SWT StyledText是否具有高度限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个包含ScrolledComposite中显示的StyledText框的应用程序。我在StyledText框中显示大量行数有困难(超过2,550个似乎导致问题)。

I am trying to create an application that contains a StyledText box displayed within a ScrolledComposite. I am having difficulties displaying a large number of lines in my StyledText box (over 2,550 seems to cause issues).

StyledText框本身不能有滚动条,但必须可以通过ScrolledComposite滚动。由于下面和上面的其他项目需要可滚动的StyledText,我不想要多个滚动条。

The StyledText box must not itself have a scroll bar but must be scrollable via the ScrolledComposite. As there are other items below and above the StyledText that need to be scrollable to and I do not want multiple scroll bars.

因此,大量的数据我有一个非常大(高度)StyledText框似乎在一定高度后停止。

Hence with large amounts of data I have a very large (as in height) StyledText box that seems to stop after a certain height.

问题是StyledText的内容应该是高的,而不是。下面的差距的原因是,包含的复合材料正在调整StyledText报告为高度的大小,但实际上并不是其高度。

The issue is that the StyledText should be as tall is its contents and it is not. The reason for the gap underneath is that the containing composite is resizing what StyledText reports to be its height but this is not in fact its height.

这是一个简化的示例代码来说明我的问题:

Here is a piece of simplified example code to illustrate my issue:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


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

        ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL);
        scrolledComposite.setLayout(new FillLayout(SWT.VERTICAL));

            Composite mainComp = new Composite(scrolledComposite, SWT.NONE);
        mainComp.setLayout(new FillLayout(SWT.VERTICAL));

        StyledText styledText = new StyledText(mainComp, SWT.NONE);
        styledText.getContent().setText(bigString());

        mainComp.setSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));

        scrolledComposite.setContent(mainComp);
        scrolledComposite.setMinSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        scrolledComposite.setExpandHorizontal(true);
        scrolledComposite.setExpandVertical(true);
        scrolledComposite.getVerticalBar().setIncrement(10);


        shell.setSize(400, 350);
        shell.open();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) {
                display.sleep ();
            }
        }
        display.dispose();

    }

    private static String bigString()
    {
        String big = "";

        for(int i=0;i<10000;i++)
        {
            big = big + "hello\r\n";
        }

        return big;
    }

}

更新:有趣的是, SWT标签和SWT文本

Update: Interestingly this problem occurs with SWT Label and SWT Text

推荐答案

这实际上是一个Windows限制。复合材料在窗口中可能只有一定大小,不超过32767(我假设为像素)。

This is actually a Windows limitation. Composites may only be of a certain size in windows, no more than 32767 (pixels, I assume).

这是找到scrolledComposite,因为它实际上不是> 32767,它似乎是。而mainComp的实际大小是> 32767,这是我们被截断的地方。

This is find for the scrolledComposite because it isn't actually > 32767, it just appears to be. Whereas with the mainComp the actual size is > 32767 and this is where we got cut off.

最初我以为这是一个Eclipse bug,并提交了一个报告,在那里我被告知这是一个Windows问题/功能: https://bugs.eclipse.org/ bug / show_bug.cgi?id = 333111

Initially I thought this was an Eclipse bug and filed a report where I was informed that this was a Windows issue/feature: https://bugs.eclipse.org/bugs/show_bug.cgi?id=333111

这篇关于SWT StyledText是否具有高度限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆