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

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8