Meter.h 2.87 KB
Newer Older
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5

#ifndef HEADER_Meter
#define HEADER_Meter
/*
Hisham Muhammad's avatar
Hisham Muhammad committed
6
htop - Meter.h
Hisham Muhammad's avatar
Hisham Muhammad committed
7
8
9
10
11
(C) 2004-2006 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

12
13
14
15
16
17
18
#define _GNU_SOURCE
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <curses.h>
#include <stdarg.h>

Hisham Muhammad's avatar
Hisham Muhammad committed
19
20
21
22
#include "Object.h"
#include "CRT.h"
#include "ListItem.h"
#include "String.h"
23
#include "ProcessList.h"
24
#include "RichString.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
25
26
27
28

#include "debug.h"
#include <assert.h>

29
30
31
32
33
#ifndef USE_FUNKY_MODES
#define USE_FUNKY_MODES 1
#endif

#define METER_BUFFER_LEN 128
Hisham Muhammad's avatar
Hisham Muhammad committed
34
35
36


typedef struct Meter_ Meter;
37
38
typedef struct MeterType_ MeterType;
typedef struct MeterMode_ MeterMode;
Hisham Muhammad's avatar
Hisham Muhammad committed
39

40
41
typedef void(*MeterType_Init)(Meter*);
typedef void(*MeterType_Done)(Meter*);
42
typedef void(*MeterType_SetMode)(Meter*, int);
43
typedef void(*Meter_SetValues)(Meter*, char*, int);
Hisham Muhammad's avatar
Hisham Muhammad committed
44
45
typedef void(*Meter_Draw)(Meter*, int, int, int);

46
struct MeterMode_ {
Hisham Muhammad's avatar
Hisham Muhammad committed
47
   Meter_Draw draw;
48
49
50
51
52
   char* uiName;
   int h;
};

struct MeterType_ {
Hisham Muhammad's avatar
Hisham Muhammad committed
53
   Meter_SetValues setValues;
54
55
   Object_Display display;
   int mode;
Hisham Muhammad's avatar
Hisham Muhammad committed
56
   int items;
57
   double total;
Hisham Muhammad's avatar
Hisham Muhammad committed
58
   int* attributes;
59
60
61
62
63
   char* name;
   char* uiName;
   char* caption;
   MeterType_Init init;
   MeterType_Done done;
64
   MeterType_SetMode setMode;
65
66
67
68
69
70
71
72
73
74
75
76
77
   Meter_Draw draw;
};

struct Meter_ {
   Object super;
   char* caption;
   MeterType* type;
   int mode;
   int param;
   Meter_Draw draw;
   void* drawBuffer;
   int h;
   ProcessList* pl;
Hisham Muhammad's avatar
Hisham Muhammad committed
78
79
80
81
   double* values;
   double total;
};

82
83
84
85
86
87
88
89
90
91
typedef enum {
   CUSTOM_METERMODE = 0,
   BAR_METERMODE,
   TEXT_METERMODE,
#ifdef USE_FUNKY_MODES
   GRAPH_METERMODE,
   LED_METERMODE,
#endif
   LAST_METERMODE
} MeterModeId;
Hisham Muhammad's avatar
Hisham Muhammad committed
92
93


Hisham Muhammad's avatar
Hisham Muhammad committed
94
95
96
97
98
99
#include "CPUMeter.h"
#include "MemoryMeter.h"
#include "SwapMeter.h"
#include "TasksMeter.h"
#include "LoadAverageMeter.h"
#include "UptimeMeter.h"
100
#include "ClockMeter.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
101

102
103
104
105
106
107
108
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif

109
#ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
110
extern char* METER_CLASS;
111
112
113
#else
#define METER_CLASS NULL
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
114

Hisham Muhammad's avatar
Hisham Muhammad committed
115
extern MeterType* Meter_types[];
Hisham Muhammad's avatar
Hisham Muhammad committed
116

117
#ifdef USE_FUNKY_MODES
Hisham Muhammad's avatar
Hisham Muhammad committed
118

119
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
120

Hisham Muhammad's avatar
Hisham Muhammad committed
121
extern MeterMode* Meter_modes[];
Hisham Muhammad's avatar
Hisham Muhammad committed
122

123
Meter* Meter_new(ProcessList* pl, int param, MeterType* type);
Hisham Muhammad's avatar
Hisham Muhammad committed
124

125
void Meter_delete(Object* cast);
Hisham Muhammad's avatar
Hisham Muhammad committed
126

127
void Meter_setCaption(Meter* this, char* caption);
Hisham Muhammad's avatar
Hisham Muhammad committed
128

129
void Meter_setMode(Meter* this, int modeIndex);
Hisham Muhammad's avatar
Hisham Muhammad committed
130
131
132

ListItem* Meter_toListItem(Meter* this);

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* ---------- TextMeterMode ---------- */

void TextMeterMode_draw(Meter* this, int x, int y, int w);

/* ---------- BarMeterMode ---------- */

void BarMeterMode_draw(Meter* this, int x, int y, int w);

#ifdef USE_FUNKY_MODES

/* ---------- GraphMeterMode ---------- */

#define DrawDot(a,y,c) do { attrset(a); mvaddch(y, x+k, c); } while(0)

void GraphMeterMode_draw(Meter* this, int x, int y, int w);

/* ---------- LEDMeterMode ---------- */

void LEDMeterMode_draw(Meter* this, int x, int y, int w);

#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
155
#endif