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
81
82
|
/***************************************************************************
* 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(TQWidget *parent, Type type)
: TQFrame(parent), _type(type)
{
initLayout();
}
Container::Container(TQWidgetStack *stack, uint index, Type type)
: TQFrame(stack), _type(type)
{
initLayout();
stack->addWidget(this, index);
}
Container::Container(TQTabWidget *tabw, const TQString &title, Type type)
: TQFrame(tabw), _type(type)
{
initLayout();
tabw->addTab(this, title);
}
void Container::setFrame(Type type)
{
_type = type;
switch (type) {
case Flat:
setMargin(parent() && parent()->inherits("TQTabWidget") ? 10 : 0);
setFrameStyle(TQFrame::NoFrame);
break;
case Sunken:
setMargin(10);
setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
break;
}
}
void Container::initLayout()
{
_topLayout = new TQGridLayout(this, 1, 1, 0, 10);
_gridLayout = new TQGridLayout(1, 1, 10);
_topLayout->addLayout(_gridLayout, 0, 0);
_topLayout->setRowStretch(1, 1);
setFrame(_type);
}
void Container::addWidget(TQWidget *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(TQLayout *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 TQString &title, TQWidget *parent)
: Container(parent, Sunken)
{
_button = new PopupButton(title, this);
addWidget(_button, 0,0, 0,1);
setColStretch(2, 1);
}
#include "container.moc"
|