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

📄 zcr14list.cpp

📁 一个画笔的程序,可以进行直线,圆和方形等图形进行画图,并可以撤消上一步的动作
💻 CPP
字号:
// ZCR14List.cpp: implementation of the CZCR14List class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ZCR14Paint.h"
#include "ZCR14List.h"
#include "ZCR14Shape.h"
#include "ZCR14Line.h"
#include "ZCR14Rect.h"
#include "ZCR14Ellipse.h"

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

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

CZCR14List::CZCR14List()
{
    //m_nCount=0;
}

CZCR14List::~CZCR14List()
{

}

void CZCR14List::DeleteAt(POSITION position)
{
	delete GetAt(position);
	CObList::RemoveAt(position);
}

void CZCR14List::DelateAll()
{
	POSITION pos = CObList::GetHeadPosition();
    while(pos)
	{
		CZCR14Shape* pShape = (CZCR14Shape*)GetNext(pos);
         delete pShape;
	}
   
	CObList::RemoveAll();
}

void CZCR14List::Serialize(CArchive &ar)
{
    if(ar.IsStoring())
	{
		ar.WriteCount(m_nCount);
		for (CNode* pNode = m_pNodeHead;
		pNode != NULL; pNode = pNode->pNext)
		{
			CZCR14Shape* pShape = (CZCR14Shape*)pNode->data; 	   
			ar << pShape->GetClassName();
			pShape->Serialize(ar);
		}
	}
	else  // IsLoading() 
	{	 
		DWORD nNewCount = ar.ReadCount();
	if (nNewCount > 0)  
		DelateAll(); 
	while (nNewCount--)
	{ 
		CString strClassName;
		  ar>>strClassName;
		  CZCR14Shape* newShape=NewShape(strClassName);
		  newShape->Serialize(ar);
		  AddTail(newShape);
	}
	}
	
}

CZCR14Shape* CZCR14List::NewShape(CString &strClassName)
{
	CZCR14Shape* pShape=NULL;
	if (strClassName =="CZCR14Line") 
		pShape =CZCR14Line::NewShape();
	else if (strClassName =="CZCR14Rect") 
		pShape=CZCR14Rect::NewShape();
	else if(strClassName =="CZCR14Ellipse")
		pShape=CZCR14Ellipse::NewShape();
	return pShape;
	
	
}

⌨️ 快捷键说明

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