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

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

#include "Object.h"
#include "Vector.h"
#include "CRT.h"
#include "RichString.h"
16
#include "ListItem.h"
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

#include <math.h>
#include <stdbool.h>

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

#include <curses.h>
//#link curses


typedef struct Panel_ Panel;

typedef enum HandlerResult_ {
   HANDLED,
   IGNORED,
   BREAK_LOOP
} HandlerResult;

36
37
#define EVENT_SETSELECTED -1

38
39
40
41
42
43
44
45
46
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);

struct Panel_ {
   Object super;
   int x, y, w, h;
   WINDOW* window;
   Vector* items;
   int selected;
   int scrollV, scrollH;
47
   int scrollHAmount;
48
49
50
51
   int oldSelected;
   bool needsRedraw;
   RichString header;
   Panel_EventHandler eventHandler;
52
   char* eventHandlerBuffer;
53
54
55
};


Hisham Muhammad's avatar
Hisham Muhammad committed
56
57
58
59
60
61
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
62

63
#ifdef DEBUG
Hisham Muhammad's avatar
Hisham Muhammad committed
64
extern char* PANEL_CLASS;
65
66
67
68
#else
#define PANEL_CLASS NULL
#endif

69
70
71
72
#define KEY_CTRLN      0016            /* control-n key */
#define KEY_CTRLP      0020            /* control-p key */
#define KEY_CTRLF      0006            /* control-f key */
#define KEY_CTRLB      0002            /* control-b key */
73

74
Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner, Object_Compare compare);
75
76
77
78
79
80
81

void Panel_delete(Object* cast);

void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner);

void Panel_done(Panel* this);

82
RichString* Panel_getHeader(Panel* this);
83

Hisham Muhammad's avatar
Hisham Muhammad committed
84
extern void Panel_setHeader(Panel* this, const char* header);
85

Hisham Muhammad's avatar
Hisham Muhammad committed
86
void Panel_setEventHandler(Panel* this, Panel_EventHandler eh);
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

void Panel_move(Panel* this, int x, int y);

void Panel_resize(Panel* this, int w, int h);

void Panel_prune(Panel* this);

void Panel_add(Panel* this, Object* o);

void Panel_insert(Panel* this, int i, Object* o);

void Panel_set(Panel* this, int i, Object* o);

Object* Panel_get(Panel* this, int i);

Object* Panel_remove(Panel* this, int i);

Object* Panel_getSelected(Panel* this);

void Panel_moveSelectedUp(Panel* this);

void Panel_moveSelectedDown(Panel* this);

int Panel_getSelectedIndex(Panel* this);

Hisham Muhammad's avatar
Hisham Muhammad committed
112
int Panel_size(Panel* this);
113
114
115
116
117

void Panel_setSelected(Panel* this, int selected);

void Panel_draw(Panel* this, bool focus);

Hisham Muhammad's avatar
Hisham Muhammad committed
118
bool Panel_onKey(Panel* this, int key);
119

120
121
122

HandlerResult Panel_selectByTyping(Panel* this, int ch);

123
#endif