-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagelayout.cpp
executable file
·64 lines (54 loc) · 1.62 KB
/
imagelayout.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
#include "imagelayout.h"
QImageLayoutButton::QImageLayoutButton(QWidget *parent) :
QPushButton(parent),
imageList(0)
{
initLayout();
}
QImageLayoutButton::QImageLayoutButton(const QString &text, QWidget *parent) :
QPushButton(text, parent),
imageList(0)
{
initLayout();
}
QImageLayoutButton::QImageLayoutButton(const QIcon &icon, const QString &text, QWidget *parent) :
QPushButton(icon, text, parent),
imageList(0)
{
initLayout();
}
QImageLayoutButton::~QImageLayoutButton()
{
delete imageList;
}
void QImageLayoutButton::initLayout()
{
imageList = new QList<TImage>();
rect.setCoords(0,0,0,0);
}
void QImageLayoutButton::setRect(QRectF rect)
{
this->rect = rect;
}
void QImageLayoutButton::setRect(qreal x, qreal y, qreal w, qreal h)
{
// Just call the other variant so everthing is done in one place
setRect(QRectF(x,y,w,h));
}
void QImageLayoutButton::addImage(QRectF rect, int flags)
{
TImage *image = new TImage;
image->rect = rect;
image->flags = flags;
imageList->append(*image);
// Adjust the bounding rectangle if necessary
if (rect.left() < this->rect.left() ) this->rect.setLeft(rect.left());
if (rect.right() > this->rect.right() ) this->rect.setRight(rect.right());
if (rect.top() < this->rect.top() ) this->rect.setTop(rect.top());
if (rect.bottom() > this->rect.bottom()) this->rect.setBottom(rect.bottom());
}
void QImageLayoutButton::addImage(qreal x, qreal y, qreal w, qreal h, int flags)
{
// Just call the other variant so everthing is done in one place
addImage(QRectF(x,y,w,h), flags);
}