View Full Version : DrawComponent in grid

27 Mar 2012, 6:23 AM
I want to draw an image with DrawComponent and add that to a grid. Is it possible? I can't find something like a DrawComponentCell in order to do the rendering of the drawComponent.

27 Mar 2012, 5:53 PM
No there is no draw cell and it is probably to complex a component to be made a cell. What are you trying to do exactly?

27 Mar 2012, 9:41 PM
I need to display an icon in a grid. The icon is not complex but the color must be unique for each row in the grid. Currently I create the icon on server side based on the color parameters I pass in via a URL and then I render the icon in the grid via an ImageCell. This is a bit slow. I thought that drawing the icon on the client side might be faster.

29 Mar 2012, 5:49 PM
Yeah even if there was something like draw component cell having a draw component surface for each icon would become very taxing. Unfortunately I don't think the draw package can help you in this situation.

30 Mar 2012, 12:42 AM
A classical trick in Web design is to transmit only one image with several widgets (the trick is used by Sencha in their menu icons, among others).
Perhaps you can make the server to draw all the icons you need (for a given view) in a single image (in a row or in a column) and use the image as background of a span, with CSS selecting the position and size of the background with regard to the span area. Thus, only the selected image is displayed. Never tried this in GWT, though... Perhaps it offers facilities for this functionality (I guess so).

Colin Alworth
30 Mar 2012, 6:42 AM
Another idea, if just the color needs to be changed of part of the icon, is to use an image with transparency set for part of it, and always draw the same image, but with a different background color each time.