Meter.h 2.82 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
#include "RichString.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
13
14
15
16
#include "Object.h"
#include "CRT.h"
#include "ListItem.h"
#include "String.h"
17
#include "ProcessList.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
18
19
20
21
22

#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
23
24
25
26

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

27
#ifndef USE_FUNKY_MODES
28
#include <time.h>
29
30
31
32
#define USE_FUNKY_MODES 1
#endif

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


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

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

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

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

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

81
82
83
84
85
86
87
#ifdef USE_FUNKY_MODES
typedef struct GraphData_ {
   time_t time;
   double values[METER_BUFFER_LEN];
} GraphData;
#endif

88
89
90
91
92
93
94
95
96
97
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
98
99


Hisham Muhammad's avatar
Hisham Muhammad committed
100
101
102
103
104
105
#include "CPUMeter.h"
#include "MemoryMeter.h"
#include "SwapMeter.h"
#include "TasksMeter.h"
#include "LoadAverageMeter.h"
#include "UptimeMeter.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
106
#include "BatteryMeter.h"
107
#include "ClockMeter.h"
108
#include "HostnameMeter.h"
Hisham Muhammad's avatar
Hisham Muhammad committed
109

Hisham Muhammad's avatar
Hisham Muhammad committed
110

111
112
113
114
115
116
117
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif

118
#ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
119
extern char* METER_CLASS;
120
121
122
#else
#define METER_CLASS NULL
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
123

Hisham Muhammad's avatar
Hisham Muhammad committed
124
extern MeterType* Meter_types[];
Hisham Muhammad's avatar
Hisham Muhammad committed
125

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

128
void Meter_delete(Object* cast);
Hisham Muhammad's avatar
Hisham Muhammad committed
129

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

132
void Meter_setMode(Meter* this, int modeIndex);
Hisham Muhammad's avatar
Hisham Muhammad committed
133
134
135

ListItem* Meter_toListItem(Meter* this);

136
137
138
139
140
141
142
143
144
145
146
147
/* ---------- TextMeterMode ---------- */

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

#ifdef USE_FUNKY_MODES

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

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

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

148
149
150
#endif

#ifdef USE_FUNKY_MODES
151
152
153

#endif

154
155
extern MeterMode* Meter_modes[];

Hisham Muhammad's avatar
Hisham Muhammad committed
156
#endif