File: MainWindow.H

package info (click to toggle)
pppload 1.0-5
  • links: PTS
  • area: contrib
  • in suites: hamm
  • size: 116 kB
  • ctags: 84
  • sloc: cpp: 408; makefile: 175
file content (83 lines) | stat: -rw-r--r-- 2,716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// pppload - A PPP Load Monitor
// Copyright (C) 1996  Sean Vyain
// svyain@mail.tds.net
// smvyain@softart.com
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#ifndef _MainWindow_H_
#define _MainWindow_H_

#include <qwidget.h>
#include <qpixmap.h>

//: Main window of PPPLoad.
//. The MainWindow takes PPP stats updates from a PPPStats object, and draws
//. a graph of the transmit and receive rates.  Below the graph, the total
//. number of bytes transmitted and received is displayed.
class MainWindow : public QWidget {
	Q_OBJECT;
	//: The size of the history arrays (basically the width of the window).
	int  _historySize;
	//: Array of last n transmit rates.
	int* _txHistory;
	//: Array of last n receive rates.
	int* _rxHistory;
	//: The size of the data arrays.
	int  _dataSize;
	//: Array of transmit data for computing average.
	int* _txData;
	//: Array of receive data for computing average.
	int* _rxData;
	//: Average transmit rate.
	int  _txAverage;
	//: Average receive rate.
	int  _rxAverage;
	//: Current maximum transfer rate.
	int _max;
	//: Width of one character.
	int _fontWidth;
	//: Height of one character.
	int _fontHeight;
	//: Baseline for the font.
	int _fontBaseline;
	//: Last transmit total string.
	QString _txStr;
	//: Last receive total string.
	QString _rxStr;
	//: Off-screen buffer for drawing and paint events.
	QPixmap _pixmap;

	//: Convert a number of bytes to a reasonable string.
	QString bytesToString( int bytes );
	//: Redraw the graph using the stored data.
	void redrawGraph();
 protected:
	//: Rescale the graph to fit in the new window size.
	virtual void resizeEvent( QResizeEvent* e );
	//: Redraw the contents of the window.
	virtual void paintEvent( QPaintEvent* e );
 public:
	//: Create the main window.
	MainWindow( QWidget* parent=0, const char* name=0 );
 public slots:
	//: Process the stats update from a PPPStats object.
	void updateStats( unsigned int rxDelta, unsigned int txDelta, unsigned int rxTotal, unsigned int txTotal );
	
	//: Process a link down indication.
	void linkDown();
};

#endif