[fpc-devel] An enhanced TRect

Michael Van Canneyt michael at freepascal.org
Fri Aug 10 16:26:37 CEST 2007



On Fri, 10 Aug 2007, Graeme Geldenhuys wrote:

> Hi,
> 
> In fpGUI I created a enhanced Rectangle structure called TfpgRect. It
> is defined as follows:
> 
>   TfpgCoord = integer;  // could change to floating point in the future.
> 
>   TfpgRect = object  // not class for static allocations
>     Top: TfpgCoord;
>     Left: TfpgCoord;
>     Width: TfpgCoord;
>     Height: TfpgCoord;
>     procedure SetRect(aLeft, aTop, aWidth, aHeight: TfpgCoord);
>     function  Bottom: TfpgCoord;
>     function  Right: TfpgCoord;
>     procedure SetBottom(Value: TfpgCoord);
>     procedure SetRight(Value: TfpgCoord);
>   end;
> 
> TfpgRect prevents minor calculation errors or 'on the spot
> calculations' for parameters like when calculating the Width of a
> rectangle etc.  It promotes the use of Top, Left, Width and Height and
> calculates for you Right and Bottom. You can also set Right and
> Bottom, in which case it calculates Width and Height.
> 
> Anyway, a fpGUI user asked me the following.  Could TfpgRect replace
> or merge with TRect in FPC itself.  He found the same problem
> (limitations) mentioned below in many applications and constantly have
> to define similar custom rectangle structures for is applications and
> floating point rectangle structures.
> 
> Would such a merge be possible?  What would the implications be? I
> couldn't give him an exact answer.  For one, Windows API calls require
> a TRect which doesn't support Width and Height in the structure, etc..
> I'm sure other platforms will have similar issues.
> 
> What's your thoughts on this?  Is it possible to merge this structure
> into FPC itself replacing TRect?

Unfortunately not. 

TRect needs to be Delphi & Windows compatible.

Michael.



More information about the fpc-devel mailing list