Wt examples: /home/koen/project/wt/public-git/wt/examples/charts/PanelList.C Source File

Wt examples 3.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

/home/koen/project/wt/public-git/wt/examples/charts/PanelList.C
Go to the documentation of this file.

    00001 /*
    00002  * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
    00003  *
    00004  * See the LICENSE file for terms of use.
    00005  */
    00006
    00007 #include <Wt/WPanel>
    00008
    00009 #include "PanelList.h"
    00010
    00011 using namespace Wt;
    00012
    00013 PanelList::PanelList(WContainerWidget *parent)
    00014   : WContainerWidget(parent)
    00015 { }
    00016
    00017 WPanel *PanelList::addWidget(const WString& text, WWidget *w)
    00018 {
    00019   WPanel *p = new WPanel();
    00020   p->setTitle(text);
    00021   p->setCentralWidget(w);
    00022
    00023   addPanel(p);
    00024
    00025   return p;
    00026 }
    00027
    00028 void PanelList::addPanel(WPanel *panel)
    00029 {
    00030   panel->setCollapsible(true);
    00031   panel->collapse();
    00032
    00033   panel->expandedSS().connect(this, &PanelList::onExpand);
    00034
    00035   WContainerWidget::addWidget(panel);
    00036 }
    00037
    00038 void PanelList::onExpand(bool notUndo)
    00039 {
    00040   WPanel *panel = dynamic_cast<WPanel *>(sender());
    00041
    00042   if (notUndo) {
    00043     wasExpanded_ = -1;
    00044
    00045     for (unsigned i = 0; i < children().size(); ++i) {
    00046       WPanel *p = dynamic_cast<WPanel *>(children()[i]);
    00047       if (p != panel) {
    00048         if (!p->isCollapsed())
    00049           wasExpanded_ = i;
    00050         p->collapse();
    00051       }
    00052     }
    00053   } else {
    00054     if (wasExpanded_ != -1) {
    00055       WPanel *p = dynamic_cast<WPanel *>(children()[wasExpanded_]);
    00056       p->expand();
    00057     }
    00058   }
    00059 }