3 * \brief Header: WListbox widget
6 #ifndef MC__WIDGET_LISTBOX_H
7 #define MC__WIDGET_LISTBOX_H
9 /*** typedefs(not structures) and defined constants **********************************************/
11 /*** enums ***************************************************************************************/
13 /* callback should return one of the following values */
16 LISTBOX_CONT
, /* continue */
17 LISTBOX_DONE
/* finish dialog */
22 LISTBOX_APPEND_AT_END
= 0, /* append at the end */
23 LISTBOX_APPEND_BEFORE
, /* insert before current */
24 LISTBOX_APPEND_AFTER
, /* insert after current */
25 LISTBOX_APPEND_SORTED
/* insert alphabetically */
28 /*** structures declarations (and typedefs of structures)*****************************************/
31 typedef lcback_ret_t (*lcback_fn
) (struct WListbox
* l
);
33 typedef struct WLEntry
35 char *text
; /* Text to display */
37 void *data
; /* Client information */
40 typedef struct WListbox
43 GList
*list
; /* Pointer to the double linked list */
44 int pos
; /* The current element displayed */
45 int top
; /* The first element displayed */
46 int count
; /* Number of items in the listbox */
47 gboolean allow_duplicates
; /* Do we allow duplicates on the list? */
48 gboolean scrollbar
; /* Draw a scrollbar? */
49 gboolean deletable
; /* Can list entries be deleted? */
50 lcback_fn callback
; /* The callback function */
51 int cursor_x
, cursor_y
; /* Cache the values */
54 /*** global variables defined in .c file *********************************************************/
56 /*** declarations of public functions ************************************************************/
58 WListbox
*listbox_new (int y
, int x
, int height
, int width
, gboolean deletable
, lcback_fn callback
);
59 int listbox_search_text (WListbox
* l
, const char *text
);
60 void listbox_select_first (WListbox
* l
);
61 void listbox_select_last (WListbox
* l
);
62 void listbox_select_entry (WListbox
* l
, int dest
);
63 void listbox_get_current (WListbox
* l
, char **string
, void **extra
);
64 void listbox_remove_current (WListbox
* l
);
65 void listbox_set_list (WListbox
* l
, GList
* list
);
66 void listbox_remove_list (WListbox
* l
);
67 char *listbox_add_item (WListbox
* l
, listbox_append_t pos
,
68 int hotkey
, const char *text
, void *data
);
70 /*** inline functions ****************************************************************************/
72 #endif /* MC__WIDGET_LISTBOX_H */