FlRect.cpp
资源名称:44757463.rar [点击查看]
上传用户:lj3531212
上传日期:2007-06-18
资源大小:346k
文件大小:2k
源码类别:
绘图程序
开发平台:
Visual C++
- // FlRect.cpp: implementation of the CFlRect class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "graphsoft.h"
- #include "FlRect.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CFlRect::CFlRect()
- {
- left=0;
- top=0;
- right=0;
- bottom=0;
- }
- CFlRect::CFlRect(CRect rect)
- {
- left=rect.left;
- top=rect.top;
- right=rect.right;
- bottom=rect.bottom;
- }
- CFlRect::CFlRect(CPoint topLeft,CPoint bottomRight)
- {
- left=topLeft.x;
- top=topLeft.y;
- right=bottomRight.x;
- bottom=bottomRight.y;
- }
- CFlRect::CFlRect(float lf,float tp,float rt,float bm)
- {
- left=lf;
- top=tp;
- right=rt;
- bottom=bm;
- }
- CFlRect::~CFlRect()
- {
- }
- CRect CFlRect::GetRect()
- {
- CRect rect(left,top,right,bottom);
- return rect;
- }
- void CFlRect::OffsetRect(float cx,float cy)
- {
- left=left+cx;
- right=right+cx;
- top=top+cy;
- bottom=bottom+cy;
- }
- CPoint CFlRect::LeftTop()
- {
- CPoint point(left,top);
- return point;
- }
- CPoint CFlRect::BottomRight()
- {
- CPoint point(right,bottom);
- return point;
- }
- CPoint CFlRect::CenterPoint()
- {
- CPoint point((left+right)/2,(top+bottom)/2);
- return point;
- }
- float CFlRect::Width()
- {
- return fabs(right-left);
- }
- float CFlRect::Height()
- {
- return fabs(bottom-top);
- }
- bool CFlRect::PtInRect(CPoint pt)
- {
- if(pt.x<left || pt.x>right)
- return false;
- if(pt.y<top || pt.y>bottom)
- return false;
- return true;
- }
- bool CFlRect::PtInRect(float x,float y)
- {
- if(x<left || x>right)
- return false;
- if(y<top || y>bottom)
- return false;
- return true;
- }
- void CFlRect::InflateRect(float cx,float cy)
- {
- left=left-cx;
- right=right+cx;
- top=top-cy;
- bottom=bottom+cy;
- }
- void CFlRect::DeflateRect(float cx,float cy)
- {
- left=left+cx;
- right=right-cx;
- top=top+cy;
- bottom=bottom-cy;
- }
- void CFlRect::NormalizeRect()
- {
- left = min(left,right);
- right = max(left,right);
- top = min(top,bottom);
- bottom = max(top,bottom);
- }
- CFlRect::operator CRect( )
- {
- return CRect(left,top,right,bottom);
- }
- bool operator !=(CFlRect& rtA,CFlRect& rtB)
- {
- return rtA.GetRect()!=rtB.GetRect();
- }