Recent

Author Topic: [SOLVED] No Rect helpers?  (Read 1900 times)

knuckles

  • Full Member
  • ***
  • Posts: 122
[SOLVED] No Rect helpers?
« on: May 05, 2016, 02:37:21 am »
Coming from Delphi and back to Lazarus there is one little niggly thing bothering me.

In Delphi when accessing a TRect you have available functions such as R.Height and R.Width as well as IsRectEmpty for example.

In Lazarus however there only appears to be access to the Top, Right, Bottom of the rect etc.

Coding this yourself is not particularly difficult however, for example:

Code: Pascal  [Select][+][-]
  1. function GetRectHeight(ARect: TRect): Integer;
  2. begin
  3.   Result := ARect.Bottom + ARect.Top;
  4. end;
  5.  
  6. function GetRectWidth(ARect: TRect): Integer;
  7. begin
  8.   Result := ARect.Left + ARect.Right;
  9. end;
  10.  
  11. function RectEmpty(ARect: TRect): Boolean;
  12. begin
  13.   Result := (ARect.Right <= ARect.Left) or (ARect.Bottom <= ARect.Top);
  14. end;  

I guess I was hoping for a built-in solution if there exists one?
« Last Edit: May 05, 2016, 08:50:41 pm by knuckles »

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: No Rect helpers?
« Reply #1 on: May 05, 2016, 03:12:48 am »
revision 32998 and up, if not mistaken.

knuckles

  • Full Member
  • ***
  • Posts: 122
Re: No Rect helpers?
« Reply #2 on: May 05, 2016, 04:02:34 am »
Thanks, i should have said I was using Lazarus 1.6 and those dont seem available.

Will look again tomorrow thanks.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: No Rect helpers?
« Reply #3 on: May 05, 2016, 04:08:38 am »
afaik lazarus 1,.6 comes with fpc 3.0.0. teh latter was released (at least announced) on nov 26th. So you would have to use a trunk version (3.1.1) of FPC for that.

It is always possible to write/copy the operators and/or write temporary record helpers to aid you (while waiting for a new official stable release).

 

TinyPortal © 2005-2018