Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeRect.h

Go to the documentation of this file.
00001 //
00002 // CascadeRect.h - header file for class CascadeRect
00003 //
00004 // Copyright (c) 2003, Roku, LLC.  All rights reserved.
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 //  LOG
00206 //  20-Dec-02   dwoodward       created
00207 //  20-Jan-03   dwoodward       1.0 STATUS: 100% complete
00208 //  10-Feb-03   dwoodward   added MakeIntersectRect
00209 //  25-Feb-03   dwoodward   added MakeUnionRect
00210 //  14-Apr-03   mjkobb      Added TopLeft, BottomLeft, TopRight, BottomRight
00211 //  05-May-03   dwoodward   doxygenated
00212 //  04-Jun-03   dwoodward   added InflateRect and OffsetRect
00213 //  14-Jul-03   dwoodward   added operator !=
00214 //  02-Sep-03   dwoodward   added IsObscuredBy()

Generated on Sun Jul 24 14:27:17 2005 for Cascade Library by  doxygen 1.4.1