Project

General

Profile

Bug #7396 » forum_16637_2.cpp

Roel Standaert, 01/30/2020 04:33 PM

 
#include <Wt/WApplication.h>
#include <Wt/WBootstrapTheme.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WDateEdit.h>
#include <Wt/WDialog.h>
#include <Wt/WPanel.h>
#include <Wt/WText.h>
#include <Wt/WVBoxLayout.h>
#include <Wt/WLabel.h>


#include <memory>

// set to 1 to test with a dialog instead
#define DIALOG 0

using namespace Wt;


int main(int argc, char *argv[])
{
return Wt::WRun(argc, argv, [](const Wt::WEnvironment &env) {
auto app = std::make_unique<Wt::WApplication>(env);

auto theme = std::make_shared<Wt::WBootstrapTheme>();
theme->setVersion(Wt::BootstrapVersion::v3);
app->setTheme(theme);

#if DIALOG
Wt::WDialog *dialog = app->addChild(std::make_unique<Wt::WDialog>());
dialog->resize(300, 150);
dialog->setTitleBarEnabled(true);
dialog->titleBar()->addNew<Wt::WText>("Titlebar");
dialog->contents()->addNew<Wt::WDateEdit>();

dialog->show();
#else
WVBoxLayout *mainLayout;

auto layout = std::make_unique<WVBoxLayout>();
mainLayout = layout.get();

app->root()->setLayout(std::move(layout));

auto mainContainer = mainLayout->addWidget(std::make_unique<WContainerWidget>());
auto rightLayout = mainContainer->setLayout(std::make_unique<WVBoxLayout>());


Wt::WPanel *panel = rightLayout->addWidget(std::make_unique<WPanel>());
panel->setTitle(Wt::utf8("Titlebar"));
auto containerPtr = std::make_unique<Wt::WContainerWidget>();
auto container = containerPtr.get();
container->setMargin(50);
panel->setCentralWidget(std::move(containerPtr));
container->addNew<Wt::WDateEdit>();

rightLayout->addWidget(std::make_unique<WText>("Popup Cut Off Example"));
rightLayout->addWidget(std::make_unique<WLabel>(), 1);


#endif

return app;
});
}
(4-4/4)