WRadio: use the new mouse API.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-01-19 15:05:00 +03:00
parent ebac1745bc
commit e8c6608fa5

View File

@ -10,7 +10,7 @@
Jakub Jelinek, 1995
Andrej Borsenkow, 1996
Norbert Warmuth, 1997
Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2013
Andrew Borodin <aborodin@vmail.ru>, 2009, 2010, 2013, 2016
This file is part of the Midnight Commander.
@ -39,7 +39,6 @@
#include "lib/global.h"
#include "lib/tty/tty.h"
#include "lib/tty/mouse.h"
#include "lib/widget.h"
/*** global variables ****************************************************************************/
@ -143,31 +142,25 @@ radio_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
/* --------------------------------------------------------------------------------------------- */
static int
radio_event (Gpm_Event * event, void *data)
static void
radio_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
{
Widget *w = WIDGET (data);
if (!mouse_global_in_widget (event, w))
return MOU_UNHANDLED;
if ((event->type & (GPM_DOWN | GPM_UP)) != 0)
switch (msg)
{
WRadio *r = RADIO (data);
Gpm_Event local;
local = mouse_get_local (event, w);
r->pos = local.y - 1;
case MSG_MOUSE_DOWN:
RADIO (w)->pos = event->y;
dlg_select_widget (w);
if ((event->type & GPM_UP) != 0)
{
radio_callback (w, NULL, MSG_KEY, ' ', NULL);
send_message (w->owner, w, MSG_POST_KEY, ' ', NULL);
}
}
break;
return MOU_NORMAL;
case MSG_MOUSE_CLICK:
RADIO (w)->pos = event->y;
send_message (w, NULL, MSG_KEY, ' ', NULL);
send_message (w->owner, w, MSG_POST_KEY, ' ', NULL);
break;
default:
break;
}
}
/* --------------------------------------------------------------------------------------------- */
@ -196,8 +189,9 @@ radio_new (int y, int x, int count, const char **texts)
wmax = max (width, wmax);
}
widget_init (w, y, x, count, 4 + wmax, radio_callback, radio_event);
/* 4 is width of "(*) " */
widget_init (w, y, x, count, 4 + wmax, radio_callback, NULL);
set_easy_mouse_callback (w, radio_mouse_callback);
r->state = 1;
r->pos = 0;
r->sel = 0;