Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » column content alignment
column content alignment [message #489049] Thu, 01 October 2009 11:25 Go to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: October 2009
Junior Member
Hello

I have a problem with alignment of column content.
By default, if a content of a column is too long 3 dots appears (e.g HelloWorl...). I would lile to have such a behaviour on the left side of column (e.g: ...elloWorld).

Is there any possibility to do it ?

Re: column content alignment [message #489120 is a reply to message #489049] Thu, 01 October 2009 14:38 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi,

The best way to do this is by drawing the items yourself. The basic steps
would be:
- add an EraseItem listener. When it's received:
- use the event's GC to measure the full string, if it does not fit then
remove the SWT.FOREGROUND bit from the event's detail
- add a PaintItem listener. When it's received:
- if the item did not fit when it was measured in the EraseItem listener
then use the event's GC to measure a string that will fit (eg.- replace the
first x characters with "...", measure it, if it doesn't fit then replace
the first x+2 characters with "..." measure it, etc.), then draw the string
with the GC

For info about TableItem/TreeItem custom draw see
http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html .

An alternative approach (not really recommended) would be to listen for
column Resize events, and when one is received calculate the shortened
strings for all items down the column and change their texts with
setText(columnIndex, value).

Grant


<doktor.kat@gmail.com> wrote in message
news:ha23in$imn$1@build.eclipse.org...
> Hello
>
> I have a problem with alignment of column content.
> By default, if a content of a column is too long 3 dots appears (e.g
HelloWorl...). I would lile to have such a behaviour on the left side of
column (e.g: ...elloWorld).
>
> Is there any possibility to do it ?
>
>
Previous Topic:is docShell.setZoom not supported by XULRunner?
Next Topic:Problem with toolbar button activation
Goto Forum:
  


Current Time: Wed Apr 24 18:11:56 GMT 2024

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

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

Back to the top