areai.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. }
  17. Constructor TPTCArea.Create(_left, _top, _right, _bottom : Integer);
  18. Begin
  19. If _left < _right Then
  20. Begin
  21. Fleft := _left;
  22. Fright := _right;
  23. End
  24. Else
  25. Begin
  26. Fleft := _right;
  27. Fright := _left;
  28. End;
  29. If _top < _bottom Then
  30. Begin
  31. Ftop := _top;
  32. Fbottom := _bottom;
  33. End
  34. Else
  35. Begin
  36. Ftop := _bottom;
  37. Fbottom := _top;
  38. End;
  39. End;
  40. Constructor TPTCArea.Create;
  41. Begin
  42. Fleft := 0;
  43. Fright := 0;
  44. Ftop := 0;
  45. Fbottom := 0;
  46. End;
  47. Constructor TPTCArea.Create(Const area : TPTCArea);
  48. Begin
  49. ASSign(area);
  50. End;
  51. Destructor TPTCArea.Destroy;
  52. Begin
  53. Inherited Destroy;
  54. End;
  55. Procedure TPTCArea.Assign(Const area : TPTCArea);
  56. Begin
  57. If Self = area Then
  58. Raise TPTCError.Create('self assignment is not allowed');
  59. Fleft := area.Fleft;
  60. Ftop := area.Ftop;
  61. Fright := area.Fright;
  62. Fbottom := area.Fbottom;
  63. End;
  64. Function TPTCArea.Equals(Const area : TPTCArea) : Boolean;
  65. Begin
  66. Equals := (Fleft = area.Fleft) And
  67. (Ftop = area.Ftop) And
  68. (Fright = area.Fright) And
  69. (Fbottom = area.Fbottom);
  70. End;
  71. Function TPTCArea.width : Integer;
  72. Begin
  73. width := Fright - Fleft;
  74. End;
  75. Function TPTCArea.height : Integer;
  76. Begin
  77. height := Fbottom - Ftop;
  78. End;