Meter.h 3.78 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
(C) 2004-2011 Hisham H. Muhammad
Hisham Muhammad's avatar
Hisham Muhammad committed
8
9
10
11
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

Hisham Muhammad's avatar
Hisham Muhammad committed
12
#define METER_BUFFER_LEN 256
Hisham Muhammad's avatar
Hisham Muhammad committed
13

14
15
#define GRAPH_DELAY (DEFAULT_DELAY/2)

16
17
#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */

Hisham Muhammad's avatar
Hisham Muhammad committed
18
#include "ListItem.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
19
20

#include <sys/time.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
21
22
23

typedef struct Meter_ Meter;

24
25
26
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
27
typedef void(*Meter_SetValues)(Meter*, char*, int);
Hisham Muhammad's avatar
Hisham Muhammad committed
28
29
typedef void(*Meter_Draw)(Meter*, int, int, int);

30
31
32
33
34
35
36
37
38
39
typedef struct MeterClass_ {
   ObjectClass super;
   const Meter_Init init;
   const Meter_Done done;
   const Meter_UpdateMode updateMode;
   const Meter_Draw draw;
   const Meter_SetValues setValues;
   const int defaultMode;
   const double total;
   const int* attributes;
Hisham Muhammad's avatar
Hisham Muhammad committed
40
41
42
   const char* name;
   const char* uiName;
   const char* caption;
43
   const char* description;
44
45
   const char maxItems;
   char curItems;
46
47
48
49
50
51
52
53
54
55
56
57
} MeterClass;

#define As_Meter(this_)                ((MeterClass*)((this_)->super.klass))
#define Meter_initFn(this_)            As_Meter(this_)->init
#define Meter_init(this_)              As_Meter(this_)->init((Meter*)(this_))
#define Meter_done(this_)              As_Meter(this_)->done((Meter*)(this_))
#define Meter_updateModeFn(this_)      As_Meter(this_)->updateMode
#define Meter_updateMode(this_, m_)    As_Meter(this_)->updateMode((Meter*)(this_), m_)
#define Meter_drawFn(this_)            As_Meter(this_)->draw
#define Meter_doneFn(this_)            As_Meter(this_)->done
#define Meter_setValues(this_, c_, i_) As_Meter(this_)->setValues((Meter*)(this_), c_, i_)
#define Meter_defaultMode(this_)       As_Meter(this_)->defaultMode
58
59
#define Meter_getItems(this_)          As_Meter(this_)->curItems
#define Meter_setItems(this_, n_)      As_Meter(this_)->curItems = (n_)
Explorer09's avatar
Explorer09 committed
60
#define Meter_getMaxItems(this_)       As_Meter(this_)->maxItems
61
62
63
#define Meter_attributes(this_)        As_Meter(this_)->attributes
#define Meter_name(this_)              As_Meter(this_)->name
#define Meter_uiName(this_)            As_Meter(this_)->uiName
64
65
66

struct Meter_ {
   Object super;
67
68
   Meter_Draw draw;
   
69
70
71
   char* caption;
   int mode;
   int param;
72
   void* drawData;
73
   int h;
Hisham Muhammad's avatar
Hisham Muhammad committed
74
   struct ProcessList_* pl;
Hisham Muhammad's avatar
Hisham Muhammad committed
75
76
77
78
   double* values;
   double total;
};

79
80
81
82
83
typedef struct MeterMode_ {
   Meter_Draw draw;
   const char* uiName;
   int h;
} MeterMode;
84

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

94
95
96
typedef struct GraphData_ {
   struct timeval time;
   double values[METER_BUFFER_LEN];
97
   int colors[METER_BUFFER_LEN][GRAPH_HEIGHT];
98
99
   double *prevItems;
   double *currentItems;
100
101
} GraphData;

Hisham Muhammad's avatar
Hisham Muhammad committed
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
110
111
#ifndef CLAMP
#define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#endif
112

113
extern MeterClass Meter_class;
Hisham Muhammad's avatar
Hisham Muhammad committed
114

Hisham Muhammad's avatar
Hisham Muhammad committed
115
Meter* Meter_new(struct ProcessList_* pl, int param, MeterClass* type);
Hisham Muhammad's avatar
Hisham Muhammad committed
116

Christian Hesse's avatar
Christian Hesse committed
117
118
int Meter_humanUnit(char* buffer, unsigned long int value, int size);

119
void Meter_delete(Object* cast);
Hisham Muhammad's avatar
Hisham Muhammad committed
120

Hisham Muhammad's avatar
Hisham Muhammad committed
121
void Meter_setCaption(Meter* this, const char* caption);
Hisham Muhammad's avatar
Hisham Muhammad committed
122

123
void Meter_setMode(Meter* this, int modeIndex);
Hisham Muhammad's avatar
Hisham Muhammad committed
124

125
ListItem* Meter_toListItem(Meter* this, bool moving);
Hisham Muhammad's avatar
Hisham Muhammad committed
126

127
128
129
130
131
132
/* ---------- TextMeterMode ---------- */

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

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

133
134
#ifdef HAVE_LIBNCURSESW

Christian Hesse's avatar
Christian Hesse committed
135
#define PIXPERROW_UTF8 4
136
137
#endif

Christian Hesse's avatar
Christian Hesse committed
138
139
#define PIXPERROW_ASCII 2

140
141
/* ---------- LEDMeterMode ---------- */

142
143
144
145
#ifdef HAVE_LIBNCURSESW

#endif

146
147
extern MeterMode* Meter_modes[];

Hisham Muhammad's avatar
Hisham Muhammad committed
148
149
150
151
152
153
/* Blank meter */

extern int BlankMeter_attributes[];

extern MeterClass BlankMeter_class;

Hisham Muhammad's avatar
Hisham Muhammad committed
154
#endif