Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wt/WApplication>
- #include <Wt/WComboBox>
- #include <Wt/WContainerWidget>
- #include <Wt/WGridLayout>
- #include <Wt/WVBoxLayout>
- #include <Wt/WGroupBox>
- #include <Wt/WLabel>
- #include <Wt/WText>
- #include <Wt/WPushButton>
- #include <iostream>
- class WtApp : public Wt::WApplication
- {
- public:
- WtApp( const Wt::WEnvironment& env);
- ~WtApp() {}
- private:
- Wt::WText *createText(const Wt::WString& text);
- Wt::WWidget *createSelection();
- private:
- Wt::WGridLayout* mLayout;
- };
- WtApp::WtApp(const Wt::WEnvironment& env)
- : Wt::WApplication(env)
- , mLayout(new Wt::WGridLayout(root()))
- {
- root()->setLayout(mLayout);
- // row 0
- mLayout->addWidget(createText("Title"), 0, 0, 0, 3, Wt::AlignTop|Wt::AlignCenter);
- // row 1
- mLayout->addWidget(createText("SubTitle"), 1, 0, 1, 3, Wt::AlignMiddle|Wt::AlignCenter);
- // row 2
- mLayout->addWidget(createSelection(), 2, 0, Wt::AlignLeft);
- mLayout->addWidget(createText("Main Area"), 2, 1, Wt::AlignJustify);
- mLayout->addWidget(createText("Details"), 2, 2, Wt::AlignJustify);
- // row 3
- mLayout->addWidget(createText("More details"), 3, 0, 1, 3);
- /*
- * Let row 2 and column 1 take the excess space.
- */
- mLayout->setRowStretch(2, 1);
- mLayout->setRowStretch(3, 1);
- mLayout->setColumnStretch(1, 1);
- mLayout->setColumnStretch(2, 0);
- mLayout->setColumnResizable(1);
- mLayout->setRowResizable(2);
- mLayout->setHorizontalSpacing(4);
- mLayout->setVerticalSpacing(2);
- mLayout->setContentsMargins(4, 4, 4, 4);
- }
- Wt::WText *WtApp::createText(const Wt::WString& text)
- {
- return new Wt::WText(text);
- }
- Wt::WWidget *WtApp::createSelection()
- {
- Wt::WContainerWidget *w = new Wt::WContainerWidget();
- Wt::WGroupBox *gbox1 = new Wt::WGroupBox("Config");
- gbox1->addWidget(createText("Config selection"));
- Wt::WComboBox *cbox1 = new Wt::WComboBox();
- cbox1->addItem("please select");
- cbox1->addItem("System");
- Wt::WGroupBox *gbox2 = new Wt::WGroupBox("Selection Box");
- Wt::WComboBox *cbox2 = new Wt::WComboBox();
- cbox2->addItem("please select");
- cbox2->addItem("Entity 1");
- Wt::WVBoxLayout* gvbox2 = new Wt::WVBoxLayout();
- gvbox2->addWidget(createText("Test 1"), 0, Wt::AlignTop);
- gvbox2->addWidget(cbox2, 0, Wt::AlignTop);
- gbox2->setLayout(gvbox2);
- Wt::WVBoxLayout* vbox = new Wt::WVBoxLayout();
- vbox->setContentsMargins(4, 2, 4, 2);
- vbox->addWidget(gbox1, 0, Wt::AlignTop);
- vbox->addWidget(cbox1, 0, Wt::AlignTop);
- vbox->addWidget(gbox2, 0, Wt::AlignTop);
- vbox->addWidget(createText(""), 1);
- w->setLayout(vbox);
- return w;
- }
- Wt::WApplication *createApplication(const Wt::WEnvironment& env)
- {
- Wt::WApplication* myApplication = 0;
- myApplication = new WtApp( env );
- return myApplication;
- }
- int main(int argc, char **argv)
- {
- Wt::WRun(argc, argv, &createApplication);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment