You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. *
  9. *
  10. */
  11. #if defined( Uses_TRect ) && !defined( __TRect )
  12. #define __TRect
  13. class TRect
  14. {
  15. public:
  16. TRect( int ax, int ay, int bx, int by );
  17. TRect( TPoint p1, TPoint p2 );
  18. TRect();
  19. void move( int aDX, int aDY );
  20. void grow( int aDX, int aDY );
  21. void intersect( const TRect& r );
  22. void Union( const TRect& r );
  23. Boolean contains( const TPoint& p ) const;
  24. Boolean operator == ( const TRect& r ) const;
  25. Boolean operator != ( const TRect& r ) const;
  26. Boolean isEmpty();
  27. TPoint a, b;
  28. };
  29. inline TRect::TRect( int ax, int ay, int bx, int by)
  30. {
  31. a.x = ax;
  32. a.y = ay;
  33. b.x = bx;
  34. b.y = by;
  35. }
  36. inline TRect::TRect( TPoint p1, TPoint p2 )
  37. {
  38. a = p1;
  39. b = p2;
  40. }
  41. inline TRect::TRect()
  42. {
  43. }
  44. inline void TRect::move( int aDX, int aDY )
  45. {
  46. a.x += aDX;
  47. a.y += aDY;
  48. b.x += aDX;
  49. b.y += aDY;
  50. }
  51. inline void TRect::grow( int aDX, int aDY )
  52. {
  53. a.x -= aDX;
  54. a.y -= aDY;
  55. b.x += aDX;
  56. b.y += aDY;
  57. }
  58. inline void TRect::intersect( const TRect& r )
  59. {
  60. a.x = max( a.x, r.a.x );
  61. a.y = max( a.y, r.a.y );
  62. b.x = min( b.x, r.b.x );
  63. b.y = min( b.y, r.b.y );
  64. }
  65. inline void TRect::Union( const TRect& r )
  66. {
  67. a.x = min( a.x, r.a.x );
  68. a.y = min( a.y, r.a.y );
  69. b.x = max( b.x, r.b.x );
  70. b.y = max( b.y, r.b.y );
  71. }
  72. inline Boolean TRect::contains( const TPoint& p ) const
  73. {
  74. return Boolean(
  75. p.x >= a.x && p.x < b.x && p.y >= a.y && p.y < b.y
  76. );
  77. }
  78. inline Boolean TRect::operator == ( const TRect& r) const
  79. {
  80. return Boolean( a == r.a && b == r.b );
  81. }
  82. inline Boolean TRect::operator != ( const TRect& r ) const
  83. {
  84. return Boolean( !(*this == r) );
  85. }
  86. inline Boolean TRect::isEmpty()
  87. {
  88. return Boolean( a.x >= b.x || a.y >= b.y );
  89. }
  90. inline ipstream& operator >> ( ipstream& is, TRect& r )
  91. { return is >> r.a >> r.b; }
  92. inline ipstream& operator >> ( ipstream& is, TRect*& r )
  93. { return is >> r->a >> r->b; }
  94. inline opstream& operator << ( opstream& os, TRect& r )
  95. { return os << r.a << r.b; }
  96. inline opstream& operator << ( opstream& os, TRect* r )
  97. { return os << r->a << r->b; }
  98. #endif // Uses_TRect