1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
/*
* Copyright (C) 2008 Emweb bvba, Heverlee, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WPushButton>
#include <Wt/WText>
#include "SimpleChatServer.h"
#include "SimpleChatWidget.h"
using namespace Wt;
/**
* @addtogroup chatexample
*/
/*@{*/
/*! \brief The single chat server instance.
*/
SimpleChatServer theServer;
/*! \brief A chat demo application.
*/
class ChatApplication : public WApplication
{
public:
/*! \brief Create a new instance.
*/
ChatApplication(const WEnvironment& env);
private:
/*! \brief Add another chat client.
*/
void addChatWidget();
};
ChatApplication::ChatApplication(const WEnvironment& env)
: WApplication(env)
{
setTitle("Wt Chat");
useStyleSheet("simplechat.css");
messageResourceBundle().use("simplechat");
root()->addWidget(new WText(WString::tr("introduction")));
SimpleChatWidget *chatWidget = new SimpleChatWidget(theServer, root());
chatWidget->setStyleClass("chat");
root()->addWidget(new WText(WString::tr("details")));
WPushButton *b = new WPushButton("I'm schizophrenic ...", root());
b->clicked().connect(SLOT(b, WPushButton::hide));
b->clicked().connect(SLOT(this, ChatApplication::addChatWidget));
}
void ChatApplication::addChatWidget()
{
SimpleChatWidget *chatWidget2 = new SimpleChatWidget(theServer, root());
chatWidget2->setStyleClass("chat");
}
WApplication *createApplication(const WEnvironment& env)
{
return new ChatApplication(env);
}
int main(int argc, char **argv)
{
return WRun(argc, argv, &createApplication);
}
/*@}*/
|