Project

General

Profile

Bug #2801 ยป main.cpp

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

 
1
#include <Wt/WApplication>
2
#include <Wt/WContainerWidget>
3
#include <Wt/WText>
4
#include <Wt/WDialog>
5
#include <Wt/WPushButton>
6

    
7
class AnimationTestApp : public Wt::WApplication
8
{
9
public:
10
	AnimationTestApp(const Wt::WEnvironment &env) : Wt::WApplication(env)
11
	{
12
		setTitle("Animation test");
13

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

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

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

    
30
	void hideDialog(Wt::WDialog *dialog, bool withAnimation)
31
	{
32
		if (withAnimation)
33
			dialog->setHidden(true, Wt::WAnimation(Wt::WAnimation::Fade));
34
		else
35
			dialog->setHidden(true);
36
	}
37
};
38

    
39
Wt::WApplication *createApplication(const Wt::WEnvironment &env)
40
{
41
	return new AnimationTestApp(env);
42
}
43

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