Home » Eclipse Projects » Standard Widget Toolkit (SWT) » why StyledText's hight is not correct in SWT3.0
why StyledText's hight is not correct in SWT3.0 [message #445476] |
Sat, 06 November 2004 03:17  |
Eclipse User |
|
|
|
Hi!
My StyledText work perfictly in SWT2.0, if the text is too long, it show
in multi lines. bug the same code in SWT3.0 it is always show in single
line, even if the text is long enough to be wrapped. I used SWT.MULTI
flag, and grid lay out.
I found that the computeSize() in 3.0 always return the same hight, how
can i resove it?
thank you!
roger
|
|
| | | |
Re: why StyledText's hight is not correct in SWT3.0 [message #445882 is a reply to message #445476] |
Thu, 11 November 2004 11:47  |
Eclipse User |
|
|
|
You need to add the line:
gridData.grabExcessHorizontalSpace = true;
This will enable wrapping.
The old StyledText.computeSize code was actually quite wrong because it
based the height it returned on its current width and not on the width
passed in as the wHint argument. Therefore if you changed the width by only
a small amount, it seemed to give the right answer but if you changed the
width by a large amount, you got quite a wrong answer.
My tests show that StyledText.computeSize returns the correct result based
on the width passed in as the wHint.
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
StyledText st = new StyledText(shell, SWT.WRAP);
st.setText("aaaaabbbbbcccccdddddeeeeeaaaaabbbbbcccccdddddeeeee ");
System.out.println("100, SWT.DEFAULT "+st.computeSize(100,
SWT.DEFAULT));
System.out.println("50, SWT.DEFAULT "+st.computeSize(50,
SWT.DEFAULT));
System.out.println("300, SWT.DEFAULT "+st.computeSize(300,
SWT.DEFAULT));
System.out.println("SWT.DEFAULT, SWT.DEFAULT
"+st.computeSize(SWT.DEFAULT, SWT.DEFAULT));
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
"Roger" <yuanq@necas.nec.com.cn> wrote in message
news:cmi1ao$d1e$1@eclipse.org...
> Hi!
> My StyledText work perfictly in SWT2.0, if the text is too long, it show
> in multi lines. bug the same code in SWT3.0 it is always show in single
> line, even if the text is long enough to be wrapped. I used SWT.MULTI
> flag, and grid lay out.
> I found that the computeSize() in 3.0 always return the same hight, how
> can i resove it?
> thank you!
> roger
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 13:41:35 EDT 2025
Powered by FUDForum. Page generated in 0.40489 seconds
|