2014-06-01 17:55:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2006-04-03 17:36:27 +00:00
|
|
|
// Event header file
|
|
|
|
|
|
|
|
#ifndef _EVENT_H
|
|
|
|
#define _EVENT_H
|
2012-03-30 14:29:03 +00:00
|
|
|
#include "maths.h"
|
2006-04-03 17:36:27 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2009-05-21 12:16:39 +00:00
|
|
|
typedef enum event_type
|
|
|
|
{
|
2010-01-07 14:49:07 +00:00
|
|
|
EVENT_IDLE = 0,
|
2010-05-03 08:44:46 +00:00
|
|
|
EVENT_QUIT,
|
|
|
|
|
2011-02-02 00:36:43 +00:00
|
|
|
EVENT_JOYSTICK_BUTTON_DOWN,
|
|
|
|
EVENT_JOYSTICK_BUTTON_UP,
|
|
|
|
EVENT_JOYSTICK_MOVED,
|
|
|
|
|
2010-03-24 07:26:52 +00:00
|
|
|
EVENT_MOUSE_BUTTON_DOWN,
|
|
|
|
EVENT_MOUSE_BUTTON_UP,
|
2011-10-09 10:31:44 +00:00
|
|
|
EVENT_MOUSE_DOUBLE_CLICKED,
|
2011-01-13 04:36:19 +00:00
|
|
|
EVENT_MOUSE_MOVED,
|
2010-05-03 08:44:46 +00:00
|
|
|
|
2010-01-07 14:49:07 +00:00
|
|
|
EVENT_KEY_COMMAND,
|
2011-02-02 00:36:43 +00:00
|
|
|
EVENT_KEY_RELEASE,
|
2010-05-03 08:44:46 +00:00
|
|
|
|
2013-12-13 22:39:01 +00:00
|
|
|
EVENT_WINDOW_CREATED,
|
2010-01-20 05:10:32 +00:00
|
|
|
EVENT_WINDOW_ACTIVATED,
|
2010-02-02 03:38:29 +00:00
|
|
|
EVENT_WINDOW_DEACTIVATED,
|
2010-01-20 05:10:32 +00:00
|
|
|
EVENT_WINDOW_DRAW,
|
|
|
|
EVENT_WINDOW_CLOSE,
|
2010-02-02 07:52:03 +00:00
|
|
|
EVENT_WINDOW_CLOSED,
|
2010-05-03 08:44:46 +00:00
|
|
|
|
|
|
|
EVENT_NEWMENU_DRAW, // draw after the newmenu stuff is drawn (e.g. savegame previews)
|
|
|
|
EVENT_NEWMENU_CHANGED, // an item had its value/text changed
|
2012-03-03 12:12:25 +00:00
|
|
|
EVENT_NEWMENU_SELECTED, // user chose something - pressed enter/clicked on it
|
|
|
|
|
2012-03-24 09:18:03 +00:00
|
|
|
EVENT_UI_DIALOG_DRAW, // draw after the dialog stuff is drawn (e.g. spinning robots)
|
2012-03-03 12:12:25 +00:00
|
|
|
EVENT_UI_GADGET_PRESSED, // user 'pressed' a gadget
|
|
|
|
EVENT_UI_LISTBOX_MOVED,
|
|
|
|
EVENT_UI_LISTBOX_SELECTED,
|
|
|
|
EVENT_UI_USERBOX_DRAGGED
|
2009-05-21 12:16:39 +00:00
|
|
|
} event_type;
|
|
|
|
|
|
|
|
// A vanilla event. Cast to the correct type of event according to 'type'.
|
2013-12-22 22:03:07 +00:00
|
|
|
struct d_event
|
2009-05-21 12:16:39 +00:00
|
|
|
{
|
|
|
|
event_type type;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2009-05-21 12:16:39 +00:00
|
|
|
|
2014-12-20 04:36:09 +00:00
|
|
|
struct d_create_event : d_event
|
|
|
|
{
|
|
|
|
const void *createdata;
|
|
|
|
};
|
|
|
|
|
2015-02-28 22:34:07 +00:00
|
|
|
struct d_change_event : d_event
|
|
|
|
{
|
|
|
|
int citem;
|
|
|
|
d_change_event(const int c) :
|
|
|
|
d_event{EVENT_NEWMENU_CHANGED}, citem(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-02-28 22:34:07 +00:00
|
|
|
struct d_select_event : d_event
|
|
|
|
{
|
|
|
|
int citem;
|
|
|
|
d_select_event(const int c) :
|
|
|
|
d_event{EVENT_NEWMENU_SELECTED}, citem(c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-04-03 17:36:27 +00:00
|
|
|
int event_init();
|
2010-03-24 07:26:52 +00:00
|
|
|
|
|
|
|
// Sends input events to event handlers
|
2006-04-03 17:36:27 +00:00
|
|
|
void event_poll();
|
2010-07-30 17:59:21 +00:00
|
|
|
void event_flush();
|
2006-04-03 17:36:27 +00:00
|
|
|
|
2010-04-02 05:01:08 +00:00
|
|
|
// Set and call the default event handler
|
2014-10-04 21:47:13 +00:00
|
|
|
void set_default_handler(int (*handler)(const d_event &event));
|
|
|
|
int call_default_handler(const d_event &event);
|
2010-04-02 05:01:08 +00:00
|
|
|
|
2011-10-09 10:31:44 +00:00
|
|
|
// Send an event to the front window as first priority, then to the windows behind if it's not modal (editor), then the default handler
|
2014-10-04 21:47:13 +00:00
|
|
|
void event_send(const d_event &event);
|
2011-01-13 04:36:19 +00:00
|
|
|
|
2010-03-24 07:26:52 +00:00
|
|
|
// Sends input, idle and draw events to event handlers
|
2009-05-21 12:16:39 +00:00
|
|
|
void event_process();
|
|
|
|
|
2010-12-28 18:11:06 +00:00
|
|
|
void event_toggle_focus(int activate_focus);
|
|
|
|
|
2012-03-18 10:04:16 +00:00
|
|
|
// See how long we were idle for
|
|
|
|
void event_reset_idle_seconds();
|
2012-03-30 14:29:03 +00:00
|
|
|
fix event_get_idle_seconds();
|
2012-03-18 10:04:16 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-03 17:36:27 +00:00
|
|
|
#endif
|