Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » PaintEvent question
PaintEvent question [message #447262] Sat, 11 December 2004 00:02 Go to next message
Tomas Carnecky is currently offline Tomas CarneckyFriend
Messages: 11
Registered: July 2009
Junior Member
The x, y, width, height field in class PaintEvent.
Those fields, do they indicate the position/size of
the whole widget or only of the area that needs to
be repainted?
In the description is:
/**
* the x offset of the bounding rectangle of the
* region that requires painting
*/
.... region that requires painting. What if only
a part of the widget needs painting?
Can I always start painting my widget at position
x/y? Or do I need to compute how to shift the whole
painting so the stuff gets painted on the right place?

An illustration:

(x/y) here?
+-----------------------------------------------+
| The whole widget |
| |
| or (x/y) here? |
| +--------------------------------+
| | The area that needs painting |
| | |
| | |
+--------------+--------------------------------+


thanks
tom
Re: PaintEvent question [message #447311 is a reply to message #447262] Mon, 13 December 2004 16:30 Go to previous messageGo to next message
Tomas Carnecky is currently offline Tomas CarneckyFriend
Messages: 11
Registered: July 2009
Junior Member
Tomas Carnecky wrote:
> The x, y, width, height field in class PaintEvent.
> Those fields, do they indicate the position/size of
> the whole widget or only of the area that needs to
> be repainted?
> In the description is:
> /**
> * the x offset of the bounding rectangle of the
> * region that requires painting
> */
> ... region that requires painting. What if only
> a part of the widget needs painting?
> Can I always start painting my widget at position
> x/y? Or do I need to compute how to shift the whole
> painting so the stuff gets painted on the right place?
>

Is it just me who doesn't understand how it works?
The documentation certainly doesn't help much. It is
quite a big difference whether x/y/width/height points to
the whole widget or only a part of it.
Maybe someone should add some more description to the
source code.

tom
Re: PaintEvent question [message #447313 is a reply to message #447311] Mon, 13 December 2004 16:59 Go to previous messageGo to next message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
Hi Thomas,

In my opinion, as most SWT developers would agree, the API Doc for
PaintEvent is quite clear and unambigous:

The Class description pasted from the docs:

"Instances of this class are sent as a result of visible areas of controls
requiring re-painting."

and as you have mentioned before, the description for the x field:

" the x offset of the bounding rectangle of the region that requires
painting"

I beleive that "visible areas", "requiring re-painting" and "x OFFSET"
describe the situation perfectly:

According to the above mentiond descriptions, the fields in the PaintEvent
describe only THE region of the control, that:
1-is visible (it makes no sense to draw the unvisible regions, and it would
also be serious performance drawback (e.g. in very long Lists or Tables)))
2- requres repaint (it is not alwats neccessary to redraw the wholde visible
region (e.g. when only a part of the visible region is covered by another
window))

So the x, y, width and height are the bounds of only THE part of the control
that requires repainting. The word "Offset" means by definition that the
given coordinates are RELATIVE to the bounds of the control requiring
repaint.

The following diagram should illusterate the case (hope the ASCII art turns
out right ;) ):

(0,0)
+------------------------------------------------------+
| The whole Control |
|
|
| (PaintEvent.x, PaintEvent.y) |
| +----------------------+ |
| | |
|
| | |
|
| +----------------------+(PaintEvent.width, |
| PaintEvent.height) |
|
|
+------------------------------------------------------+ (Control.width,
Control.height)

regards,

Mani

"Tomas Carnecky" <tom@dbservice.com> wrote in message
news:cpkg0g$nu$1@www.eclipse.org...
> Tomas Carnecky wrote:
>> The x, y, width, height field in class PaintEvent.
>> Those fields, do they indicate the position/size of
>> the whole widget or only of the area that needs to
>> be repainted?
>> In the description is:
>> /**
>> * the x offset of the bounding rectangle of the
>> * region that requires painting
>> */
>> ... region that requires painting. What if only
>> a part of the widget needs painting?
>> Can I always start painting my widget at position
>> x/y? Or do I need to compute how to shift the whole
>> painting so the stuff gets painted on the right place?
>>
>
> Is it just me who doesn't understand how it works?
> The documentation certainly doesn't help much. It is
> quite a big difference whether x/y/width/height points to
> the whole widget or only a part of it.
> Maybe someone should add some more description to the
> source code.
>
> tom
Re: PaintEvent question [message #447314 is a reply to message #447313] Mon, 13 December 2004 17:10 Go to previous messageGo to next message
Tomas Carnecky is currently offline Tomas CarneckyFriend
Messages: 11
Registered: July 2009
Junior Member
Mani Ghamari wrote:
> Hi Thomas,
>
> In my opinion, as most SWT developers would agree, the API Doc for
> PaintEvent is quite clear and unambigous:
>
> The Class description pasted from the docs:
>
> "Instances of this class are sent as a result of visible areas of controls
> requiring re-painting."
>
> and as you have mentioned before, the description for the x field:
>
> " the x offset of the bounding rectangle of the region that requires
> painting"
>
> I beleive that "visible areas", "requiring re-painting" and "x OFFSET"
> describe the situation perfectly:
>
> According to the above mentiond descriptions, the fields in the PaintEvent
> describe only THE region of the control, that:
> 1-is visible (it makes no sense to draw the unvisible regions, and it would
> also be serious performance drawback (e.g. in very long Lists or Tables)))
> 2- requres repaint (it is not alwats neccessary to redraw the wholde visible
> region (e.g. when only a part of the visible region is covered by another
> window))
>
> So the x, y, width and height are the bounds of only THE part of the control
> that requires repainting. The word "Offset" means by definition that the
> given coordinates are RELATIVE to the bounds of the control requiring
> repaint.

Oh.. now I got it. Is there somewhere in the documentation that whenever
PaintEvent.run() is called, the coordinates (0,0) are the top left
corner of the widget? Oh.. wait.. the Control, is it the widget or the
whole window?

>
> The following diagram should illusterate the case (hope the ASCII art turns
> out right ;) ):
>
> (0,0)
> +------------------------------------------------------+
> | The whole Control |
> | |
> | |
> | (PaintEvent.x, PaintEvent.y) |
> | +----------------------+ |
> | | | |
> | | | |
> | | | |
> | | | |
> | +----------------------+(PaintEvent.width, |
> | PaintEvent.height) |
> | |
> | |
> +------------------------------------------------------+ (Control.width,
> Control.height)
>

