root/lib/widget/group.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. group_add_widget
  2. group_add_widget_before
  3. group_select_current_widget
  4. group_get_current_widget_id

   1 /*
   2  *  Widget group features module for Midnight Commander
   3  */
   4 
   5 /** \file group.h
   6  *  \brief Header: widget group features module
   7  */
   8 
   9 #ifndef MC__GROUP_H
  10 #define MC__GROUP_H
  11 
  12 #include "lib/global.h"
  13 
  14 /*** typedefs(not structures) and defined constants **********************************************/
  15 
  16 #define GROUP(x)       ((WGroup *) (x))
  17 #define CONST_GROUP(x) ((const WGroup *) (x))
  18 
  19 /*** enums ***************************************************************************************/
  20 
  21 /*** typedefs(not structures) ********************************************************************/
  22 
  23 /*** structures declarations (and typedefs of structures)*****************************************/
  24 
  25 struct WGroup
  26 {
  27     Widget widget;
  28 
  29     // Group members
  30     GList *widgets;  // widgets list
  31     GList *current;  // Currently active widget
  32 
  33     gboolean winch_pending;  // SIGWINCH signal has been got. Resize group after rise
  34     int mouse_status;        // For the autorepeat status of the mouse
  35 };
  36 
  37 /*** global variables defined in .c file *********************************************************/
  38 
  39 /*** declarations of public functions ************************************************************/
  40 
  41 void group_init (WGroup *g, const WRect *r, widget_cb_fn callback,
  42                  widget_mouse_cb_fn mouse_callback);
  43 /* Default callback for groups */
  44 cb_ret_t group_default_callback (Widget *w, Widget *sender, widget_msg_t msg, int parm, void *data);
  45 cb_ret_t group_default_set_state (Widget *w, widget_state_t state, gboolean enable);
  46 int group_handle_mouse_event (Widget *w, Gpm_Event *event);
  47 
  48 unsigned long group_add_widget_autopos (WGroup *g, void *w, widget_pos_flags_t pos_flags,
  49                                         const void *before);
  50 void group_remove_widget (void *w);
  51 
  52 void group_set_current_widget_next (WGroup *g);
  53 void group_set_current_widget_prev (WGroup *g);
  54 
  55 GList *group_get_widget_next_of (GList *w);
  56 GList *group_get_widget_prev_of (GList *w);
  57 
  58 void group_select_next_widget (WGroup *g);
  59 void group_select_prev_widget (WGroup *g);
  60 
  61 void group_select_widget_by_id (const WGroup *g, unsigned long id);
  62 
  63 void group_send_broadcast_msg (WGroup *g, widget_msg_t message);
  64 
  65 /* --------------------------------------------------------------------------------------------- */
  66 /*** inline functions ****************************************************************************/
  67 /* --------------------------------------------------------------------------------------------- */
  68 
  69 /**
  70  * Add widget to group before current widget.
  71  *
  72  * @param g WGroup object
  73  * @param w widget to be added
  74  *
  75  * @return widget ID
  76  */
  77 
  78 static inline unsigned long
  79 group_add_widget (WGroup *g, void *w)
     /* [previous][next][first][last][top][bottom][index][help]  */
  80 {
  81     return group_add_widget_autopos (g, w, WPOS_KEEP_DEFAULT,
  82                                      g->current != NULL ? g->current->data : NULL);
  83 }
  84 
  85 /* --------------------------------------------------------------------------------------------- */
  86 /**
  87  * Add widget to group before specified widget.
  88  *
  89  * @param g WGroup object
  90  * @param w widget to be added
  91  * @param before add @w before this widget
  92  *
  93  * @return widget ID
  94  */
  95 
  96 static inline unsigned long
  97 group_add_widget_before (WGroup *g, void *w, void *before)
     /* [previous][next][first][last][top][bottom][index][help]  */
  98 {
  99     return group_add_widget_autopos (g, w, WPOS_KEEP_DEFAULT, before);
 100 }
 101 
 102 /* --------------------------------------------------------------------------------------------- */
 103 /**
 104  * Select current widget in the Dialog.
 105  *
 106  * @param h WDialog object
 107  */
 108 
 109 static inline void
 110 group_select_current_widget (WGroup *g)
     /* [previous][next][first][last][top][bottom][index][help]  */
 111 {
 112     if (g->current != NULL)
 113         widget_select (WIDGET (g->current->data));
 114 }
 115 
 116 /* --------------------------------------------------------------------------------------------- */
 117 
 118 static inline unsigned long
 119 group_get_current_widget_id (const WGroup *g)
     /* [previous][next][first][last][top][bottom][index][help]  */
 120 {
 121     return WIDGET (g->current->data)->id;
 122 }
 123 
 124 #endif

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