[SOLVED] Unwanted canvas redrawing when maximizing/minimizing/restoring shell [message #661556] |
Fri, 25 March 2011 10:08 |
Albert Pikus 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 #662145 is a reply to message #661556] |
Tue, 29 March 2011 14:05 |
Grant Gayed 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 |
Albert Pikus 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
|
|
|
Powered by
FUDForum. Page generated in 0.03104 seconds