Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Resetting a canvas
Resetting a canvas [message #445707] Tue, 09 November 2004 20:30 Go to next message
Eclipse UserFriend
Originally posted by: wayneg.ananzi.co.za

Hi all,

Could anyone tell me how to reset a canvas to its original state after
drawing on it with GC (pictures or simple lines). If it makes any
difference all the drawings are done in paintListeners.

Regards
Wayne
Re: Resetting a canvas [message #445733 is a reply to message #445707] Wed, 10 November 2004 07:14 Go to previous messageGo to next message
Ryan is currently offline RyanFriend
Messages: 34
Registered: July 2009
Member
Hi Wayne,

The only way I know of doing this is to create a new GC, set its
background colour to the background colour of the canvas, and then draw a
big fill-rectangle to cover the whole canvas. i.e.:

GC gc = new GC(canvas);
gc.setBackground(canvas.getBackground());
gc.fillRectangle(0, 0, canvas.getSize().x, canvas.getSize().y);
gc.dispose();

Ryan


Wayne Gemmell wrote:

> Hi all,

> Could anyone tell me how to reset a canvas to its original state after
> drawing on it with GC (pictures or simple lines). If it makes any
> difference all the drawings are done in paintListeners.

> Regards
> Wayne
Re: Resetting a canvas [message #445746 is a reply to message #445707] Wed, 10 November 2004 14:47 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You could use Control.redraw() and Control.update(). The redraw() method
will cause the operating system to invalidate the canvas and queue a paint
event. If you update() right away, then the paint will get delivered after
the operating system has filled the canvas with the background. Then you
can draw. It's a bit of a hack but should work.

"Wayne Gemmell" <wayneg@ananzi.co.za> wrote in message
news:cmr9dg$15e$1@eclipse.org...
> Hi all,
>
> Could anyone tell me how to reset a canvas to its original state after
> drawing on it with GC (pictures or simple lines). If it makes any
> difference all the drawings are done in paintListeners.
>
> Regards
> Wayne
>
Previous Topic:Modifying the default behaviour of TrayItem
Next Topic:Set Keyboard cursor position in Combo
Goto Forum:
  


Current Time: Wed Apr 24 18:55:46 GMT 2024

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

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

Back to the top