Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » [SOLVED] Unwanted canvas redrawing when maximizing/minimizing/restoring shell(How to prevent canvas redraws)
icon5.gif  [SOLVED] Unwanted canvas redrawing when maximizing/minimizing/restoring shell [message #661556] Fri, 25 March 2011 10:08 Go to next message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi everybody,

I have a question regarding Canvas behavior when Shell is maximized, minimized or restored.

Namely, I have some rectangles drawn on Canvas, which are drawn when SWT.MouseDown event is fired when clicking on some region of the Canvas. When I move the shell (non maximized), or when shell is covered behind some other window and then revealed again, or shell loses/gains focus (shell deactivacted/activated events) the rectangle stays visible on canvas.

But when I minimize the shell (shell is iconified) and then restore it again, rectangle disappears. There is no effect if I call redraw() or update() on Canvas inside shellDeiconified(ShellEvent e) method. I have also tried with canvas.notifyListeners(SWT.Mouse down, null) when shell is deiconfied, which doesn't help either.

Does anyone have some suggestions on how could I retain drawn rectangle in such case?


Best regards,

Albert

[Updated on: Fri, 01 April 2011 07:44]

Report message to a moderator

Re: Unwanted canvas redrawing when maximizing/minimizing/restoring shell [message #661986 is a reply to message #661556] Mon, 28 March 2011 18:11 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

On which platform are you seeing this? Can you post an example snippet that shows this behavior.


Lakshmi P Shanmugam
Re: Unwanted canvas redrawing when maximizing/minimizing/restoring shell [message #662145 is a reply to message #661556] Tue, 29 March 2011 14:05 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Albert,

From your description it sounds like the rectangles may not be being painted
in an SWT.Paint callback. If this is the case then it's not surprising that
the rectangles do not survive some redraws on the parent Shell. For an
example of drawing in a Paint callback, which is how all drawing should be
done, see
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.sn ippets/src/org/eclipse/swt/snippets/Snippet245.java?view=co .

If the above assumption is wrong then please provide some code that shows
how/where the rectangles are being drawn.

Grant


"Albert" <albert.pikus@gmail.com> wrote in message
news:imhp5d$1u0$1@news.eclipse.org...
> Hi everybody,
>
> I have a question regarding Canvas behavior when Shell is maximized,
> minimized or restored.
>
> Namely, I have some rectangles drawn on Canvas, which are drawn when
> SWT.MouseDown event is fired when clicking on some region of the Canvas.
> When I move the shell (non maximized), or when shell is covered behind
> some other window and then revealed again, the rectangle stays visible on
> canvas.
>
> But when I minimize the shell (shell is iconified) and then restore it
> again, rectangle disappears. There is no effect if I call redraw() or
> update() on Canvas inside shellDeiconified(ShellEvent e) method. I have
> also tried with canvas.notifyListeners(SWT.Mouse down, null) when shell is
> deiconfied, which doesn't help either.
>
> Does anyone have some suggestions on how could I retain drawn rectangle in
> such case?
>
>
> Best regards,
>
> Albert
>
>
Re: Unwanted canvas redrawing when maximizing/minimizing/restoring shell [message #662837 is a reply to message #661556] Fri, 01 April 2011 07:43 Go to previous message
Albert Pikus is currently offline Albert PikusFriend
Messages: 70
Registered: October 2009
Member
Hi,

thank you both for your answers. I'm sorry, this was entirely my mistake. As Grant says, rectangle should be drawn inside Paint event, which is triggered every time Shell is iconified/deiconfied.

So I simply added drawing of rectangle inside a PaintListener which is now correctly redrawn when Shell is maximized/restored/iconified/deiconified.

@Lakshmi: I was seeing this on Windows 7, but, as said, this was my fault.


Thanks again, best regards,

Albert

[Updated on: Fri, 01 April 2011 08:21]

Report message to a moderator

Previous Topic:Combo & CCombo
Next Topic:Setting ImageData alpha behaves strange on Mac
Goto Forum:
  


Current Time: Sat Apr 20 01:35:23 GMT 2024

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

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

Back to the top