source: trunk/src/ddraw/rectangle.h@ 312

Last change on this file since 312 was 312, checked in by hugh, 26 years ago

Added rectangle.h to remove dep. within IBM classes

File size: 2.0 KB
Line 
1#ifndef __DDRectandle
2 #define __DDRectandle
3
4#include <ibase.hpp>
5
6class DDRectangle : public IBase {
7typedef IBase
8 Inherited;
9public:
10/*------------------------------ Related Types -------------------------------*/
11 typedef long Coord;
12
13/*------------------------------- Constructors -------------------------------*/
14 DDRectangle ( );
15
16
17 DDRectangle ( Coord point1X,
18 Coord point1Y,
19 Coord point2X,
20 Coord point2Y );
21
22
23/*------------------------------- Comparisons --------------------------------*/
24Boolean
25 operator == ( const DDRectangle& rectangle ) const,
26 operator != ( const DDRectangle& rectangle ) const;
27
28/*--------------------------------- Testing ----------------------------------*/
29Boolean
30 intersects ( const DDRectangle& rectangle ) const;
31
32Coord
33 width() const,
34 height() const;
35
36/*--------------------------------- Synonyms ---------------------------------
37
38Coord
39 bottom ( ) const,
40 left ( ) const,
41 right ( ) const,
42 top ( ) const;
43*/
44
45private:
46 long lTop,lLeft;
47 long lBottom,lRight;
48}; // class DDRectangle
49
50DDRectangle :: DDRectangle ( Coord y1,
51 Coord x1,
52 Coord y2,
53 Coord x2 )
54{
55 lTop = y1;
56 lLeft = x1;
57 lBottom = y2;
58 lRight = x2;
59}
60
61IBase::Boolean DDRectangle :: operator == ( const DDRectangle &aRect ) const
62 {
63 return ( lTop == aRect.lTop && lLeft == aRect.lLeft
64 &&
65 lBottom == aRect.lBottom && lRight == aRect.lRight);
66 }
67IBase::Boolean DDRectangle :: operator != ( const DDRectangle& aRect ) const
68 {
69 return !( *this == aRect );
70 }
71IBase::Boolean DDRectangle :: intersects ( const DDRectangle &aRect ) const
72{
73 return ( lTop < aRect.lBottom && lLeft<aRect.lRight
74 &&
75 aRect.lTop < lBottom && aRect.lLeft < lRight );
76}
77
78DDRectangle::Coord DDRectangle :: width ( ) const
79{
80 return ( lRight - lLeft);
81}
82
83DDRectangle::Coord DDRectangle :: height ( ) const
84{
85 return ( lBottom - lTop);
86}
87
88#endif
Note: See TracBrowser for help on using the repository browser.