Meter.h 3.18 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.
*/

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

Hisham Muhammad's avatar
Hisham Muhammad committed
14
15
#include "ListItem.h"
#include "ProcessList.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
16
17
18

typedef struct Meter_ Meter;

19
20
21
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
22
typedef void(*Meter_SetValues)(Meter*, char*, int);
Hisham Muhammad's avatar
Hisham Muhammad committed
23
24
typedef void(*Meter_Draw)(Meter*, int, int, int);

25
26
27
28
29
30
31
32
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;
Hisham Muhammad's avatar
Hisham Muhammad committed
33
   int items;
34
35
   const double total;
   const int* attributes;
Hisham Muhammad's avatar
Hisham Muhammad committed
36
37
38
   const char* name;
   const char* uiName;
   const char* caption;
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
} 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
#define Meter_getItems(this_)          As_Meter(this_)->items
#define Meter_setItems(this_, n_)      As_Meter(this_)->items = (n_)
#define Meter_attributes(this_)        As_Meter(this_)->attributes
#define Meter_name(this_)              As_Meter(this_)->name
#define Meter_uiName(this_)            As_Meter(this_)->uiName
56
57
58

struct Meter_ {
   Object super;
59
60
   Meter_Draw draw;
   
61
62
63
   char* caption;
   int mode;
   int param;
64
   void* drawData;
65
66
   int h;
   ProcessList* pl;
Hisham Muhammad's avatar
Hisham Muhammad committed
67
68
69
70
   double* values;
   double total;
};

71
72
73
74
75
typedef struct MeterMode_ {
   Meter_Draw draw;
   const char* uiName;
   int h;
} MeterMode;
76

77
78
79
80
81
82
83
84
typedef enum {
   CUSTOM_METERMODE = 0,
   BAR_METERMODE,
   TEXT_METERMODE,
   GRAPH_METERMODE,
   LED_METERMODE,
   LAST_METERMODE
} MeterModeId;
Hisham Muhammad's avatar
Hisham Muhammad committed
85

86
87
88
89
90
typedef struct GraphData_ {
   struct timeval time;
   double values[METER_BUFFER_LEN];
} GraphData;

Hisham Muhammad's avatar
Hisham Muhammad committed
91

92
93
94
95
96
97
98
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif

99
extern MeterClass Meter_class;
Hisham Muhammad's avatar
Hisham Muhammad committed
100

101
extern MeterClass* Meter_types[];
Hisham Muhammad's avatar
Hisham Muhammad committed
102

103
Meter* Meter_new(ProcessList* pl, int param, MeterClass* type);
Hisham Muhammad's avatar
Hisham Muhammad committed
104

105
void Meter_delete(Object* cast);
Hisham Muhammad's avatar
Hisham Muhammad committed
106

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

109
void Meter_setMode(Meter* this, int modeIndex);
Hisham Muhammad's avatar
Hisham Muhammad committed
110
111
112

ListItem* Meter_toListItem(Meter* this);

113
114
115
116
117
118
119
120
121
122
/* ---------- TextMeterMode ---------- */

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

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

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

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

123
124
extern MeterMode* Meter_modes[];

Hisham Muhammad's avatar
Hisham Muhammad committed
125
#endif