[Lazarus] 0019723: Implement TControl.InvalidateRect?

Flávio Etrusco flavio.etrusco at gmail.com
Fri Jul 15 23:22:28 CEST 2011


On Fri, Jul 15, 2011 at 5:47 PM, Martin <lazarus at mfriebe.de> wrote:
> On 15/07/2011 20:33, Flávio Etrusco wrote:
>>
>> 2011/7/15 Martin<lazarus at mfriebe.de>:
>>>
>>> http://bugs.freepascal.org/view.php?id=19723
>>>
>>> It would be nice to have TControl.InvalidateRect, so that component
>>> developers can avoid calls to LCLIntf.InvalidateRect :-)
>
> ...
>>>
>>> There is the question of drawing a lie, to how much to put on
>>> TWinControl.
>>> There are more Handle related functions... So there could be an
>>> additional
>>> HandleObject property, with an object representing the handle.
>>> Though, IMHO that would be too much...
>>>
>>>
>>> What is the specific use case for it?
>>> I can only really see use, if you develop your own component. But then
>>> you
>>> can add it there...
>>>
>>> --
>>
>> The intended use is for component developers, yes. But actually I
>> thought about it while checking a bug report and having to offset for
>> InvalidateRect with a TPaintBox, so I'd prefer it was implemented in
>> TControl ;-) It's just a matter of extract the method from
>> TContol.Invalidate.
>> I guess it's impossible to draw line, they need to be indeed discussed
>> on a case-by-case basis. That's why I posted the RFE as a question ;-)
>
> Well, one other think is, the current function would still have to remain.
> (or compatibility would be broken badly).
> So doing this would simply be a duplicate.
>
>
> I am definitely with the comment on mantis. I wouldn't want to add to many
> more things to T(Win)Control. That would speak for a
> TWinControl.HandleObj.InvalidateRect(x,y,x2,y2)
>
> I do see the point of wanting to access it in context of a
> T(Graphic)Control, but there is no handle. there could be a handle object;
> but it probably wouldn't work for all functions...
>
> Also TGraphicControl, and TCustomControl(inherit TWinControl)  introduce a
> Canvas, maybe then it could go there?
> TCanvas, has other handle related functions, like GetClipRect.
>
>
> Just some ideas....
>
> --

My thought of declaring in TControl is it would be just a matter of
changing InvalidateControl (sorry for the typo in my previous post):
From:
procedure TControl.InvalidateControl(CtrlIsVisible, CtrlIsOpaque: Boolean);
To:
procedure TControl.InvalidateControlRect(CtrlIsVisible, CtrlIsOpaque:
Boolean; const ABounds: TRect);

then replace the call to Self.Bounds to ABounds, and add a new
InvalidateControl calling InvalidateControlRect.

> BTW, you realize, that if your intend is to minimize the invalidated rectangle, to what needs to be
> redrawn, then a TGraphicControl (or any none TWinControl) is not your best choice anyway?

Yes, but since we have TPaintBox which is a hack, maybe we can
complement the hack ;-)

-Flávio




More information about the Lazarus mailing list