|
Re: Background mode and SWT.NO_REDRAW_RESIZE [message #494217 is a reply to message #493909] |
Thu, 29 October 2009 15:43 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
I think what you're trying to do should work but doesn't, so I've logged
https://bugs.eclipse.org/bugs/show_bug.cgi?id=293681 . The only workaround
I can suggest is to not inherit the background image and just do the work to
emulate it instead. Here's an example:
static int counter = 0;
public static void main(String[] args) {
final String IMAGE_FILENAME = "c:\\picture.jpg";
final Display display = new Display();
Image image = new Image(display, IMAGE_FILENAME);
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setBackgroundImage(image);
Canvas canvas = new Canvas(shell, SWT.NO_REDRAW_RESIZE);
canvas.addListener(SWT.Paint, new Listener() {
public void handleEvent(Event event) {
System.out.println("Paint event " + counter++);
Control control = (Control)event.widget;
Image inheritedImage = control.getParent().getBackgroundImage();
if (inheritedImage != null) {
Point location = control.getLocation();
event.gc.drawImage(inheritedImage, location.x + event.x,
location.y + event.y, event.width, event.height, event.x, event.y,
event.width, event.height);
}
}
});
shell.setBounds(10,10,200,200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}
}
Grant
"Benjamin Leipold" <rabbit171@web.de> wrote in message
news:hc9gmc$deb$1@build.eclipse.org...
> I have redraw problems with Composite.setBackgroundMode(int). If i set
SWT.INHERIT_DEFAULT as background mode and a background image on a
Composite, Canvas that are children of this Composite are always repainted
completely although using style SWT.NO_REDRAW_RESIZE.
> My first idea was to insert a Composite with background mode
SWT.INHERITE_NONE between the first Composite and the Canvas, but that does
not work. Setting background mode of the root Composite back to
SWT.INHERITE_NONE solves the repaint problem but now other children that are
intended to inherite the background image clearly do inherit nothing. Does
anybody can tell me how to combine SWT.INHERIT_DEFAULT and
SWT.NO_REDRAW_RESIZE?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04544 seconds