source: trunk/wx/speed-stats.h @ 2907

Last change on this file since 2907 was 2907, checked in by charles, 15 years ago

implement the `speed' tab.

  • Property svn:keywords set to Date Rev Author Id
File size: 2.4 KB
Line 
1/*
2 * Xmission - a cross-platform bittorrent client
3 * Copyright (C) 2007 Charles Kerr <charles@rebelbase.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 *
18 * $Id: speed-stats.h 2907 2007-08-22 19:49:24Z charles $
19 */
20
21#ifndef __XMISSION_SPEED_STATS_H__
22#define __XMISSION_SPEED_STATS_H__
23
24#include <ctime>
25#include <vector>
26#include <wx/colour.h>
27#include <wx/panel.h>
28#include <libtransmission/transmission.h>
29
30extern "C"
31{
32    struct tr_torrent_s;
33}
34
35class SpeedStats: public wxPanel
36{
37    public:
38
39        SpeedStats( wxWindow * parent,
40                    wxWindowID id = wxID_ANY,
41                    const wxPoint& pos = wxDefaultPosition,
42                    const wxSize& size = wxDefaultSize,
43                    long style = wxTAB_TRAVERSAL,
44                    const wxString& name = _T("panel"));
45
46        virtual ~SpeedStats();
47
48    public:
49
50        void SetTorrent( struct tr_torrent_s * );
51
52        void Pulse( tr_handle_t * handle );
53
54    private:
55
56        virtual void OnSize( wxSizeEvent& event );
57
58        void OnPaint( wxPaintEvent& );
59
60        DECLARE_EVENT_TABLE()
61
62    private:
63
64        wxBitmap * myBitmap;
65
66        struct tr_torrent_s * myTorrent;
67
68        struct Speed
69        {
70            time_t time;
71            double torrentUp;
72            double torrentDown;
73            double allUp;
74            double allDown;
75            Speed(): time(0),
76                     torrentUp(0), torrentDown(0),
77                     allUp(0), allDown(0) {}
78        };
79           
80        typedef std::vector<Speed> stats_t;
81
82        stats_t myStats;
83
84        double myMaxSpeed;
85
86        int myHistory;
87
88        enum {
89            BACKGROUND,
90            FRAME,
91            TORRENT_UP,
92            TORRENT_DOWN,
93            ALL_UP,
94            ALL_DOWN,
95            N_COLORS
96        };
97
98        wxColour myColors[N_COLORS];
99};
100
101#endif
Note: See TracBrowser for help on using the repository browser.