Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/monitor/network_stats_widget.h @ 9569

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

more gui work

File size: 2.8 KB
Line 
1/*!
2 * @file network_stats_widget.h
3 * @brief Definition of an EnergyWidget, that displays a bar and a Text
4 */
5
6#ifndef _NETWORK_STATS_WIDGET_H
7#define _NETWORK_STATS_WIDGET_H
8
9#include "glgui_fixedposition_box.h"
10#include "glgui_bar.h"
11#include "glgui_text.h"
12#include "glgui_pushbutton.h"
13
14#include "network/ip.h"
15
16class NetworkMonitor;
17
18
19class HostWidget : public OrxGui::GLGuiBox
20{
21  public:
22    HostWidget(const std::string& name, const IP& ip);
23
24    void setName(const std::string& name) { this->_name.setText(name); };
25    void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; };
26
27    void setNameWidth(float width) { this->_name.setLineWidth(width); };
28
29    bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
30    bool operator==(const std::string& name) const { return (this->_name == name); };
31
32  protected:
33    virtual void showing();
34    virtual void hiding();
35
36  private:
37    OrxGui::GLGuiText _name;           //!< The Name of the Proxy server to be displayed.
38    OrxGui::GLGuiText _ip;             //!< The IP of the proxy server.
39    IP                _storedIP;       //!< The ip to compare.
40};
41
42
43class ProxyWidget : public OrxGui::GLGuiBox
44{
45  public:
46    ProxyWidget(const std::string& proxyName, const IP& ip);
47
48    void addClient(const std::string& name, const IP& ip);
49
50    bool removeClient(const IP& ip);
51    bool removeClient(const std::string& name);
52    bool removeClient(const std::string& name, const IP& ip);
53
54    void setClientNameWidths(float width);
55
56
57  protected:
58    virtual void hiding();
59    virtual void showing();
60
61
62  private:
63    HostWidget                _proxyWidget;
64
65    std::vector<HostWidget*>  _clients;
66    float                     _clientNameWidth;
67};
68
69
70
71
72//! A class to display network Statistics.
73class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
74{
75  public:
76    NetworkStatsWidget(const NetworkMonitor* monitor);
77    virtual ~NetworkStatsWidget();
78
79    void setUpstream(unsigned int upstream);
80    void setDownstream(unsigned int upstream);
81    void setIP(const IP& ip);
82
83
84
85    void addProxy(const std::string& name, const IP& proxy);
86    void clearProxies();
87
88    void rebuild();
89
90    //void rebuildConnectedHosts(std::vector<hosts> hosts);
91
92    void setMaximum(float max);
93    void setValue(float value);
94
95    virtual void tick(float dt);
96
97  protected:
98    virtual void resize();
99    virtual void showing();
100    virtual void hiding();
101
102  private:
103    const NetworkMonitor*  _monitor;
104
105    OrxGui::GLGuiText      _thisHostIs;
106    HostWidget             _thisHost;
107
108    OrxGui::GLGuiText      _upstreamText;
109    OrxGui::GLGuiText      _downstreamText;
110
111    OrxGui::GLGuiWidget    _serverBox;
112
113    std::vector<HostWidget*> _proxies;
114
115
116    OrxGui::GLGuiPushButton _refreshButton;
117
118    //OrxGui::GLGuiText       _valueText;
119    //OrxGui::GLGuiBar        _bar;
120};
121
122#endif /* _NETWORK_STATS_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.