-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamebutton.cpp
More file actions
38 lines (30 loc) · 778 Bytes
/
gamebutton.cpp
File metadata and controls
38 lines (30 loc) · 778 Bytes
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
#include "gamebutton.h"
#include "scaler.h"
#include "gamestock.h"
GameButton::GameButton(GamePanel *parent, const QRect &rect, const QString &text) :
GamePanel(parent, rect),
myText(text),
myFont(&gameStock->Font20),
myPicture(0)
{
}
void GameButton::paintContent(QPainter &p)
{
GamePanel::paintContent(p);
if (myHover && myPaintHover)
{
p.setPen(myTextHoverColor);
}
else
p.setPen(myTextColor);
if (myFont)
p.setFont(*myFont);
QRect r(DRECT(myRect));
if (myPicture)
{
int dy = (r.height() - myPicture->height()) / 2;
p.drawPixmap(r.topLeft()+QPoint(DX(5),dy), *myPicture);
r.setLeft(r.left() + DX(10) + myPicture->width());
}
p.drawText(r, Qt::AlignCenter, myText);
}