Panel.h 3.16 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
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

//#link curses

Hisham Muhammad's avatar
Hisham Muhammad committed
14
15
#include "Object.h"
#include "Vector.h"
16
#include "FunctionBar.h"
17
18
19
20

typedef struct Panel_ Panel;

typedef enum HandlerResult_ {
21
22
23
   HANDLED     = 0x01,
   IGNORED     = 0x02,
   BREAK_LOOP  = 0x04,
24
25
   REDRAW      = 0x08,
   RESCAN      = 0x10,
26
   SYNTH_KEY   = 0x20,
27
28
} HandlerResult;

29
30
31
32
#define EVENT_SET_SELECTED -1

#define EVENT_HEADER_CLICK(x_) (-10000 + x_)
#define EVENT_HEADER_CLICK_GET_X(ev_) (ev_ + 10000)
Hisham Muhammad's avatar
Hisham Muhammad committed
33
34
35
36
37
#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ < -9000)

#define EVENT_SCREEN_TAB_CLICK(x_) (-20000 + x_)
#define EVENT_SCREEN_TAB_GET_X(ev_) (ev_ + 20000)
#define EVENT_IS_SCREEN_TAB_CLICK(ev_) (ev_ >= -20000 && ev_ < -10000)
38

39
40
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);

41
42
43
44
45
46
47
48
49
typedef struct PanelClass_ {
   const ObjectClass super;
   const Panel_EventHandler eventHandler;
} PanelClass;

#define As_Panel(this_)                ((PanelClass*)((this_)->super.klass))
#define Panel_eventHandlerFn(this_)    As_Panel(this_)->eventHandler
#define Panel_eventHandler(this_, ev_) As_Panel(this_)->eventHandler((Panel*)(this_), ev_)

50
51
52
struct Panel_ {
   Object super;
   int x, y, w, h;
53
   int cursorX, cursorY;
54
55
56
57
   WINDOW* window;
   Vector* items;
   int selected;
   int oldSelected;
58
   int selectedLen;
Hisham Muhammad's avatar
Hisham Muhammad committed
59
   void* eventHandlerState;
Hisham Muhammad's avatar
Hisham Muhammad committed
60
61
   int scrollV;
   short scrollH;
62
   bool needsRedraw;
63
   bool cursorOn;
64
65
   FunctionBar* currentBar;
   FunctionBar* defaultBar;
66
   RichString header;
67
   int selectionColor;
68
69
};

70
71
#define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0)

72

Hisham Muhammad's avatar
Hisham Muhammad committed
73
74
75
76
77
78
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
79

80
#define KEY_CTRL(l) ((l)-'A'+1)
81

82
83
void Panel_setCursorToSelection(Panel* this);

84
85
extern PanelClass Panel_class;

86
Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar);
87
88
89

void Panel_delete(Object* cast);

90
void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar);
91
92
93

void Panel_done(Panel* this);

94
95
void Panel_setSelectionColor(Panel* this, int color);

96
RichString* Panel_getHeader(Panel* this);
97

Hisham Muhammad's avatar
Hisham Muhammad committed
98
extern void Panel_setHeader(Panel* this, const char* header);
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

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
124
int Panel_size(Panel* this);
125
126
127
128
129

void Panel_setSelected(Panel* this, int selected);

void Panel_draw(Panel* this, bool focus);

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

132
133
HandlerResult Panel_selectByTyping(Panel* this, int ch);

134
135
136
int Panel_getCh(Panel* this);


137
#endif