www.pudn.com > 44757463.rar > FlRect.cpp


// 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.xright) 
		return false; 
	if(pt.ybottom) 
		return false; 
	return true; 
} 
bool CFlRect::PtInRect(float x,float y) 
{ 
	if(xright) 
		return false; 
	if(ybottom) 
		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(); 
}