I'm writing an app and our designer's want to user gradient's for some of the backgrounds on a few of our composite's.
I wrote the following code:
composite.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event e) {
GC gc = e.gc;
Rectangle rect = composite.getClientArea ();
Color color1 = new Color (display, 0, 0, 0);
Color color2 = new Color (display, 255, 255, 255);
gc.setForeground(color1);
gc.setBackground(color2);
gc.fillGradientRectangle (rect.x, rect.y, rect.width, rect.height , true);
}
});
This draw's the gradient fine on the composite, but we have Label/CLabel's, Canvas's and Link's on top of the composite.
In these area's the background is just the plain gray you get when drawing and empty canvas.
I've tried forcing the Label's to inherit the background like so:
label.setBackgroundMode(SWT.INHERIT_DEFAULT) //SWT.INHERIT_FORCE Doesn't work either
But this leaves me with the same default gray and no gradient behind the components on top of the Composite.
Any suggestion's for getting the gradient to be the background of each element?
I wouldn't be apposed to drawing the Gradient onto a gc with an imagine supplied and then setting the background to that Image. However that method just hasn't been working at all, composite or any of it's elements.
Also it's not possible for me to set the gradient individually to my knowledge.We want the whole composite to be one uniform flowing gradient.
[edit] I uploaded an example upto twitpic here.
Thanks,
Brian Gianforcaro