types.pp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2002 by Florian Klaempfl,
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$MODE OBJFPC}
  12. unit Types;
  13. interface
  14. {$modeswitch advancedrecords}
  15. {$modeswitch class}
  16. {$ifdef Windows}
  17. uses
  18. Windows;
  19. {$endif Windows}
  20. {$ifdef mswindows}
  21. const
  22. RT_RCDATA = Windows.RT_RCDATA deprecated 'Use Windows.RT_RCDATA instead';
  23. {$endif mswindows}
  24. type
  25. TEndian = (Big,Little);
  26. TDirection = (FromBeginning, FromEnd);
  27. TValueRelationship = -1..1;
  28. DWORD = LongWord;
  29. PLongint = System.PLongint;
  30. PSmallInt = System.PSmallInt;
  31. {$ifndef FPUNONE}
  32. PDouble = System.PDouble;
  33. {$endif}
  34. PByte = System.PByte;
  35. Largeint = int64;
  36. LARGE_INT = LargeInt;
  37. PLargeInt = ^LargeInt;
  38. LargeUint = qword;
  39. LARGE_UINT= LargeUInt;
  40. PLargeuInt = ^LargeuInt;
  41. TBooleanDynArray = array of Boolean;
  42. TByteDynArray = array of Byte;
  43. TCardinalDynArray = array of Cardinal;
  44. TInt64DynArray = array of Int64;
  45. TIntegerDynArray = array of Integer;
  46. TLongWordDynArray = array of LongWord;
  47. TPointerDynArray = array of Pointer;
  48. TQWordDynArray = array of QWord;
  49. TShortIntDynArray = array of ShortInt;
  50. TSmallIntDynArray = array of SmallInt;
  51. TStringDynArray = array of AnsiString;
  52. TWideStringDynArray = array of WideString;
  53. TWordDynArray = array of Word;
  54. TCurrencyArray = Array of currency;
  55. {$ifndef FPUNONE}
  56. TSingleDynArray = array of Single;
  57. TDoubleDynArray = array of Double;
  58. TExtendedDynArray = array of Extended;
  59. TCompDynArray = array of Comp;
  60. {$endif}
  61. {$ifdef Windows}
  62. TSmallPoint = Windows.TSmallPoint;
  63. PSmallPoint = Windows.PSmallPoint;
  64. TSize = Windows.TSize;
  65. TagSize = Windows.tagSize deprecated;
  66. PSize = Windows.PSize;
  67. TPoint = Windows.TPoint;
  68. TagPoint = Windows.TagPoint deprecated;
  69. PPoint = Windows.PPoint;
  70. TRect = Windows.TRect;
  71. PRect = Windows.PRect;
  72. {$else}
  73. {$i typshrdh.inc}
  74. TagSize = tSize deprecated;
  75. TagPoint = TPoint deprecated;
  76. {$endif}
  77. { TPointF }
  78. TPointF =
  79. {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
  80. packed
  81. {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
  82. record
  83. x,y : Single;
  84. public
  85. function Add(const apt: TPoint): TPointF;
  86. function Add(const apt: TPointF): TPointF;
  87. function Distance(const apt : TPointF) : Single;
  88. function DotProduct(const apt : TPointF) : Single;
  89. function IsZero : Boolean;
  90. function Subtract(const apt : TPointF): TPointF;
  91. function Subtract(const apt : TPoint): TPointF;
  92. procedure SetLocation(const apt :TPointF);
  93. procedure SetLocation(const apt :TPoint);
  94. procedure SetLocation(ax,ay : Longint);
  95. procedure Offset(const apt :TPointF);
  96. procedure Offset(const apt :TPoint);
  97. procedure Offset(dx,dy : Longint);
  98. function Scale (afactor:Single) : TPointF;
  99. function Ceiling : TPoint;
  100. function Truncate: TPoint;
  101. function Floor : TPoint;
  102. function Round : TPoint;
  103. function Length : Single;
  104. class operator = (const apt1, apt2 : TPointF) : Boolean;
  105. class operator <> (const apt1, apt2 : TPointF): Boolean;
  106. class operator + (const apt1, apt2 : TPointF): TPointF;
  107. class operator - (const apt1, apt2 : TPointF): TPointF;
  108. end;
  109. { TRectF }
  110. TRectF =
  111. {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
  112. packed
  113. {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
  114. record
  115. private
  116. function GetHeight: Single; inline;
  117. function GetWidth: Single; inline;
  118. procedure SetHeight(AValue: Single);
  119. procedure SetWidth (AValue: Single);
  120. public
  121. function Union (const r: TRectF):TRectF; inline;
  122. procedure Offset (const dx,dy : Single); inline;
  123. property Width : Single read GetWidth write SetWidth;
  124. property Height : Single read GetHeight write SetHeight;
  125. case Integer of
  126. 0: (Left, Top, Right, Bottom: Single);
  127. 1: (TopLeft, BottomRight: TPointF);
  128. end;
  129. TDuplicates = (dupIgnore, dupAccept, dupError);
  130. type
  131. TOleChar = WideChar;
  132. POleStr = PWideChar;
  133. PPOleStr = ^POleStr;
  134. TListCallback = procedure(data,arg:pointer) of object;
  135. TListStaticCallback = procedure(data,arg:pointer);
  136. const
  137. GUID_NULL: TGUID = '{00000000-0000-0000-0000-000000000000}';
  138. STGTY_STORAGE = 1;
  139. STGTY_STREAM = 2;
  140. STGTY_LOCKBYTES = 3;
  141. STGTY_PROPERTY = 4;
  142. STREAM_SEEK_SET = 0;
  143. STREAM_SEEK_CUR = 1;
  144. STREAM_SEEK_END = 2;
  145. LOCK_WRITE = 1;
  146. LOCK_EXCLUSIVE = 2;
  147. LOCK_ONLYONCE = 4;
  148. STATFLAG_DEFAULT = 0;
  149. STATFLAG_NONAME = 1;
  150. STATFLAG_NOOPEN = 2;
  151. {$ifndef Wince}
  152. // in Wince these are in unit windows. Under 32/64 in ActiveX.
  153. // for now duplicate them. Not that bad for untyped constants.
  154. E_FAIL = HRESULT($80004005);
  155. E_INVALIDARG = HRESULT($80070057);
  156. STG_E_INVALIDFUNCTION = HRESULT($80030001);
  157. STG_E_FILENOTFOUND = HRESULT($80030002);
  158. STG_E_PATHNOTFOUND = HRESULT($80030003);
  159. STG_E_TOOMANYOPENFILES = HRESULT($80030004);
  160. STG_E_ACCESSDENIED = HRESULT($80030005);
  161. STG_E_INVALIDHANDLE = HRESULT($80030006);
  162. STG_E_INSUFFICIENTMEMORY = HRESULT($80030008);
  163. STG_E_INVALIDPOINTER = HRESULT($80030009);
  164. STG_E_NOMOREFILES = HRESULT($80030012);
  165. STG_E_DISKISWRITEPROTECTED = HRESULT($80030013);
  166. STG_E_SEEKERROR = HRESULT($80030019);
  167. STG_E_WRITEFAULT = HRESULT($8003001D);
  168. STG_E_READFAULT = HRESULT($8003001E);
  169. STG_E_SHAREVIOLATION = HRESULT($80030020);
  170. STG_E_LOCKVIOLATION = HRESULT($80030021);
  171. STG_E_FILEALREADYEXISTS = HRESULT($80030050);
  172. STG_E_INVALIDPARAMETER = HRESULT($80030057);
  173. STG_E_MEDIUMFULL = HRESULT($80030070);
  174. STG_E_PROPSETMISMATCHED = HRESULT($800300F0);
  175. STG_E_ABNORMALAPIEXIT = HRESULT($800300FA);
  176. STG_E_INVALIDHEADER = HRESULT($800300FB);
  177. STG_E_INVALIDNAME = HRESULT($800300FC);
  178. STG_E_UNKNOWN = HRESULT($800300FD);
  179. STG_E_UNIMPLEMENTEDFUNCTION = HRESULT($800300FE);
  180. STG_E_INVALIDFLAG = HRESULT($800300FF);
  181. STG_E_INUSE = HRESULT($80030100);
  182. STG_E_NOTCURRENT = HRESULT($80030101);
  183. STG_E_REVERTED = HRESULT($80030102);
  184. STG_E_CANTSAVE = HRESULT($80030103);
  185. STG_E_OLDFORMAT = HRESULT($80030104);
  186. STG_E_OLDDLL = HRESULT($80030105);
  187. STG_E_SHAREREQUIRED = HRESULT($80030106);
  188. STG_E_EXTANTMARSHALLINGS = HRESULT($80030108);
  189. STG_E_DOCFILECORRUPT = HRESULT($80030109);
  190. STG_E_BADBASEADDRESS = HRESULT($80030110);
  191. STG_E_INCOMPLETE = HRESULT($80030201);
  192. STG_E_TERMINATED = HRESULT($80030202);
  193. STG_S_CONVERTED = $00030200;
  194. STG_S_BLOCK = $00030201;
  195. STG_S_RETRYNOW = $00030202;
  196. STG_S_MONITORING = $00030203;
  197. {$endif}
  198. {$ifndef Windows}
  199. type
  200. PCLSID = PGUID;
  201. TCLSID = TGUID;
  202. PDWord = ^DWord;
  203. PDisplay = Pointer;
  204. PEvent = Pointer;
  205. TXrmOptionDescRec = record
  206. end;
  207. XrmOptionDescRec = TXrmOptionDescRec;
  208. PXrmOptionDescRec = ^TXrmOptionDescRec;
  209. Widget = Pointer;
  210. WidgetClass = Pointer;
  211. ArgList = Pointer;
  212. Region = Pointer;
  213. _FILETIME =
  214. {$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
  215. packed
  216. {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
  217. record
  218. dwLowDateTime : DWORD;
  219. dwHighDateTime : DWORD;
  220. end;
  221. TFileTime = _FILETIME;
  222. FILETIME = _FILETIME;
  223. PFileTime = ^TFileTime;
  224. {$else}
  225. type
  226. PCLSID = Windows.PCLSID;
  227. TCLSID = Windows.CLSID;
  228. TFiletime = Windows.TFileTime;
  229. Filetime = Windows.FileTime;
  230. PFiletime = Windows.PFileTime;
  231. {$endif Windows}
  232. type
  233. tagSTATSTG = record
  234. pwcsName : POleStr;
  235. dwType : DWord;
  236. cbSize : Large_uint;
  237. mtime : TFileTime;
  238. ctime : TFileTime;
  239. atime : TFileTime;
  240. grfMode : DWord;
  241. grfLocksSupported : DWord;
  242. clsid : TCLSID;
  243. grfStateBits : DWord;
  244. reserved : DWord;
  245. end;
  246. TStatStg = tagSTATSTG;
  247. STATSTG = TStatStg;
  248. PStatStg = ^TStatStg;
  249. { classes depends on these interfaces, we can't use the activex unit in classes though }
  250. IClassFactory = Interface(IUnknown) ['{00000001-0000-0000-C000-000000000046}']
  251. Function CreateInstance(Const unkOuter : IUnknown;Const riid : TGUID;Out vObject) : HResult;StdCall;
  252. Function LockServer(fLock : LongBool) : HResult;StdCall;
  253. End;
  254. ISequentialStream = interface(IUnknown)
  255. ['{0c733a30-2a1c-11ce-ade5-00aa0044773d}']
  256. function Read(pv : Pointer;cb : DWORD;pcbRead : PDWORD) : HRESULT;stdcall;
  257. function Write(pv : Pointer;cb : DWORD;pcbWritten : PDWORD): HRESULT;stdcall;
  258. end;
  259. IStream = interface(ISequentialStream) ['{0000000C-0000-0000-C000-000000000046}']
  260. function Seek(dlibMove : LargeUInt; dwOrigin : Longint; out libNewPosition : LargeUInt) : HResult;stdcall;
  261. function SetSize(libNewSize : LargeUInt) : HRESULT;stdcall;
  262. function CopyTo(stm: IStream;cb : LargeUInt;out cbRead : LargeUInt; out cbWritten : LargeUInt) : HRESULT;stdcall;
  263. function Commit(grfCommitFlags : Longint) : HRESULT;stdcall;
  264. function Revert : HRESULT;stdcall;
  265. function LockRegion(libOffset : LargeUInt;cb : LargeUInt; dwLockType : Longint) : HRESULT;stdcall;
  266. function UnlockRegion(libOffset : LargeUInt;cb : LargeUInt; dwLockType : Longint) : HRESULT;stdcall;
  267. Function Stat(out statstg : TStatStg;grfStatFlag : Longint) : HRESULT;stdcall;
  268. function Clone(out stm : IStream) : HRESULT;stdcall;
  269. end;
  270. function EqualRect(const r1,r2 : TRect) : Boolean;
  271. function Rect(Left,Top,Right,Bottom : Integer) : TRect;
  272. function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
  273. function Point(x,y : Integer) : TPoint; inline;
  274. function PtInRect(const Rect : TRect; const p : TPoint) : Boolean;
  275. function IntersectRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
  276. function UnionRect(var Rect : TRect; const R1,R2 : TRect) : Boolean;
  277. function IsRectEmpty(const Rect : TRect) : Boolean;
  278. function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
  279. function CenterPoint(const Rect: TRect): TPoint;
  280. function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean;
  281. function Size(AWidth, AHeight: Integer): TSize;
  282. function Size(const ARect: TRect): TSize;
  283. implementation
  284. Uses Math;
  285. {$ifndef Windows}
  286. {$i typshrd.inc}
  287. {$endif}
  288. function EqualRect(const r1,r2 : TRect) : Boolean;
  289. begin
  290. EqualRect:=(r1.left=r2.left) and (r1.right=r2.right) and (r1.top=r2.top) and (r1.bottom=r2.bottom);
  291. end;
  292. function Rect(Left,Top,Right,Bottom : Integer) : TRect;
  293. begin
  294. Rect.Left:=Left;
  295. Rect.Top:=Top;
  296. Rect.Right:=Right;
  297. Rect.Bottom:=Bottom;
  298. end;
  299. function Bounds(ALeft,ATop,AWidth,AHeight : Integer) : TRect;
  300. begin
  301. Bounds.Left:=ALeft;
  302. Bounds.Top:=ATop;
  303. Bounds.Right:=ALeft+AWidth;
  304. Bounds.Bottom:=ATop+AHeight;
  305. end;
  306. function Point(x,y : Integer) : TPoint; inline;
  307. begin
  308. Point.x:=x;
  309. Point.y:=y;
  310. end;
  311. function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;
  312. begin
  313. PtInRect:=(p.y>=Rect.Top) and
  314. (p.y<Rect.Bottom) and
  315. (p.x>=Rect.Left) and
  316. (p.x<Rect.Right);
  317. end;
  318. function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
  319. var
  320. lRect: TRect;
  321. begin
  322. lRect := R1;
  323. if R2.Left > R1.Left then
  324. lRect.Left := R2.Left;
  325. if R2.Top > R1.Top then
  326. lRect.Top := R2.Top;
  327. if R2.Right < R1.Right then
  328. lRect.Right := R2.Right;
  329. if R2.Bottom < R1.Bottom then
  330. lRect.Bottom := R2.Bottom;
  331. // The var parameter is only assigned in the end to avoid problems
  332. // when passing the same rectangle in the var and const parameters.
  333. // See http://bugs.freepascal.org/view.php?id=17722
  334. if IsRectEmpty(lRect) then
  335. begin
  336. FillChar(Rect,SizeOf(Rect),0);
  337. IntersectRect:=false;
  338. end
  339. else
  340. begin
  341. IntersectRect:=true;
  342. Rect := lRect;
  343. end;
  344. end;
  345. function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;
  346. var
  347. lRect: TRect;
  348. begin
  349. lRect:=R1;
  350. if R2.Left<R1.Left then
  351. lRect.Left:=R2.Left;
  352. if R2.Top<R1.Top then
  353. lRect.Top:=R2.Top;
  354. if R2.Right>R1.Right then
  355. lRect.Right:=R2.Right;
  356. if R2.Bottom>R1.Bottom then
  357. lRect.Bottom:=R2.Bottom;
  358. if IsRectEmpty(lRect) then
  359. begin
  360. FillChar(Rect,SizeOf(Rect),0);
  361. UnionRect:=false;
  362. end
  363. else
  364. begin
  365. Rect:=lRect;
  366. UnionRect:=true;
  367. end;
  368. end;
  369. function IsRectEmpty(const Rect : TRect) : Boolean;
  370. begin
  371. IsRectEmpty:=(Rect.Right<=Rect.Left) or (Rect.Bottom<=Rect.Top);
  372. end;
  373. function OffsetRect(var Rect : TRect;DX : Integer;DY : Integer) : Boolean;
  374. begin
  375. if assigned(@Rect) then
  376. begin
  377. with Rect do
  378. begin
  379. inc(Left,dx);
  380. inc(Top,dy);
  381. inc(Right,dx);
  382. inc(Bottom,dy);
  383. end;
  384. OffsetRect:=true;
  385. end
  386. else
  387. OffsetRect:=false;
  388. end;
  389. function Avg(a, b: Longint): Longint;
  390. begin
  391. if a < b then
  392. Result := a + ((b - a) shr 1)
  393. else
  394. Result := b + ((a - b) shr 1);
  395. end;
  396. function CenterPoint(const Rect: TRect): TPoint;
  397. begin
  398. with Rect do
  399. begin
  400. Result.X := Avg(Left, Right);
  401. Result.Y := Avg(Top, Bottom);
  402. end;
  403. end;
  404. function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean;
  405. begin
  406. if Assigned(@Rect) then
  407. begin
  408. with Rect do
  409. begin
  410. dec(Left, dx);
  411. dec(Top, dy);
  412. inc(Right, dx);
  413. inc(Bottom, dy);
  414. end;
  415. Result := True;
  416. end
  417. else
  418. Result := False;
  419. end;
  420. function Size(AWidth, AHeight: Integer): TSize;
  421. begin
  422. Result.cx := AWidth;
  423. Result.cy := AHeight;
  424. end;
  425. function Size(const ARect: TRect): TSize;
  426. begin
  427. Result.cx := ARect.Right - ARect.Left;
  428. Result.cy := ARect.Bottom - ARect.Top;
  429. end;
  430. { TPointF}
  431. function TPointF.Add(const apt: TPoint): TPointF;
  432. begin
  433. result.x:=x+apt.x;
  434. result.y:=y+apt.y;
  435. end;
  436. function TPointF.Add(const apt: TPointF): TPointF;
  437. begin
  438. result.x:=x+apt.x;
  439. result.y:=y+apt.y;
  440. end;
  441. function TPointF.Subtract(const apt : TPointF): TPointF;
  442. begin
  443. result.x:=x-apt.x;
  444. result.y:=y-apt.y;
  445. end;
  446. function TPointF.Subtract(const apt: TPoint): TPointF;
  447. begin
  448. result.x:=x-apt.x;
  449. result.y:=y-apt.y;
  450. end;
  451. function TPointF.Distance(const apt : TPointF) : Single;
  452. begin
  453. result:=sqrt(sqr(apt.x-x)+sqr(apt.y-y));
  454. end;
  455. function TPointF.DotProduct(const apt: TPointF): Single;
  456. begin
  457. result:=x*apt.x+y*apt.y;
  458. end;
  459. function TPointF.IsZero : Boolean;
  460. begin
  461. result:=SameValue(x,0.0) and SameValue(y,0.0);
  462. end;
  463. procedure TPointF.Offset(const apt :TPointF);
  464. begin
  465. x:=x+apt.x;
  466. y:=y+apt.y;
  467. end;
  468. procedure TPointF.Offset(const apt: TPoint);
  469. begin
  470. x:=x+apt.x;
  471. y:=y+apt.y;
  472. end;
  473. procedure TPointF.Offset(dx,dy : Longint);
  474. begin
  475. x:=x+dx;
  476. y:=y+dy;
  477. end;
  478. function TPointF.Scale(afactor: Single): TPointF;
  479. begin
  480. result.x:=afactor*x;
  481. result.y:=afactor*y;
  482. end;
  483. function TPointF.Ceiling: TPoint;
  484. begin
  485. result.x:=ceil(x);
  486. result.y:=ceil(y);
  487. end;
  488. function TPointF.Truncate: TPoint;
  489. begin
  490. result.x:=trunc(x);
  491. result.y:=trunc(y);
  492. end;
  493. function TPointF.Floor: TPoint;
  494. begin
  495. result.x:=Math.floor(x);
  496. result.y:=Math.floor(y);
  497. end;
  498. function TPointF.Round: TPoint;
  499. begin
  500. result.x:=System.round(x);
  501. result.y:=System.round(y);
  502. end;
  503. function TPointF.Length: Single;
  504. begin //distance(self) ?
  505. result:=sqrt(sqr(x)+sqr(y));
  506. end;
  507. class operator TPointF.= (const apt1, apt2 : TPointF) : Boolean;
  508. begin
  509. result:=SameValue(apt1.x,apt2.x) and SameValue(apt1.y,apt2.y);
  510. end;
  511. class operator TPointF.<> (const apt1, apt2 : TPointF): Boolean;
  512. begin
  513. result:=NOT (SameValue(apt1.x,apt2.x) and Samevalue(apt1.y,apt2.y));
  514. end;
  515. class operator TPointF.+ (const apt1, apt2 : TPointF): TPointF;
  516. begin
  517. result.x:=apt1.x+apt2.x;
  518. result.y:=apt1.y+apt2.y;
  519. end;
  520. class operator TPointF.- (const apt1, apt2 : TPointF): TPointF;
  521. begin
  522. result.x:=apt1.x-apt2.x;
  523. result.y:=apt1.y-apt2.y;
  524. end;
  525. procedure TPointF.SetLocation(const apt :TPointF);
  526. begin
  527. x:=apt.x; y:=apt.y;
  528. end;
  529. procedure TPointF.SetLocation(const apt: TPoint);
  530. begin
  531. x:=apt.x; y:=apt.y;
  532. end;
  533. procedure TPointF.SetLocation(ax,ay : Longint);
  534. begin
  535. x:=ax; y:=ay;
  536. end;
  537. { TRectF }
  538. function TRectF.GetHeight: Single;
  539. begin
  540. result:=bottom-top;
  541. end;
  542. function TRectF.GetWidth: Single;
  543. begin
  544. result:=right-left;
  545. end;
  546. procedure TRectF.SetHeight(AValue: Single);
  547. begin
  548. bottom:=top+avalue;
  549. end;
  550. procedure TRectF.SetWidth(AValue: Single);
  551. begin
  552. right:=left+avalue;
  553. end;
  554. function TRectF.Union(const r: TRectF): TRectF;
  555. begin
  556. result.left:=min(r.left,left);
  557. result.top:=min(r.top,top);
  558. result.right:=min(r.right,right);
  559. result.bottom:=min(r.bottom,bottom);
  560. end;
  561. procedure TRectF.Offset(const dx, dy: Single);
  562. begin
  563. left:=left+dx; right:=right+dx;
  564. bottom:=bottom+dy; top:=top+dy;
  565. end;
  566. end.