[fpc-devel] InflateRect() not cross-platform
tizzziano at tiscali.it
Wed Jul 26 09:47:32 CEST 2006
Graeme Geldenhuys ha scritto:
> Any reason why there isn't a cross-platfrom InflateRect() function in
> the RTL? It only appears in the Windows API translations and is a
> very handly funtion to have.
> For those that don't know InflateRect():
> InflateRect(Rect, 1, 1);
> InflateRect(Rect, -2, -2);
> You can enlarge/shrink the X and Y co-ordinates of a TRect using this
Maybe because it is trivial?
There are a lot of ways to implement and use such a function.
This was from JvUtils.PAS in the Project JEDI's JVCL:
function TrueInflateRect(const R: TRect; const I: Integer): TRect;
with R do
SetRect(Result, Left - I, Top - I, Right + I, Bottom + I);
but I prefer this one (tested on Delphi and Lazarus):
procedure inflateR(var r: trect; xy: array of integer);
with r do
then SetRect(R, Left - xy, Top - xy,
Right + xy, Bottom + xy)
else SetRect(R, Left - xy, Top - xy,
Right + xy, Bottom + xy);
Note that if you don't use the LCL also implement SetRect.
you can find another implementation in the LCL (winapi.inc) were you can
find other platofrm independent functions of this kind .
what do you prefer?
More information about the fpc-devel