中国象棋控件 v2.0.13
载入中...
搜索中...
未找到
ChineseChessView.h
1#pragma once
2
3#include "ChineseChess.h"
4
5#ifdef CHINESE_CHESS_USE_PNG
6 #include<atlimage.h>
7#endif
8
9class AFX_EXT_CLASS CChineseChessHandler
10{
11public:
14
29 virtual int OnGoChess(int i, int j, CPiece::ENUM_QiZi chess) = 0;
30};
31
32class AFX_EXT_CLASS CChineseChessView : public CView, public CChineseChess
33{
34 DECLARE_DYNAMIC(CChineseChessView)
35
36public:
38 virtual ~CChineseChessView();
39 void AboutBox();
40
41 int SetQiPangColor(COLORREF col);
42 COLORREF GetQiPangColor();
43 int SetTiShiBoxColor(COLORREF col);
44 COLORREF GetTiShiBoxColor();
45 virtual int SaveChessGame(LPCTSTR pszFile);
46 virtual int LoadChessGame(LPCTSTR pszFile);
47 virtual int SetRedName(LPCTSTR pszName);
48 virtual int SetBlackName(LPCTSTR pszName);
49 virtual int AddGameTag(LPCTSTR pszTag, LPCTSTR szVal);
50 CString GetGameTag(LPCTSTR szTag);
51
52 int SetChineseChessHandler(CChineseChessHandler* handler);
53
54protected:
55 DECLARE_MESSAGE_MAP()
56 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
57 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
58 afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
59 afx_msg void OnSize(UINT nType, int cx, int cy);
60 virtual void OnDraw(CDC* pDC);
61
62protected:
63 virtual int onPromptSound(PROMPT_SOUND sound);
64 virtual int onPromptMessage(CGoRule::ENUM_ReturnValue val);
65
66 virtual int onCleanPrompt(int i, int j);
67 virtual int onDrawPrompt(int i, int j);
68 virtual int onGoChess(int i, int j, CPiece::ENUM_QiZi chess);
69
70private:
71 LONG m_QiPangStartX; //̵Ŀʼ
72 LONG m_QiPangStartY; //̵Ŀʼ
73 LONG m_QiPangDistance; //̸ľ
74
75 COLORREF m_QiPangColor;
76 COLORREF m_TiShiBoxColor;
77
78
79 //Ӻ
80 CBitmap m_Chu;
81 CBitmap m_He;
82 CBitmap m_Han;
83 CBitmap m_Jie;
84 CBitmap m_Copyright;
85
86#ifdef CHINESE_CHESS_USE_PNG
87 ATL::CImage m_QiPangPicture; //̱ͼƬ
88
89 //ͼƬ
90 ATL::CImage m_RedShuai; //˧
91 ATL::CImage m_RedShi; //
92 ATL::CImage m_RedXiang; //
93 ATL::CImage m_RedMa; //
94 ATL::CImage m_RedChe; //쳵
95 ATL::CImage m_RedBing; //
96 ATL::CImage m_RedPao; //
97
98 ATL::CImage m_BlackShuai; //˧
99 ATL::CImage m_BlackShi; //
100 ATL::CImage m_BlackXiang; //
101 ATL::CImage m_BlackMa; //
102 ATL::CImage m_BlackChe; //ڳ
103 ATL::CImage m_BlackBing; //ڱ
104 ATL::CImage m_BlackPao; //
105#else
106 CBitmap m_QiPangPicture; //̱ͼƬ
107
108 //ͼƬ
109 CBitmap m_RedShuai; //˧
110 CBitmap m_RedShi; //
111 CBitmap m_RedXiang; //
112 CBitmap m_RedMa; //
113 CBitmap m_RedChe; //쳵
114 CBitmap m_RedBing; //
115 CBitmap m_RedPao; //
116
117 CBitmap m_BlackShuai; //˧
118 CBitmap m_BlackShi; //
119 CBitmap m_BlackXiang; //
120 CBitmap m_BlackMa; //
121 CBitmap m_BlackChe; //ڳ
122 CBitmap m_BlackBing; //ڱ
123 CBitmap m_BlackPao; //
124#endif
125
126#ifdef CHINESE_CHESS_USE_PNG
127 // ԴмͼƬ CImage
128 BOOL LoadImageFromResource(ATL::CImage *pImage, UINT ID, LPCTSTR pType = _T("PNG"));
129 BOOL LoadImageFromResource(ATL::CImage *pImage, LPCTSTR pID, LPCTSTR pType = _T("PNG"));
130#endif
131
132 //ת
133 enum ENUM_ConvertCoordinate { XYToIJ, IJToXY };
134 BOOL ConvertCoordinate(long *x, long *y, int *i, int *j, ENUM_ConvertCoordinate eCC = XYToIJ);
135
136 //λ
137 enum ENUM_XINWEI { XinWei, Left_XinWei, Right_XinWei };
138 void DrawXinWei(CDC *pdc, int i, int j, ENUM_XINWEI xinwei = XinWei);
139 BOOL DrawTiShiBox(CDC *pdc, int i, int j);
140 BOOL DrawQiZi(CDC *pdc, int i, int j, CPiece::ENUM_QiZi eQiZi);
141 void DrawQiPang(CDC *pdc, CRect rcBounds);
142#ifdef CHINESE_CHESS_USE_PNG
143 BOOL DrawPicture(CDC *pdc, int i, int j, ATL::CImage* pImage);
144#endif
145 BOOL DrawPicture(CDC *pdc, int i, int j, CBitmap* pbmp, BOOL CHHJKL = false);
146
147 void InvalidateRectage(int i, int j);
148
149 BOOL SetQiPang(int width, int height);
150 BOOL PromptSound(LPCTSTR ID = NULL);
151
152 CChineseChessHandler* m_pGoChessHandler;
153};
virtual int OnGoChess(int i, int j, CPiece::ENUM_QiZi chess)=0
Executes the go chess action
中国象棋类
PROMPT_SOUND
提示音