root/lib/widget/listbox.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


   1 
   2 /** \file listbox.h
   3  *  \brief Header: WListbox widget
   4  */
   5 
   6 #ifndef MC__WIDGET_LISTBOX_H
   7 #define MC__WIDGET_LISTBOX_H
   8 
   9 /*** typedefs(not structures) and defined constants **********************************************/
  10 
  11 #define LISTBOX(x) ((WListbox *) (x))
  12 #define LENTRY(x)  ((WLEntry *) (x))
  13 
  14 /*** enums ***************************************************************************************/
  15 
  16 /* callback should return one of the following values */
  17 typedef enum
  18 {
  19     LISTBOX_CONT,  // continue
  20     LISTBOX_DONE   // finish dialog
  21 } lcback_ret_t;
  22 
  23 typedef enum
  24 {
  25     LISTBOX_APPEND_AT_END = 0,  // append at the end
  26     LISTBOX_APPEND_BEFORE,      // insert before current
  27     LISTBOX_APPEND_AFTER,       // insert after current
  28     LISTBOX_APPEND_SORTED       // insert alphabetically
  29 } listbox_append_t;
  30 
  31 /*** structures declarations (and typedefs of structures)*****************************************/
  32 
  33 struct WListbox;
  34 typedef lcback_ret_t (*lcback_fn) (struct WListbox *l);
  35 
  36 typedef struct WLEntry
  37 {
  38     char *text;  // Text to display
  39     int hotkey;
  40     void *data;          // Client information
  41     gboolean free_data;  // Whether to free the data on entry's removal
  42 } WLEntry;
  43 
  44 typedef struct WListbox
  45 {
  46     Widget widget;
  47     GQueue *list;               // Pointer to the list of WLEntry
  48     int top;                    // The first element displayed
  49     int current;                // The current element displayed
  50     gboolean allow_duplicates;  // Do we allow duplicates on the list?
  51     gboolean scrollbar;         // Draw a scrollbar?
  52     gboolean deletable;         // Can list entries be deleted?
  53     lcback_fn callback;         // The callback function
  54     int cursor_x, cursor_y;     // Cache the values
  55 } WListbox;
  56 
  57 /*** global variables defined in .c file *********************************************************/
  58 
  59 extern const global_keymap_t *listbox_map;
  60 
  61 /*** declarations of public functions ************************************************************/
  62 
  63 WListbox *listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn callback);
  64 int listbox_search_text (WListbox *l, const char *text);
  65 int listbox_search_data (WListbox *l, const void *data);
  66 void listbox_select_first (WListbox *l);
  67 void listbox_select_last (WListbox *l);
  68 void listbox_set_current (WListbox *l, int dest);
  69 int listbox_get_length (const WListbox *l);
  70 void listbox_get_current (WListbox *l, char **string, void **extra);
  71 WLEntry *listbox_get_nth_entry (const WListbox *l, int pos);
  72 GList *listbox_get_first_link (const WListbox *l);
  73 void listbox_remove_current (WListbox *l);
  74 gboolean listbox_is_empty (const WListbox *l);
  75 void listbox_set_list (WListbox *l, GQueue *list);
  76 void listbox_remove_list (WListbox *l);
  77 char *listbox_add_item (WListbox *l, listbox_append_t pos, int hotkey, const char *text, void *data,
  78                         gboolean free_data);
  79 char *listbox_add_item_take (WListbox *l, listbox_append_t pos, int hotkey, char *text, void *data,
  80                              gboolean free_data);
  81 
  82 /*** inline functions ****************************************************************************/
  83 
  84 #endif

/* [previous][next][first][last][top][bottom][index][help]  */