svn up
[tore.git] / pytx / txlist.h
blobd37aba281c44ddbc25b2f72d64fabd26cf96bfbe
1 #ifndef _TXLIST_H_
2 #define _TXLIST_H_
4 #include <ncurses.h>
5 #include <panel.h>
6 #include "txobj.h"
7 #include "list.h"
9 typedef struct _TX_List TX_List;
10 typedef struct _TXColumns TXColumns;
12 struct Row {
13 struct list_head node;
14 char *text;
15 void *data;
16 int key;
19 typedef int (*cmpr_fn)(TXObj *,
20 const struct list_head *,
21 const struct list_head *);
22 typedef void (*bind_fn)(TXObj *, int ch, int key);
23 typedef char *(*text_fn)(TXObj *, char *, void *);
24 typedef void *(*data_fn)(TXObj *, void *, void *);
25 typedef char **(*cols_fn)(TXObj *, char *, void *);
27 struct _TX_List {
28 struct Row **map; /* integer mapping to rows */
29 struct list_head rows; /* sorted rows */
30 struct list_head *top;
31 struct list_head *sel;
33 int size; /* max amount of rows before new allocation */
34 int count; /* amount of rows */
35 int asc; /* ascending sort */
37 struct _TXColumns {
38 int ncols;
39 int sort;
40 int *widths;
41 int *offsets;
42 char **titles;
43 } cols;
45 obj_fn draw_cb;
46 cmpr_fn cmpr_cb;
47 bind_fn bind_cb;
48 text_fn text_cb;
49 data_fn data_cb;
50 cols_fn cols_cb;
53 /* upto 15 */
54 enum {
55 TX_LIST_SCROLL = 1<<10,
56 TX_LIST_SEPARATOR = 1<<11,
57 TX_LIST_TITLE = 1<<12,
58 TX_LIST_HLIGHT = 1<<13
61 void tx_list_new (TXObj *obj);
62 void tx_list_init (TXObj *obj);
63 void tx_list_sort (TXObj *obj);
64 void tx_list_sort_asc_set (TXObj *obj, int asc);
65 int tx_list_sort_asc_get (TXObj *obj);
66 void tx_list_clear (TXObj *obj);
67 void tx_list_sync (TXObj *obj);
68 void tx_list_row_remove (TXObj *obj, int k);
69 void tx_list_scroll (TXObj *obj, int scroll);
70 void tx_list_row_sync (TXObj *obj, int k, void *d);
71 int tx_list_selected_get (TXObj *obj);
72 void tx_list_selected_set (TXObj *obj, int k); /* NI */
75 void tx_list_cols_cb_set (TXObj *obj, cols_fn);
76 void tx_list_text_cb_set (TXObj *obj, text_fn);
77 void tx_list_data_cb_set (TXObj *obj, data_fn);
78 void tx_list_cmpr_cb_set (TXObj *obj, cmpr_fn);
79 void tx_list_bind_cb_set (TXObj *obj, bind_fn);
82 int *tx_list_columns_width_get (TXObj *obj);
83 void tx_list_columns_width_set (TXObj *obj, int ncols, int *widths);
84 void tx_list_columns_title_set (TXObj *obj, int ncols, char **titles);
85 void tx_list_column_sort_set (TXObj *obj, int i);
86 int tx_list_column_sort_get (TXObj *obj); /* NI */
87 #endif