/home/koen/project/wt/cvs/wt/examples/simplechat/simpleChat.C

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Koen Deforche
00003  *
00004  * See the LICENSE file for terms of use.
00005  */
00006 
00007 #include <WApplication>
00008 #include <WContainerWidget>
00009 #include <WPushButton>
00010 #include <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->resize(WLength(85, WLength::Percentage), WLength(300));
00052   chatWidget->setStyleClass("chat");
00053 
00054   root()->addWidget(new WText(WString::tr("details")));
00055 
00056   WPushButton *b = new WPushButton("I'm schizophrenic ...", root());
00057   b->clicked.connect(SLOT(b, WPushButton::hide));
00058   b->clicked.connect(SLOT(this, ChatApplication::addChatWidget));
00059 }
00060 
00061 void ChatApplication::addChatWidget()
00062 {
00063   SimpleChatWidget *chatWidget2 = new SimpleChatWidget(theServer, root());
00064   chatWidget2->resize(WLength(85, WLength::Percentage), WLength(200));
00065   chatWidget2->setStyleClass("chat");
00066 }
00067 
00068 WApplication *createApplication(const WEnvironment& env)
00069 {
00070   return new ChatApplication(env);
00071 }
00072 
00073 int main(int argc, char **argv)
00074 {
00075   return WRun(argc, argv, &createApplication);
00076 }
00077 

Generated on Mon Apr 14 15:15:04 2008 for Wt by doxygen 1.5.3