tags:

views:

117

answers:

2

How does SWT work out how to scale Images in a Table ?

I am using an ITableLabelProvider to provide images for an SWT Table.

I have recently widened the table columns from 140 to 170 and I have widened the Image object passed from ITableLabelProvider.

SWT now scales this 170-pixel image down to 140 pixels and displays 30 pixels of empty text on the right hand side. I have taken out all the references to the old width that I am aware of.

Other cells contain text only, and these are behaving perfectly correctly. The TableItem, Column and Image widths are definitely all 170.

I am running swt3.3 and jface 3.4.2 on Windows XP.

I have a workaround which listens to the SWT.PaintItem events on the Table, and then drawing the image directly into the Paint Event's Graphics context. This seems to do the trick, but its really bugging me that I don't understand how to make the more elegant solution work.

+2  A: 

Now I understand.

have a look at this http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg15042.html

The first image inserted into a table column will determine the dimensions of ALL other images inserted into that table column.

In a silent and hard-to-debug sense. You just have to know the secret.

I have added 30 pixels of white space to the first image added to the table, and now it is working perfectly.

Ben Hammond
A: 

Hi,

Is this thread still open?

I am facing the same problem.

My application contains a TableViewer on which i want to display images of different sizes, but as Ben Hammond mentioned here, TableViewer scales images.

This swt bug seems to be fixed after SWT version 3.0.1

I'm using SWT version 3.4.2, but still I'm facing the same problem.

Is there any work-around ??

Thanks in advance.

tujentg