AUTO_LT_SYNC
[tore.git] / pytx / txobj.h
blob07e3a4c285ca6425a142eceb03647bd276659750
1 #ifndef _TXOBJ_H_
2 #define _TXOBJ_H_
3 #include <ncurses.h>
4 #include <panel.h>
5 #include "list.h"
7 #define TX_EXT(type, var) type *var = (type *)obj->extend
8 #define MIN(a,b) (((a) < (b) ? (a) : (b)))
9 #define MAX(a,b) (((a) < (b) ? (a) : (b)))
11 typedef struct _TXObj TXObj;
13 typedef void (*obj_fn) (TXObj *);
14 typedef int (*getc_fn)(TXObj *);
15 typedef int (*draw_fn)(TXObj *);
16 typedef int (*size_fn)(TXObj *, int, int);
17 typedef void (*oper_fn)(TXObj *, int);
19 struct _TXObj {
20 struct list_head node;
21 void *extend;
23 char *title;
24 int x, y, h, w;
26 int flags;
27 int type;
29 WINDOW *bwin;
30 PANEL *bpanel;
31 WINDOW *win;
32 PANEL *panel;
34 obj_fn init_cb;
35 obj_fn rsze_cb;
36 obj_fn idle_cb;
37 draw_fn draw_cb;
38 getc_fn getc_cb;
39 size_fn size_cb;
40 oper_fn oper_cb;
42 /* passed to the above functions */
43 void *data;
45 /* spare variable, useful for bindings */
46 void *bind;
50 extern TXObj *tx_obj_root;
51 extern TXObj *tx_obj_focus;
53 enum {TX_LIST = 1, TX_BOX = 2};
54 /* upto 10 */
55 /* XXX: BORDER MUST BE 1 << 0 because it uses the value 1 as an offset when drawing */
56 enum {TX_OBJ_BORDER = 1<<0, TX_OBJ_ROOT = 1<<1, TX_OBJ_FOCUS = 1<<2, TX_OBJ_TITLE = 1<<3};
58 int tx_obj_init (TXObj *obj, int type, int flags);
59 void tx_obj_border (TXObj *obj);
60 void tx_obj_free (TXObj *obj);
61 void tx_obj_get_type (TXObj *obj);
62 void tx_obj_reset (TXObj *obj);
64 void tx_obj_title_set (TXObj *obj, char *title);
65 void tx_obj_size_set (TXObj *obj, int x, int y, int w, int h);
66 void tx_obj_map (TXObj *obj, void (*fn)(TXObj *));
67 void tx_obj_flag_set (TXObj *obj, int flag, int set);
68 int tx_obj_flag_get (TXObj *obj, int flag);
69 int tx_obj_flag_toggle (TXObj *obj, int flag);
72 /* object functions */
73 void tx_obj_draw (TXObj *obj);
74 void tx_obj_resize (TXObj *obj);
75 void tx_obj_idle (TXObj *obj);
76 void tx_obj_operate (TXObj *obj);
78 /* set object cb functions */
79 void tx_obj_size_cb_set (TXObj *obj, size_fn);
80 void tx_obj_rsze_cb_set (TXObj *obj, obj_fn);
81 void tx_obj_idle_cb_set (TXObj *obj, obj_fn);
82 void tx_obj_getc_cb_set (TXObj *obj, getc_fn);
84 #endif