Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 10:00 Go to next message
Toby Weston is currently offline Toby WestonFriend
Messages: 22
Registered: July 2009
Junior Member
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 10:03 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
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
------------------------------------------------------------ --------
Re: JFace table : getColumnImage can't return different sized images? [message #327356 is a reply to message #327355] Wed, 16 April 2008 10:57 Go to previous messageGo to next message
Toby Weston is currently offline Toby WestonFriend
Messages: 22
Registered: July 2009
Junior Member
Thanks for the info, any links for custom drawing? Where to get started? are you talking here about adding a PaintListener somehow?

All the best
Re: JFace table : getColumnImage can't return different sized images? [message #327358 is a reply to message #327356] Wed, 16 April 2008 11:59 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
http://wiki.eclipse.org/JFaceSnippets
http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html

Tom

Toby Weston schrieb:
> Thanks for the info, any links for custom drawing? Where to get started? are you talking here about adding a PaintListener somehow?
>
> All the best


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: JFace table : getColumnImage can't return different sized images? [message #327510 is a reply to message #327358] Tue, 22 April 2008 19:02 Go to previous messageGo to next message
Toby Weston is currently offline Toby WestonFriend
Messages: 22
Registered: July 2009
Junior Member
Hi Tom,

I don't spose you saw this post did you? http://www.eclipsezone.org/forums/thread.jspa?threadID=10928 8 ... the image disappears when the row is selected, any ideas?

Cheers,
Toby
Re: JFace table : getColumnImage can't return different sized images? [message #327537 is a reply to message #327510] Wed, 23 April 2008 22:22 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
This doesn't happen to me (was there a bug report I saw lately from
yourside describing this and I commented there?

Tom

Toby Weston schrieb:
> Hi Tom,
>
> I don't spose you saw this post did you? http://www.eclipsezone.org/forums/thread.jspa?threadID=10928 8 ... the image disappears when the row is selected, any ideas?
>
> Cheers,
> Toby


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: JFace table : getColumnImage can't return different sized images? [message #327590 is a reply to message #327537] Fri, 25 April 2008 12:55 Go to previous message
Toby Weston is currently offline Toby WestonFriend
Messages: 22
Registered: July 2009
Junior Member
Hi,

Don't think I raised a bug report but I'll try and put a sample together that dis/proves it and pass it on.

Cheers,
Toby
Previous Topic:Project Manager
Next Topic:Using FieldEditors and getFieldEditorParent() on constructor
Goto Forum:
  


Current Time: Thu Jul 18 06:20:59 GMT 2024

Powered by FUDForum. Page generated in 0.25478 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top