Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » problem with custom drawing table
icon5.gif  problem with custom drawing table [message #816784] Fri, 09 March 2012 03:54 Go to next message
Julien Mengelle is currently offline Julien Mengelle
Messages: 1
Registered: March 2012
Location: France
Junior Member
Hi !

First, sorry for my english, i hope you will understand Smile

So :

I have a Table (with SWT.FULL_SELECTION, SWT.VIRTUAL), and i try de make posssible to select multiple Cell (like select 0,3 and 0,6).

For that, i'm trying to change the default behavior when i select a ligne.

First of all, i just want to cancel the "background selection".
After that i will try to draw the background only on the cell that i want.

I found this article about this here : www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html
(exemple 3)

i had succesfully change the background of my cells but when i try du change the foreground it has no effect. And therein lies the problemn, because when i set the background to white, the foreground is also drawing in white !!
like when you select the row : white text on blue background, so it's like i have nothing in the line.
i didn't found anything about this on the web.

What i am missing ?

I'm using eclipse 3.3.2 on Windows XP.

this.table.addListener(SWT.EraseItem, new Listener() 
{
   public void handleEvent(Event event)
   {
	event.detail &= ~SWT.HOT;
	event.detail &= ~SWT.SELECTED;


	//Try to solve the problem, without effect						
	TableItem item = (TableItem)event.item;
	item.setForeground(unselectForegroundColor);
			
   }			
});



Thanks

[Updated on: Fri, 09 March 2012 05:13]

Report message to a moderator

Re: problem with custom drawing table [message #817251 is a reply to message #816784] Fri, 09 March 2012 16:11 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
Hi,

You may be seeing a bug in SWT (3.3.2 is quite old). With the latest
Eclipse/SWT the following successfully changes the foreground in
EraseItem for "selected" cells:

final Color selectedForegroundColor =
display.getSystemColor(SWT.COLOR_DARK_GREEN);
final Color unselectedForegroundColor = table.getForeground();
table.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
event.detail &= ~SWT.HOT;
event.detail &= ~SWT.SELECTED;
/* the following "selects" every 5th cell */
TableItem item = (TableItem)event.item;
int itemIndex = table.indexOf(item);
if (((itemIndex * columnCount) + event.index) % 5 == 0) {
item.setForeground(event.index, selectedForegroundColor);
} else {
item.setForeground(event.index, unselectedForegroundColor);
}
}
});

HTH,
Grant


On 3/9/2012 3:54 AM, Julien Mengelle wrote:
> Hi !
>
> First, sorry for my english, i hope you will understand :)
>
> So :
> I have a Table (with SWT.FULL_SELECTION, SWT.VIRTUAL), and i try de make
> posssible to select multiple Cell (like select 0,3 and 0,6).
>
> For that, i'm trying to change the default behavior when i select a ligne.
> First of all, i just want to cancel the "background selection". After
> that i will try to draw the background only on the cell that i want.
> I found this article about this here :
> www.eclipse.org/articles/article.php?file=Article-CustomDrawingTableAndTreeItems/index.html
>
> (exemple 3)
>
> i had succesfully change the background of my cells but when i try du
> change the foreground it has no effect. And therein lies the problemn,
> because when i set the background to white, the foreground is also
> drawing in white !! like when you select the row : white text on blue
> background, so it's like i have nothing in the line.
> i didn't found anything about this on the web.
> What i am missing ?
> I'm using eclipse 3.3.2 on Windows XP.
>
>
> this.table.addListener(SWT.EraseItem, new Listener() {
> public void handleEvent(Event event)
> {
> event.detail &= ~SWT.HOT;
> event.detail &= ~SWT.SELECTED;
>
>
> //Try to solve the problem, without effect
> TableItem item = (TableItem)event.item;
> item.setForeground(unselectForegroundColor);
>
> }
> });
>
>
>
> Thanks
Previous Topic:SWT Browser User-agent
Next Topic:Redraw problem after a refactoring
Goto Forum:
  


Current Time: Sat Apr 19 18:35:06 EDT 2014

Powered by FUDForum. Page generated in 0.02381 seconds