Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2006 Wim Dumon, Koen Deforche
- *
- * See the LICENSE file for terms of use.
- */
- #include <iostream>
- #include <vector>
- #include <string>
- #include <boost/format.hpp>
- #include <Wt/WApplication>
- #include <Wt/WBreak>
- #include <Wt/WContainerWidget>
- #include <Wt/WDialog>
- #include <Wt/WLineEdit>
- #include <Wt/WPushButton>
- #include <Wt/WText>
- #include <Wt/WGridLayout>
- #include <Wt/WRadioButton>
- #include <Wt/WButtonGroup>
- #include <Wt/WTextArea>
- #include <Wt/WHBoxLayout>
- #include <Wt/WVBoxLayout>
- #include <Wt/WTabWidget>
- #include <Wt/WSignalMapper>
- #include <Wt/WPanel>
- #define ALIGN_TITLE (Wt::AlignCenter | Wt::AlignTop)
- #define ALIGN_TOP_LEFT (Wt::AlignLeft | Wt::AlignTop)
- #define ALIGN_TOP_RIGHT (Wt::AlignRight | Wt::AlignTop)
- #define ALIGN_TOP_CENTER (Wt::AlignCenter | Wt::AlignTop)
- using namespace Wt;
- using namespace std;
- /*
- * demonstrate layout with tabs and panels
- */
- class LayoutDemo : public WApplication
- {
- public:
- LayoutDemo(const WEnvironment& env);
- ~LayoutDemo();
- private:
- WTabWidget *createTabs();
- WContainerWidget *createATab(string label);
- WWidget *showLog();
- WWidget *showScanStatus();
- void ShowDialog();
- };
- /*
- * The env argument contains information about the new session, and
- * the initial request. It must be passed to the WApplication
- * constructor so it is typically also an argument for your custom
- * application constructor.
- */
- LayoutDemo::LayoutDemo(const WEnvironment& env) : WApplication(env)
- {
- useStyleSheet("layoutDemo.css");
- setCssTheme("polished");
- setTitle("Layout Demo Test "); // application title
- WContainerWidget *outerContainer = new WContainerWidget(WApplication::instance()->root());
- WVBoxLayout *innerVbox = new WVBoxLayout(outerContainer);
- WText *top = new WText("This is the top line");
- innerVbox->addWidget(top, 0, AlignTop | AlignJustify);
- WContainerWidget *scrolledContainer = new WContainerWidget(); // no parent
- scrolledContainer->setStyleClass("scrolledContainer");
- // TODO - why don't scrollbars resize with window?
- scrolledContainer->setOverflow(WContainerWidget::OverflowAuto, Horizontal);
- scrolledContainer->setOverflow(WContainerWidget::OverflowAuto, Vertical);
- WVBoxLayout *vbox2 = new WVBoxLayout(scrolledContainer);
- // create all widgets in a tab selection
- vbox2->addWidget( createTabs(), 0, ALIGN_TOP_CENTER);
- innerVbox->addWidget(scrolledContainer, 1, ALIGN_TOP_CENTER);
- WPanel *panel1 = new WPanel();
- WContainerWidget *cw = new WContainerWidget();
- WHBoxLayout *logScanLayout = new WHBoxLayout(cw);
- logScanLayout->addWidget( showLog(), 1, ALIGN_TOP_LEFT);
- logScanLayout->addWidget( showScanStatus(), 1, ALIGN_TOP_RIGHT);
- panel1->setCentralWidget(cw);
- panel1->setTitle("Log & Scan Status");
- panel1->setTitleBar(true);
- panel1->setCollapsible(true);
- vbox2->addWidget(panel1, 0, ALIGN_TOP_CENTER);
- }
- WWidget *LayoutDemo::showLog() {
- WContainerWidget *container = new WContainerWidget();
- container->setOverflow(WContainerWidget::OverflowScroll);
- container->setStyleClass("log-container");
- return container;
- }
- WWidget *LayoutDemo::showScanStatus( ) {
- WContainerWidget *container = new WContainerWidget();
- container->setOverflow(WContainerWidget::OverflowScroll);
- container->setStyleClass("log-container");
- return container;
- }
- LayoutDemo::~LayoutDemo()
- {
- }
- WContainerWidget *LayoutDemo::createATab(string label)
- {
- WContainerWidget *cw = new WContainerWidget();
- WHBoxLayout *contentsLayout = new WHBoxLayout();
- cw->setStyleClass("editScanContainer");
- cw->setLayout(contentsLayout);
- WVBoxLayout *scanSelVbox = new WVBoxLayout();
- WText *head1 = new WText(label);
- head1->setStyleClass("col_text");
- scanSelVbox->addWidget(head1, 0, ALIGN_TITLE);
- scanSelVbox->addWidget(new WText("xxx"));
- scanSelVbox->addWidget(new WText("yyy"));
- scanSelVbox->addWidget(new WText("zzz"));
- contentsLayout->addLayout(scanSelVbox, 1, ALIGN_TOP_LEFT);
- contentsLayout->addWidget(new WText("00000"), 0, ALIGN_TOP_LEFT);
- contentsLayout->addWidget(new WText("11111"), 0, ALIGN_TOP_LEFT);
- contentsLayout->addWidget(new WText("22222"), 0, ALIGN_TOP_LEFT);
- contentsLayout->addWidget(new WText("33333"), 0, ALIGN_TOP_LEFT);
- return cw;
- }
- WTabWidget *LayoutDemo::createTabs()
- {
- WTabWidget *tabWidget = new WTabWidget( );
- tabWidget->setStyleClass("mainTab");
- WContainerWidget *cw;
- tabWidget->addTab(cw = createATab("Axx"), "A", WTabWidget::PreLoading);
- tabWidget->addTab(cw = createATab("Bxx"), "B", WTabWidget::PreLoading);
- tabWidget->addTab(cw = createATab("Cxx"), "C", WTabWidget::PreLoading);
- tabWidget->addTab(cw = createATab("Dxx"), "D", WTabWidget::PreLoading);
- return tabWidget;
- }
- WApplication *createApplication(const WEnvironment& env)
- {
- /*
- * You could read information from the environment to decide whether
- * the user has permission to start a new application
- */
- LayoutDemo *r = new LayoutDemo(env);
- // r->readConfiguration("/tmp/radar_ctl.txt");
- return r;
- }
- int main(int argc, char **argv)
- {
- /*
- * Your main method may set up some shared resources, but should then
- * start the server application (FastCGI or httpd) that starts listening
- * for requests, and handles all of the application life cycles.
- *
- * The last argument to WRun specifies the function that will instantiate
- * new application objects. That function is executed when a new user surfs
- * to the Wt application, and after the library has negotiated browser
- * support. The function should return a newly instantiated application
- * object.
- */
- return WRun(argc, argv, &createApplication);
- }
Advertisement
Add Comment
Please, Sign In to add comment