<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Wt examples: /home/koen/project/wt/public-git/wt/examples/simplechat/PopupChatWidget.C Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">Wt examples  <span id="projectnumber">3.2.3</span> </div> </td> </tr> </tbody> </table> </div> <!-- Generated by Doxygen 1.7.5.1 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">/home/koen/project/wt/public-git/wt/examples/simplechat/PopupChatWidget.C</div> </div> </div> <div class="contents"> <a href="PopupChatWidget_8C.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2010 Emweb bvba, Heverlee, Belgium.</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * See the LICENSE file for terms of use.</span> <a name="l00005"></a>00005 <span class="comment"> */</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="preprocessor">#include <Wt/WApplication></span> <a name="l00008"></a>00008 <span class="preprocessor">#include <Wt/WEnvironment></span> <a name="l00009"></a>00009 <span class="preprocessor">#include <Wt/WImage></span> <a name="l00010"></a>00010 <span class="preprocessor">#include <Wt/WText></span> <a name="l00011"></a>00011 <span class="preprocessor">#include <Wt/WVBoxLayout></span> <a name="l00012"></a>00012 <a name="l00013"></a>00013 <span class="preprocessor">#include "<a class="code" href="PopupChatWidget_8h.html">PopupChatWidget.h</a>"</span> <a name="l00014"></a>00014 <span class="preprocessor">#include "<a class="code" href="SimpleChatServer_8h.html">SimpleChatServer.h</a>"</span> <a name="l00015"></a>00015 <a name="l00016"></a>00016 <span class="comment">// TODO:</span> <a name="l00017"></a>00017 <span class="comment">// - i18n</span> <a name="l00018"></a>00018 <a name="l00019"></a><a class="code" href="classPopupChatWidget.html#a2ad5f9731ed08d14603b6c0588969f8d">00019</a> <a class="code" href="classPopupChatWidget.html#a2ad5f9731ed08d14603b6c0588969f8d">PopupChatWidget::PopupChatWidget</a>(<a class="code" href="classSimpleChatServer.html" title="A simple chat server.">SimpleChatServer</a>& server, <a name="l00020"></a>00020 <span class="keyword">const</span> std::string& <span class="keywordtype">id</span>) <a name="l00021"></a>00021 : <a class="code" href="classSimpleChatWidget.html" title="A self-contained chat widget.">SimpleChatWidget</a>(server), <a name="l00022"></a>00022 missedMessages_(0) <a name="l00023"></a>00023 { <a name="l00024"></a>00024 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a31bbe256124dd34461800c9dd5558b0b">setId</a>(<span class="keywordtype">id</span>); <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="keywordflow">if</span> (<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html#a38d922da0a0d83395519f3eaab85d0f6">Wt::WApplication::instance</a>()->environment().agentIsIE()) { <a name="l00027"></a>00027 <span class="keywordflow">if</span> (<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WApplication.html#a38d922da0a0d83395519f3eaab85d0f6">Wt::WApplication::instance</a>()->environment().agent() <a name="l00028"></a>00028 == <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WEnvironment.html#a412018893e570badb4b95056c4c934fda737c9af8220cbd65cdfe9b0789e87f9d">Wt::WEnvironment::IE6</a>) <a name="l00029"></a>00029 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a8bb78ee97f060daff1216a09a41e7963">setPositionScheme</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a2551043da5512cfe7b857c5db6e5ae40af924d8e24cb9e55dbeac9284c5640c69">Wt::Absolute</a>); <a name="l00030"></a>00030 <span class="keywordflow">else</span> <a name="l00031"></a>00031 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#a8bb78ee97f060daff1216a09a41e7963">setPositionScheme</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/namespaceWt.html#a2551043da5512cfe7b857c5db6e5ae40a2e157222a2018e8665c15c1ba56df530">Wt::Fixed</a>); <a name="l00032"></a>00032 } <a name="l00033"></a>00033 <a name="l00034"></a>00034 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WObject.html#a214deee5d7324b9afd4ce44534daa782">implementJavaScript</a> <a name="l00035"></a>00035 (&<a class="code" href="classPopupChatWidget.html#a48bd41c4ceae67476bdac74cda3afef7">PopupChatWidget::toggleSize</a>, <a name="l00036"></a>00036 <span class="stringliteral">"{"</span> <a name="l00037"></a>00037 <span class="stringliteral">""</span><span class="stringliteral">"var s = $('#"</span> + <span class="keywordtype">id</span> + <span class="stringliteral">"');"</span> <a name="l00038"></a>00038 <span class="stringliteral">""</span><span class="stringliteral">"s.toggleClass('chat-maximized chat-minimized');"</span> <a name="l00039"></a>00039 <span class="stringliteral">"}"</span>); <a name="l00040"></a>00040 <a name="l00041"></a>00041 <a class="code" href="classPopupChatWidget.html#a0464d97cb7aef7c1ff1d8dff72673029">online_</a> = <span class="keyword">false</span>; <a name="l00042"></a>00042 <a class="code" href="classPopupChatWidget.html#a3421b48caa17df82d1b48e1e96bbbcea">minimized_</a> = <span class="keyword">true</span>; <a name="l00043"></a>00043 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#afd3a3b359681111460a93d13979d17dd">setStyleClass</a>(<span class="stringliteral">"chat-widget chat-minimized"</span>); <a name="l00044"></a>00044 <a name="l00045"></a>00045 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a608f748cbdda763f1a11556ddad9fbe1">clear</a>(); <a name="l00046"></a>00046 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a2cfe66d9b62940f889e99538a9f478d2">addWidget</a>(<a class="code" href="classPopupChatWidget.html#a48263d727d3a94c480a8b2b229b2f266">createBar</a>()); <a name="l00047"></a>00047 <a class="code" href="classPopupChatWidget.html#a5c9dd041e3ea9ea83a5723167064353c">updateUsers</a>(); <a name="l00048"></a>00048 <a name="l00049"></a>00049 <a class="code" href="classSimpleChatWidget.html#a5fa75ab733ce294065a1233dfcbe83d6">connect</a>(); <a name="l00050"></a>00050 <a name="l00051"></a>00051 } <a name="l00052"></a>00052 <a name="l00053"></a><a class="code" href="classPopupChatWidget.html#a469d1da19c27831606ecaa39ec2a24eb">00053</a> <span class="keywordtype">void</span> <a class="code" href="classPopupChatWidget.html#a469d1da19c27831606ecaa39ec2a24eb">PopupChatWidget::setName</a>(<span class="keyword">const</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>& name) <a name="l00054"></a>00054 { <a name="l00055"></a>00055 <span class="keywordflow">if</span> (name.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html#a87a90e69ab25d62ba029e10ea244abaf">empty</a>()) <a name="l00056"></a>00056 <span class="keywordflow">return</span>; <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="keywordflow">if</span> (<a class="code" href="classPopupChatWidget.html#a0464d97cb7aef7c1ff1d8dff72673029">online_</a>) { <a name="l00059"></a>00059 <span class="keywordtype">int</span> tries = 1; <a name="l00060"></a>00060 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a> n = name; <a name="l00061"></a>00061 <span class="keywordflow">while</span> (!<a class="code" href="classSimpleChatWidget.html#a839a181c695589b066c4d68152ab05c0">server</a>().<a class="code" href="classSimpleChatServer.html#a0154462f2176611e8c44d93efe306283" title="Changes the name.">changeName</a>(<a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a>, n)) <a name="l00062"></a>00062 n = name + boost::lexical_cast<std::string>(++tries); <a name="l00063"></a>00063 <a name="l00064"></a>00064 <a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a> = n; <a name="l00065"></a>00065 } <span class="keywordflow">else</span> <a name="l00066"></a>00066 <a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a> = name; <a name="l00067"></a>00067 } <a name="l00068"></a>00068 <a name="l00069"></a><a class="code" href="classPopupChatWidget.html#a48263d727d3a94c480a8b2b229b2f266">00069</a> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *<a class="code" href="classPopupChatWidget.html#a48263d727d3a94c480a8b2b229b2f266">PopupChatWidget::createBar</a>() <a name="l00070"></a>00070 { <a name="l00071"></a>00071 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *bar = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a520ba6e52a36a7f2efbef1a31a69e898">Wt::WContainerWidget</a>(); <a name="l00072"></a>00072 bar-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#afd3a3b359681111460a93d13979d17dd">setStyleClass</a>(<span class="stringliteral">"chat-bar"</span>); <a name="l00073"></a>00073 <a name="l00074"></a>00074 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">Wt::WText</a> *toggleButton = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">Wt::WText</a>(); <a name="l00075"></a>00075 toggleButton-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#ad0957c892e70c6bf5399cf71e66f3e11">setInline</a>(<span class="keyword">false</span>); <a name="l00076"></a>00076 toggleButton-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWebWidget.html#afd3a3b359681111460a93d13979d17dd">setStyleClass</a>(<span class="stringliteral">"chat-minmax"</span>); <a name="l00077"></a>00077 bar-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html#ae11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(<span class="keyword">this</span>, &<a class="code" href="classPopupChatWidget.html#a48bd41c4ceae67476bdac74cda3afef7">PopupChatWidget::toggleSize</a>); <a name="l00078"></a>00078 bar-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WInteractWidget.html#ae11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(<span class="keyword">this</span>, &<a class="code" href="classPopupChatWidget.html#a8c3471399eaaf7febde283b446712a62">PopupChatWidget::goOnline</a>); <a name="l00079"></a>00079 <a name="l00080"></a>00080 bar-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a2cfe66d9b62940f889e99538a9f478d2">addWidget</a>(toggleButton); <a name="l00081"></a>00081 <a name="l00082"></a>00082 <a class="code" href="classPopupChatWidget.html#afd7af936c7f6527e4c8b9a6f8bac8c82">title_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html">Wt::WText</a>(bar); <a name="l00083"></a>00083 <a name="l00084"></a>00084 <a class="code" href="classPopupChatWidget.html#a75b99895520e26803ad59d8bc15f2b86">bar_</a> = bar; <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="keywordflow">return</span> bar; <a name="l00087"></a>00087 } <a name="l00088"></a>00088 <a name="l00089"></a><a class="code" href="classPopupChatWidget.html#a48bd41c4ceae67476bdac74cda3afef7">00089</a> <span class="keywordtype">void</span> <a class="code" href="classPopupChatWidget.html#a48bd41c4ceae67476bdac74cda3afef7">PopupChatWidget::toggleSize</a>() <a name="l00090"></a>00090 { <a name="l00091"></a>00091 <a class="code" href="classPopupChatWidget.html#a3421b48caa17df82d1b48e1e96bbbcea">minimized_</a> = !<a class="code" href="classPopupChatWidget.html#a3421b48caa17df82d1b48e1e96bbbcea">minimized_</a>; <a name="l00092"></a>00092 } <a name="l00093"></a>00093 <a name="l00094"></a><a class="code" href="classPopupChatWidget.html#a8c3471399eaaf7febde283b446712a62">00094</a> <span class="keywordtype">void</span> <a class="code" href="classPopupChatWidget.html#a8c3471399eaaf7febde283b446712a62">PopupChatWidget::goOnline</a>() <a name="l00095"></a>00095 { <a name="l00096"></a>00096 <span class="keywordflow">if</span> (!<a class="code" href="classPopupChatWidget.html#a0464d97cb7aef7c1ff1d8dff72673029">online_</a>) { <a name="l00097"></a>00097 <a class="code" href="classPopupChatWidget.html#a0464d97cb7aef7c1ff1d8dff72673029">online_</a> = <span class="keyword">true</span>; <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="keywordtype">int</span> tries = 1; <a name="l00100"></a>00100 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a> name = <a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a>; <a name="l00101"></a>00101 <span class="keywordflow">if</span> (name.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html#a87a90e69ab25d62ba029e10ea244abaf">empty</a>()) <a name="l00102"></a>00102 name = <a class="code" href="classSimpleChatWidget.html#a839a181c695589b066c4d68152ab05c0">server</a>().<a class="code" href="classSimpleChatServer.html#abf692567706118193111c2b2589c8d3f" title="Get a suggestion for a guest user name.">suggestGuest</a>(); <a name="l00103"></a>00103 <a name="l00104"></a>00104 <span class="keywordflow">while</span> (!<a class="code" href="classSimpleChatWidget.html#a19c0deeaf8952ec36791c3f444964878" title="Start a chat for the given user.">startChat</a>(name)) { <a name="l00105"></a>00105 <span class="keywordflow">if</span> (<a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html#a87a90e69ab25d62ba029e10ea244abaf">empty</a>()) <a name="l00106"></a>00106 name = <a class="code" href="classSimpleChatWidget.html#a839a181c695589b066c4d68152ab05c0">server</a>().<a class="code" href="classSimpleChatServer.html#abf692567706118193111c2b2589c8d3f" title="Get a suggestion for a guest user name.">suggestGuest</a>(); <a name="l00107"></a>00107 <span class="keywordflow">else</span> <a name="l00108"></a>00108 name = <a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a> + boost::lexical_cast<std::string>(++tries); <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <a name="l00111"></a>00111 <a class="code" href="classPopupChatWidget.html#a5ac023b53119cb3e1346b2daaf36c300">name_</a> = name; <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a>00114 <a class="code" href="classPopupChatWidget.html#a9f2f6a1931b377ce5a97e9dae1bc4582">missedMessages_</a> = 0; <a name="l00115"></a>00115 <a class="code" href="classPopupChatWidget.html#a75b99895520e26803ad59d8bc15f2b86">bar_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#a3b8a35e37ef06c408f346c63a5f1aa8e">removeStyleClass</a>(<span class="stringliteral">"alert"</span>); <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a><a class="code" href="classPopupChatWidget.html#a0bef3d63c991081040b68d0f224a18fa">00118</a> <span class="keywordtype">void</span> <a class="code" href="classPopupChatWidget.html#a0bef3d63c991081040b68d0f224a18fa">PopupChatWidget::createLayout</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">Wt::WWidget</a> *messages, <a name="l00119"></a>00119 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">Wt::WWidget</a> *userList, <a name="l00120"></a>00120 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">Wt::WWidget</a> *messageEdit, <a name="l00121"></a>00121 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">Wt::WWidget</a> *sendButton, <a name="l00122"></a>00122 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html">Wt::WWidget</a> *logoutButton) <a name="l00123"></a>00123 { <a name="l00124"></a>00124 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WVBoxLayout.html">Wt::WVBoxLayout</a> *<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#afaba82a27836f4a82bab48e8b26ccca2">layout</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WVBoxLayout.html">Wt::WVBoxLayout</a>(); <a name="l00125"></a>00125 layout-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WLayout.html#af18bae8c743c9f9a5cabee58826ffb45">setContentsMargins</a>(0, 0, 0, 0); <a name="l00126"></a>00126 layout-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WBoxLayout.html#a34d544a1a2bd8beffa6b8e5e84fbc19b">setSpacing</a>(0); <a name="l00127"></a>00127 <a name="l00128"></a>00128 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html">Wt::WContainerWidget</a> *bar = <a class="code" href="classPopupChatWidget.html#a48263d727d3a94c480a8b2b229b2f266">createBar</a>(); <a name="l00129"></a>00129 <a name="l00130"></a>00130 layout-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WBoxLayout.html#a7c1ec58e25d0b7add93f5f4342844db6">addWidget</a>(bar); <a name="l00131"></a>00131 layout-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WBoxLayout.html#a7c1ec58e25d0b7add93f5f4342844db6">addWidget</a>(messages, 1); <a name="l00132"></a>00132 layout-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WBoxLayout.html#a7c1ec58e25d0b7add93f5f4342844db6">addWidget</a>(messageEdit); <a name="l00133"></a>00133 <a name="l00134"></a>00134 <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a1c84e0ffe330d4798f0ce217f75be08c">setLayout</a>(layout); <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <a name="l00137"></a><a class="code" href="classPopupChatWidget.html#a5c9dd041e3ea9ea83a5723167064353c">00137</a> <span class="keywordtype">void</span> <a class="code" href="classPopupChatWidget.html#a5c9dd041e3ea9ea83a5723167064353c">PopupChatWidget::updateUsers</a>() <a name="l00138"></a>00138 { <a name="l00139"></a>00139 <a class="code" href="classPopupChatWidget.html#a5c9dd041e3ea9ea83a5723167064353c">SimpleChatWidget::updateUsers</a>(); <a name="l00140"></a>00140 <a name="l00141"></a>00141 <span class="keywordtype">int</span> <a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WContainerWidget.html#a85abd4d928575717052ff7fa04c3c2c9">count</a> = <a class="code" href="classSimpleChatWidget.html#a839a181c695589b066c4d68152ab05c0">server</a>().<a class="code" href="classSimpleChatServer.html#a40f5c6465b1edb44278be93c97a29a39" title="Get the users currently logged in.">users</a>().size(); <a name="l00142"></a>00142 <a name="l00143"></a>00143 <span class="keywordflow">if</span> (!<a class="code" href="classSimpleChatWidget.html#aa05605599e6eb9e6a7aeb51234533241">loggedIn</a>()) { <a name="l00144"></a>00144 <span class="keywordflow">if</span> (count == 0) <a name="l00145"></a>00145 <a class="code" href="classPopupChatWidget.html#afd7af936c7f6527e4c8b9a6f8bac8c82">title_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6">setText</a>(<span class="stringliteral">"Thoughts? Ventilate."</span>); <a name="l00146"></a>00146 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (count == 1) <a name="l00147"></a>00147 <a class="code" href="classPopupChatWidget.html#afd7af936c7f6527e4c8b9a6f8bac8c82">title_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6">setText</a>(<span class="stringliteral">"Chat: 1 user online"</span>); <a name="l00148"></a>00148 <span class="keywordflow">else</span> <a name="l00149"></a>00149 <a class="code" href="classPopupChatWidget.html#afd7af936c7f6527e4c8b9a6f8bac8c82">title_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6">setText</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>(<span class="stringliteral">"Chat: {1} users online"</span>).arg(count)); <a name="l00150"></a>00150 } <span class="keywordflow">else</span> { <a name="l00151"></a>00151 <a class="code" href="classPopupChatWidget.html#afd7af936c7f6527e4c8b9a6f8bac8c82">title_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WText.html#a2f788aa524d51b3962642c9f565e66e6">setText</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WString.html">Wt::WString</a>(<span class="stringliteral">"Chat: <span class=\"self\">{1}</span>"</span> <a name="l00152"></a>00152 <span class="stringliteral">" <span class=\"online\">({2} user{3})</span>"</span>) <a name="l00153"></a>00153 .arg(<a class="code" href="classSimpleChatWidget.html#af080cd053547503668a1ee29fd428d5f">userName</a>()).arg(count).arg(count == 1 ? <span class="stringliteral">""</span> : <span class="stringliteral">"s"</span>)); <a name="l00154"></a>00154 } <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <a name="l00157"></a><a class="code" href="classPopupChatWidget.html#a23967836774a1de9984bbfcb5652e76c">00157</a> <span class="keywordtype">void</span> <a class="code" href="classPopupChatWidget.html#a23967836774a1de9984bbfcb5652e76c">PopupChatWidget::newMessage</a>() <a name="l00158"></a>00158 { <a name="l00159"></a>00159 <span class="keywordflow">if</span> (<a class="code" href="classSimpleChatWidget.html#aa05605599e6eb9e6a7aeb51234533241">loggedIn</a>() && <a class="code" href="classPopupChatWidget.html#ace866c0c5a1f8576fb24e1ff33c8c78c">minimized</a>()) { <a name="l00160"></a>00160 ++<a class="code" href="classPopupChatWidget.html#a9f2f6a1931b377ce5a97e9dae1bc4582">missedMessages_</a>; <a name="l00161"></a>00161 <span class="keywordflow">if</span> (<a class="code" href="classPopupChatWidget.html#a9f2f6a1931b377ce5a97e9dae1bc4582">missedMessages_</a> == 1) { <a name="l00162"></a>00162 <a class="code" href="classPopupChatWidget.html#a75b99895520e26803ad59d8bc15f2b86">bar_</a>-><a class="codeRef" doxygen="wt.tags:../../reference/html" href="../../reference/html/classWt_1_1WWidget.html#abb5949e98f47edb7db98d7b6df07a31c">addStyleClass</a>(<span class="stringliteral">"alert"</span>); <a name="l00163"></a>00163 } <a name="l00164"></a>00164 } <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <a name="l00167"></a><a class="code" href="classPopupChatWidget.html#ace866c0c5a1f8576fb24e1ff33c8c78c">00167</a> <span class="keywordtype">bool</span> <a class="code" href="classPopupChatWidget.html#ace866c0c5a1f8576fb24e1ff33c8c78c">PopupChatWidget::minimized</a>()<span class="keyword"> const</span> <a name="l00168"></a>00168 <span class="keyword"></span>{ <a name="l00169"></a>00169 <span class="keywordflow">return</span> <a class="code" href="classPopupChatWidget.html#a3421b48caa17df82d1b48e1e96bbbcea">minimized_</a>; <a name="l00170"></a>00170 } </pre></div></div> </div> <hr size="1"><address style="text-align: right; margin: 3px"><small> Generated on Thu Nov 1 2012 for <a href="http://www.webtoolkit.eu/wt">the C++ Web Toolkit (Wt)</a> by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" border="0" style="vertical-align: middle; display: inline-block; height: 2em"></a> 1.7.5.1</small></address> </body> </html>