Add a generic list box implementation
This adds a very generic list box implementation. List boxes with items of different heights are supported. Two callback functions to determine the height of every single item and to draw a specific item are used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
@@ -515,6 +515,20 @@ struct scrollwin {
|
||||
const char *label;
|
||||
};
|
||||
|
||||
/* Generic list box structure. */
|
||||
typedef int (*listbox_fn_item_height_t) (int, void *);
|
||||
typedef void (*listbox_fn_draw_item_t) (int, WINDOW *, int, int, void *);
|
||||
|
||||
struct listbox {
|
||||
struct scrollwin sw;
|
||||
unsigned item_count;
|
||||
unsigned item_sel;
|
||||
listbox_fn_item_height_t fn_height;
|
||||
unsigned *ch;
|
||||
listbox_fn_draw_item_t fn_draw;
|
||||
void *cb_data;
|
||||
};
|
||||
|
||||
/* Pad structure to handle scrolling. */
|
||||
struct pad {
|
||||
int width;
|
||||
@@ -802,6 +816,18 @@ void keys_save_bindings(FILE *);
|
||||
int keys_check_missing_bindings(void);
|
||||
void keys_fill_missing(void);
|
||||
|
||||
/* listbox.c */
|
||||
void listbox_init(struct listbox *, int, int, int, int, const char *, listbox_fn_item_height_t, listbox_fn_draw_item_t);
|
||||
void listbox_delete(struct listbox *);
|
||||
void listbox_resize(struct listbox *, int, int, int, int);
|
||||
void listbox_set_cb_data(struct listbox *, void *);
|
||||
void listbox_load_items(struct listbox *, int);
|
||||
void listbox_draw_deco(struct listbox *);
|
||||
void listbox_display(struct listbox *);
|
||||
int listbox_get_sel(struct listbox *);
|
||||
void listbox_set_sel(struct listbox *, unsigned);
|
||||
void listbox_sel_move(struct listbox *, int);
|
||||
|
||||
/* mem.c */
|
||||
void *xmalloc(size_t);
|
||||
void *xcalloc(size_t, size_t);
|
||||
|
||||
Reference in New Issue
Block a user