Hey, Yufeng
this is an example.
=======
//start
// MyWidget.h
// MyServer
// MyWidget
#ifndef MY_WIDGET_H
#define MY_WIDGET_H
#include <Wt/WObject>
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
#include <Wt/WText>
#include <Wt/WString>
#include <Wt/WSignal>
#include <Wt/WBreak>
#include <Wt/WApplication>
#include <Wt/WPushButton>
using namespace Wt;
class MyServer : public WObject
{
public:
MyServer()
: done_(this)
{ }
Signal<WString>& done() { return done_; }
void sendMessage(WString my_str)
{
done_.emit(my_str);
}
private:
Signal<WString> done_;
};
class MyWidget : public WContainerWidget
{
public:
MyWidget(MyServer& server, WContainerWidget *parent = 0)
: WContainerWidget(parent) ,
server_(server) ,
app_(WApplication::instance())
{
WText *sysCmd = new WText("Enter Command: ", parent);
sysCmdEdit_ = new WLineEdit(parent);
sysCmdEdit_->setFocus();
parent->addWidget(new WBreak());
message_ = new WText(parent);
sysCmdEdit_->enterPressed().connect(SLOT(this, MyWidget::send));
server_.done().connect(SLOT(this, MyWidget::process));
app_->enableUpdates();
}
private:
WApplication *app_;
MyServer& server_;
WText *message_;
WLineEdit *sysCmdEdit_;
virtual void send()
{
server_.sendMessage(sysCmdEdit_->text());
}
virtual void process(WString message)
{
WApplication::UpdateLock lock = app_->getUpdateLock();
message_->setText(message);
app_->triggerUpdate();
}
};
#endif
/*
// MyApplication.cpp
#include "MyWidget.h"
#include <Wt/WApplication>
#include <Wt/WEnvironment>
using namespace Wt;
MyServer theServer;
class MyApplication : public WApplication
{
public:
MyApplication(const WEnvironment& env)
: WApplication(env)
{
MyWidget *my_widget = new MyWidget(theServer, root());
}
};
WApplication *createApplication(const WEnvironment& env)
{
return new MyApplication(env);
}
int main(int argc, char** argv)
{
return WRun(argc, argv, &createApplication);
}
*/
//end
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest