10 #include <Wt/WApplication>
11 #include <Wt/WContainerWidget>
12 #include <Wt/WEnvironment>
13 #include <Wt/WInPlaceEdit>
14 #include <Wt/WHBoxLayout>
15 #include <Wt/WVBoxLayout>
17 #include <Wt/WLineEdit>
18 #include <Wt/WTemplate>
20 #include <Wt/WTextArea>
21 #include <Wt/WPushButton>
22 #include <Wt/WCheckBox>
92 statusMsg_->setText(
"Sorry, name '" + escapeText(name) +
93 "' is already taken.");
174 if (flags & RenderFull) {
180 +
messages_->jsRef() +
".scrollHeight;}, 0);");
184 WContainerWidget::render(flags);
209 messages_->setOverflow(WContainerWidget::OverflowAuto);
210 userList_->setOverflow(WContainerWidget::OverflowAuto);
231 (
"function(o, e) { setTimeout(function() {"
244 WApplication::instance()->setConnectionMonitor(
246 "'onChange':function(type, newV) {"
247 "var connected = window.monitor.status.connectionStatus != 0;"
253 +
messageEdit_->jsRef() +
".placeholder='connection lost';"
282 joinMsg->bindWidget(
"name", nameEdit);
295 if (!logoutButton->parent())
329 for (SimpleChatServer::UserSet::iterator i = users.begin();
330 i != users.end(); ++i) {
334 UserMap::const_iterator j = oldUsers.find(*i);
335 if (j != oldUsers.end())
430 +
messages_->jsRef() +
".scrollHeight;");
void setButtonsEnabled(bool enabled=true)
void setText(const WString &text)
void addLayout(WLayout *layout, int stretch=0, WFlags< AlignmentFlag > alignment=0)
void sendMessage(const Wt::WString &user, const Wt::WString &message)
Send a message on behalve of a user.
bool connect(Client *client, const ChatEventCallback &handleEvent)
Connects to the chat server.
Encapsulate a chat event.
const Wt::WString formattedHTML(const Wt::WString &user, Wt::TextFormat format) const
Get the message formatted as HTML, rendered for the given user.
UserSet users()
Get the users currently logged in.
Signal< WString > & valueChanged()
std::set< Wt::WString > UserSet
Typedef for a collection of user names.
bool changeName(const Wt::WString &user, const Wt::WString &newUser)
Changes the name.
Wt::WString suggestGuest()
Get a suggestion for a guest user name.
bool login(const Wt::WString &user)
Try to login with given user name.
bool disconnect(Client *client)
Disconnect from the chat server.
void enableUpdates(bool enabled=true)
virtual void setText(const WString &text)
void logout(const Wt::WString &user)
Logout from the server.
const WString & text() const
static WApplication * instance()
void setResizable(int index, bool enabled=true, const WLength &initialSize=WLength::Auto)
const Wt::WString & user() const
Get the user who caused the event.
void addWidget(WWidget *widget, int stretch=0, WFlags< AlignmentFlag > alignment=0)
Type type() const
Get the event type.
void doJavaScript(const std::string &javascript, bool afterLoaded=true)
void setJavaScript(const std::string &javaScript, int nbArgs=0)
const Wt::WString & data() const
Get the extra data for this event.