]> Shamusworld >> Repos - architektonas/blob - src/blockitemwidget.cpp
ea786f922924f4c2b2a983516b5abe74729543d5
[architektonas] / src / blockitemwidget.cpp
1 // layeritemwidget.cpp: Layer item widget
2 //
3 // Part of the Architektonas Project
4 // (C) 2011 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
6 //
7 // JLH = James Hammons <jlhamm@acm.org>
8 //
9 // WHO  WHEN        WHAT
10 // ---  ----------  ------------------------------------------------------------
11 // JLH  07/13/2013  Created this file
12 //
13
14 #include "blockitemwidget.h"
15
16
17 BlockItemWidget::BlockItemWidget(QString s, QPixmap * i/*=0*/):
18         QWidget(),
19         name(new QLabel(s)),
20         image(new QLabel)
21 {
22         QHBoxLayout * mainLayout = new QHBoxLayout;
23         mainLayout->setContentsMargins(0, 0, 0, 0); // This is required, otherwise the layout engine puts too much space around this widget. :-/
24
25         if (i == 0)
26         {
27                 i = new QPixmap(36, 32);
28                 i->fill();      // Fills pixmap with white
29                 QPainter p(i);
30                 p.setPen(Qt::black);
31                 p.drawLine(0, 0, 31, 31);
32                 p.drawLine(0, 31, 31, 0);
33         }
34
35         image->setPixmap(*i);
36
37         mainLayout->addWidget(image);
38         mainLayout->addWidget(name);
39         mainLayout->addStretch();
40         setLayout(mainLayout);
41 QSize size = mainLayout->sizeHint();
42 printf("BlockItemWidget: size. w=%i, h=%i\n", size.width(), size.height());
43 }
44
45
46 BlockItemWidget::~BlockItemWidget()
47 {
48 }
49