Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 24, 2006, 4:55:41 PM (18 years ago)
Author:
bensch
Message:

movements

File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/monitor/network_stats_widget.cc

    r9435 r9437  
    2323//#include "network_monitor.h"
    2424
    25 namespace OrxGui
    26 {
    27   SHELL_COMMAND(gui, NetworkStatsWidget, gui);
    28 
    29 
    30   HostWidget::HostWidget(const std::string& name, const IP& ip)
    31       : GLGuiBox(Horizontal)
     25SHELL_COMMAND(gui, NetworkStatsWidget, gui);
     26
     27
     28HostWidget::HostWidget(const std::string& name, const IP& ip)
     29  : GLGuiBox(OrxGui::Horizontal)
     30{
     31  this->setName(name);
     32  this->setIP(ip);
     33
     34  this->pack(&this->_name);
     35  this->pack(&this->_ip);
     36}
     37
     38void HostWidget::showing()
     39{
     40  this->_name.show();
     41  this->_ip.show();
     42}
     43
     44void HostWidget::hiding()
     45{
     46  this->_name.hide();
     47  this->_ip.hide();
     48}
     49
     50
     51
     52//======================================================//
     53
     54
     55ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
     56    : _proxyWidget(proxyName, ip)
     57{
     58  this->_clientNameWidth = 100.0f;
     59  this->pack(&_proxyWidget);
     60}
     61
     62void ProxyWidget::addClient(const std::string& name, const IP& ip)
     63{
     64  HostWidget* newClient = new HostWidget(name, ip);
     65  newClient->setNameWidth(this->_clientNameWidth);
     66
     67  this->pack(newClient);
     68
     69  if (this->isVisible())
     70    newClient->show();
     71}
     72
     73bool ProxyWidget::removeClient(const IP& ip)
     74{
     75  std::vector<HostWidget*>::iterator rmIt;
     76  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    3277  {
    33     this->setName(name);
    34     this->setIP(ip);
    35 
    36     this->pack(&this->_name);
    37     this->pack(&this->_ip);
     78    if (*(*rmIt) == ip)
     79    {
     80      delete (*rmIt);
     81      this->_clients.erase(rmIt);
     82      return true;
     83    }
    3884  }
    39 
    40   void HostWidget::showing()
     85  return false;
     86}
     87
     88bool ProxyWidget::removeClient(const std::string& name)
     89{
     90  std::vector<HostWidget*>::iterator rmIt;
     91  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    4192  {
    42     this->_name.show();
    43     this->_ip.show();
     93    if (*(*rmIt) == name)
     94    {
     95      delete (*rmIt);
     96      this->_clients.erase(rmIt);
     97      return true;
     98    }
    4499  }
    45 
    46   void HostWidget::hiding()
     100  return false;
     101
     102}
     103
     104bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
     105{
     106  std::vector<HostWidget*>::iterator rmIt;
     107  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    47108  {
    48     this->_name.hide();
    49     this->_ip.hide();
     109    if (*(*rmIt) == ip && *(*rmIt) == name)
     110    {
     111      delete (*rmIt);
     112      this->_clients.erase(rmIt);
     113      return true;
     114    }
    50115  }
    51 
    52 
    53 
    54   //======================================================//
    55 
    56 
    57   ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
    58   : _proxyWidget(proxyName, ip)
    59   {
    60     this->_clientNameWidth = 100.0f;
    61     this->pack(&_proxyWidget);
    62   }
    63 
    64   void ProxyWidget::addClient(const std::string& name, const IP& ip)
    65   {
    66     HostWidget* newClient = new HostWidget(name, ip);
    67     newClient->setNameWidth(this->_clientNameWidth);
    68 
    69     this->pack(newClient);
    70 
    71     if (this->isVisible())
    72       newClient->show();
    73   }
    74 
    75   bool ProxyWidget::removeClient(const IP& ip)
    76   {
    77     std::vector<HostWidget*>::iterator rmIt;
    78     for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    79     {
    80       if (*(*rmIt) == ip)
    81       {
    82         delete (*rmIt);
    83         this->_clients.erase(rmIt);
    84         return true;
    85       }
    86     }
    87     return false;
    88   }
    89 
    90   bool ProxyWidget::removeClient(const std::string& name)
    91   {
    92     std::vector<HostWidget*>::iterator rmIt;
    93     for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    94     {
    95       if (*(*rmIt) == name)
    96       {
    97         delete (*rmIt);
    98         this->_clients.erase(rmIt);
    99         return true;
    100       }
    101     }
    102     return false;
    103 
    104   }
    105 
    106   bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
    107   {
    108     std::vector<HostWidget*>::iterator rmIt;
    109     for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    110     {
    111       if (*(*rmIt) == ip && *(*rmIt) == name)
    112       {
    113         delete (*rmIt);
    114         this->_clients.erase(rmIt);
    115         return true;
    116       }
    117     }
    118     return false;
    119   }
    120 
    121 
    122   void ProxyWidget::setClientNameWidths(float width)
    123   {
    124     this->_clientNameWidth = width;
    125     for (unsigned int i = 0; i < this->_clients.size(); ++i)
    126       this->_clients[i]->setNameWidth(width);
    127   }
    128 
    129   void ProxyWidget::hiding()
    130   {
    131     this->_proxyWidget.hide();
    132     for (unsigned int i = 0; i < this->_clients.size(); ++i)
    133       this->_clients[i]->hide();
    134   }
    135 
    136   void ProxyWidget::showing()
    137   {
    138     this->_proxyWidget.show();
    139     for (unsigned int i = 0; i < this->_clients.size(); ++i)
    140       this->_clients[i]->show();
    141   }
    142 
    143 
    144   //======================================================//
    145 
    146 
    147   void NetworkStatsWidget::gui()
    148   {
    149     printf("YEAH\n");
    150   }
    151 
    152 
    153   /**
    154    * @brief standard constructor
    155    */
    156   NetworkStatsWidget::NetworkStatsWidget ()
    157   : GLGuiBox(Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
    158   {
    159     //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
    160 
    161     this->_bar.setSize2D(100, 30);
    162     this->pack(&this->_valueText);
    163     this->_bar.setParent2D(&this->_valueText);
    164 
    165     this->_valueText.setChangedTextColor(Color::white);
    166 
    167     //this->setBackgroundTexture("maps/gui_element_background_2.png");
    168     this->setBackgroundColor(Color(.5,.5,.5,1));
    169 
    170     //this->_name.setBackgroundTexture(Texture());
    171     //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
    172     this->_bar.setBackgroundTexture(Texture());
    173     this->_bar.setBackgroundColor(Color(0,0,0,0));
    174     this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
    175     this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
    176     this->_bar.setChangedValueColor(Color::black);
    177   }
    178 
    179 
    180   /**
    181    * @brief standard deconstructor
    182    */
    183   NetworkStatsWidget::~NetworkStatsWidget ()
    184   {}
    185 
    186 
    187   void NetworkStatsWidget::setMaximum(float max)
    188   {
    189     this->_bar.setMaximum(max);
    190   }
    191 
    192   void NetworkStatsWidget::setValue(float value)
    193   {
    194     MultiType val(value);
    195     val.setType(MT_INT);
    196 
    197 
    198     this->_bar.setValue(value);
    199     this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
    200     this->_bar.setFrontColor(Color(1,1,1,1), true);
    201     this->_valueText.setText(val.getString());
    202   }
    203 
    204   void NetworkStatsWidget::resize()
    205   {
    206     GLGuiBox::resize();
    207   }
    208 
    209 
    210   void NetworkStatsWidget::showing()
    211   {
    212     this->_valueText.show();
    213     this->_bar.show();
    214   }
    215 
    216   void NetworkStatsWidget::hiding()
    217   {
    218     this->_valueText.hide();
    219     this->_bar.hide();
    220   }
    221 }
     116  return false;
     117}
     118
     119
     120void ProxyWidget::setClientNameWidths(float width)
     121{
     122  this->_clientNameWidth = width;
     123  for (unsigned int i = 0; i < this->_clients.size(); ++i)
     124    this->_clients[i]->setNameWidth(width);
     125}
     126
     127void ProxyWidget::hiding()
     128{
     129  this->_proxyWidget.hide();
     130  for (unsigned int i = 0; i < this->_clients.size(); ++i)
     131    this->_clients[i]->hide();
     132}
     133
     134void ProxyWidget::showing()
     135{
     136  this->_proxyWidget.show();
     137  for (unsigned int i = 0; i < this->_clients.size(); ++i)
     138    this->_clients[i]->show();
     139}
     140
     141
     142//======================================================//
     143
     144
     145void NetworkStatsWidget::gui()
     146{
     147  printf("YEAH\n");
     148}
     149
     150
     151/**
     152 * @brief standard constructor
     153 */
     154NetworkStatsWidget::NetworkStatsWidget ()
     155  : GLGuiBox(OrxGui::Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
     156{
     157  //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
     158
     159  this->_bar.setSize2D(100, 30);
     160  this->pack(&this->_valueText);
     161  this->_bar.setParent2D(&this->_valueText);
     162
     163  this->_valueText.setChangedTextColor(Color::white);
     164
     165  //this->setBackgroundTexture("maps/gui_element_background_2.png");
     166  this->setBackgroundColor(Color(.5,.5,.5,1));
     167
     168  //this->_name.setBackgroundTexture(Texture());
     169  //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
     170  this->_bar.setBackgroundTexture(Texture());
     171  this->_bar.setBackgroundColor(Color(0,0,0,0));
     172  this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
     173  this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
     174  this->_bar.setChangedValueColor(Color::black);
     175}
     176
     177
     178/**
     179 * @brief standard deconstructor
     180 */
     181NetworkStatsWidget::~NetworkStatsWidget ()
     182{}
     183
     184
     185void NetworkStatsWidget::setMaximum(float max)
     186{
     187  this->_bar.setMaximum(max);
     188}
     189
     190void NetworkStatsWidget::setValue(float value)
     191{
     192  MultiType val(value);
     193  val.setType(MT_INT);
     194
     195
     196  this->_bar.setValue(value);
     197  this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
     198  this->_bar.setFrontColor(Color(1,1,1,1), true);
     199  this->_valueText.setText(val.getString());
     200}
     201
     202void NetworkStatsWidget::resize()
     203{
     204  GLGuiBox::resize();
     205}
     206
     207
     208void NetworkStatsWidget::showing()
     209{
     210  this->_valueText.show();
     211  this->_bar.show();
     212}
     213
     214void NetworkStatsWidget::hiding()
     215{
     216  this->_valueText.hide();
     217  this->_bar.hide();
     218}
Note: See TracChangeset for help on using the changeset viewer.