📄 stroke.cpp
字号:
// Stroke.cpp: implementation of the CStroke class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SingleDraw.h"
#include "Stroke.h"
#include "afxTempl.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
IMPLEMENT_SERIAL(CStroke, CObject, 1)
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CStroke::CStroke()
{
m_penWidth = 1; // default pen width
m_penStyle = PS_SOLID; // default pen style
m_colorRef = RGB(0, 0, 0); // default color
}
CStroke::~CStroke()
{
m_pointArray.RemoveAll(); // delete all element.
}
void CStroke::Serialize(CArchive &ar)
{
if(ar.IsStoring())
{
ar << m_penWidth;
ar << m_penStyle;
ar << m_colorRef;
}
else
{
ar >> m_penWidth;
ar >> m_penStyle;
ar >> m_colorRef;
}
m_pointArray.Serialize(ar);
}
void CStroke::DrawStroke(CDC *pDC)
{
CPen *pOldPen;
CPen *pCurPen = new CPen;
pCurPen->CreatePen(PS_SOLID, m_penWidth, m_colorRef);
pOldPen = pDC->SelectObject(pCurPen);
pDC->MoveTo(m_pointArray[0]);
int i;
for(i=1; i<m_pointArray.GetSize(); i++)
{
pDC->LineTo(m_pointArray[i]);
pDC->MoveTo(m_pointArray[i]);
}
pDC->SelectObject(pOldPen);
}
void CStroke::SetPen(UINT penStyle, UINT penWidth, COLORREF rgb)
{
m_colorRef = rgb;
m_penStyle = penStyle;
m_penWidth = penWidth;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -