www.pudn.com > subject_1_113294.rar > Line.cpp, change:2002-05-22,size:1353b
// Line.cpp: implementation of the CLine class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Paint.h"
#include "Line.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CLine::CLine():CElement()
{
StartPoint=*(new CPoint(0,0));
EndPoint=*(new CPoint(0,0));
this->LineStyle=LineStyle;
this->LineWidth=LineWidth;
this->LineColor=LineColor;
}
CLine::CLine(int LineStyle,int LineWidth,COLORREF LineColor):CElement()
{
StartPoint=*(new CPoint(0,0));
EndPoint=*(new CPoint(0,0));
this->LineStyle=LineStyle;
this->LineWidth=LineWidth;
this->LineColor=LineColor;
}
CLine::~CLine()
{
}
void CLine::DrawItem(CDC *pDC)
{
CPen *Pen=new CPen();
CPen *OldPen;
Pen->CreatePen(LineStyle,LineWidth,LineColor);
OldPen=pDC->SelectObject(Pen);
pDC->MoveTo(StartPoint);
pDC->LineTo(EndPoint);
pDC->SelectObject(OldPen);
delete Pen;
}
void CLine::Serialize(CArchive &ar)
{
CElement::Serialize(ar);
if(ar.IsStoring())
{
ar<<StartPoint;
ar<<EndPoint;
}
else
{
ar>>StartPoint;
ar>>EndPoint;
}
}