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
|
// bbload.hh for bbsload - an tool to display the average load in X11.
//
// 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.
//
// (See the included file COPYING / GPL-2.0)
//
#ifndef __MAIN_HH
#define __MAIN_HH
#include "Image.hh"
#include "Basewindow.hh"
#include "resource.hh"
#include "Timer.hh"
#define LEFT_BUTTON 1
#define MIDDLE_BUTTON 2
#define RIGHT_BUTTON 3
class Resource;
class BaseResource;
class Basewindow;
class ToolWindow;
struct PIXMAP {
Pixmap frame;
Pixmap label;
Pixmap loadbar_active;
Pixmap loadbar_inactive;
Pixmap loadbar_background;
};
struct LABELSIZE {
int seperator_width;
int space_width;
int width[13];
int total_width;
int height;
};
struct FRAMESIZE {
int x;
int y;
int height;
int width;
};
struct GEOM {
int x;
int y;
int width;
int height;
double level;
};
struct MEMORYINFO {
unsigned long total;
unsigned long used;
unsigned long free;
unsigned long shared;
unsigned long buffers;
unsigned long cached;
};
struct SWAPINFO {
unsigned long total;
unsigned long used;
unsigned long free;
};
struct NORM {
double total_used;
double mem_used;
double swap_used;
};
struct CPUINFO {
double user;
double nice;
double system;
double idle;
};
struct LOADINFO {
float average1m;
float average5m;
float average15m;
};
struct TASK {
int running;
int total;
};
class CheckLoad : public TimeoutHandler {
public:
CheckLoad(ToolWindow *);
struct LOADINFO getLoad(void) { return(load); }
struct MEMORYINFO getMemory(void) { return(mem); }
struct SWAPINFO getSwap(void) { return(swap); }
struct CPUINFO getCpu(void) {return(cpu); }
struct NORM getNorm(void) { return(norm); }
struct TASK getTask(void) { return(task); }
bool getBroken(void) { return(broken); }
void Reconfigure(void);
private:
void timeout(void);
struct LOADINFO load;
struct MEMORYINFO mem;
struct SWAPINFO swap;
struct CPUINFO cpu;
struct NORM norm;
struct TASK task;
bool broken;
ToolWindow *bbtool;
BTimer *timer;
};
class ToolWindow : public Basewindow
{
public:
ToolWindow(int argc,char **argv,struct CMDOPTIONS *);
~ToolWindow(void);
Window framewin;
Window labelwin;
Window loadwin;
void MakeWindow(bool);
void ReadLoad(void);
void Redraw(void);
void EventLoop(void);
void reconfigure(void);
void CheckConfig(void);
void RedrawGauge(double,int);
void RedrawLabel(double,int);
bool raised;
Resource *getResource(void) { return(resource); }
protected:
virtual void process_event(XEvent *);
private:
XGCValues gcv;
GC frameGC;
Resource *resource;
struct LABELSIZE label;
struct FRAMESIZE frame;
struct GEOM *load;
int loadbar_height;
int gauge_height;
int xposition;
bool mapped;
XPoint points[11];
struct PIXMAP pixmap;
//bool broken;
CheckLoad *check_load;
};
#endif /* __MAIN_HH */
|