Apply the new ground_level method.
[crawl.git] / crawl-ref / source / windowmanager.h
blobd28b22c9fca5f9116180c656adeb47c40722c6ba
1 #ifndef WINDOWMANAGER_H
2 #define WINDOWMANAGER_H
4 #ifdef USE_TILE
6 #include "externs.h"
7 #include "glwrapper.h"
8 #include "tilereg.h"
9 #include "tilesdl.h"
10 #include "tiletex.h"
12 enum wm_endianness
14 WM_BIG_ENDIAN,
15 WM_LIL_ENDIAN,
18 enum wm_event_type
20 WM_NOEVENT = 0,
21 WM_ACTIVEEVENT,
22 WM_KEYDOWN,
23 WM_KEYUP,
24 WM_MOUSEMOTION,
25 WM_MOUSEBUTTONUP,
26 WM_MOUSEBUTTONDOWN,
27 WM_QUIT,
28 WM_CUSTOMEVENT,
29 WM_RESIZE,
30 WM_EXPOSE,
31 WM_NUMEVENTS = 15
34 struct wm_keysym
36 unsigned char scancode;
37 int sym;
38 unsigned char key_mod;
39 unsigned int unicode;
42 struct wm_active_event
44 unsigned char type;
45 unsigned char gain;
46 unsigned char state;
49 struct wm_keyboard_event
51 unsigned char type;
52 unsigned char state;
53 wm_keysym keysym;
56 struct wm_resize_event
58 unsigned char type;
59 int w, h;
62 struct wm_expose_event
64 unsigned char type;
67 struct wm_quit_event
69 unsigned char type;
72 struct wm_custom_event
74 unsigned char type;
75 int code;
76 void *data1;
77 void *data2;
80 // Basically a generic SDL_Event
81 struct wm_event
83 unsigned char type;
84 wm_active_event active;
85 wm_keyboard_event key;
86 MouseEvent mouse_event;
87 wm_resize_event resize;
88 wm_expose_event expose;
89 wm_quit_event quit;
90 wm_custom_event custom;
93 // custom timer callback function
94 typedef unsigned int (*wm_timer_callback)(unsigned int interval);
96 class WindowManager
98 public:
99 // To silence pre 4.3 g++ compiler warnings
100 virtual ~WindowManager() {};
102 // Static Alloc/deallocators
103 // Note: Write this function in each implementation-specific file,
104 // e.g. windowmanager-sdl.cc has its own WindowManager::create().
105 static void create();
106 static void shutdown();
108 // Class functions
109 virtual int init(coord_def *m_windowsz) = 0;
111 // Environment state functions
112 virtual void set_window_title(const char *title) = 0;
113 virtual bool set_window_icon(const char* icon_name) = 0;
114 virtual key_mod get_mod_state() const = 0;
115 virtual void set_mod_state(key_mod mod) = 0;
116 virtual int byte_order() = 0;
118 // System time functions
119 virtual void set_timer(unsigned int interval,
120 wm_timer_callback callback) = 0;
121 virtual unsigned int get_ticks() const = 0;
122 virtual void delay(unsigned int ms) = 0;
124 // Event functions
125 virtual int raise_custom_event() = 0;
126 virtual int wait_event(wm_event *event) = 0;
127 virtual unsigned int get_event_count(wm_event_type type) = 0;
129 // Display functions
130 virtual void resize(coord_def &m_windowsz) = 0;
131 virtual void swap_buffers() = 0;
132 virtual int screen_width() const = 0;
133 virtual int screen_height() const = 0;
134 virtual int desktop_width() const = 0;
135 virtual int desktop_height() const = 0;
137 // Texture loading
138 virtual bool load_texture(GenericTexture *tex, const char *filename,
139 MipMapOptions mip_opt, unsigned int &orig_width,
140 unsigned int &orig_height,
141 tex_proc_func proc = NULL,
142 bool force_power_of_two = true) = 0;
146 // Main interface for UI functions
147 extern WindowManager *wm;
149 #endif //USE_TILE
150 #endif //include guard