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.

Mailing lists / fpc-devel / 2006-07
4 messages · 3 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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.
You mean it would compute the surface size ?
Michael.
No, TSize is a record with a Width and a Height member.
Micha
You mean it would compute the surface size ? Michael.
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.