Home » Eclipse Projects » Eclipse Platform » JFace table : getColumnImage can't return different sized images?
JFace table : getColumnImage can't return different sized images? [message #327354] |
Wed, 16 April 2008 06:00  |
Eclipse User |
|
|
|
Hi Folks,
Have a strange problem with my first ITableLabelProvider implementation, in the getColumnImage method I create an Image and use the GC to draw to it directly, all seems fine until I want to create images of different sizes between columns.
The following snippet demonstrates the problem. Basically, if in the first column a set an image size of 100x50, the second column's image will somehow use that size, even though I create the image as 50x50.
Any ideas? The code below is a cut down version, I've been doing the image creation in its own method and using the image registry to keep hold of them.
Any ideas would be most appreciated, this is driving me mad!
<pre>
public Image getColumnImage(Object element, int columnIndex) {
Image image = null;
GC gc = null;
switch (columnIndex) {
case 0:
image = new Image(getDisplay(), 100, 50);
gc = new GC(image);
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED)) ;
gc.fillRectangle(0, 0, 100, 50);
gc.drawLine(0, 0, 100, 50);
gc.dispose();
return image;
case 1:
image = new Image(getDisplay(), 50, 50);
gc = new GC(image);
gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED)) ;
gc.fillRectangle(0, 0, 50, 50);
gc.drawLine(0, 0, 50, 50);
gc.dispose();
return image;
}
return null;
}
</pre>
Thanks
|
|
|
Re: JFace table : getColumnImage can't return different sized images? [message #327355 is a reply to message #327354] |
Wed, 16 April 2008 06:03   |
Eclipse User |
|
|
|
SWT-Table/Tree don't support different sizes. If you want to draw
different sized images you'll have to use the custom drawing.
Tom
Toby Weston schrieb:
> Hi Folks,
>
> Have a strange problem with my first ITableLabelProvider implementation, in the getColumnImage method I create an Image and use the GC to draw to it directly, all seems fine until I want to create images of different sizes between columns.
>
> The following snippet demonstrates the problem. Basically, if in the first column a set an image size of 100x50, the second column's image will somehow use that size, even though I create the image as 50x50.
>
> Any ideas? The code below is a cut down version, I've been doing the image creation in its own method and using the image registry to keep hold of them.
>
> Any ideas would be most appreciated, this is driving me mad!
> <pre>
> public Image getColumnImage(Object element, int columnIndex) {
> Image image = null;
> GC gc = null;
> switch (columnIndex) {
> case 0:
> image = new Image(getDisplay(), 100, 50);
> gc = new GC(image);
> gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED)) ;
> gc.fillRectangle(0, 0, 100, 50);
> gc.drawLine(0, 0, 100, 50);
> gc.dispose();
> return image;
> case 1:
> image = new Image(getDisplay(), 50, 50);
> gc = new GC(image);
> gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_RED)) ;
> gc.fillRectangle(0, 0, 50, 50);
> gc.drawLine(0, 0, 50, 50);
> gc.dispose();
> return image;
> }
> return null;
> }
>
> </pre>
> Thanks
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
| | | | | |
Goto Forum:
Current Time: Sat May 03 15:03:46 EDT 2025
Powered by FUDForum. Page generated in 0.03611 seconds
|