Yeah.. this makes everything clearer (exept the thing that I don't know
wheter 'Control' is only the one widget that needs repainting or the
whole window).

thanks
tom
Re: PaintEvent question [message #447315 is a reply to message #447311] Mon, 13 December 2004 17:11 Go to previous messageGo to next message
Stefan Zeiger is currently offline Stefan ZeigerFriend
Messages: 102
Registered: July 2009
Senior Member
Tomas Carnecky wrote:

>> In the description is:
>> /**
>> * the x offset of the bounding rectangle of the
>> * region that requires painting
>> */
>> ... region that requires painting. What if only
>> a part of the widget needs painting?
>> Can I always start painting my widget at position
>> x/y? Or do I need to compute how to shift the whole
>> painting so the stuff gets painted on the right place?
>>
>
> Is it just me who doesn't understand how it works?
> The documentation certainly doesn't help much. It is
> quite a big difference whether x/y/width/height points to
> the whole widget or only a part of it.

The bounding rectangle of the clipped region is using your Control's
coordinate system, just like the GC that is supplied in the PaintEvent
or a custom GC that you create for your Control.

You can always repaint the entire display area of the Control. If you
want to optimize the repaint operation, you only need to repaint the
area in the bounding rectangle. The GC is always using the Control's
coordinate system. The origin is _not_ shifted to the top left corner of
the bounding rectangle.

--
Stefan Zeiger http://www.szeiger.de http://www.novocode.com
My SWT controls: http://www.novocode.com/swt
Re: PaintEvent question [message #447317 is a reply to message #447314] Mon, 13 December 2004 17:31 Go to previous messageGo to next message
Mani Ghamari is currently offline Mani GhamariFriend
Messages: 33
Registered: July 2009
Member
"Control" refers only to the widget that needs repainting, and NOT the whole
window (shell).
The "Control" does not need to know about the whole window in order to draw
itself....

regards,

Mani
"Tomas Carnecky" <tom@dbservice.com> wrote in message
news:cpkidk$90j$1@www.eclipse.org...
> Mani Ghamari wrote:
>> Hi Thomas,
>>
>> In my opinion, as most SWT developers would agree, the API Doc for
>> PaintEvent is quite clear and unambigous:
>>
>> The Class description pasted from the docs:
>>
>> "Instances of this class are sent as a result of visible areas of
>> controls requiring re-painting."
>>
>> and as you have mentioned before, the description for the x field:
>>
>> " the x offset of the bounding rectangle of the region that requires
>> painting"
>>
>> I beleive that "visible areas", "requiring re-painting" and "x OFFSET"
>> describe the situation perfectly:
>>
>> According to the above mentiond descriptions, the fields in the
>> PaintEvent describe only THE region of the control, that:
>> 1-is visible (it makes no sense to draw the unvisible regions, and it
>> would also be serious performance drawback (e.g. in very long Lists or
>> Tables)))
>> 2- requres repaint (it is not alwats neccessary to redraw the wholde
>> visible region (e.g. when only a part of the visible region is covered by
>> another window))
>>
>> So the x, y, width and height are the bounds of only THE part of the
>> control that requires repainting. The word "Offset" means by definition
>> that the given coordinates are RELATIVE to the bounds of the control
>> requiring repaint.
>
> Oh.. now I got it. Is there somewhere in the documentation that whenever
> PaintEvent.run() is called, the coordinates (0,0) are the top left corner
> of the widget? Oh.. wait.. the Control, is it the widget or the whole
> window?
>
>>
>> The following diagram should illusterate the case (hope the ASCII art
>> turns out right ;) ):
>>
>> (0,0)
>> +------------------------------------------------------+
>> | The whole Control |
>> | |
>> | |
>> | (PaintEvent.x, PaintEvent.y) |
>> | +----------------------+ |
>> | | | |
>> | | | |
>> | | | |
>> | | | |
>> | +----------------------+(PaintEvent.width, |
>> | PaintEvent.height) |
>> | |
>> | |
>> +------------------------------------------------------+ (Control.width,
>> Control.height)
>>
>
> Yeah.. this makes everything clearer (exept the thing that I don't know
> wheter 'Control' is only the one widget that needs repainting or the whole
> window).
>
> thanks
> tom
Re: PaintEvent question [message #447318 is a reply to message #447317] Mon, 13 December 2004 17:35 Go to previous message
Tomas Carnecky is currently offline Tomas CarneckyFriend
Messages: 11
Registered: July 2009
Junior Member
Mani Ghamari wrote:
> "Control" refers only to the widget that needs repainting, and NOT the whole
> window (shell).
> The "Control" does not need to know about the whole window in order to draw
> itself....
>

Thanks very much...

tom
Previous Topic:Setting Table row height
Next Topic:Newsgroup for general Eclipse problems?
Goto Forum:
  


Current Time: Fri Oct 23 09:30:34 GMT 2020

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

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

Back to the top