rect.cpp

来自「C语言库函数(包括所有的C语言库函数)」· C++ 代码 · 共 58 行

CPP
58
字号
// Rect.cpp: implementation of the Rect class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PainterUsePattern.h"
#include "Rect.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


//=================================================================
//
//=================================================================
Rect::Rect()
{

}
//=================================================================
//
//=================================================================
Rect::~Rect()
{

}
//=================================================================
//接受访问者访问方法;
//=================================================================
void Rect::Accept( AbstractVisitor& v , CDC* pDC )
{
	v.VisitRect( this ,pDC );
}
//=================================================================
//检测点p是否在显示区域内部;
//=================================================================
bool Rect::Intersects( CPoint p )
{
	int flag1 = ( p.x >= m_rect.left   && p.x <= m_rect.right )? true : false;
	int flag2 = ( p.y >= m_rect.top    && p.y <= m_rect.bottom)? true : false;
	
	if( flag1 && flag2 )
		return true;
	return false;
}
//=================================================================
//设置显示位置偏移量;
//=================================================================
void Rect::SetOffset( int offsetX , int offsetY )
{
	m_rect.top    += offsetY;
	m_rect.bottom += offsetY;
	m_rect.left   += offsetX;
	m_rect.right  += offsetX;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?