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

📄 paintitemvisitor.cpp

📁 C语言库函数(包括所有的C语言库函数)
💻 CPP
字号:
// PaintItemVisitor.cpp: implementation of the PaintItemVisitor class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PainterUsePattern.h"
#include "PaintItemVisitor.h"

#include "Point.h"
#include "Line.h"
#include "Rect.h"
#include "Circle.h"

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



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

PaintItemVisitor::PaintItemVisitor()
{

}

PaintItemVisitor::~PaintItemVisitor()
{

}

void PaintItemVisitor::VisitCircle( Circle* c ,CDC* pDC )
{
	CPen   newPen;
	CPen*  oldPen;

	newPen.CreatePen( PS_SOLID , 1 , c->GetColor() );
	oldPen = pDC->SelectObject( &newPen );

	CPoint point = c->GetCentrePoint();
	int    radix = c->GetRadix();
	CRect  rect ; 
	CString str;
	str.Format("%d",radix);
	pDC->TextOut(0,0,str);
//	AfxMessageBox(str);
	rect.top    = point.y - radix;
	rect.bottom = point.y + radix;
	rect.left   = point.x - radix;
	rect.right  = point.x + radix;

	pDC->Ellipse( &rect );
	newPen.Detach();
	pDC->SelectObject( oldPen );

}
void PaintItemVisitor::VisitLine( Line* l ,CDC* pDC )
{
	CPen   newPen;
	CPen*  oldPen;

	newPen.CreatePen( PS_SOLID , 1 , l->GetColor() );
	oldPen = pDC->SelectObject( &newPen );

	CPoint startPoint  = l->GetStartPoint();
	CPoint endPoint    = l->GetEndPoint();
	
	pDC->MoveTo( startPoint );
	pDC->LineTo( endPoint );

	newPen.Detach();
	pDC->SelectObject( oldPen );
}
void PaintItemVisitor::VisitPoint( Point* p  ,CDC* pDC )
{
	CPen   newPen;
	CPen*  oldPen;

	newPen.CreatePen( PS_SOLID , 1 , p->GetColor() );
	oldPen = pDC->SelectObject( &newPen );

	CPoint point = p->GetCentrePoint();
	int    radix = p->GetRadix();
	CRect  rect ; 
//	CString str;
//	str.Format("%d",radix);
//	AfxMessageBox(str);
	rect.top    = point.y - radix;
	rect.bottom = point.y + radix;
	rect.left   = point.x - radix;
	rect.right  = point.x + radix;

	pDC->Ellipse( &rect );

	newPen.Detach();
	pDC->SelectObject( oldPen );
//	pDC->TextOut(0,0,radix);
}
void PaintItemVisitor::VisitRect( Rect* r ,CDC* pDC )
{
	CPen   newPen;
	CPen*  oldPen;

	newPen.CreatePen( PS_SOLID , 1 , r->GetColor() );
	oldPen = pDC->SelectObject( &newPen );

	CRect rect = r->GetRect();

	pDC->Rectangle( rect );
	
	newPen.Detach();
	pDC->SelectObject( oldPen );
}

⌨️ 快捷键说明

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