32 #include "CEGUI/Vector.h"
33 #include "CEGUI/Size.h"
44 public AllocatedObject<Rect<T> >
52 inline Rect(
const T& left,
const T& top,
const T& right,
const T& bottom):
57 inline Rect(
const Vector2<T>& min,
const Vector2<T>& max):
62 inline Rect(
const Vector2<T>& pos,
const Size<T>& size):
64 d_max(pos + Vector2<T>(size.d_width, size.d_height))
67 inline Rect(
const Rect& r):
72 inline Rect& operator=(
const Rect& rhs)
80 inline void left(
const T& v)
85 inline const T& left()
const
90 inline void top(
const T& v)
95 inline const T& top()
const
100 inline void right(
const T& v)
105 inline const T& right()
const
110 inline void bottom(
const T& v)
115 inline const T& bottom()
const
140 void setSize(
const Size<T>& size)
142 d_max = d_min +
Vector2<T>(size.d_width, size.d_height);
154 void setWidth(
const T& w)
156 d_max.d_x = d_min.d_x + w;
165 return d_max.d_x - d_min.d_x;
168 void setHeight(
const T& h)
170 d_max.d_y = d_min.d_y + h;
179 return d_max.d_y - d_min.d_y;
192 if ((d_max.d_x > rect.d_min.d_x) &&
193 (d_min.d_x < rect.d_max.d_x) &&
194 (d_max.d_y > rect.d_min.d_y) &&
195 (d_min.d_y < rect.d_max.d_y))
200 ret.d_min.d_x = (d_min.d_x > rect.d_min.d_x) ? d_min.d_x : rect.d_min.d_x;
201 ret.d_max.d_x = (d_max.d_x < rect.d_max.d_x) ? d_max.d_x : rect.d_max.d_x;
202 ret.d_min.d_y = (d_min.d_y > rect.d_min.d_y) ? d_min.d_y : rect.d_min.d_y;
203 ret.d_max.d_y = (d_max.d_y < rect.d_max.d_y) ? d_max.d_y : rect.d_max.d_y;
209 return Rect(0.0f, 0.0f, 0.0f, 0.0f);
241 if ((d_min.d_x > v.d_x) ||
242 (d_max.d_x <= v.d_x) ||
243 (d_min.d_y > v.d_y) ||
244 (d_max.d_y <= v.d_y))
267 setWidth(size.d_width);
272 setHeight(size.d_height);
291 setWidth(size.d_width);
296 setHeight(size.d_height);
318 if (curr_sz.d_width > max_sz.d_width)
320 setWidth(max_sz.d_width);
322 else if (curr_sz.d_width < min_sz.d_width)
324 setWidth(min_sz.d_width);
327 if (curr_sz.d_height > max_sz.d_height)
329 setHeight(max_sz.d_height);
331 else if (curr_sz.d_height < min_sz.d_height)
333 setHeight(min_sz.d_height);
341 inline bool operator==(
const Rect& rhs)
const
343 return ((d_min == rhs.d_min) && (d_max == rhs.d_max));
346 inline bool operator!=(
const Rect& rhs)
const
348 return !operator==(rhs);
351 inline Rect operator*(T scalar)
const
353 return Rect(d_min * scalar, d_max * scalar);
356 const Rect& operator*=(T scalar)
363 Rect operator+(
const Rect& r)
const
365 return Rect(d_min + r.d_min, d_max + r.d_max);
368 inline friend std::ostream& operator << (std::ostream& s,
const Rect& v)
370 s <<
"CEGUI::Rect<" <<
typeid(T).name() <<
">(" << v.d_min.d_x <<
", " << v.d_min.d_y <<
", " << v.d_max.d_x <<
", " << v.d_max.d_y <<
")";
393 typedef Rect<float> Rectf;
396 inline Rect<UDim> operator * (
const Rect<UDim>& v,
const float c)
398 return Rect<UDim>(v.d_min * c, v.d_max * c);
401 typedef Rect<UDim> URect;
406 #endif // end of guard _CEGUIRect_h_