33 #include "CEGUI/Vector.h"
34 #include "CEGUI/Size.h"
45 public AllocatedObject<Rect<T> >
53 inline Rect(
const T& left,
const T& top,
const T& right,
const T& bottom):
58 inline Rect(
const Vector2<T>& min,
const Vector2<T>& max):
63 inline Rect(
const Vector2<T>& pos,
const Size<T>& size):
65 d_max(pos + Vector2<T>(size.d_width, size.d_height))
68 inline Rect(
const Rect& r):
73 inline Rect& operator=(
const Rect& rhs)
81 inline void left(
const T& v)
86 inline const T& left()
const
91 inline void top(
const T& v)
96 inline const T& top()
const
101 inline void right(
const T& v)
106 inline const T& right()
const
111 inline void bottom(
const T& v)
116 inline const T& bottom()
const
141 void setSize(
const Size<T>& size)
143 d_max = d_min +
Vector2<T>(size.d_width, size.d_height);
155 void setWidth(
const T& w)
157 d_max.d_x = d_min.d_x + w;
166 return d_max.d_x - d_min.d_x;
169 void setHeight(
const T& h)
171 d_max.d_y = d_min.d_y + h;
180 return d_max.d_y - d_min.d_y;
193 if ((d_max.d_x > rect.d_min.d_x) &&
194 (d_min.d_x < rect.d_max.d_x) &&
195 (d_max.d_y > rect.d_min.d_y) &&
196 (d_min.d_y < rect.d_max.d_y))
201 ret.d_min.d_x = (d_min.d_x > rect.d_min.d_x) ? d_min.d_x : rect.d_min.d_x;
202 ret.d_max.d_x = (d_max.d_x < rect.d_max.d_x) ? d_max.d_x : rect.d_max.d_x;
203 ret.d_min.d_y = (d_min.d_y > rect.d_min.d_y) ? d_min.d_y : rect.d_min.d_y;
204 ret.d_max.d_y = (d_max.d_y < rect.d_max.d_y) ? d_max.d_y : rect.d_max.d_y;
210 return Rect(0.0f, 0.0f, 0.0f, 0.0f);
242 if ((d_min.d_x > v.d_x) ||
243 (d_max.d_x <= v.d_x) ||
244 (d_min.d_y > v.d_y) ||
245 (d_max.d_y <= v.d_y))
268 setWidth(size.d_width);
273 setHeight(size.d_height);
292 setWidth(size.d_width);
297 setHeight(size.d_height);
319 if (curr_sz.d_width > max_sz.d_width)
321 setWidth(max_sz.d_width);
323 else if (curr_sz.d_width < min_sz.d_width)
325 setWidth(min_sz.d_width);
328 if (curr_sz.d_height > max_sz.d_height)
330 setHeight(max_sz.d_height);
332 else if (curr_sz.d_height < min_sz.d_height)
334 setHeight(min_sz.d_height);
342 inline bool operator==(
const Rect& rhs)
const
344 return ((d_min == rhs.d_min) && (d_max == rhs.d_max));
347 inline bool operator!=(
const Rect& rhs)
const
349 return !operator==(rhs);
352 inline Rect operator*(T scalar)
const
354 return Rect(d_min * scalar, d_max * scalar);
357 const Rect& operator*=(T scalar)
364 Rect operator+(
const Rect& r)
const
366 return Rect(d_min + r.d_min, d_max + r.d_max);
369 inline friend std::ostream& operator << (std::ostream& s,
const Rect& v)
371 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 <<
")";
394 typedef Rect<float> Rectf;
397 inline Rect<UDim> operator * (
const Rect<UDim>& v,
const float c)
399 return Rect<UDim>(v.d_min * c, v.d_max * c);
402 typedef Rect<UDim> URect;
407 #endif // end of guard _CEGUIRect_h_