Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Images

Hi,
I have what I would think is a usual enough problem that I was hoping someone could help me out with it.

I'm porting a UI component from AWT/Swing to SWT . It is a canvas that has selectable objects. The object's selection must match exactly what is rendered on the canvas. To do this in AWT/Swing, we created a custom composite function and rendered the alpha channel of everything as a unique color to a background buffer. Selection is accomplished by simply seeing what unique color the mouse was over, and then retrieving the associated object from a map.

This doesn't seem to be readily doable in SWT. You can create a wrapper for a GC, make it ignore changes to color, and instead use a picking color when drawing objects. You run into problems, however, when you start rendering images because the images don't render the same way shapes do. I've tried a number of approaches, all of which are unsatisfactory because of the expense in instantiating Image objects. Does anyone have an idea of how/if someone has done this in SWT? It seems like there might be an inherent limitation in the platform that would be worth taking a look at from a design perspective...

Back to the top