summaryrefslogtreecommitdiff
path: root/src/calcurse.h
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-05-13 20:30:02 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-05-18 11:02:42 +0200
commit27b39a56ef8a2cf94ace5911614d0bd63c26ba06 (patch)
tree92894d27c67f49033cb02c85584986311a4d1e0e /src/calcurse.h
parent7184da0fa364049424f626f55f7c2bc0a7d22929 (diff)
downloadcalcurse-27b39a56ef8a2cf94ace5911614d0bd63c26ba06.zip
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>
Diffstat (limited to 'src/calcurse.h')
-rw-r--r--src/calcurse.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 53610c4..4f5c2c0 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -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);