Project

General

Profile

Bug #2801 ยป main.cpp

Example app - Torsten Schulz, 03/26/2015 09:56 AM

 
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WText>
#include <Wt/WDialog>
#include <Wt/WPushButton>

class AnimationTestApp : public Wt::WApplication
{
public:
AnimationTestApp(const Wt::WEnvironment &env) : Wt::WApplication(env)
{
setTitle("Animation test");

root()->addWidget(new Wt::WText("This page is for test the animation on hiding"));

Wt::WPushButton *fOpenButton = new Wt::WPushButton("Open Dialog", root());
fOpenButton->clicked().connect(this, &AnimationTestApp::openDialog);
}

void openDialog()
{
Wt::WDialog *fDialog = new Wt::WDialog("Test dialog");
Wt::WPushButton *hideAnimatedButton = new Wt::WPushButton("hide with animation", fDialog->contents());
hideAnimatedButton->clicked().connect(boost::bind(&AnimationTestApp::hideDialog, this, fDialog, true));
Wt::WPushButton *hideNormalButton = new Wt::WPushButton("hide without animation", fDialog->contents());
hideNormalButton->clicked().connect(boost::bind(&AnimationTestApp::hideDialog, this, fDialog, false));
fDialog->setHidden(false, Wt::WAnimation(Wt::WAnimation::Fade));
}

void hideDialog(Wt::WDialog *dialog, bool withAnimation)
{
if (withAnimation)
dialog->setHidden(true, Wt::WAnimation(Wt::WAnimation::Fade));
else
dialog->setHidden(true);
}
};

Wt::WApplication *createApplication(const Wt::WEnvironment &env)
{
return new AnimationTestApp(env);
}

int main(int argc, char** argv)
{
return Wt::WRun(argc, argv, &createApplication);
}
    (1-1/1)