Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

gui in gui itself

File size: 2.9 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    static void toggleGUI();
77
78    NetworkStatsWidget(const NetworkMonitor* monitor);
79    virtual ~NetworkStatsWidget();
80
81    void setUpstream(unsigned int upstream);
82    void setDownstream(unsigned int upstream);
83    void setIP(const IP& ip);
84
85
86
87    void addProxy(const std::string& name, const IP& proxy);
88    void clearProxies();
89
90    void rebuild();
91
92    //void rebuildConnectedHosts(std::vector<hosts> hosts);
93
94    void setMaximum(float max);
95    void setValue(float value);
96
97    virtual void tick(float dt);
98
99  protected:
100    virtual void resize();
101    virtual void showing();
102    virtual void hiding();
103
104  private:
105    const NetworkMonitor*  _monitor;
106
107    OrxGui::GLGuiText      _thisHostIs;
108    HostWidget             _thisHost;
109
110    OrxGui::GLGuiText      _upstreamText;
111    OrxGui::GLGuiText      _downstreamText;
112
113    OrxGui::GLGuiWidget    _serverBox;
114
115    std::vector<HostWidget*> _proxies;
116
117
118    OrxGui::GLGuiPushButton _refreshButton;
119
120    static NetworkStatsWidget*    _statsWidget;
121
122    //OrxGui::GLGuiText       _valueText;
123    //OrxGui::GLGuiBar        _bar;
124};
125
126#endif /* _NETWORK_STATS_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.