1
|
#include <Wt/WTable>
|
2
|
#include <Wt/WTableCell>
|
3
|
#include <Wt/WText>
|
4
|
#include <Wt/WApplication>
|
5
|
#include <Wt/WEnvironment>
|
6
|
#include <Wt/WCssTheme>
|
7
|
#include <Wt/WCssStyleSheet>
|
8
|
#include <Wt/WBootstrapTheme>
|
9
|
#include <Wt/WPushButton>
|
10
|
#include <Wt/WTable>
|
11
|
#include <Wt/WWidget>
|
12
|
#include <Wt/WContainerWidget>
|
13
|
#include <Wt/WString>
|
14
|
#include <Wt/WMenuItem>
|
15
|
#include <Wt/WMenu>
|
16
|
#include <Wt/WPopupWidget>
|
17
|
#include <Wt/WObject>
|
18
|
#include <iostream>
|
19
|
#include <string>
|
20
|
#include <stdlib.h>
|
21
|
|
22
|
|
23
|
class FrameButton : public Wt::WObject
|
24
|
{
|
25
|
public:
|
26
|
FrameButton(Wt::WPushButton *, Wt::WPopupWidget *);
|
27
|
Wt::WPushButton *getButton() { return fButton; }
|
28
|
Wt::WPopupWidget *popup;
|
29
|
void setTransient1();
|
30
|
void setTransient2();
|
31
|
|
32
|
private:
|
33
|
void buttonClicked();
|
34
|
Wt::WPushButton *fButton;
|
35
|
bool popuphidden;
|
36
|
};
|
37
|
|
38
|
|
39
|
FrameButton::FrameButton(Wt::WPushButton *button, Wt::WPopupWidget *popupWidget) {
|
40
|
fButton = button;
|
41
|
popup = popupWidget;
|
42
|
popup->setAnchorWidget(fButton, Wt::Vertical);
|
43
|
popup->setTransient(false, 1000);
|
44
|
popuphidden = false;
|
45
|
popup->setHidden(true);
|
46
|
fButton->clicked().connect(this, &FrameButton::buttonClicked);
|
47
|
printf("FrameButton::FrameButton(...) popup=%p", popup);
|
48
|
}
|
49
|
|
50
|
void FrameButton::buttonClicked() {
|
51
|
if (popuphidden) {
|
52
|
popuphidden = false;
|
53
|
popup->setHidden(false);
|
54
|
fButton->setText("Popup verbergen");
|
55
|
} else {
|
56
|
popuphidden = true;
|
57
|
fButton->setText("Popup anzeigen");
|
58
|
popup->setHidden(true);
|
59
|
}
|
60
|
popup->show();
|
61
|
}
|
62
|
|
63
|
void FrameButton::setTransient1() {
|
64
|
// is called but setTransient(true,0) has no effect :-(
|
65
|
popup->setTransient(true,0);
|
66
|
printf("FrameButton::setTransient1() popup=%p", popup);
|
67
|
}
|
68
|
|
69
|
void FrameButton::setTransient2() {
|
70
|
// is called but setTransient(false,4000) has no effect :-(
|
71
|
popup->setTransient(false,4000);
|
72
|
printf("FrameButton::setTransient2() popup=%p", popup);
|
73
|
}
|
74
|
|
75
|
|
76
|
|
77
|
Wt::WApplication *createApplication(const Wt::WEnvironment& env)
|
78
|
{
|
79
|
Wt::WApplication* app = new Wt::WApplication(env);
|
80
|
|
81
|
if (app->appRoot().empty()) {
|
82
|
std::cerr << "!!!!!!!!!!" << std::endl
|
83
|
<< "!! Warning: read the README.md file for hints on deployment,"
|
84
|
<< " the approot looks suspect!" << std::endl
|
85
|
<< "!!!!!!!!!!" << std::endl;
|
86
|
}
|
87
|
|
88
|
//app->setTheme(new Wt::WBootstrapTheme(app));
|
89
|
|
90
|
|
91
|
Wt::WContainerWidget *testDiv = new Wt::WContainerWidget();
|
92
|
testDiv->setContentAlignment(Wt::AlignRight);
|
93
|
|
94
|
Wt::WContainerWidget *buttonContainer = new Wt::WContainerWidget(testDiv);
|
95
|
Wt::WPushButton *button = new Wt::WPushButton("showPopup", buttonContainer);
|
96
|
|
97
|
Wt::WContainerWidget *popupInhalt = new Wt::WContainerWidget();
|
98
|
|
99
|
// Tabelle 3:
|
100
|
Wt::WTable *table3 = new Wt::WTable(popupInhalt);
|
101
|
table3->elementAt(0, 0)->addWidget(new Wt::WText("t @ row 0, t 0"));
|
102
|
table3->elementAt(0, 1)->addWidget(new Wt::WText("t @ row 0, t 1"));
|
103
|
table3->elementAt(1, 0)->addWidget(new Wt::WText("t @ row 1, t 0"));
|
104
|
table3->elementAt(1, 1)->addWidget(new Wt::WText("t @ row 1, t 1"));
|
105
|
|
106
|
Wt::WPopupWidget *popWid = new Wt::WPopupWidget(popupInhalt);
|
107
|
|
108
|
FrameButton *builder = new FrameButton(button, popWid);
|
109
|
buttonContainer->addWidget(builder->getButton());
|
110
|
|
111
|
Wt::WPushButton *butSetTransient1 = new Wt::WPushButton("setTransient(true,0)");
|
112
|
Wt::WPushButton *butSetTransient2 = new Wt::WPushButton("setTransient(false,4000)");
|
113
|
|
114
|
butSetTransient1->clicked().connect(builder, &FrameButton::setTransient1);
|
115
|
butSetTransient2->clicked().connect(builder, &FrameButton::setTransient2);
|
116
|
|
117
|
app->root()->addWidget(butSetTransient1);
|
118
|
app->root()->addWidget(butSetTransient2);
|
119
|
|
120
|
app->root()->addWidget(testDiv);
|
121
|
return app;
|
122
|
}
|
123
|
|
124
|
|
125
|
int main(int argc, char **argv)
|
126
|
{
|
127
|
return Wt::WRun(argc, argv, &createApplication);
|
128
|
}
|