📄 command.h
字号:
#ifndef _Command_h_
#define _Command_h_
#include "POSITION.H"
enum ECommandType // 命令类
{
ctUnknown = 0,
// 创建对象命令类
ctCreateLine = 1, // 创建对象
ctCreateRectangle = 2, // 创建矩形
ctCreateCircle = 3, // 创建圆
ctCreateArc = 4, // 创建圆弧
// ...其他创建类型
// 修改命令类
ctMove = 11, // 移动
ctRotate = 12, // 旋转
ctMirror = 13 // 镜像
// ...其他创建类型
};
class CCommand
{
protected:
int m_nStep ; // 命令操作步
public:
CCommand() {}
~CCommand() {}
virtual int GetType() = 0; // 返回命令类型 ECommandType
virtual int OnLButtonDown(UINT nFlags, const Position& pos) = 0 ;
virtual int OnMouseMove(UINT nFlags, const Position& pos) = 0 ;
virtual int OnRButtonDown(UINT nFlags, const Position& pos) = 0 ;
virtual int Cancel() = 0 ;
} ;
///////////////////////////////////////////////////////////////
/*
* CCreateLine
*/
class CCreateLine : public CCommand
{
private:
Position m_begin; // 直线的起点
Position m_end; // 直线的终点
public:
CCreateLine() ;
~CCreateLine() ;
int GetType();
int OnLButtonDown(UINT nFlags, const Position& pos) ;
int OnMouseMove(UINT nFlags, const Position& pos) ;
int OnRButtonDown(UINT nFlags, const Position& pos) ;
int Cancel() ;
} ;
///////////////////////////////////////////////////////////////
/*
* CCreateRect
*/
class CCreateRect : public CCommand
{
private:
Position m_LeftTop;
Position m_RightBottom;
public:
CCreateRect() ;
~CCreateRect() ;
int GetType();
int OnLButtonDown(UINT nFlags, const Position& pos) ;
int OnMouseMove(UINT nFlags, const Position& pos) ;
int OnRButtonDown(UINT nFlags, const Position& pos) ;
int Cancel() ;
} ;
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
/*
* CCreateArc
*/
class CCreateArc : public CCommand
{
private:
Position m_center;
Position m_begin;
Position m_end ;
public:
CCreateArc() ;
~CCreateArc() ;
int GetType();
int OnLButtonDown(UINT nFlags, const Position& pos) ;
int OnMouseMove(UINT nFlags, const Position& pos) ;
int OnRButtonDown(UINT nFlags, const Position& pos) ;
int Cancel() ;
} ;
class CMove : public CCommand
{
private:
Position m_basePos;
Position m_desPos;
public:
CMove() ;
~CMove() ;
int GetType();
int OnLButtonDown(UINT nFlags, const Position& pos) ;
int OnMouseMove(UINT nFlags, const Position& pos) ;
int OnRButtonDown(UINT nFlags, const Position& pos) ;
int Cancel() ;
} ;
class CRotate : public CCommand
{
private:
Position m_basePos;
Position m_desPos;
public:
CRotate() ;
~CRotate() ;
int GetType();
int OnLButtonDown(UINT nFlags, const Position& pos) ;
int OnMouseMove(UINT nFlags, const Position& pos) ;
int OnRButtonDown(UINT nFlags, const Position& pos) ;
int Cancel() ;
} ;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -