Project

General

Profile

Bug #1436 ยป disable.cpp

Koen Deforche, 10/11/2012 09:41 PM

 
#include <Wt/WApplication>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WPushButton>
#include <Wt/WText>
#include <Wt/WMessageBox>
#include <Wt/WProgressBar>
#include <Wt/WFileUpload>
#include <Wt/WLogger>

using namespace Wt;

class HelloApplication : public WApplication
{
public:
HelloApplication(const WEnvironment& env);

private:
void fileUploaded();

WPushButton* button_;
WFileUpload* fileUpload_;
};

HelloApplication::HelloApplication(const WEnvironment& env)
: WApplication(env)
{
setTitle("Hello world");

fileUpload_ = new WFileUpload(root());
button_ = new WPushButton("Send", root());
button_->setMargin(5, Left);

button_->clicked().connect(fileUpload_, &WFileUpload::upload);
button_->clicked().connect(button_, &WPushButton::disable);
fileUpload_->uploaded().connect(this, &HelloApplication::fileUploaded);
fileUpload_->setProgressBar(new WProgressBar());

WPushButton *enable = new WPushButton("Enable", root());
enable->clicked().connect(fileUpload_, &WWidget::enable);

WPushButton *disable = new WPushButton("Disable", root());
disable->clicked().connect(fileUpload_, &WWidget::disable);
}

void HelloApplication::fileUploaded()
{
log("trace") << "fileUploaded";
}

WApplication *createApplication(const WEnvironment& env)
{
return new HelloApplication(env);
}

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