Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

IMG_Rect.h

00001 
00005 
00006 #ifndef _H_IMG_Rect
00007 #define _H_IMG_Rect
00008 
00009 #include "IMG_Types.h"
00010 #include "IMG_Line.h"
00011 
00021 
00022 class IMG_Rect {
00023 public:
00024 
00032         IMG_Rect(TInt32 l=0, TInt32 t=0, TInt32 r=0, TInt32 b=0)
00033                 : m_l(l), m_t(t), m_r(r), m_b(b) {}
00034 
00039         IMG_Rect(const IMG_Rect& r)
00040                 : m_l(r.m_l), m_t(r.m_t), m_r(r.m_r), m_b(r.m_b) {}
00041         
00045         virtual ~IMG_Rect() {};
00046 
00051         virtual inline TInt32 getWidth() const;
00052 
00057         virtual inline TInt32 getHeight() const;
00058 
00066         virtual inline void set(TInt32 l, TInt32 t, TInt32 r, TInt32 b);
00067 
00073         virtual inline bool isEmpty() const;
00074 
00080         virtual inline bool isValid() const;
00081 
00087         virtual void inset(TInt32 i);
00088 
00094         virtual inline void unionRect(const IMG_Rect& r);
00095 
00101         virtual inline void unionPoint(TInt32 x, TInt32 y);
00102 
00110         virtual inline bool isInside(TInt32 x, TInt32 y) const;
00111 
00117         virtual TVisibility getVisibility(IMG_Rect& r) const;
00118 
00124         virtual TVisibility getVisibility(IMG_Line& l) const;
00125 
00132         virtual void setCenter(TInt32 cx, TInt32 cy);
00133 
00143         virtual void setCenter(TInt32 cx, TInt32 cy, TInt32 w, TInt32 h);
00144 
00152         virtual bool clip(IMG_Rect& r) const;
00153 
00161         virtual bool clip(IMG_Line& l) const;
00162 
00164         TInt32 m_l;
00166         TInt32 m_t;
00168         TInt32 m_r;
00170         TInt32 m_b;
00171 };
00172 
00173 
00174 inline TInt32 IMG_Rect::getWidth() const
00175 {
00176         return m_r - m_l;
00177 }
00178 
00179 inline TInt32 IMG_Rect::getHeight() const
00180 {
00181         return m_b - m_t;
00182 }
00183 
00184 inline void IMG_Rect::set(TInt32 l, TInt32 t, TInt32 r, TInt32 b)
00185 {
00186         m_l = l; m_t = t; m_r = r; m_b = b;
00187 }
00188 
00189 inline bool     IMG_Rect::isEmpty() const
00190 {
00191         return (getWidth() == 0) || (getHeight() == 0);
00192 }
00193 
00194 inline bool IMG_Rect::isValid() const
00195 {
00196         return (m_l <= m_r) && (m_t <= m_b);
00197 }
00198 
00199 inline void IMG_Rect::unionRect(const IMG_Rect& r)
00200 {
00201         if (r.m_l < m_l) m_l = r.m_l;
00202         if (r.m_r > m_r) m_r = r.m_r;
00203         if (r.m_t < m_t) m_t = r.m_t;
00204         if (r.m_b > m_b) m_b = r.m_b;
00205 }
00206 
00207 inline void IMG_Rect::unionPoint(TInt32 x, TInt32 y)
00208 {
00209         if (x < m_l) m_l = x;
00210         if (x > m_r) m_r = x;
00211         if (y < m_t) m_t = y;
00212         if (y > m_b) m_b = y;
00213 }
00214 
00215 inline bool IMG_Rect::isInside(TInt32 x, TInt32 y) const
00216 {
00217         return (x >= m_l) && (x <= m_r) && (y >= m_t) && (y <= m_b);
00218 }
00219 
00220 #endif // _H_IMG_Rect

Generated at Thu May 3 17:29:38 2001 for ImgLib by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000