rectangle.cpp

来自「画简单的图形用VC++开发的利用鼠标响应程序的实行」· C++ 代码 · 共 90 行

CPP
90
字号
// Rectangle.cpp: implementation of the CRectangle class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "画图.h"
#include "Rectangle.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CRectangle,CObject,1)
CRectangle::CRectangle()
{
	start=end=CPoint(0,0);
	width=1;
	color=RGB(0,0,255);

}

CRectangle::~CRectangle()
{

}

CRectangle::CRectangle(CPoint p1, CPoint p2, int w,COLORREF c)
{
	start=p1;
	end=p2;
	width=2;
	color=c;
}

void CRectangle::Serialize(CArchive &ar)
{
	if(ar.IsStoring())
		ar<<start<<end<<width<<color;
	else
		ar>>start>>end>>width>>color;
}

CPoint CRectangle::GetStart()
{
	return start;
}


CPoint CRectangle::GetEnd()
{
	return end;
}

void CRectangle::SetStart(CPoint p)
{
	start=p;
}

void CRectangle::SetEnd(CPoint p)
{
	end=p;

}

void CRectangle::SetWidth(int w)
{
	width=w;
}

int CRectangle::GetWidth()
{
	return width;

}

COLORREF CRectangle::GetColor()
{
	return color;
}

void CRectangle::SetColor(COLORREF c)
{
	color=c;
}

⌨️ 快捷键说明

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