2009-05-21 12:16:39 +00:00
|
|
|
/*
|
|
|
|
* A 'window' is simply a canvas that can receive events.
|
|
|
|
* It can be anything from a simple message box to the
|
|
|
|
* game screen when playing.
|
|
|
|
*
|
|
|
|
* See event.c for event handling code.
|
|
|
|
*
|
|
|
|
* -kreator 2009-05-06
|
|
|
|
*/
|
|
|
|
|
2010-01-09 09:19:26 +00:00
|
|
|
#ifndef DESCENT_WINDOW_H
|
|
|
|
#define DESCENT_WINDOW_H
|
|
|
|
|
2009-05-21 12:16:39 +00:00
|
|
|
#include "event.h"
|
|
|
|
#include "gr.h"
|
2010-12-05 12:33:25 +00:00
|
|
|
#include "console.h"
|
2009-05-21 12:16:39 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2009-05-21 12:16:39 +00:00
|
|
|
typedef struct window window;
|
|
|
|
|
2012-11-11 00:14:30 +00:00
|
|
|
void arch_init(void);
|
2013-12-01 05:21:47 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class window_subfunction_t
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef int (*type)(window *menu, d_event *event, T *userdata);
|
|
|
|
};
|
|
|
|
|
|
|
|
class unused_window_userdata_t;
|
|
|
|
static unused_window_userdata_t *const unused_window_userdata = NULL;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
window *window_create(grs_canvas *src, int x, int y, int w, int h, typename window_subfunction_t<T>::type event_callback, T *data)
|
|
|
|
{
|
|
|
|
return window_create(src, x, y, w, h, (window_subfunction_t<void>::type)event_callback, (void *)(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
window *window_create(grs_canvas *src, int x, int y, int w, int h, window_subfunction_t<void>::type event_callback, void *data);
|
|
|
|
|
2009-12-02 13:49:54 +00:00
|
|
|
extern int window_close(window *wind);
|
2010-03-17 09:44:19 +00:00
|
|
|
extern int window_exists(window *wind);
|
2009-05-21 12:16:39 +00:00
|
|
|
extern window *window_get_front(void);
|
|
|
|
extern window *window_get_first(void);
|
|
|
|
extern window *window_get_next(window *wind);
|
2010-04-04 09:41:53 +00:00
|
|
|
extern window *window_get_prev(window *wind);
|
2009-05-21 12:16:39 +00:00
|
|
|
extern void window_select(window *wind);
|
|
|
|
extern void window_set_visible(window *wind, int visible);
|
|
|
|
extern int window_is_visible(window *wind);
|
|
|
|
extern grs_canvas *window_get_canvas(window *wind);
|
2012-03-24 06:43:08 +00:00
|
|
|
extern void window_update_canvases(void);
|
2009-05-21 12:16:39 +00:00
|
|
|
extern int window_send_event(window *wind, d_event *event);
|
2011-10-09 10:31:44 +00:00
|
|
|
extern void window_set_modal(window *wind, int modal);
|
|
|
|
extern int window_is_modal(window *wind);
|
2010-12-05 12:33:25 +00:00
|
|
|
|
|
|
|
#define WINDOW_SEND_EVENT(w, e) \
|
|
|
|
do { \
|
2013-12-07 00:47:27 +00:00
|
|
|
con_printf(CON_DEBUG, "Sending event %s to window of dimensions %dx%d", #e, window_get_canvas(w)->cv_bitmap.bm_w, window_get_canvas(w)->cv_bitmap.bm_h); \
|
2010-12-05 12:33:25 +00:00
|
|
|
event.type = e; \
|
|
|
|
window_send_event(w, &event); \
|
|
|
|
} while (0)
|
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#endif
|
|
|
|
|
2010-06-14 08:19:27 +00:00
|
|
|
#endif
|