00001 /* 00002 * Copyright (C) 2008 Emweb bvba, Heverlee, Belgium. 00003 * 00004 * See the LICENSE file for terms of use. 00005 */ 00006 00007 #include <Wt/WApplication> 00008 #include <Wt/WContainerWidget> 00009 #include <Wt/WPushButton> 00010 #include <Wt/WText> 00011 00012 #include "SimpleChatServer.h" 00013 #include "SimpleChatWidget.h" 00014 00015 using namespace Wt; 00016 00021 00024 SimpleChatServer theServer; 00025 00028 class ChatApplication : public WApplication 00029 { 00030 public: 00033 ChatApplication(const WEnvironment& env); 00034 00035 private: 00038 void addChatWidget(); 00039 }; 00040 00041 ChatApplication::ChatApplication(const WEnvironment& env) 00042 : WApplication(env) 00043 { 00044 setTitle("Wt Chat"); 00045 useStyleSheet("simplechat.css"); 00046 messageResourceBundle().use("simplechat"); 00047 00048 root()->addWidget(new WText(WString::tr("introduction"))); 00049 00050 SimpleChatWidget *chatWidget = new SimpleChatWidget(theServer, root()); 00051 chatWidget->setStyleClass("chat"); 00052 00053 root()->addWidget(new WText(WString::tr("details"))); 00054 00055 WPushButton *b = new WPushButton("I'm schizophrenic ...", root()); 00056 b->clicked().connect(SLOT(b, WPushButton::hide)); 00057 b->clicked().connect(SLOT(this, ChatApplication::addChatWidget)); 00058 } 00059 00060 void ChatApplication::addChatWidget() 00061 { 00062 SimpleChatWidget *chatWidget2 = new SimpleChatWidget(theServer, root()); 00063 chatWidget2->setStyleClass("chat"); 00064 } 00065 00066 WApplication *createApplication(const WEnvironment& env) 00067 { 00068 return new ChatApplication(env); 00069 } 00070 00071 int main(int argc, char **argv) 00072 { 00073 return WRun(argc, argv, &createApplication); 00074 } 00075