Wt examples: mission/impossible.C File Reference

Wt examples 4.10.4

Loading...
Searching...
No Matches
Functions
impossible.C File Reference
`#include <Wt/WApplication.h>`
`#include <Wt/WBreak.h>`
`#include <Wt/WContainerWidget.h>`
`#include <Wt/WPushButton.h>`
`#include <Wt/WText.h>`
`#include "CountDownWidget.h"`

Go to the source code of this file.

## Functions
std::unique_ptr< WApplication > | createApplication (const WEnvironment &env)
int | main (int argc, char **argv)

## Function Documentation

## ◆ createApplication()

std::unique_ptr< WApplication > createApplication | ( | const WEnvironment & | env | ) |

Definition at line 15 of file impossible.C.

16{
17 std::unique_ptr<WApplication> appl
18 = std::make_unique<WApplication>(env);
19
20 appl->root()->addWidget(std::make_unique<WText>("<h1>Your mission</h1>"));
21 WText *secret
22 = appl->root()->addWidget(std::make_unique<WText>("Your mission, Jim, should you accept, is to create solid "
23 "web applications."));
24
25 appl->root()->addWidget(std::make_unique<WBreak>());
26 appl->root()->addWidget(std::make_unique<WBreak>());
27
28 appl->root()->addWidget(std::make_unique<WText>("This program will quit in "));
29 CountDownWidget *countdown = appl->root()->addWidget(std::make_unique<CountDownWidget>(10, 0, std::chrono::milliseconds{1000}));
30 appl->root()->addWidget(std::make_unique<WText>(" seconds."));
31
32 appl->root()->addWidget(std::make_unique<WBreak>());
33 appl->root()->addWidget(std::make_unique<WBreak>());
34
35 WPushButton *cancelButton = appl->root()->addWidget(std::make_unique<WPushButton>("Cancel!"));
36 WPushButton *quitButton = appl->root()->addWidget(std::make_unique<WPushButton>("Quit"));
37 quitButton->clicked().connect(appl.get(), &WApplication::quit);
38
39 countdown->done().connect([](){ WApplication::instance()->quit(); });
40 cancelButton->clicked().connect(countdown, &CountDownWidget::cancel);
41 cancelButton->clicked().connect(cancelButton, &WFormWidget::disable);
42 cancelButton->clicked().connect(secret, &WWidget::hide);
43
44 return appl;
45}
CountDownWidget
A widget which displays a decrementing number.
Definition CountDownWidget.h:27
CountDownWidget::done
Signal & done()
Signal emitted when the countdown reached stop.
Definition CountDownWidget.h:38
CountDownWidget::cancel
void cancel()
Cancel the count down.
Definition CountDownWidget.C:29

## ◆ main()

int main | ( | int | argc,
|  | char ** | argv )

Definition at line 47 of file impossible.C.

48{
49 return WRun(argc, argv, &createApplication);
50}
createApplication
std::unique_ptr< WApplication > createApplication(const WEnvironment &env)
Definition impossible.C:15