Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/monitor/network_stats_widget.cc @ 9438

Last change on this file since 9438 was 9438, checked in by bensch, 18 years ago

more gui

File size: 4.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "network_stats_widget.h"
19
20#include "multi_type.h"
21
22HostWidget::HostWidget(const std::string& name, const IP& ip)
23  : GLGuiBox(OrxGui::Horizontal)
24{
25  this->setName(name);
26  this->setIP(ip);
27
28  this->pack(&this->_name);
29  this->pack(&this->_ip);
30}
31
32void HostWidget::showing()
33{
34  this->_name.show();
35  this->_ip.show();
36}
37
38void HostWidget::hiding()
39{
40  this->_name.hide();
41  this->_ip.hide();
42}
43
44
45
46//======================================================//
47
48
49ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
50    : _proxyWidget(proxyName, ip)
51{
52  this->_clientNameWidth = 100.0f;
53  this->pack(&_proxyWidget);
54}
55
56void ProxyWidget::addClient(const std::string& name, const IP& ip)
57{
58  HostWidget* newClient = new HostWidget(name, ip);
59  newClient->setNameWidth(this->_clientNameWidth);
60
61  this->pack(newClient);
62
63  if (this->isVisible())
64    newClient->show();
65}
66
67bool ProxyWidget::removeClient(const IP& ip)
68{
69  std::vector<HostWidget*>::iterator rmIt;
70  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
71  {
72    if (*(*rmIt) == ip)
73    {
74      delete (*rmIt);
75      this->_clients.erase(rmIt);
76      return true;
77    }
78  }
79  return false;
80}
81
82bool ProxyWidget::removeClient(const std::string& name)
83{
84  std::vector<HostWidget*>::iterator rmIt;
85  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
86  {
87    if (*(*rmIt) == name)
88    {
89      delete (*rmIt);
90      this->_clients.erase(rmIt);
91      return true;
92    }
93  }
94  return false;
95
96}
97
98bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
99{
100  std::vector<HostWidget*>::iterator rmIt;
101  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
102  {
103    if (*(*rmIt) == ip && *(*rmIt) == name)
104    {
105      delete (*rmIt);
106      this->_clients.erase(rmIt);
107      return true;
108    }
109  }
110  return false;
111}
112
113
114void ProxyWidget::setClientNameWidths(float width)
115{
116  this->_clientNameWidth = width;
117  for (unsigned int i = 0; i < this->_clients.size(); ++i)
118    this->_clients[i]->setNameWidth(width);
119}
120
121void ProxyWidget::hiding()
122{
123  this->_proxyWidget.hide();
124  for (unsigned int i = 0; i < this->_clients.size(); ++i)
125    this->_clients[i]->hide();
126}
127
128void ProxyWidget::showing()
129{
130  this->_proxyWidget.show();
131  for (unsigned int i = 0; i < this->_clients.size(); ++i)
132    this->_clients[i]->show();
133}
134
135
136//======================================================//
137
138/**
139 * @brief standard constructor
140 */
141NetworkStatsWidget::NetworkStatsWidget ()
142  : GLGuiBox(OrxGui::Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
143{
144  //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
145
146  /*
147  this->_bar.setSize2D(100, 30);
148  this->pack(&this->_valueText);
149  this->_bar.setParent2D(&this->_valueText);
150
151  this->_valueText.setChangedTextColor(Color::white);
152
153  //this->setBackgroundTexture("maps/gui_element_background_2.png");
154  this->setBackgroundColor(Color(.5,.5,.5,1));
155
156  //this->_name.setBackgroundTexture(Texture());
157  //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
158  this->_bar.setBackgroundTexture(Texture());
159  this->_bar.setBackgroundColor(Color(0,0,0,0));
160  this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
161  this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
162  this->_bar.setChangedValueColor(Color::black);
163  */
164  this->pack(&this->_thisHost);
165
166  this->pack(&this->_upstreamText);
167  this->pack(&this->_downstreamText);
168
169  this->pack(&this->_serverIP);
170}
171
172
173/**
174 * @brief standard deconstructor
175 */
176NetworkStatsWidget::~NetworkStatsWidget ()
177{}
178
179
180void NetworkStatsWidget::setMaximum(float max)
181{
182 // this->_bar.setMaximum(max);
183}
184
185void NetworkStatsWidget::setValue(float value)
186{
187  MultiType val(value);
188  val.setType(MT_INT);
189  /*
190
191  this->_bar.setValue(value);
192  this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
193  this->_bar.setFrontColor(Color(1,1,1,1), true);
194  this->_valueText.setText(val.getString());
195  */
196}
197
198void NetworkStatsWidget::resize()
199{
200  GLGuiBox::resize();
201}
202
203
204void NetworkStatsWidget::showing()
205{
206}
207
208void NetworkStatsWidget::hiding()
209{
210}
Note: See TracBrowser for help on using the repository browser.