Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Background mode and SWT.NO_REDRAW_RESIZE
Background mode and SWT.NO_REDRAW_RESIZE [message #493909] Wed, 28 October 2009 13:24 Go to next message
Benjamin Leipold is currently offline Benjamin LeipoldFriend
Messages: 13
Registered: July 2009
Junior Member
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?
Re: Background mode and SWT.NO_REDRAW_RESIZE [message #494217 is a reply to message #493909] Thu, 29 October 2009 15:43 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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?
Re: Background mode and SWT.NO_REDRAW_RESIZE [message #494311 is a reply to message #493909] Fri, 30 October 2009 08:34 Go to previous messageGo to next message
Benjamin Leipold is currently offline Benjamin LeipoldFriend
Messages: 13
Registered: July 2009
Junior Member
I feared that. Unfortunately, emulating is no real alternative since there are to many code places that should be considered. Nevertheless, thanks for filling the bug report. Any idea when the fix will be available and in which SWT version?
Re: Background mode and SWT.NO_REDRAW_RESIZE [message #494389 is a reply to message #494311] Fri, 30 October 2009 14:04 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
I don't know at this point, I likely won't be working on it. If you add
yourself to its CC list you can be notified of its progress.

One other potential workaround: Are you able to not use the
SWT.NO_REDRAW_RESIZE style in your context? It's basically just a
performance optimization.

Grant


"Benjamin Leipold" <rabbit171@web.de> wrote in message
news:hce8e0$l88$1@build.eclipse.org...
> I feared that. Unfortunately, emulating is no real alternative since there
are to many code places that should be considered. Nevertheless, thanks for
filling the bug report. Any idea when the fix will be available and in which
SWT version?
Re: Background mode and SWT.NO_REDRAW_RESIZE [message #494647 is a reply to message #493909] Sun, 01 November 2009 17:53 Go to previous message
Benjamin Leipold is currently offline Benjamin LeipoldFriend
Messages: 13
Registered: July 2009
Junior Member
Unfortunately not. The Canvas is part of a custom drawing widget and not setting this flag makes it unbearable slow. So i have to wait for the fix. Thanks for your hints.
Previous Topic:Losing clicks and redraws on Ubuntu Karmic with Eclipse 3.5?
Next Topic:differences between browser.setText and browser.setUrl behavior
Goto Forum:
  


Current Time: Fri Mar 29 01:00:16 GMT 2024

Powered by FUDForum. Page generated in 0.04388 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top