MyCommand.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:2k
源码类别:

绘图程序

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "MyDefine.h"
  3. #include "MyCommand.h"
  4. //////////////////////////////////////////////////////////////////////////////////////////////
  5. CMyCommandStruct::CMyCommandStruct(int command, int num, int* object, int* index)
  6. {
  7. int i;
  8. m_command = command;
  9. m_num = num;
  10. m_object = new int[m_num];
  11. m_index = new int[m_num];
  12. for(i=0; i<m_num; i++)
  13. {
  14. m_object[i] = object[i];
  15. m_index[i] = index[i];
  16. }
  17. }
  18. CMyCommandStruct::~CMyCommandStruct()
  19. {
  20. delete m_object;
  21. delete m_index;
  22. }
  23. //////////////////////////////////////////////////////////////////////////////////////////////
  24. IMPLEMENT_DYNCREATE(CMyCommand, CObject)
  25. CMyCommand::CMyCommand()
  26. {
  27. CommandPointer = -1;   //命令指针
  28. ProportionPointer = -1;
  29. PositionPointer = -1;
  30. LineStylePointer = -1;
  31. ColorPointer = -1;
  32. }
  33. CMyCommand::~CMyCommand()
  34. {
  35. int index = m_CommandArray.GetSize();
  36. while(index--)
  37. delete (CMyCommandStruct*)m_CommandArray.GetAt(index);
  38. m_CommandArray.RemoveAll();
  39. }
  40. void CMyCommand::AddCommand(int command, int num, int* object, int* index)
  41. {
  42.    CMyCommandStruct* pCommand;
  43.    pCommand = new CMyCommandStruct(command, num, object, index);
  44.    m_CommandArray.Add(pCommand);
  45. }
  46. CMyCommandStruct* CMyCommand::GetCommandAt(int index)
  47. {
  48. CMyCommandStruct* pCommand;
  49. pCommand = (CMyCommandStruct*)m_CommandArray.GetAt(index);
  50. return pCommand;
  51. }
  52. void CMyCommand::DelCommandFrom(int index)
  53. {
  54. while(index < m_CommandArray.GetSize())
  55. {
  56. delete (CMyCommandStruct*)m_CommandArray.GetAt(index);
  57. m_CommandArray.RemoveAt(index);
  58. }
  59. }