⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 line.cpp

📁 电子白板程序
💻 CPP
字号:
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Line.h"
#include "DrawView.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLine::CLine( CDrawView & v ) : CDrawBase( v )
{
	this->draw.tag = LINE;
}

CLine::~CLine()
{

}

CDrawBase * CLine::Clone( void )
{
	CLine * obj = new CLine( this->view );

	memcpy( &obj->draw , &this->draw , sizeof( DRAW ) );

	return obj;
}

HCURSOR CLine::GetCursor( void )
{
	static HCURSOR hCursor = ::AfxGetApp()->LoadStandardCursor( IDC_CROSS );

	return hCursor;
}

bool CLine::Select( CRect & rc )
{
	rc.NormalizeRect();

	CRgn r0 , r1;

	r0.CreateRectRgn( rc.left , rc.top , rc.right , rc.bottom );

	POINT pt[] = 
	{
		{ this->draw.start.x , this->draw.start.y } ,
		{ this->draw.end.x , this->draw.end.y } ,
		{ this->draw.end.x + this->draw.pen.lopnWidth.x , this->draw.end.y + ( this->draw.start.y == this->draw.end.y ? 1 : 0 ) } ,
		{ this->draw.start.x + this->draw.pen.lopnWidth.x , this->draw.start.y + ( this->draw.start.y == this->draw.end.y ? 1 : 0 ) }
	};
	r1.CreatePolygonRgn( pt , sizeof( pt ) / sizeof( POINT ) , WINDING );

	return this->draw_select = r0.CombineRgn( &r0 , &r1 , RGN_AND ) != NULLREGION;
}

void CLine::OnMouseMove( UINT nFlags , CPoint point )
{
	if( nFlags & MK_SHIFT )
	{   //水平线 
		if( abs( point.x - this->draw.start.x ) < 10 ) point.x = this->draw.start.x;
		//垂直线
		if( abs( point.y - this->draw.start.y ) < 10 ) point.y = this->draw.start.y;
		//45度线
	}
	CDrawBase::OnMouseMove( nFlags , point );
}
void CLine::OnDraw(  CDC * pDC )
{
	CDrawBase::OnDraw( pDC );

	pDC->MoveTo( this->draw.start );

	pDC->LineTo( this->draw.end );
}

⌨️ 快捷键说明

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