-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathkey.cpp
More file actions
72 lines (59 loc) · 1.18 KB
/
key.cpp
File metadata and controls
72 lines (59 loc) · 1.18 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
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
#include <QDebug>
#include "key.h"
key::key(QString t,QObject *parent) : QObject(parent)
{
text = t;
X =10;
Y =10;
W =t.length()*5 + 20;
H =25;
pressed = false;
}
QRect key::getRect()
{
return QRect(X,Y,W,H);
}
void key::setX(int x )
{
// qDebug() << "setX " << x << " " << text;
X = x;
}
void key::setY(int y )
{
// qDebug() << "setY " << y;
Y = y;
}
void key::setIconFile(QString i )
{
iconFilename = i;
W = 25;
}
void key::setPressed( bool b)
{
// qDebug() << "setPessed " << b;
pressed = b;
}
void key::draw(QPainter *p,QStyle *style) {
QStyleOptionButton opt;
opt.palette = QPalette(Qt::red);
/*
if ( pressed )
{
opt.state = QStyle::State_Active;
} else {
opt.state = QStyle::State_Enabled;
}
*/
opt.rect = QRect(X, Y, W, H);
if ( iconFilename !="" )
{
opt.icon = QIcon(iconFilename);
opt.iconSize=QSize(16,16);
}
else
{
if (text =="&") opt.text = "&&";
else opt.text = text;
}
style->drawControl(QStyle::CE_PushButton, &opt, p);
}