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

📄 paintercollection.cpp

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

#include "stdafx.h"
#include "PainterUsePattern.h"
#include "PainterCollection.h"

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

//=================================================================
//
//=================================================================
PainterCollection::PainterCollection()
{

	m_itemList          = new CTypedPtrList<CObList,CGraphicItem*>;
	
	this->m_currentPosition = 0;
	m_count = 0;
}
//=================================================================
//
//=================================================================
PainterCollection::~PainterCollection()
{
	delete m_itemList;
}
//=================================================================
//在子链表中添加新的子结点
//=================================================================
void PainterCollection::Add( CGraphicItem* newItem )
{
	m_count++;
	m_itemList->AddTail( newItem );
}
//=================================================================
//删除选中结点
//=================================================================
void PainterCollection::RemoveAt( int index )
{
	m_itemList->RemoveAt( m_itemList->FindIndex(index) );		
	m_count--;
}
//=================================================================
//取得子链表中第一个子结点指针
//=================================================================
CGraphicItem* PainterCollection::GetFirstItem()
{
   	this->m_currentPosition=0;
	if( !IsDone() )
    	return   m_itemList->GetHead();
	else
		return NULL;

}
//=================================================================
//取得子链表中当前结点的下一个结点指针
//=================================================================
CGraphicItem* PainterCollection::GetNextItem()
{
	POSITION  position;

	m_currentPosition++;
	
	if( !IsDone() ) 
	{
    	position = m_itemList->FindIndex( m_currentPosition );
    	return m_itemList->GetAt(position);
	}
	else
		return NULL;

}
//=================================================================
//判断遍历子链表是否结束
//=================================================================
int PainterCollection::IsDone()
{

	if( m_currentPosition >= m_itemList->GetCount() )
		return 1;
	else
		return 0;

}
//=================================================================
//取得指定位置的图形元素;
//=================================================================
CGraphicItem* PainterCollection::GetAt( int index )
{
	if( index <= m_count )
	{
		return m_itemList->GetAt( m_itemList->FindIndex( index-1 ) );
	}
	else
		return 0;
}

⌨️ 快捷键说明

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