-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchess.cpp
46 lines (40 loc) · 943 Bytes
/
chess.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "chess.h"
#include "def.h"
Chess::Chess(QString sName,ChessColor clr)
:m_Name(sName)
,m_Color(clr)
{
}
void Chess::Draw(QPainter& painter,int i,int j)
{
//painter.setPen(Qt::NoPen); // 不绘制边框
if(GetColor()==ChessColor::RED)
{
painter.setBrush(Qt::red);
}
else
{
painter.setBrush(Qt::black); // 设置圆的填充颜色
}
painter.drawEllipse(BOARD_LEFT+j*SPAN_CX, BOARD_TOP+i*SPAN_CY, 35, 35);
// 设置文本颜色和字体
painter.setPen(Qt::white);
painter.setFont(QFont("Arial", 20,1000));
painter.drawText(BOARD_LEFT+3+j*SPAN_CX, BOARD_TOP+28+i*SPAN_CY, GetName());
}
QString Chess::GetName()
{
return m_Name;
}
void Chess::SetName(QString sName)
{
m_Name=sName;
}
void Chess::SetChessColor(ChessColor clr)
{
m_Color=clr;
}
ChessColor Chess::GetColor()
{
return m_Color;
}