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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
/* ksim - a system monitor for kde
*
* Copyright (C) 2001 Robbie Ward <linuxphreak@gmx.co.uk>
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KSIM__CHART_H
#define KSIM__CHART_H
#include <tqwidget.h>
#include "common.h"
#include <kdemacros.h>
class TQColor;
namespace KSim
{
/**
* provides a graph displaying data onscreen using gkrellm themes
* @author Robbie Ward <linuxphreak@gmx.co.uk>
*/
class KDE_EXPORT Chart : public TQWidget, public KSim::Base
{
Q_OBJECT
TQ_OBJECT
public:
enum DataType { DataIn = 0, DataOut };
enum LabelType { Label = 0, Progress, Led };
/**
* Constructs a KSim::Chart.
*
* @param displayMeter is if the krellbar should be shown
* @param minValue is the minimum value to show
* @param maxValue is the maximum value to show
* @param title is the title off the krell bar (if enabled)
* @param parent is the parent widget
*/
Chart(bool displayMeter, int maxValue,
const TQString &title, TQWidget *parent,
const char *name = 0, WFlags fl = 0);
/**
* Constructs a KSim::Chart.
*
* @param showKrell is if the krellbar should be shown
* @param minValue is the minimum value to show
* @param maxValue is the maximum value to show
* @param parent is the parent widget
*/
Chart(bool displayMeter, int maxValue,
TQWidget *parent, const char *name = 0,
WFlags fl = 0);
/**
* destructs KSim::Chart
*/
virtual ~Chart();
/**
* returns the current text of the chart
*/
const TQString &text(DataType type) const;
/**
* @return the title of the chart
*/
const TQString &title() const;
/**
* @return true if the meter is enabled
*/
bool displayMeter() const;
/**
* @return the minimum value
*/
int minValue() const;
/**
* @return the minimum value
*/
int maxValue() const;
/**
* @return the current value
*/
int value(DataType dataType) const;
/**
* sets the type of the label that will appear under the graph
*/
void setLabelType(LabelType labelType);
/**
* @return the current label type, one of: Label, Progress, Led
*/
LabelType labelType() const;
/**
* reimplemented for internal reasons
*/
virtual void configureObject(bool repaintWidget = true);
/**
* reimplemented for internal reasons
*/
TQSize tqsizeHint() const;
/**
* reimplemented for internal reasons
*/
TQSize tqminimumSizeHint() const;
void disableAutomaticUpdates();
public slots:
/**
* Cleats the graphs contents
*/
void clear();
/**
* sets the title of the chart, this function returns if
* the optional krell widget is disabled
*/
void setTitle(const TQString &);
/**
* turns the meter on and off
*/
void setDisplayMeter(bool);
/**
* sets the current text that apears in the top left hand corner
*/
void setText(const TQString &in, const TQString &out = TQString());
/**
* Sets the minimum value the graph will display
*/
void setMinValue(int);
/**
* Sets the maximum value the graph will display
*/
void setMaxValue(int);
/**
* sets the value of the graph
*/
void setValue(int valueIn, int valueOut = 0);
protected:
/**
* Set the config values depending on the chart type
*/
void setConfigValues();
/**
* reimplemented for internal reasons
*/
virtual void extraTypeCall();
TQColor chartColour(const DataType &dataType, int x = 1, int y = 1) const;
virtual void paintEvent(TQPaintEvent *);
virtual void fontChange(const TQFont &);
virtual void resizeEvent(TQResizeEvent *re);
protected slots:
void updateDisplay();
private:
void buildPixmaps();
int yLocation(int) const;
void drawChart();
TQSize chartSize() const;
TQBitmap drawMask(TQPainter *);
void drawIn(TQPainter *, int, int, bool = false);
void drawOut(TQPainter *, int, int, bool = false);
int range(int) const;
void init(bool, int, const TQString &);
class Timer;
class Private;
Private *d;
};
}
#endif
|