|
#include <Wt/WTable>
|
|
#include <Wt/WTableCell>
|
|
#include <Wt/WText>
|
|
#include <Wt/WApplication>
|
|
#include <Wt/WEnvironment>
|
|
#include <Wt/WCssTheme>
|
|
#include <Wt/WCssStyleSheet>
|
|
#include <Wt/WBootstrapTheme>
|
|
#include <Wt/WPushButton>
|
|
#include <Wt/WTable>
|
|
#include <Wt/WWidget>
|
|
#include <Wt/WContainerWidget>
|
|
#include <Wt/WString>
|
|
#include <Wt/WMenuItem>
|
|
#include <Wt/WMenu>
|
|
#include <Wt/WPopupWidget>
|
|
#include <Wt/WObject>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <stdlib.h>
|
|
|
|
|
|
class FrameButton : public Wt::WObject
|
|
{
|
|
public:
|
|
FrameButton(Wt::WPushButton *, Wt::WPopupWidget *);
|
|
Wt::WPushButton *getButton() { return fButton; }
|
|
Wt::WPopupWidget *popup;
|
|
void setTransient1();
|
|
void setTransient2();
|
|
|
|
private:
|
|
void buttonClicked();
|
|
Wt::WPushButton *fButton;
|
|
bool popuphidden;
|
|
};
|
|
|
|
|
|
FrameButton::FrameButton(Wt::WPushButton *button, Wt::WPopupWidget *popupWidget) {
|
|
fButton = button;
|
|
popup = popupWidget;
|
|
popup->setAnchorWidget(fButton, Wt::Vertical);
|
|
popup->setTransient(false, 1000);
|
|
popuphidden = false;
|
|
popup->setHidden(true);
|
|
fButton->clicked().connect(this, &FrameButton::buttonClicked);
|
|
printf("FrameButton::FrameButton(...) popup=%p", popup);
|
|
}
|
|
|
|
void FrameButton::buttonClicked() {
|
|
if (popuphidden) {
|
|
popuphidden = false;
|
|
popup->setHidden(false);
|
|
fButton->setText("Popup verbergen");
|
|
} else {
|
|
popuphidden = true;
|
|
fButton->setText("Popup anzeigen");
|
|
popup->setHidden(true);
|
|
}
|
|
popup->show();
|
|
}
|
|
|
|
void FrameButton::setTransient1() {
|
|
// is called but setTransient(true,0) has no effect :-(
|
|
popup->setTransient(true,0);
|
|
printf("FrameButton::setTransient1() popup=%p", popup);
|
|
}
|
|
|
|
void FrameButton::setTransient2() {
|
|
// is called but setTransient(false,4000) has no effect :-(
|
|
popup->setTransient(false,4000);
|
|
printf("FrameButton::setTransient2() popup=%p", popup);
|
|
}
|
|
|
|
|
|
|
|
Wt::WApplication *createApplication(const Wt::WEnvironment& env)
|
|
{
|
|
Wt::WApplication* app = new Wt::WApplication(env);
|
|
|
|
if (app->appRoot().empty()) {
|
|
std::cerr << "!!!!!!!!!!" << std::endl
|
|
<< "!! Warning: read the README.md file for hints on deployment,"
|
|
<< " the approot looks suspect!" << std::endl
|
|
<< "!!!!!!!!!!" << std::endl;
|
|
}
|
|
|
|
//app->setTheme(new Wt::WBootstrapTheme(app));
|
|
|
|
|
|
Wt::WContainerWidget *testDiv = new Wt::WContainerWidget();
|
|
testDiv->setContentAlignment(Wt::AlignRight);
|
|
|
|
Wt::WContainerWidget *buttonContainer = new Wt::WContainerWidget(testDiv);
|
|
Wt::WPushButton *button = new Wt::WPushButton("showPopup", buttonContainer);
|
|
|
|
Wt::WContainerWidget *popupInhalt = new Wt::WContainerWidget();
|
|
|
|
// Tabelle 3:
|
|
Wt::WTable *table3 = new Wt::WTable(popupInhalt);
|
|
table3->elementAt(0, 0)->addWidget(new Wt::WText("t @ row 0, t 0"));
|
|
table3->elementAt(0, 1)->addWidget(new Wt::WText("t @ row 0, t 1"));
|
|
table3->elementAt(1, 0)->addWidget(new Wt::WText("t @ row 1, t 0"));
|
|
table3->elementAt(1, 1)->addWidget(new Wt::WText("t @ row 1, t 1"));
|
|
|
|
Wt::WPopupWidget *popWid = new Wt::WPopupWidget(popupInhalt);
|
|
|
|
FrameButton *builder = new FrameButton(button, popWid);
|
|
buttonContainer->addWidget(builder->getButton());
|
|
|
|
Wt::WPushButton *butSetTransient1 = new Wt::WPushButton("setTransient(true,0)");
|
|
Wt::WPushButton *butSetTransient2 = new Wt::WPushButton("setTransient(false,4000)");
|
|
|
|
butSetTransient1->clicked().connect(builder, &FrameButton::setTransient1);
|
|
butSetTransient2->clicked().connect(builder, &FrameButton::setTransient2);
|
|
|
|
app->root()->addWidget(butSetTransient1);
|
|
app->root()->addWidget(butSetTransient2);
|
|
|
|
app->root()->addWidget(testDiv);
|
|
return app;
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
return Wt::WRun(argc, argv, &createApplication);
|
|
}
|