00001
00002
00003
00004
00005
00008
00009 #ifndef _ROKU_INCLUDE_CASCADE_GRAPHICS_CASCADERECT_H
00010 #define _ROKU_INCLUDE_CASCADE_GRAPHICS_CASCADERECT_H
00011
00012 #include <cascade/CascadeObject.h>
00013 #include <cascade/graphics/CascadePoint.h>
00014
00026 class CascadeRect : public CascadeObject
00027 {
00028 public:
00029 CascadeRect() { x = y = w = h = 0; }
00033 CascadeRect(s32 xx, s32 yy, u32 ww, u32 hh) { x = xx; y = yy; w = ww; h = hh; }
00041 CascadeRect(const CascadeRect & rect) { x = rect.x; y = rect.y; w = rect.w; h = rect.h; }
00046 public:
00047 s32 x;
00051 s32 y;
00055 u32 w;
00059 u32 h;
00063 public:
00064 inline bool IsObscuredBy(const CascadeRect & rect) const
00065 {
00066 return ((x >= rect.x) && (y >= rect.y) && (x + w <= rect.x + rect.w) && (y + h <= rect.y + rect.h));
00067 }
00074 bool IntersectRect(const CascadeRect & rect) const;
00081 bool MakeIntersectRect(const CascadeRect & rect, CascadeRect & intersectRectToMake) const;
00091 void MakeUnionRect(const CascadeRect & rect, CascadeRect & unionRectToMake) const;
00098 bool PointInRect(const CascadePoint & point) const;
00105 inline CascadePoint TopLeft() const { return CascadePoint( x, y ); }
00111 inline CascadePoint BottomLeft() const { return CascadePoint( x, y+(h-1) ); }
00117 inline CascadePoint TopRight() const { return CascadePoint( x+(w-1), y ); }
00123 inline CascadePoint BottomRight() const { return CascadePoint( x+(w-1), y+(h-1) ); }
00129 inline CascadePoint CenterPoint() const { return CascadePoint( x + (w-1)/2, y + (h-1)/2 ); }
00135 inline void MoveTo(const CascadePoint & point) { x = point.x; y = point.y; }
00140 inline void MoveCenterTo(const CascadePoint & point) { x = point.x - (w-1)/2; y = point.y - (h-1)/2; }
00147 void InsetRect(s32 dx, s32 dy);
00163 inline void InflateRect(s32 dx, s32 dy) { InsetRect(-dx, -dy); }
00179 inline void OffsetRect(s32 dx, s32 dy) { x += dx, y += dy; }
00186 inline bool operator == (const CascadeRect & rect) const { return (x == rect.x && y == rect.y && w == rect.w && h == rect.h); }
00192 inline bool operator != (const CascadeRect & rect) const { return (! operator== (rect)); }
00198 };
00199
00200 #endif // #ifndef _ROKU_INCLUDE_CASCADE_GRAPHICS_CASCADERECT_H
00201
00202
00204
00206
00207
00208
00209
00210
00211
00212
00213
00214