Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 08:17 Go to next message
Roger is currently offline RogerFriend
Messages: 9
Registered: July 2009
Junior Member
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 #445699 is a reply to message #445476] Tue, 09 November 2004 19:49 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Roger,

Please log a bug report with Platform - SWT, and provide a small snippet
that shows the problem, thanks.

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/faq.html#whatisasnippet

Grant

"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&#65281;
> roger
>
Re: why StyledText's hight is not correct in SWT3.0 [message #445737 is a reply to message #445476] Wed, 10 November 2004 09:05 Go to previous messageGo to next message
Henning Rogge is currently offline Henning RoggeFriend
Messages: 148
Registered: July 2009
Senior Member
Roger wrote:
> 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?

Did you try using SWT.WRAP too ?

Henning.
Re: why StyledText's hight is not correct in SWT3.0 [message #445754 is a reply to message #445476] Wed, 10 November 2004 15:21 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Assuming that you are using the WRAP style, please log a bug report with
Platform - SWT and provide a stand-alone snippet that shows the problem,
thanks. (If you aren't using WRAP then first try adding it).

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/faq.html#whatisasnippet

Grant

"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&#65281;
> roger
>
Re: why StyledText's hight is not correct in SWT3.0 [message #445882 is a reply to message #445476] Thu, 11 November 2004 16:47 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
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&#65281;
> roger
>
Previous Topic:Test
Next Topic:TableColumn background color
Goto Forum:
  


Current Time: Fri Mar 29 11:00:57 GMT 2024

Powered by FUDForum. Page generated in 0.02446 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top