2016-09-27 13:53:17 +03:00
|
|
|
/*
|
|
|
|
* Widget group features module for Midnight Commander
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file group.h
|
|
|
|
* \brief Header: widget group features module
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MC__GROUP_H
|
|
|
|
#define MC__GROUP_H
|
|
|
|
|
|
|
|
#include "lib/global.h"
|
|
|
|
|
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
|
|
|
#define GROUP(x) ((WGroup *)(x))
|
|
|
|
#define CONST_GROUP(x) ((const WGroup *)(x))
|
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
/*** typedefs(not structures) ********************************************************************/
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
struct WGroup
|
|
|
|
{
|
|
|
|
Widget widget;
|
|
|
|
|
|
|
|
/* Group members */
|
|
|
|
GList *widgets; /* widgets list */
|
|
|
|
GList *current; /* Currently active widget */
|
2016-09-27 14:08:42 +03:00
|
|
|
|
|
|
|
gboolean winch_pending; /* SIGWINCH signal has been got. Resize group after rise */
|
2016-11-15 09:33:34 +03:00
|
|
|
int mouse_status; /* For the autorepeat status of the mouse */
|
2016-09-27 13:53:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
2022-05-21 19:30:17 +03:00
|
|
|
void group_init (WGroup * g, const WRect * r, widget_cb_fn callback,
|
2016-09-28 14:34:08 +03:00
|
|
|
widget_mouse_cb_fn mouse_callback);
|
|
|
|
/* Default callback for groups */
|
|
|
|
cb_ret_t group_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
|
|
|
void *data);
|
2019-11-17 17:02:52 +03:00
|
|
|
cb_ret_t group_default_set_state (Widget * w, widget_state_t state, gboolean enable);
|
2016-11-15 09:33:34 +03:00
|
|
|
int group_handle_mouse_event (Widget * w, Gpm_Event * event);
|
2016-09-28 14:34:08 +03:00
|
|
|
|
2016-09-28 11:01:30 +03:00
|
|
|
unsigned long group_add_widget_autopos (WGroup * g, void *w, widget_pos_flags_t pos_flags,
|
|
|
|
const void *before);
|
2019-10-16 10:33:00 +03:00
|
|
|
void group_remove_widget (void *w);
|
2016-09-28 11:01:30 +03:00
|
|
|
|
2016-09-27 16:16:38 +03:00
|
|
|
void group_set_current_widget_next (WGroup * g);
|
|
|
|
void group_set_current_widget_prev (WGroup * g);
|
|
|
|
|
|
|
|
GList *group_get_widget_next_of (GList * w);
|
|
|
|
GList *group_get_widget_prev_of (GList * w);
|
|
|
|
|
|
|
|
void group_select_next_widget (WGroup * g);
|
|
|
|
void group_select_prev_widget (WGroup * g);
|
|
|
|
|
|
|
|
void group_select_widget_by_id (const WGroup * g, unsigned long id);
|
|
|
|
|
2016-09-28 13:14:10 +03:00
|
|
|
void group_send_broadcast_msg (WGroup * g, widget_msg_t message);
|
|
|
|
|
2016-09-27 13:53:17 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** inline functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2016-09-27 16:16:38 +03:00
|
|
|
/**
|
2016-09-28 11:01:30 +03:00
|
|
|
* Add widget to group before current widget.
|
|
|
|
*
|
|
|
|
* @param g WGroup object
|
|
|
|
* @param w widget to be added
|
|
|
|
*
|
|
|
|
* @return widget ID
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline unsigned long
|
2024-06-01 21:12:14 +03:00
|
|
|
group_add_widget (WGroup *g, void *w)
|
2016-09-28 11:01:30 +03:00
|
|
|
{
|
|
|
|
return group_add_widget_autopos (g, w, WPOS_KEEP_DEFAULT,
|
|
|
|
g->current != NULL ? g->current->data : NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Add widget to group before specified widget.
|
2016-09-27 16:16:38 +03:00
|
|
|
*
|
|
|
|
* @param g WGroup object
|
2016-09-28 11:01:30 +03:00
|
|
|
* @param w widget to be added
|
|
|
|
* @param before add @w before this widget
|
|
|
|
*
|
|
|
|
* @return widget ID
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline unsigned long
|
2024-06-01 21:12:14 +03:00
|
|
|
group_add_widget_before (WGroup *g, void *w, void *before)
|
2016-09-28 11:01:30 +03:00
|
|
|
{
|
|
|
|
return group_add_widget_autopos (g, w, WPOS_KEEP_DEFAULT, before);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Select current widget in the Dialog.
|
|
|
|
*
|
|
|
|
* @param h WDialog object
|
2016-09-27 16:16:38 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void
|
2024-06-01 21:12:14 +03:00
|
|
|
group_select_current_widget (WGroup *g)
|
2016-09-27 16:16:38 +03:00
|
|
|
{
|
|
|
|
if (g->current != NULL)
|
|
|
|
widget_select (WIDGET (g->current->data));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2016-09-30 11:31:44 +03:00
|
|
|
static inline unsigned long
|
2024-06-01 21:12:14 +03:00
|
|
|
group_get_current_widget_id (const WGroup *g)
|
2016-09-30 11:31:44 +03:00
|
|
|
{
|
|
|
|
return WIDGET (g->current->data)->id;
|
|
|
|
}
|
|
|
|
|
2016-09-27 13:53:17 +03:00
|
|
|
#endif /* MC__GROUP_H */
|