You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
5.2 KiB
165 lines
5.2 KiB
13 years ago
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson *
|
||
|
* (c) 2002, Ben Burton *
|
||
|
* *
|
||
|
* 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. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#ifndef __STATDOCK_H
|
||
|
#define __STATDOCK_H
|
||
|
|
||
12 years ago
|
#include <tqcolor.h>
|
||
13 years ago
|
#include <ksystemtray.h>
|
||
|
|
||
|
class StatPopup;
|
||
|
|
||
|
/**
|
||
|
* A system tray window that displays a recent history of readings.
|
||
|
* A single application might have many of these windows.
|
||
|
*
|
||
|
* Two simultaneous sets of readings are supported; these will be
|
||
|
* referred to as upper and lower readings. When diagram splitting is
|
||
|
* switched on, these readings will be displayed together on the diagram
|
||
|
* with the upper readings shown above the lower readings. When diagram
|
||
|
* splitting is switched off, only the upper readings will be displayed.
|
||
|
*
|
||
12 years ago
|
* The parent window of a StatDock must be a StatPopup, which provides
|
||
13 years ago
|
* all of the actions in this window's context menu.
|
||
|
*/
|
||
|
class StatDock : public KSystemTray {
|
||
|
Q_OBJECT
|
||
11 years ago
|
|
||
13 years ago
|
|
||
|
public:
|
||
|
/**
|
||
|
* Fill style constants.
|
||
|
*/
|
||
|
static const int fillLines;
|
||
|
static const int fillBars;
|
||
|
static const int fillShaded;
|
||
|
|
||
|
/**
|
||
|
* Colour constants.
|
||
|
*/
|
||
12 years ago
|
static const TQColor colorGrid;
|
||
|
static const TQColor colorGridInactive;
|
||
|
static const TQColor colorLabel;
|
||
|
static const TQColor colorLabelInactive;
|
||
|
static const TQColor colorLower;
|
||
|
static const TQColor colorLowerInactive;
|
||
|
static const TQColor colorBlack;
|
||
13 years ago
|
|
||
|
public:
|
||
|
/**
|
||
|
* Constructor and destructor.
|
||
|
*
|
||
12 years ago
|
* Note that the constructor will call parent->initDock().
|
||
13 years ago
|
*
|
||
|
* Parameter whichDock must be 0 or 1 to specify whether this dock
|
||
12 years ago
|
* will become dock[0] or dock[1] in the given StatPopup parent.
|
||
13 years ago
|
* Parameter useLabel should contain the label that will be drawn on
|
||
|
* the diagram if labelling is enabled.
|
||
|
*/
|
||
12 years ago
|
StatDock(int whichDock, const TQString& useLabel, StatPopup *parent,
|
||
13 years ago
|
const char *name = 0);
|
||
|
~StatDock();
|
||
|
|
||
|
/**
|
||
|
* Setting display options.
|
||
|
*/
|
||
|
void setGrid(bool);
|
||
|
void setActive(bool);
|
||
|
void setSoft(bool);
|
||
|
void setSplit(bool);
|
||
|
void setLabelled(bool);
|
||
12 years ago
|
void setLabel(const TQString&);
|
||
13 years ago
|
void setFill(int);
|
||
12 years ago
|
void setColor(const TQColor&);
|
||
13 years ago
|
|
||
|
public slots:
|
||
|
/**
|
||
|
* Clear the history of recent readings.
|
||
|
* All readings will be reset to zero and the diagram will be
|
||
|
* updated.
|
||
|
*/
|
||
|
void clearHistory();
|
||
|
|
||
|
/**
|
||
|
* Add the given pair of readings as the most recent in our list.
|
||
|
* The diagram will be updated accordingly.
|
||
|
*
|
||
|
* Each argument should be a percentage between 0 and 100.
|
||
|
* The sum of both arguments must not exceed 100.
|
||
|
*
|
||
|
* If diagram splitting is switched off, the given lower reading
|
||
|
* will be ignored completely and 0 will be used instead.
|
||
|
*
|
||
|
* @param upper the upper reading in this pair.
|
||
|
* @param lower the lower reading in this pair.
|
||
|
*/
|
||
|
void addPercentReading(int upper, int lower);
|
||
|
|
||
|
private:
|
||
|
/**
|
||
|
* Repaint this system tray window with a fresh diagram.
|
||
|
*/
|
||
12 years ago
|
void paintEvent(TQPaintEvent*);
|
||
13 years ago
|
|
||
|
private:
|
||
|
/**
|
||
|
* Display options.
|
||
|
*/
|
||
|
bool grid;
|
||
|
/**< Should the grid be displayed behind the diagram? */
|
||
|
bool active;
|
||
|
/**< Is this meter currently active? */
|
||
|
bool soft;
|
||
|
/**< Are we artificially modifying the readings to produce a
|
||
|
soft curve? */
|
||
|
bool split;
|
||
|
/**< Are we displaying both upper and lower readings? */
|
||
|
bool labelled;
|
||
|
/**< Should this diagram be labelled? */
|
||
12 years ago
|
TQString label;
|
||
13 years ago
|
/**< The specific label to draw on this diagram. */
|
||
|
int fill;
|
||
|
/**< Specifies which of the predefined fill styles to use. */
|
||
12 years ago
|
TQColor colorUpper;
|
||
13 years ago
|
/**< Colour for displaying the upper readings. */
|
||
12 years ago
|
TQColor colorUpperInactive;
|
||
13 years ago
|
/**< Colour for displaying the upper readings whilst the diagram
|
||
|
is inactive. */
|
||
|
|
||
|
/**
|
||
|
* Stored readings.
|
||
|
*/
|
||
|
int* bufUpper;
|
||
|
/**< Stores our list of recent upper readings.
|
||
|
This list begins at index (pos + 1) as the earliest reading
|
||
|
and cycles around to index (pos) as the latest reading. */
|
||
|
int* bufLower;
|
||
|
/**< Stores our list of recent lower readings.
|
||
|
This list begins at index (pos + 1) as the earliest reading
|
||
|
and cycles around to index (pos) as the latest reading. */
|
||
|
int pos;
|
||
|
/**< The index in our arrays of the most recent reading. */
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Temporaries.
|
||
|
*/
|
||
|
int i, j, tmpPos, oldUpper, oldLower;
|
||
|
/**< Temporary variables used during computations. */
|
||
13 years ago
|
|
||
|
protected:
|
||
12 years ago
|
void resizeEvent ( TQResizeEvent * );
|
||
13 years ago
|
};
|
||
|
|
||
|
#endif
|