[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Transparent images in virtual tables

Hi,

I would like to add transparent gif images into my tableitems. I find a way to do it. Please recognize the code below.
My problem is the selection of the table. If the line is marked, the image is not transparent anymore.


I tried to use a selection listener and redraw the image but the performance is bad. And what about the MenuItems? They are able to provide full transparency for the items! Please recognize the attached screenshot. What is the difference between menuitem and tableitem?

Thank you!

Sebastian



<code>

Label label = new Label(item.getParent(), SWT.NONE);
label.setImage(image);
label.pack();
label.setBackground(WHITE);
		
// listener provides transparency
final Canvas canvas = new Canvas(label.getShell(), SWT.NO_REDRAW_RESIZE);
		
canvas.addPaintListener(new PaintListener() {
	public void paintControl(PaintEvent e) {
		e.gc.drawImage(image, 0, 0);
	}
});

TableEditor editor = new TableEditor(item.getParent());
editor.minimumWidth = label.getBounds().width;
editor.minimumHeight= label.getBounds().height;
editor.grabHorizontal = false;
editor.grabVertical = false;
editor.horizontalAlignment = alignment;
editor.setEditor(label, item, colIndex);

</code>


JPEG image