Populous: The Beginning Script 3  1.0.0
Documentation for Populous Script 3 engine

◆ LB_API_CLASS()

LB_API_CLASS ( TbRect  )

Definition at line 10 of file TbRect.h.

11 {
12  LB_PUBLIC_MEMBERS
13  SINT Left, Top, Right, Bottom;
14 
15  inline void Set(SINT l, SINT t, SINT r, SINT b)
16  {
17  Left = l;
18  Right = r;
19  Top = t;
20  Bottom = b;
21  };
22 
23  // default Constructor
24  TbRect()
25  {
26  Left = Top = Right = Bottom = 0;
27  };
28 
29  // all the bits constructor
30  TbRect(SINT l, SINT t, SINT r, SINT b)
31  {
32  Set(l, t, r, b);
33  };
34 
35  // a point and size constructor
36  TbRect(const Pop3Point& Point, const Pop3Size& Size)
37  {
38  Left = Point.X;
39  Top = Point.Y;
40  Right = Point.X + Size.Width;
41  Bottom = Point.Y + Size.Height;
42  }
43 
44  // a size only constructor
45  TbRect(const Pop3Size& size)
46  {
47  Left = 0;
48  Top = 0;
49  Right = size.Width;
50  Bottom = size.Height;
51  }
52 
53  TbRect(const Pop3Point& topLeft, const Pop3Point& botRight)
54  {
55  Left = topLeft.X;
56  Top = topLeft.Y;
57  Right = botRight.X;
58  Bottom = botRight.Y;
59  }
60 
61  // assignment
62  //TbRect operator=( const TbRect& rhs ) { Left=rhs.Left; Right=rhs.Right; Top=rhs.Top; Bottom=rhs.Bottom; return *this;}
63  TbRect operator=(const Pop3Point& rhs)
64  {
65  Left = rhs.X;
66  Right = rhs.X;
67  Top = rhs.Y;
68  Bottom = rhs.Y;
69  return *this;
70  }
71 
72  TbRect operator=(const Pop3Size& rhs)
73  {
74  Left = 0;
75  Right = rhs.Width;
76  Top = 0;
77  Bottom = rhs.Height;
78  return *this;
79  }
80 
81  // Comparison
82  BOOL operator==(const TbRect& a) const
83  {
84  return ((Left == a.Left) && (Right == a.Right) && (Top == a.Top) && (Bottom == a.Bottom));
85  };
86 
87  BOOL operator!=(const TbRect& a) const
88  {
89  return ((Left != a.Left) || (Right != a.Right) || (Top != a.Top) || (Bottom != a.Bottom));
90  };
91 
92  // Decompose into size and point
93  Pop3Point GetPosition() const
94  {
95  return Pop3Point(Left, Top);
96  };
97 
98  Pop3Size GetSize() const
99  {
100  return Pop3Size(UINT(Right - Left), UINT(Bottom - Top));
101  };
102 
103  Pop3Point GetBottomRight() const
104  {
105  return Pop3Point(Right, Bottom);
106  };
107 
108  Pop3Point GetTopRight() const
109  {
110  return Pop3Point(Right, Top);
111  };
112 
113  Pop3Point GetBottomLeft() const
114  {
115  return Pop3Point(Left, Bottom);
116  };
117 
118  // alter the size
119  void Grow(SINT dx, SINT dy)
120  {
121  Left -= dx;
122  Right += dx;
123  Top -= dy;
124  Bottom += dy;
125  };
126 
127  void Shrink(SINT dx, SINT dy)
128  {
129  Left += dx;
130  Right -= dx;
131  Top += dy;
132  Bottom -= dy;
133  };
134 
135  // Intersection
136  TbRect Intersection(const TbRect& a) const;
137  BOOL Intersects(const TbRect& a) const;
138 
139  // Containment check
140  BOOL Contains(const Pop3Point& a) const
141  {
142  return ((a.X >= Left) && (a.X < Right) && (a.Y >= Top) && (a.Y < Bottom));
143  };
144 
145  BOOL Contains(const TbRect& a) const
146  {
147  return ((Left <= a.Left) && (Top <= a.Top) && (Right >= a.Right) && (Bottom >= a.Bottom));
148  };
149 
150  // Repositioning via arithmetic operations
151  TbRect operator+(const Pop3Point& a) const
152  {
153  return TbRect(Left + a.X, Top + a.Y, Right + a.X, Bottom + a.Y);
154  };
155 
156  TbRect operator-(const Pop3Point& a) const
157  {
158  return TbRect(Left - a.X, Top - a.Y, Right - a.X, Bottom - a.Y);
159  };
160 
161  TbRect operator+=(const Pop3Point& a)
162  {
163  Left += a.X;
164  Top += a.Y;
165  Right += a.X;
166  Bottom += a.Y;
167  return *this;
168  };
169 
170  TbRect operator-=(const Pop3Point& a)
171  {
172  Left -= a.X;
173  Top -= a.Y;
174  Right -= a.X;
175  Bottom -= a.Y;
176  return *this;
177  };
178 
179  // Repositioning and resizing
180  void Empty()
181  {
182  Right = Left;
183  Bottom = Top;
184  };
185  void Offset(Pop3Point& a)
186  {
187  Offset(TbPoint(a));
188  }
189 
190  void Offset(TbPoint& a);
191 
192  void SetPosition(const Pop3Point& a);
193  void SetPosition(SINT x, SINT y);
194  void SetBottomRight(const Pop3Point& a);
195  void SetBottomRight(SINT x, SINT y);
196 
197  void SetSize(const TbSize& a);
198 
199  void SetSize(const Pop3Size& a)
200  {
201  SetSize(TbSize(a));
202  }
203 
204  void Set(const Pop3Point& topleft, const Pop3Size& size)
205  {
206  SetPosition(topleft);
207  SetSize(size);
208  };
209 
210  void Set(const Pop3Point& topleft, const Pop3Point& botright)
211  {
212  SetPosition(topleft);
213  SetBottomRight(botright);
214  };
215 
216  // Null check
217  BOOL IsNull() const
218  {
219  return ((Left == Right) || (Top == Bottom));
220  };
221 
222  BOOL IsEmpty() const
223  {
224  return ((Left == Right) || (Top == Bottom));
225  };
226 
227  // Normalised Check
228  BOOL IsNormal() const;
229 
230  // Return Width of rectangle
231  SINT Width() const
232  {
233  return Right - Left;
234  };
235 
236  // Return Height of rectangle
237  SINT Height() const
238  {
239  return Bottom - Top;
240  };
241 
242  // Calculate bounding rectangle
243  TbRect Bounding(const TbRect& a) const;
244 
245  // Normalise
246  void Normalise();
247 };
bool operator!=(const ThingNum &lhs, const ObjectProxy &rhs)
bool operator==(const ThingNum &lhs, const ObjectProxy &rhs)

References operator!=(), and operator==().