Sign in Join

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

Mailing lists / fpc-devel / 2006-07

Size() function

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Would there be a use for these funtions in the Types.pas unit? They do what Point() does for TPoint...

function Size(AWidth, AHeight: Integer): TSize;
function Size(ARect: TRect): TSize;

Regards,
Graeme.

There's no place like 127.0.0.1

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
Would there be a use for these funtions in the Types.pas unit? They do what Point() does for TPoint... function Size(AWidth, AHeight: Integer): TSize; function Size(ARect: TRect): TSize;

You mean it would compute the surface size ?

Michael.

Reply by email

Micha Nelissen
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
> function Size(AWidth, AHeight: Integer): TSize; > function Size(ARect: TRect): TSize; You mean it would compute the surface size ?

No, TSize is a record with a Width and a Height member.

Micha

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: You mean it would compute the surface size ? Michael.
Show quoted text 7 lines
> Would there be a use for these funtions in the Types.pas unit? They > do what Point() does for TPoint... > > function Size(AWidth, AHeight: Integer): TSize; > function Size(ARect: TRect): TSize; You mean it would compute the surface size ?

They return a TSize record, same as Point() returns a TPoint record. I don't know why Size() wasn't included in the first place and Point() & Rect() was?

-------------------------
function Size(AWidth, AHeight: Integer): TSize;
begin
  Result.cx := AWidth;
  Result.cy := AHeight;
end;
function Size(ARect: TRect): TSize;
begin
  Result.cx := ARect.Right - ARect.Left;
  Result.cy := ARect.Bottom - ARect.Top;
end;
-------------------------

I also have a few arithmetic operator functions that work against TPoint, TSize and TRect so you can compare for example two TSize records against each other, etc...

operator = (const ASize1, ASize2: TSize) b: Boolean;
operator + (const APoint1, APoint2: TPoint) p: TPoint;
operator + (const APoint: TPoint; ASize: TSize) p: TPoint;
operator + (const ASize: TSize; APoint: TPoint) s: TSize;
operator + (const ASize1, ASize2: TSize) s: TSize;
operator + (const APoint: TPoint; i: Integer) p: TPoint;
operator + (const ASize: TSize; i: Integer) s: TSize;
operator - (const APoint1, APoint2: TPoint) p: TPoint;
operator - (const APoint: TPoint; i: Integer) p: TPoint;
operator - (const ASize: TSize; const APoint: TPoint) s: TSize;
operator - (const ASize: TSize; i: Integer) s: TSize;
[...]

Graeme.

There's no place like 127.0.0.1

Reply by email