Meter.h 2.38 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
13
14
15
16
#ifndef USE_FUNKY_MODES
#define USE_FUNKY_MODES 1
#endif

#define METER_BUFFER_LEN 128
Hisham Muhammad's avatar
Hisham Muhammad committed
17

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

typedef struct Meter_ Meter;
22
23
typedef struct MeterType_ MeterType;
typedef struct MeterMode_ MeterMode;
Hisham Muhammad's avatar
Hisham Muhammad committed
24

25
26
typedef void(*MeterType_Init)(Meter*);
typedef void(*MeterType_Done)(Meter*);
27
typedef void(*MeterType_SetMode)(Meter*, int);
28
typedef void(*Meter_SetValues)(Meter*, char*, int);
Hisham Muhammad's avatar
Hisham Muhammad committed
29
30
typedef void(*Meter_Draw)(Meter*, int, int, int);

31
struct MeterMode_ {
Hisham Muhammad's avatar
Hisham Muhammad committed
32
   Meter_Draw draw;
Hisham Muhammad's avatar
Hisham Muhammad committed
33
   const char* uiName;
34
35
36
37
   int h;
};

struct MeterType_ {
Hisham Muhammad's avatar
Hisham Muhammad committed
38
   Meter_SetValues setValues;
39
40
   Object_Display display;
   int mode;
Hisham Muhammad's avatar
Hisham Muhammad committed
41
   int items;
42
   double total;
Hisham Muhammad's avatar
Hisham Muhammad committed
43
   int* attributes;
Hisham Muhammad's avatar
Hisham Muhammad committed
44
45
46
   const char* name;
   const char* uiName;
   const char* caption;
47
48
   MeterType_Init init;
   MeterType_Done done;
49
   MeterType_SetMode setMode;
50
51
52
53
54
55
56
57
58
59
   Meter_Draw draw;
};

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

67
68
69
70
71
72
73
#ifdef USE_FUNKY_MODES
typedef struct GraphData_ {
   time_t time;
   double values[METER_BUFFER_LEN];
} GraphData;
#endif

74
75
76
77
78
79
80
81
82
83
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
84
85


86
87
88
89
90
91
92
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif

93
#ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
94
extern char* METER_CLASS;
95
96
97
#else
#define METER_CLASS NULL
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
98

Hisham Muhammad's avatar
Hisham Muhammad committed
99
extern MeterType* Meter_types[];
Hisham Muhammad's avatar
Hisham Muhammad committed
100

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

103
void Meter_delete(Object* cast);
Hisham Muhammad's avatar
Hisham Muhammad committed
104

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

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

ListItem* Meter_toListItem(Meter* this);

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

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

#ifdef USE_FUNKY_MODES

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

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

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

123
124
125
#endif

#ifdef USE_FUNKY_MODES
126
127
128

#endif

129
130
extern MeterMode* Meter_modes[];

Hisham Muhammad's avatar
Hisham Muhammad committed
131
#endif