-
Notifications
You must be signed in to change notification settings - Fork 2
/
gua64widget.cpp
36 lines (31 loc) · 999 Bytes
/
gua64widget.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
#include "gua64widget.h"
#define INITIAL_Y_LOCATION 27
#define OFFSET 12
Gua64Widget::Gua64Widget(int hexKey, QString stringKey, QWidget *parent) : QWidget(parent)
{
hex = hexKey;
string = stringKey;
setFixedWidth(121);
setFixedHeight(110);
}
void Gua64Widget::paintEvent(QPaintEvent *){
QPainter painter(this);
int y = INITIAL_Y_LOCATION;
for (int i = 5; i >= 0; i--) {
if (!((hex >> i) & 1)) {
painter.setPen(QPen(Qt::black,1));
painter.setBrush(QBrush(Qt::black,Qt::SolidPattern));
painter.drawRect(20,y,35,8);
painter.drawRect(65,y,35,8);
} else {
painter.setPen(QPen(Qt::red,1));
painter.setBrush(QBrush(Qt::red,Qt::SolidPattern));
painter.drawRect(20,y,80,8);
}
y += OFFSET;
}
}
void Gua64Widget::mouseReleaseEvent(QMouseEvent *){
SubWidget::getInstance()->showGua(hex,string);
emit clicked();
}