Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How can I force Text widget to break word when wrapping lines?(I am using indigo on windows)
How can I force Text widget to break word when wrapping lines? [message #727794] Thu, 22 September 2011 01:14 Go to next message
cn.fred is currently offline cn.fredFriend
Messages: 27
Registered: July 2010
Location: China
Junior Member
please help!

for example, if the String "hello world" can not be displayed in one line, the line wrapping happens, it will be displayed like this :

-----------
hello
world
-----------

but I hope this :

-----------
hello worl
d
-----------

this is what I said "break word"

[Updated on: Thu, 22 September 2011 07:10]

Report message to a moderator

Re: How can I force Text widget to break word when wrapping lines? [message #727882 is a reply to message #727794] Thu, 22 September 2011 06:34 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-09-22 03:14, cn.fred wrote:
> please help!

This is one of those postings where I would like to point to

http://catb.org/~esr/faqs/smart-questions.html

Please give a concrete example what you want to realize. A short snippet
similar to the SWT snippets would explain a lot.

Have to read

http://book.javanb.com/swt-the-standard-widget-toolkit/ch15lev1sec12.html

? This article explains some subtleties in regard to wrapping in SWT.

If your problem is of the kind described in

http://stackoverflow.com/questions/5014765/simultaneously-right-align-and-wrap-text-in-an-swt-label-in-linux-gnome

check the suggested solutions there, but this is all guessing on my side.

Last but not least: If you need a widget that *actively* breaks a
*single* word like "hippopotamus" automatically into one of the possible
syllables in "hip-po-pot-a-mus", you need to write your own component:
This requires knowledge about the natural language that is presented in
the text.

HTH & Greetings from Bremen,

Daniel Krügler
Re: How can I force Text widget to break word when wrapping lines? [message #727885 is a reply to message #727794] Thu, 22 September 2011 06:44 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 22.09.2011 03:14, cn.fred wrote:
> please help!
Set the SWT.WRAP style when creating the widget.

Dani
Re: How can I force Text widget to break word when wrapping lines? [message #727890 is a reply to message #727882] Thu, 22 September 2011 07:08 Go to previous messageGo to next message
cn.fred is currently offline cn.fredFriend
Messages: 27
Registered: July 2010
Location: China
Junior Member
sorry, I did not describe more, see my edits
Re: How can I force Text widget to break word when wrapping lines? [message #727893 is a reply to message #727885] Thu, 22 September 2011 07:13 Go to previous messageGo to next message
cn.fred is currently offline cn.fredFriend
Messages: 27
Registered: July 2010
Location: China
Junior Member
I am not asking about line-wrap(Create a Text Widget with SWT.Wrap), see my edits.
Re: How can I force Text widget to break word when wrapping lines? [message #727898 is a reply to message #727890] Thu, 22 September 2011 07:22 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2011-09-22 09:08, cn.fred wrote:
> sorry, I did not describe more, see my edits

The are no edits possible on eclipse.platform.rcp.

Greetings from Bremen,

Daniel Krügler
Re: How can I force Text widget to break word when wrapping lines? [message #728090 is a reply to message #727794] Thu, 22 September 2011 14:10 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
There isn't a way to make Text or StyledText behave like this on their own. You would need to do the work to listen for Modify events on the Text, and then do measurements on the control's string to determine whether additional line breaks need to be inserted to give the appearance of the behaviour that you want. For an example of measuring a string see http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet93.java .

Grant
Re: How can I force Text widget to break word when wrapping lines? [message #728324 is a reply to message #728090] Fri, 23 September 2011 01:45 Go to previous messageGo to next message
cn.fred is currently offline cn.fredFriend
Messages: 27
Registered: July 2010
Location: China
Junior Member
there is a way to make Text behavior like that on SWT GTK Version.

Re: How can I force Text widget to break word when wrapping lines? [message #728608 is a reply to message #728324] Fri, 23 September 2011 13:57 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
How? In SWT's GTK implementation the only case where this happens is
with one "word" that's longer than the width of the text. It's possible
that GTK's native text control supports the behavior you describe, but
SWT does not expose it.

Grant


On 9/22/2011 9:45 PM, cn.fred wrote:
> there is a way to make Text behavior like that on SWT GTK Version.
>
>
Previous Topic:create java project fail in the RCP product.
Next Topic:Where is "Platform Plug-in Developer Guide" in eclipse indigo help
Goto Forum:
  


Current Time: Fri Apr 19 10:49:44 GMT 2024

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

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

Back to the top