Wt examples: charts/PanelList.C Source File

Wt examples 4.10.4

Loading...
Searching...
No Matches
PanelList.C
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008 Emweb bv, Herent, Belgium.
3 *
4 * See the LICENSE file for terms of use.
5 */
6
7#include <Wt/WPanel.h>
8
9#include "PanelList.h"
10
11using namespace Wt;
12
13PanelList::PanelList()
14 : WContainerWidget()
15{ }
16
17WPanel *PanelList::addWidget(const WString& text, std::unique_ptr<WWidget> w)
18{
19 std::unique_ptr<WPanel> p
20 = std::make_unique<WPanel>();
21 WPanel *result = p.get();
22 p->setTitle(text);
23 p->setCentralWidget(std::move(w));
24
25 addPanel(std::move(p));
26
27 return result;
28}
29
30 void PanelList::addPanel(std::unique_ptr<WPanel> panel)
31{
32 panel->setCollapsible(true);
33 panel->collapse();
34
35 panel->expandedSS().connect(std::bind(&PanelList::onExpand, this, std::placeholders::_1, panel.get()));
36
37 WContainerWidget::addWidget(std::move(panel));
38}
39
40
41 void PanelList::onExpand(bool notUndo, WPanel *panel)
42{
43 if (notUndo) {
44 wasExpanded_ = -1;
45
46 for (unsigned i = 0; i < children().size(); ++i) {
47 WPanel *p = dynamic_cast<WPanel *>(children()[i]);
48 if (p != panel) {
49 if (!p->isCollapsed())
50 wasExpanded_ = i;
51 p->collapse();
52 }
53 }
54 } else {
55 if (wasExpanded_ != -1) {
56 WPanel *p = dynamic_cast<WPanel *>(children()[wasExpanded_]);
57 p->expand();
58 }
59 }
60}
PanelList.h
PanelList::PanelList
PanelList()
Definition PanelList.C:13
PanelList::wasExpanded_
int wasExpanded_
Definition PanelList.h:31
PanelList::onExpand
void onExpand(bool notUndo, Wt::WPanel *panel)
Definition PanelList.C:41
PanelList::addWidget
Wt::WPanel * addWidget(const Wt::WString &text, std::unique_ptr< Wt::WWidget > w)
Definition PanelList.C:17
PanelList::addPanel
void addPanel(std::unique_ptr< Wt::WPanel > panel)
Definition PanelList.C:30
Wt
Definition AddresseeEdit.h:16