I want to implement selecting capability in my custom control. This control contains an image and I want image to turn bluish when selected. I don't want to change image bitwise.
Is it possible to draw some half-transparent blue rectangle above other controls to simulate the selection?
UPDATE
The following code shows no any drawing:
public class ImageWithCaption extends Composite {
private Label imageLabel;
private Label textLabel;
private void init() {
setLayout(new GridLayout(1, false));
imageLabel = new Label(this, SWT.NONE);
imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
textLabel = new Label(this, SWT.NONE);
textLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setForeground(e.display.getSystemColor(SWT.COLOR_BLUE));
gc.fillRectangle(0, 0, e.width, e.height);
}
});
}
public ImageWithCaption(Composite parent, int style) {
super(parent, style);
init();
}
public void setText(String text) {
textLabel.setText(text);
}
public String getText() {
return textLabel.getText();
}
public Image getImage() {
return imageLabel.getImage();
}
public void setImage(Image image) {
imageLabel.setImage(image);
}
}