2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
/** \file listbox.h
|
|
|
|
* \brief Header: WListbox widget
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MC__WIDGET_LISTBOX_H
|
|
|
|
#define MC__WIDGET_LISTBOX_H
|
|
|
|
|
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
2012-10-11 12:25:07 +04:00
|
|
|
#define LISTBOX(x) ((WListbox *)(x))
|
|
|
|
#define LENTRY(x) ((WLEntry *)(x))
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
/* callback should return one of the following values */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LISTBOX_CONT, /* continue */
|
|
|
|
LISTBOX_DONE /* finish dialog */
|
|
|
|
} lcback_ret_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LISTBOX_APPEND_AT_END = 0, /* append at the end */
|
|
|
|
LISTBOX_APPEND_BEFORE, /* insert before current */
|
|
|
|
LISTBOX_APPEND_AFTER, /* insert after current */
|
|
|
|
LISTBOX_APPEND_SORTED /* insert alphabetically */
|
|
|
|
} listbox_append_t;
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
struct WListbox;
|
|
|
|
typedef lcback_ret_t (*lcback_fn) (struct WListbox * l);
|
|
|
|
|
|
|
|
typedef struct WLEntry
|
|
|
|
{
|
|
|
|
char *text; /* Text to display */
|
|
|
|
int hotkey;
|
|
|
|
void *data; /* Client information */
|
2015-10-04 15:14:16 +03:00
|
|
|
gboolean free_data; /* Whether to free the data on entry's removal */
|
2010-11-12 11:03:57 +03:00
|
|
|
} WLEntry;
|
|
|
|
|
|
|
|
typedef struct WListbox
|
|
|
|
{
|
|
|
|
Widget widget;
|
2013-12-02 10:27:32 +04:00
|
|
|
GQueue *list; /* Pointer to the list of WLEntry */
|
2010-11-12 11:03:57 +03:00
|
|
|
int pos; /* The current element displayed */
|
|
|
|
int top; /* The first element displayed */
|
|
|
|
gboolean allow_duplicates; /* Do we allow duplicates on the list? */
|
|
|
|
gboolean scrollbar; /* Draw a scrollbar? */
|
|
|
|
gboolean deletable; /* Can list entries be deleted? */
|
|
|
|
lcback_fn callback; /* The callback function */
|
|
|
|
int cursor_x, cursor_y; /* Cache the values */
|
|
|
|
} WListbox;
|
|
|
|
|
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
2011-02-16 18:19:48 +03:00
|
|
|
extern const global_keymap_t *listbox_map;
|
|
|
|
|
2010-11-12 11:03:57 +03:00
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
|
|
|
WListbox *listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn callback);
|
|
|
|
int listbox_search_text (WListbox * l, const char *text);
|
2017-01-25 15:07:18 +03:00
|
|
|
int listbox_search_data (WListbox * l, const void *data);
|
2010-11-12 11:03:57 +03:00
|
|
|
void listbox_select_first (WListbox * l);
|
|
|
|
void listbox_select_last (WListbox * l);
|
|
|
|
void listbox_select_entry (WListbox * l, int dest);
|
2019-07-06 19:36:56 +03:00
|
|
|
int listbox_get_length (const WListbox * l);
|
2010-11-12 11:03:57 +03:00
|
|
|
void listbox_get_current (WListbox * l, char **string, void **extra);
|
2013-12-02 10:27:32 +04:00
|
|
|
WLEntry *listbox_get_nth_item (const WListbox * l, int pos);
|
|
|
|
GList *listbox_get_first_link (const WListbox * l);
|
2010-11-12 11:03:57 +03:00
|
|
|
void listbox_remove_current (WListbox * l);
|
2013-12-02 10:27:32 +04:00
|
|
|
gboolean listbox_is_empty (const WListbox * l);
|
2019-07-20 20:15:43 +03:00
|
|
|
void listbox_set_list (WListbox * l, GQueue * list);
|
2010-11-12 11:03:57 +03:00
|
|
|
void listbox_remove_list (WListbox * l);
|
2015-10-04 15:14:16 +03:00
|
|
|
char *listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *text,
|
|
|
|
void *data, gboolean free_data);
|
2010-11-12 11:03:57 +03:00
|
|
|
|
|
|
|
/*** inline functions ****************************************************************************/
|
|
|
|
|
|
|
|
#endif /* MC__WIDGET_LISTBOX_H */
|