A popup chat widget. More...
#include <PopupChatWidget.h>
Public Member Functions | |
PopupChatWidget (SimpleChatServer &server) | |
void | setName (const Wt::WString &name) |
Protected Member Functions | |
virtual void | createLayout (Wt::WWidget *messages, Wt::WWidget *userList, Wt::WWidget *messageEdit, Wt::WWidget *sendButton, Wt::WWidget *logoutButton) |
virtual void | updateUsers () |
Private Member Functions | |
void | toggleSize () |
void | minimize () |
void | maximize () |
Wt::WContainerWidget * | createBar () |
Private Attributes | |
Wt::WString | name_ |
Wt::WText * | title_ |
bool | online_ |
A popup chat widget.
Definition at line 20 of file PopupChatWidget.h.
PopupChatWidget::PopupChatWidget | ( | SimpleChatServer & | server ) |
Definition at line 20 of file PopupChatWidget.C.
: SimpleChatWidget(server) { if (Wt::WApplication::instance()->environment().agentIsIE()) { if (Wt::WApplication::instance()->environment().agent() == Wt::WEnvironment::IE6) setPositionScheme(Wt::Absolute); else setPositionScheme(Wt::Fixed); } online_ = false; minimize(); }
Wt::WContainerWidget * PopupChatWidget::createBar | ( | ) | [private] |
Definition at line 62 of file PopupChatWidget.C.
{ Wt::WContainerWidget *bar = new Wt::WContainerWidget(); bar->setStyleClass("chat-bar"); Wt::WText *toggleButton = new Wt::WText(); toggleButton->setInline(false); toggleButton->setStyleClass("chat-minmax"); bar->clicked().connect(this, &PopupChatWidget::toggleSize); bar->addWidget(toggleButton); title_ = new Wt::WText(bar); return bar; }
void PopupChatWidget::createLayout | ( | Wt::WWidget * | messages, |
Wt::WWidget * | userList, | ||
Wt::WWidget * | messageEdit, | ||
Wt::WWidget * | sendButton, | ||
Wt::WWidget * | logoutButton | ||
) | [protected, virtual] |
Definition at line 87 of file PopupChatWidget.C.
{ Wt::WVBoxLayout *layout = new Wt::WVBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); Wt::WContainerWidget *bar = createBar(); layout->addWidget(bar); layout->addWidget(messages, 1); layout->addWidget(messageEdit); setLayout(layout); }
void PopupChatWidget::maximize | ( | ) | [private] |
Definition at line 119 of file PopupChatWidget.C.
{ if (!online_) { online_ = true; int tries = 1; Wt::WString name = name_; if (name.empty()) name = server().suggestGuest(); while (!startChat(name)) { if (name_.empty()) name = server().suggestGuest(); else name = name_ + boost::lexical_cast<std::string>(++tries); } name_ = name; } setStyleClass("chat-widget chat-maximized"); }
void PopupChatWidget::minimize | ( | ) | [private] |
Definition at line 51 of file PopupChatWidget.C.
void PopupChatWidget::setName | ( | const Wt::WString & | name ) |
Definition at line 35 of file PopupChatWidget.C.
{ if (name.empty()) return; if (online_) { int tries = 1; Wt::WString n = name; while (!server().changeName(name_, n)) n = name + boost::lexical_cast<std::string>(++tries); name_ = n; } else name_ = name; }
void PopupChatWidget::toggleSize | ( | ) | [private] |
Definition at line 79 of file PopupChatWidget.C.
{ if (styleClass() == "chat-widget chat-minimized") maximize(); else minimize(); }
void PopupChatWidget::updateUsers | ( | ) | [protected, virtual] |
Reimplemented from SimpleChatWidget.
Definition at line 106 of file PopupChatWidget.C.
Wt::WString PopupChatWidget::name_ [private] |
Definition at line 35 of file PopupChatWidget.h.
bool PopupChatWidget::online_ [private] |
Definition at line 37 of file PopupChatWidget.h.
Wt::WText* PopupChatWidget::title_ [private] |
Definition at line 36 of file PopupChatWidget.h.