Home » Eclipse Projects » Standard Widget Toolkit (SWT) » PaintEvent question
PaintEvent question [message #447262] |
Fri, 10 December 2004 19:02  |
Eclipse User |
|
|
|
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 #447313 is a reply to message #447311] |
Mon, 13 December 2004 11:59   |
Eclipse User |
|
|
|
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 12:10   |
Eclipse User |
|
|
|
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 #447317 is a reply to message #447314] |
Mon, 13 December 2004 12:31   |
Eclipse User |
|
|
|
"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 12:35  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Tue Jul 08 11:54:55 EDT 2025
Powered by FUDForum. Page generated in 0.86267 seconds
|