MyCommand.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:2k
- #include "stdafx.h"
- #include "MyDefine.h"
- #include "MyCommand.h"
- //////////////////////////////////////////////////////////////////////////////////////////////
- CMyCommandStruct::CMyCommandStruct(int command, int num, int* object, int* index)
- {
- int i;
- m_command = command;
- m_num = num;
- m_object = new int[m_num];
- m_index = new int[m_num];
- for(i=0; i<m_num; i++)
- {
- m_object[i] = object[i];
- m_index[i] = index[i];
- }
- }
- CMyCommandStruct::~CMyCommandStruct()
- {
- delete m_object;
- delete m_index;
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNCREATE(CMyCommand, CObject)
- CMyCommand::CMyCommand()
- {
- CommandPointer = -1; //命令指针
- ProportionPointer = -1;
- PositionPointer = -1;
- LineStylePointer = -1;
- ColorPointer = -1;
- }
- CMyCommand::~CMyCommand()
- {
- int index = m_CommandArray.GetSize();
- while(index--)
- delete (CMyCommandStruct*)m_CommandArray.GetAt(index);
- m_CommandArray.RemoveAll();
- }
- void CMyCommand::AddCommand(int command, int num, int* object, int* index)
- {
- CMyCommandStruct* pCommand;
- pCommand = new CMyCommandStruct(command, num, object, index);
- m_CommandArray.Add(pCommand);
- }
- CMyCommandStruct* CMyCommand::GetCommandAt(int index)
- {
- CMyCommandStruct* pCommand;
- pCommand = (CMyCommandStruct*)m_CommandArray.GetAt(index);
- return pCommand;
- }
- void CMyCommand::DelCommandFrom(int index)
- {
- while(index < m_CommandArray.GetSize())
- {
- delete (CMyCommandStruct*)m_CommandArray.GetAt(index);
- m_CommandArray.RemoveAt(index);
- }
- }