-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextedit_test.cpp
More file actions
53 lines (44 loc) · 1.3 KB
/
textedit_test.cpp
File metadata and controls
53 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WCssDecorationStyle>
class HelloApplication : public Wt::WApplication
{
public:
HelloApplication(const Wt::WEnvironment& env);
private:
Wt::WLineEdit *nameEdit_;
Wt::WText *greeting_;
void greet();
};
HelloApplication::HelloApplication(const Wt::WEnvironment& env)
: Wt::WApplication(env)
{
setTitle("Hello world");
Wt::WText *title = new Wt::WText("<h1>A Witty blog: Hangman</h1>");
root()->addWidget(title);
root()->addWidget(new Wt::WText("Your name, please?"));
nameEdit_ = new Wt::WLineEdit(root());
Wt::WPushButton *button = new Wt::WPushButton("Greet me.", root());
button->setStyleClass(button)
root()->addWidget(new Wt::WBreak());
greeting_ = new Wt::WText(root());
button->clicked().connect(this, &HelloApplication::greet);
}
void HelloApplication::greet()
{
greeting_->setText("Hello there, " + nameEdit_->text());
}
Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
Wt::WApplication *app = new HelloApplication(env);
app->useStyleSheet("hello.css");
return app;
}
int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, &createApplication);
}