#pragma once template class CakRectT { public: T left; T top; T right; T bottom; public: CakRectT(void); //CakRectT(T l, T t, T r, T b); CakRectT(const T l, const T t, const T r, const T b):left(l),top(t),right(r),bottom(b) {}; virtual ~CakRectT(void); //Attirbute // retrieves the width T Width() const throw(); // returns the height T Height() const throw(); //{ // // reference to the top-left point // CPoint& TopLeft() throw(); // // reference to the bottom-right point // CPoint& BottomRight() throw(); // // const reference to the top-left point // const CPoint& TopLeft() const throw(); // // const reference to the bottom-right point // const CPoint& BottomRight() const throw(); // // the geometric center point of the rectangle // CPoint CenterPoint() const throw(); // // bool PtInRect(POINT point) const throw(); //} // swap the left and right void SwapLeftRight() throw(); void SwapTopBottom() throw(); // returns TRUE if rectangle has no area bool IsRectEmpty() const throw(); // returns TRUE if rectangle is at (0,0) and has no area bool IsRectNull() const throw(); // returns TRUE if point is within rectangle bool PtInRect(T x, T y) const throw(); // Operations // set rectangle from left, top, right, and bottom void SetRect(T x1, T y1, T x2, T y2) throw(); //void SetRect(POINT topLeft, POINT bottomRight) throw(); // empty the rectangle void SetRectEmpty() throw(); // copy from another rectangle void CopyRect(const CakRectT* lpSrcRect) throw(); // TRUE if exactly the same as another rectangle bool EqualRect(const CakRectT* lpRect) const throw(); // Inflate rectangle's width and height by // x units to the left and right ends of the rectangle // and y units to the top and bottom. void InflateRect(T x, T y) throw(); void InflateRect(T l, T t, T r, T b) throw(); void InflateRect(CakRectT* lpRect) throw(); // deflate the rectangle's width and height without // moving its top or left void DeflateRect(T x, T y) throw(); void DeflateRect(T l, T t, T r, T b) throw(); //void DeflateRect(SIZE size) throw(); void DeflateRect(CakRectT* lpRect) throw(); // translate the rectangle by moving its top and left void OffsetRect(T x, T y) throw(); //void OffsetRect(SIZE size) throw(); //void OffsetRect(POINT point) throw(); void NormalizeRect() throw(); // absolute position of rectangle void MoveToY(T y) throw(); void MoveToX(T x) throw(); void MoveToXY(T x, T y) throw(); //void MoveToXY(POINT point) throw(); // µÎ»ç°¢ÇüÀÌ °ãÄ¡´Â ºÎºÐ¸¸ °ËÃâ ¾øÀ»½Ã 0À¸·Î ¼ÂÆÃ(ReturnÀº °ãÄ¡´Â ºÎºÐÀÌ ÀÖÀ¸¸é True) bool IntersectRect(CakRectT* lpRect1, CakRectT* lpRect2) throw(); // µÎ »ç°¢ÇüÀÇ Å׵θ® ºÎºÐ °ËÃâ(ReturnÀº °ãÄ¡´Â ºÎºÐÀÌ ÀÖÀ¸¸é True) bool UnionRect(CakRectT* lpRect1, CakRectT* lpRect2) throw(); // set this rectangle to minimum of two others //bool SubtractRect(CakRectT* lpRectSrc1, CakRectT* lpRectSrc2) throw(); // Additional Operations void operator=(const CakRectT& srcRect) throw(); bool operator==(const CakRectT& rect) const throw(); bool operator!=(const CakRectT& rect) const throw(); void operator+=(CakRectT* lpRect) throw(); void operator-=(CakRectT* lpRect) throw(); //void operator&=(const CakRectT& rect) throw(); //void operator|=(const CakRectT& rect) throw(); // Operators returning CakRectT values //CakRectT operator+(POINT point) const throw(); //CakRectT operator-(POINT point) const throw(); CakRectT operator+(CakRectT* lpRect) const throw(); //CakRectT operator+(SIZE size) const throw(); //CakRectT operator-(SIZE size) const throw(); CakRectT operator-(CakRectT* lpRect) const throw(); //CakRectT operator&(const CakRectT& rect2) const throw(); //CakRectT operator|(const CakRectT& rect2) const throw(); CakRectT MulDiv(T nMultiplier, T nDivisor) const throw(); //¿¹Àü¿¡ ¾²´ø ÇÔ¼öµé public: inline void set(T l, T t, T r, T b) { left = l; top = t; right = r; bottom = b; }; inline T getWidth(){return right-left;}; inline T getHeight(){return bottom-top;}; inline T getCenter(){return T(left+(right-left)/2.0);}; inline T getVCenter(){return T(top+(bottom-top)/2.0);}; void setAlign(){NormalizeRect();}; //ÀÛÀº°ªÀÌ ¿ÞÂÊ, À§, Å«°ªÀÌ ¿À¸¥ÂÊ ¾Æ·¡·Î °¡°Ô ÇÑ´Ù. bool getCheckAreaIn(double x, double y); //»ç°¢Çü ¿µ¿ª¿¡ x,yÆ÷ÀÎÆ®°¡ ÀÖ´ÂÁö °Ë»ç bool getCheckWidthIn(double p1); //xÆ÷ÀÎÆ® °¡¿îµ¥ Á¡ÀÌ ÀÖ´ÂÁö °Ë»ç bool getCheckHeightIn(double p1); //yÆ÷ÀÎÆ® °¡¿îµ¥ Á¡ÀÌ ÀÖ´ÂÁö °Ë»ç }; template bool CakRectT::IntersectRect( CakRectT* lpRect1, CakRectT* lpRect2 ) throw() { if ( lpRect1->left < lpRect2->right && lpRect1->top < lpRect2->bottom && lpRect1->right > lpRect2->left && lpRect1->bottom > lpRect2->top ) { //*this = *lpRect2; lpRect1->left > lpRect2->left ? left = lpRect1->left : left = lpRect2->left ; lpRect1->top > lpRect2->top ? top = lpRect1->top : top = lpRect2->top ; lpRect1->right < lpRect2->right ? right = lpRect1->right : right = lpRect2->right ; lpRect1->bottom < lpRect2->bottom ? bottom = lpRect1->bottom : bottom= lpRect2->bottom ; return true; } set(0,0,0,0); return false; } template bool CakRectT::UnionRect( CakRectT* lpRect1, CakRectT* lpRect2 ) throw() { lpRect1->left < lpRect2->left ? left = lpRect1->left : left = lpRect2->left ; lpRect1->top < lpRect2->top ? top = lpRect1->top : top = lpRect2->top ; lpRect1->right > lpRect2->right ? right = lpRect1->right : right = lpRect2->right ; lpRect1->bottom > lpRect2->bottom ? bottom = lpRect1->bottom : bottom= lpRect2->bottom ; if ( lpRect1->left < lpRect2->right && lpRect1->top < lpRect2->bottom && lpRect1->right > lpRect2->left && lpRect1->bottom > lpRect2->top ) { return true; } return false; } #include "inl/akRectT.inl"