MyCommand.h
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:2k
- #include <afxtempl.h>
- #include "MyDraw.h"
- /////////////////////////////////////////////////////////////////////////////////////////////
- class CCommandStruct: public CObject
- {
- public:
- int m_command; //操作命令ID号
- int m_num; //操作命令操作的对象数目
- int* m_object; //图形对象代号,操作命令无对象时为NULL
- int* m_index; //图形对象在其数列中的序号
- public:
- CCommandStruct(int command, int num, int* object, int* index);
- ~CCommandStruct();
- };
- /////////////////////////////////////////////////////////////////////////////////////////////
- //命令类,用于分析绘图、修改命令,并且存储所有发生的命令,以便Undo,Redo命令使用
- //命令类只涉及到绘图、修改命令的实现步骤,不能与图形对象类的数据结构相关。
- class CHandleCommand: public CObject
- {
- public:
- DECLARE_DYNCREATE(CHandleCommand)
- //用于储存命令列表类指针
- CObArray m_CommandArray;
- //用于存储图形对象发生改变后先前的信息
- CArray<float, float> m_SavedProportion;
- CArray<CPoint, CPoint> m_SavedPosition;
- CArray<int, int> m_SavedLineStyle;
- CArray<int, int> m_SavedColor;
-
- private:
- CScrollView* pScrollView;
- int CurrentCommand; //当前绘图命令
- int LRepeatTimes; //在当前绘图命令下鼠标左键点击次数
- int RRepeatTimes; //在当前绘图命令下鼠标右键点击次数
- public:
- COperateObject m_OperateObject;
-
- public:
- int CommandPointer; //命令指针
- int ProportionPointer;
- int PositionPointer;
- int LineStylePointer;
- int ColorPointer;
- public:
- CHandleCommand();
-
- public:
- void Intialize( COLORREF pcolor, int lstyle);
- void GetView(CScrollView* pView);
- void SetCommand(int command);
- int GetCommand();
- void SetPageSize(SIZE size);
- void LButtonDown(CDC* pDC, POINT point);
- void RButtonDown(CDC* pDC, POINT point);
- void MouseMove(CDC* pDC, POINT point);
- void ScrollScreen(CDC* pDC);
- void Redraw(CDC* pDC);
- public:
- //增加命令
- void AddCommand(int command, int num, int* object, int* index);
- CCommandStruct* GetCommandAt(int index);
- //删除序号从index之后的命令
- void DelCommandFrom(int index);
- void AddProportion(int proportion);
- void GetProportionAt(int index);
- void DelProportionFrom(int index);
- public:
- ~CHandleCommand();
- };