-
Notifications
You must be signed in to change notification settings - Fork 19
/
CardPic.cpp
91 lines (74 loc) · 1.26 KB
/
CardPic.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "CardPic.h"
#include <QPainter>
#include "Player.h"
CardPic::CardPic(QWidget *parent) :
QWidget(parent)
{
m_owner = NULL;
m_selected = false;
m_frontSide = true;
}
void CardPic::SetPic(const QPixmap& pic, const QPixmap& back)
{
m_pic = pic;
m_back = back;
resize(pic.size());
update();
}
QPixmap CardPic::GetPic()
{
return m_pic;
}
void CardPic::SetOwner(Player* owner)
{
m_owner = owner;
}
Player* CardPic::GetOwner()
{
return m_owner;
}
void CardPic::SetCard(Card card)
{
m_card = card;
}
Card CardPic::GetCard()
{
return m_card;
}
void CardPic::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
if (m_frontSide)
{
painter.drawPixmap(rect(), m_pic);
}
else
{
painter.drawPixmap(rect(), m_back);
}
}
void CardPic::mousePressEvent(QMouseEvent* event)
{
emit NotifySelected(event->button());
QWidget::mousePressEvent(event);
}
void CardPic::SetFrontSide(bool frontSide)
{
if (m_frontSide != frontSide)
{
m_frontSide = frontSide;
update();
}
}
bool CardPic::IsFrontSide()
{
return m_frontSide;
}
void CardPic::SetSelected(bool selected)
{
m_selected = selected;
}
bool CardPic::IsSelected()
{
return m_selected;
}