📄 draw.h
字号:
/*
*
* Define Draw Objects
*
*/
class CDrawObject : public CObject
{
private:
COLORREF m_PenColor;//图元颜色
int m_iPenWidth; //画笔宽度
bool m_bFill; //是否填充
public:
bool m_bSelected;
long m_nStyle;//图元类型
CDrawObject(){m_bSelected = false;};
void SetPenColor(COLORREF color);//设置图元颜色
COLORREF GetPenColor();//获得图元颜色
void SetPenWidth(int width) {m_iPenWidth = width;};
int GetPenWidth() {return m_iPenWidth;};
void SetFill(bool fill) { m_bFill = fill;};
bool GetFill() {return m_bFill;};
virtual void Draw(CDC* pDC) {};
virtual void MoveAt(CDC* pDC, long x, long y) {};
virtual void EndPoint(CDC* pDC) {};
virtual void NewPoint(long x, long y){};//图形对象第一点坐标,如果返回false则结束绘图
virtual int AddPoint(long x, long y){return 0;};
};
class CDrawLine : public CDrawObject
{
private:
long m_x1, m_y1, m_x2, m_y2;
public:
CDrawLine(COLORREF color = UD_RED, int width = 1);
void Draw(CDC* pDC);
void NewPoint(long x, long y);
void MoveAt(CDC* pDC, long x, long y);
};
class CDrawCurve : public CDrawObject
{
private:
long m_x, m_y;
public:
CDrawCurve(COLORREF color = UD_RED, int width = 1);
void NewPoint(long x, long y);
void MoveAt(CDC* pDC, long x, long y);
};
class CDrawRect : public CDrawObject
{
private:
long m_x1, m_y1, m_x2, m_y2;
public:
CDrawRect(COLORREF color = UD_RED, int width = 1, bool fill = false);
void MoveAt(CDC* pDC, long x, long y);
void NewPoint(long x, long y);
void Draw(CDC* pDC);
};
class CDrawSelect : public CDrawObject
{
public:
long m_x1, m_y1, m_x2, m_y2;
public:
void Set(CDC *pDC,long x1, long y1,long width,long heighth);
CPoint p_maponmouse;
CDrawSelect(COLORREF color = UD_RED);
CBitmap map_select;
CBitmap backmap;
bool copied,maponmouse;
bool isin(CPoint p);
void MoveAt(CDC* pDC, long x, long y);
void NewPoint(long x, long y);
void Clear(CDC * pDC);
long GetWidth() { return( m_x2 - m_x1 ); };
long GetHeight() { return( m_y2 - m_y1 ); };
long GetX() { return m_x1; };
long GetY() { return m_y1; };
};
class CDrawEllipse : public CDrawObject
{
private:
long m_x1, m_y1, m_x2, m_y2;
public:
CDrawEllipse(COLORREF color = UD_RED, int width = 1, bool fill = false);
void MoveAt(CDC* pDC, long x, long y);
void NewPoint(long x, long y);
void Draw(CDC* pDC);
};
class CDrawCircle : public CDrawObject
{
private:
long m_x1, m_y1, m_x2, m_y2;
public:
CDrawCircle(COLORREF color = UD_RED, int width = 1, bool fill = false);
void MoveAt(CDC* pDC, long x, long y);
void NewPoint(long x, long y);
void Draw(CDC* pDC);
};
#define MAXPLINEPOINT 20
class CDrawPoly : public CDrawObject
{
private:
CPoint m_aPoints[MAXPLINEPOINT];
long m_oldx, m_oldy;
public:
long m_nNumber;//端点总数
CDrawPoly(COLORREF color = UD_RED, int width = 1);
void MoveAt(CDC* pDC, long x, long y);
void NewPoint(long x, long y);
int AddPoint(long x, long y);
void EndPoint(CDC* pDC);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -