problem with custom drawing table [message #816784] |
Fri, 09 March 2012 08:54 |
Julien Mengelle Messages: 1 Registered: March 2012 Location: France |
Junior Member |
|
|
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
[Updated on: Fri, 09 March 2012 10:13] Report message to a moderator
|
|
|
Re: problem with custom drawing table [message #817251 is a reply to message #816784] |
Fri, 09 March 2012 21:11 |
Grant Gayed Messages: 2150 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
|
|
|
Powered by
FUDForum. Page generated in 0.14734 seconds