-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectbutton.cpp
More file actions
40 lines (38 loc) · 1.2 KB
/
selectbutton.cpp
File metadata and controls
40 lines (38 loc) · 1.2 KB
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
#include "selectbutton.h"
const QSize selectbutton::m_fixedsize(140,35);
selectbutton::selectbutton(QPoint pos,MainWindow* game):
m_game(game),
m_pos(pos)
{
m_selectboximagepath[0]=":/images/image/tower1.jpg";
m_selectboximagepath[1]=":/images/image/tower2.jpg";
m_selectboximagepath[2]=":/images/image/tower3.jpg";
m_selectboximagepath[3]=":/images/image/back.jpg";
}
selectbutton::~selectbutton()
{
m_game=NULL;
}
void selectbutton::draw(QPainter *painter) const
{
painter->save();
painter->drawPixmap(m_pos.x(),m_pos.y(),m_selectboximagepath[0]);
painter->drawPixmap(m_pos.x()+35,m_pos.y(),m_selectboximagepath[1]);
painter->drawPixmap(m_pos.x()+70,m_pos.y(),m_selectboximagepath[2]);
painter->drawPixmap(m_pos.x()+105,m_pos.y(),m_selectboximagepath[3]);
painter->restore();
}
void selectbutton::getremoved()
{
m_game->removebutton(this);
}
bool selectbutton::containpos(QPoint pos)
{
bool xinhere=pos.x()>m_pos.x()&&pos.x()<m_pos.x()+m_fixedsize.width();
bool yinhere=pos.y()>m_pos.y()&&pos.y()<m_pos.y()+m_fixedsize.height();
return xinhere&&yinhere;
}
QPoint selectbutton::getpos()
{
return this->m_pos;
}