Project

General

Profile

Bug #1379 ยป Example.cpp

Anonymous, 07/30/2012 05:38 PM

 
#include <Wt/WContainerWidget>
#include <Wt/WCompositeWidget>

#include <Wt/WGroupBox>
#include <Wt/WVBoxLayout>
#include <Wt/WHBoxLayout>
#include <Wt/WPushButton>
#include <Wt/WPanel>

using namespace Wt;

class GroupLayout : public Wt::WCompositeWidget {
public:
GroupLayout (WContainerWidget* parent = nullptr)
: WCompositeWidget(parent) {
auto impl = new WContainerWidget;
setImplementation(impl);

auto implLayout = new WVBoxLayout();
impl->setLayout(implLayout);

auto group = new WGroupBox("GroupLayout", impl);
implLayout->addWidget(group);

auto groupLayout = new WHBoxLayout(group);
group->setLayout(groupLayout);

groupLayout->addWidget(new WPushButton("eins"));
groupLayout->addWidget(new WPushButton("zwei"));
groupLayout->addWidget(new WPushButton("drei"));
}
};

class Playground : public Wt::WApplication {
public:
Playground(const Wt::WEnvironment& env)
: WApplication(env)
{
auto layout = new WVBoxLayout(root());
root()->setLayout(layout);

layout->addWidget(new GroupLayout(root()));

// auto workaround = new WContainerWidget(root());
// auto panel = new WPanel(workaround);
// layout->addWidget(workaround);

auto panel = new WPanel(root());
layout->addWidget(panel);

panel->setTitle("a title");
panel->setCentralWidget(new GroupLayout);
panel->setCollapsible(true);

layout->addWidget(new GroupLayout(root()));

layout->addStretch(1);
}

static Wt::WApplication* CreateApplication(const Wt::WEnvironment& env)
{
return new Playground(env);
}

int main (int argc, char **argv)
{
return WRun(argc, argv, &Playground::CreateApplication);
}

};
    (1-1/1)