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
73
74
75
76
77
78
79
80
|
/***************************************************************************
* Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "container.h"
#include "misc_gui.h"
//----------------------------------------------------------------------------
Container::Container(QWidget *parent, Type type)
: QFrame(parent), _type(type)
{
initLayout();
}
Container::Container(QWidgetStack *stack, uint index, Type type)
: QFrame(stack), _type(type)
{
initLayout();
stack->addWidget(this, index);
}
Container::Container(QTabWidget *tabw, const QString &title, Type type)
: QFrame(tabw), _type(type)
{
initLayout();
tabw->addTab(this, title);
}
void Container::setFrame(Type type)
{
_type = type;
switch (type) {
case Flat:
setMargin(parent() && parent()->inherits("QTabWidget") ? 10 : 0);
setFrameStyle(QFrame::NoFrame);
break;
case Sunken:
setMargin(10);
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
break;
}
}
void Container::initLayout()
{
_topLayout = new QGridLayout(this, 1, 1, 0, 10);
_gridLayout = new QGridLayout(1, 1, 10);
_topLayout->addLayout(_gridLayout, 0, 0);
_topLayout->setRowStretch(1, 1);
setFrame(_type);
}
void Container::addWidget(QWidget *w, uint startRow, uint endRow, uint startCol, uint endCol, int alignment)
{
Q_ASSERT( startRow<=endRow );
Q_ASSERT( startCol<=endCol );
w->show();
_gridLayout->addMultiCellWidget(w, startRow, endRow, startCol, endCol, alignment);
}
void Container::addLayout(QLayout *l, uint startRow, uint endRow, uint startCol, uint endCol, int alignment)
{
Q_ASSERT( startRow<=endRow );
Q_ASSERT( startCol<=endCol );
_gridLayout->addMultiCellLayout(l, startRow, endRow, startCol, endCol, alignment);
}
//----------------------------------------------------------------------------
ButtonContainer::ButtonContainer(const QString &title, QWidget *parent)
: Container(parent, Sunken)
{
_button = new PopupButton(title, this);
addWidget(_button, 0,0, 0,1);
setColStretch(2, 1);
}
|