Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-07

InflateRect() not cross-platform

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

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():
Usage:
  InflateRect(Rect, 1, 1);
  InflateRect(Rect, -2, -2);

You can enlarge/shrink the X and Y co-ordinates of a TRect using this function.

Regards,
Graeme.

There's no place like 127.0.0.1

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 13 lines
Hi, 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(): Usage: InflateRect(Rect, 1, 1); InflateRect(Rect, -2, -2); You can enlarge/shrink the X and Y co-ordinates of a TRect using this function.

Well, feel free to implement it. We'll put it in types.pas, together with the other TRect functions.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Well, feel free to implement it. We'll put it in types.pas, together with the other TRect…
Show quoted text 5 lines
> You can enlarge/shrink the X and Y co-ordinates of a TRect using this > function. Well, feel free to implement it. We'll put it in types.pas, together with the other TRect functions.

I see there is already such a function, just with a different name: OffsetRect()

I guess there is no need to add InflateRect() now...

Graeme.

There's no place like 127.0.0.1

Reply by email

Michael Van Canneyt
to Micha Nelissen
Micha Nelissen wrote 7 lines
Graeme Geldenhuys wrote: > I see there is already such a function, just with a different name: > OffsetRect() > > I guess there is no need to add InflateRect() now... Offset is for position, Inflate is for size. AFAIK.

Correct.

Michael.

Reply by email

Jesús Reyes A.
to Graeme Geldenhuys: Any reason why there isn't a cross-platfrom InflateRect() function in the RTL? It only…

----- Original Message -----

Earlier message 35 lines
From: "Graeme Geldenhuys" To: "FPC developers' list" Sent: Tuesday, July 25, 2006 4:59 AM Subject: [fpc-devel] InflateRect() not cross-platform > Hi, > > 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(): > Usage: > InflateRect(Rect, 1, 1); > InflateRect(Rect, -2, -2); > > You can enlarge/shrink the X and Y co-ordinates of a TRect using this > function. > > Regards, > Graeme. > > > -- > There's no place like 127.0.0.1 If you are using Lazarus, Just include LCLIntf unit. Jesus Reyes A. __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam �gratis! Reg�strate ya - http://correo.yahoo.com.mx/

Reply by email

Graeme Geldenhuys
to Jesús Reyes A.
If you are using Lazarus, Just include LCLIntf unit. Jesus Reyes A.

I can't use the LCL. The project I am working on is a new cross-platform widget set written in FPC. Either way, no reason such a handy function shouldn't be in FPC for all platforms.

Regards,
Graeme.

There's no place like 127.0.0.1

Reply by email

Tiziano_mk
to Graeme Geldenhuys: Any reason why there isn't a cross-platfrom InflateRect() function in the RTL? It only…

Graeme Geldenhuys ha scritto:

Show quoted text 18 lines
Hi, 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(): Usage: InflateRect(Rect, 1, 1); InflateRect(Rect, -2, -2); You can enlarge/shrink the X and Y co-ordinates of a TRect using this function. Regards, Graeme.

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;
begin
   with R do
     SetRect(Result, Left - I, Top - I, Right + I, Bottom + I);
end;

but I prefer this one (tested on Delphi and Lazarus):

   procedure inflateR(var r: trect; xy: array of integer);
   begin
     with r do
       if high(xy)=0
          then SetRect(R, Left - xy[0], Top - xy[0],
                          Right + xy[0], Bottom + xy[0])
          else SetRect(R, Left - xy[0], Top - xy[0],
                          Right + xy[1], Bottom + xy[1]);
   end;

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?

tiziano

Reply by email