A popup chat widget.
More...
#include <PopupChatWidget.h>
|
virtual void | createLayout (std::unique_ptr< WWidget > messages, std::unique_ptr< WWidget > userList, std::unique_ptr< WWidget > messageEdit, std::unique_ptr< WWidget > sendButton, std::unique_ptr< WWidget > logoutButton) |
|
virtual void | updateUsers () |
|
virtual void | newMessage () |
|
virtual void | createLayout (std::unique_ptr< Wt::WWidget > messages, std::unique_ptr< Wt::WWidget > userList, std::unique_ptr< Wt::WWidget > messageEdit, std::unique_ptr< Wt::WWidget > sendButton, std::unique_ptr< Wt::WWidget > logoutButton) |
|
virtual void | render (Wt::WFlags< Wt::RenderFlag > flags) |
|
bool | loggedIn () const |
|
A popup chat widget.
Definition at line 20 of file PopupChatWidget.h.
§ PopupChatWidget()
PopupChatWidget::PopupChatWidget |
( |
SimpleChatServer & |
server, |
|
|
const std::string & |
id |
|
) |
| |
Definition at line 19 of file PopupChatWidget.C.
26 if (Wt::WApplication::instance()->environment().agentIsIE()) {
27 if (Wt::WApplication::instance()->environment().agent()
28 == Wt::UserAgent::IE6)
29 setPositionScheme(Wt::PositionScheme::Absolute);
31 setPositionScheme(Wt::PositionScheme::Fixed);
37 """var s = $('#" +
id +
"');" 38 """s.toggleClass('chat-maximized chat-minimized');" 43 setStyleClass(
"chat-widget chat-minimized");
§ createBar()
std::unique_ptr< Wt::WContainerWidget > PopupChatWidget::createBar |
( |
| ) |
|
|
private |
Definition at line 68 of file PopupChatWidget.C.
70 auto bar(Wt::cpp14::make_unique<Wt::WContainerWidget>());
71 bar->setStyleClass(
"chat-bar");
73 auto toggleButton(Wt::cpp14::make_unique<Wt::WText>());
74 toggleButton->setInline(
false);
75 toggleButton->setStyleClass(
"chat-minmax");
79 bar->addWidget(std::move(toggleButton));
81 title_ = bar->addWidget(Wt::cpp14::make_unique<Wt::WText>());
§ createLayout()
void PopupChatWidget::createLayout |
( |
std::unique_ptr< WWidget > |
messages, |
|
|
std::unique_ptr< WWidget > |
userList, |
|
|
std::unique_ptr< WWidget > |
messageEdit, |
|
|
std::unique_ptr< WWidget > |
sendButton, |
|
|
std::unique_ptr< WWidget > |
logoutButton |
|
) |
| |
|
protectedvirtual |
Definition at line 117 of file PopupChatWidget.C.
123 auto layout(Wt::cpp14::make_unique<Wt::WVBoxLayout>());
124 layout->setContentsMargins(0, 0, 0, 0);
125 layout->setSpacing(0);
127 auto bar = layout->addWidget(
createBar());
128 bar->setMinimumSize(Wt::WLength::Auto, 20);
129 layout->addWidget(std::move(messages), 1);
130 layout->addWidget(std::move(messageEdit));
132 setLayout(std::move(layout));
§ goOnline()
void PopupChatWidget::goOnline |
( |
| ) |
|
|
private |
Definition at line 93 of file PopupChatWidget.C.
99 Wt::WString name =
name_;
107 name =
name_ + std::to_string(++tries);
114 bar_->removeStyleClass(
"alert");
Wt::WString suggestGuest()
Get a suggestion for a guest user name.
§ minimized()
bool PopupChatWidget::minimized |
( |
| ) |
const |
|
private |
§ newMessage()
void PopupChatWidget::newMessage |
( |
| ) |
|
|
protectedvirtual |
§ setName()
void PopupChatWidget::setName |
( |
const Wt::WString & |
name | ) |
|
Definition at line 52 of file PopupChatWidget.C.
61 n = name + std::to_string(++tries);
bool changeName(const Wt::WString &user, const Wt::WString &newUser)
Changes the name.
§ toggleSize()
void PopupChatWidget::toggleSize |
( |
| ) |
|
|
private |
§ updateUsers()
void PopupChatWidget::updateUsers |
( |
| ) |
|
|
protectedvirtual |
Reimplemented from SimpleChatWidget.
Definition at line 135 of file PopupChatWidget.C.
143 title_->setText(
"Thoughts? Ventilate.");
145 title_->setText(
"Chat: 1 user online");
147 title_->setText(Wt::WString(
"Chat: {1} users online").arg(count));
149 title_->setText(Wt::WString(
"Chat: <span class=\"self\">{1}</span>" 150 " <span class=\"online\">({2} user{3})</span>")
151 .arg(
userName()).arg(count).arg(count == 1 ?
"" :
"s"));
UserSet users()
Get the users currently logged in.
§ bar_
Wt::WWidget* PopupChatWidget::bar_ |
|
private |
§ minimized_
bool PopupChatWidget::minimized_ |
|
private |
§ missedMessages_
int PopupChatWidget::missedMessages_ |
|
private |
§ name_
Wt::WString PopupChatWidget::name_ |
|
private |
§ online_
bool PopupChatWidget::online_ |
|
private |
§ title_
Wt::WText* PopupChatWidget::title_ |
|
private |
The documentation for this class was generated from the following files: