Manipulate strength and color of table/tree viewer grid? [message #493667] |
Tue, 27 October 2009 14:13 |
|
Hi,
I'm creating an application whose User Interface consists mainly of a JFace Tree Viewer in table mode. Now I'm looking after a method to improve the visibility of the table grid. The default grid lines are in a very light grey and rather thin and can be rarely seen when showed by beamer projection.
Is there a smart way to manipulate these properties? Any example snippets out there?
Any help would be heavily appreciated!
Greetings
dagmar
|
|
|
Re: Manipulate strength and color of table/tree viewer grid? [message #493941 is a reply to message #493667] |
Wed, 28 October 2009 14:58 |
|
Hi Dagmar,
here is an example how to do it.... be careful, this example draws only lines if there is an element.
viewer.addListener(SWT.PaintItem, this);
@Override
public void handleEvent( Event event) {
switch (event.type) {
case SWT.PaintItem:
paintItemBorder(event);
break;
}
protected void paintItemBorder( Event event) {
if (getLinesVisible()) {
return;
}
// Draw line at bottom and right side
int x1 = event.x;
int y1 = event.y;
int x2 = x1 + getColumnWidth(event.index) - 1;
int y2 = y1 + getItemHeight() - 1;
GC gc = event.gc;
gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
gc.drawLine(x1, y2, x2, y2); //Change line width by manipulating these values
gc.drawLine(x2, y1, x2, y2);
}
[Updated on: Wed, 28 October 2009 15:00] Report message to a moderator
|
|
|
|
Re: Manipulate strength and color of table/tree viewer grid? [message #494122 is a reply to message #493941] |
Thu, 29 October 2009 09:38 |
|
Hi,
I just tried to use your snippet but I could not find a class which provides a method named getColumnWidth - Table/TreeViewer don't provide a method like this. Calling the method directly produces an error.
Do I have to extract a column and get the width from the column directly? Or do I have to import anything from which I can call that method?
Thx a lot,
Dagmar
|
|
|
|
Powered by
FUDForum. Page generated in 0.03885 seconds