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

Last change on this file since 7468 was 7468, checked in by charles, 12 years ago

(trunk) patch from wereHamster to finish off tr_handle

  • Property svn:keywords set to Date Rev Author Id
File size: 2.5 KB
Line 
1/*
2 * Xmission - a cross-platform bittorrent client
3 * Copyright (C) 2007 Charles Kerr <charles@transmissionbt.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 7468 2008-12-22 19:14:43Z 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;
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 * );
51
52        void Pulse( tr_session * handle );
53
54    public:
55
56        enum {
57            BACKGROUND,
58            FRAME,
59            TORRENT_UP,
60            TORRENT_DOWN,
61            ALL_UP,
62            ALL_DOWN,
63            N_COLORS
64        };
65
66        void SetColor( int, const wxColour& );
67
68        static wxString GetColorName( int );
69
70    private:
71
72        virtual void OnSize( wxSizeEvent& event );
73
74        void OnPaint( wxPaintEvent& );
75
76        DECLARE_EVENT_TABLE()
77
78    private:
79
80        wxBitmap * myBitmap;
81
82        struct tr_torrent * myTorrent;
83
84        struct Speed
85        {
86            time_t time;
87            double torrentUp;
88            double torrentDown;
89            double allUp;
90            double allDown;
91            Speed(): time(0),
92                     torrentUp(0), torrentDown(0),
93                     allUp(0), allDown(0) {}
94        };
95           
96        typedef std::vector<Speed> stats_t;
97
98        stats_t myStats;
99
100        double myMaxSpeed;
101
102        int myHistory;
103
104        wxColour myColors[N_COLORS];
105};
106
107#endif
Note: See TracBrowser for help on using the repository browser.