00001 #ifndef WINDOWMANAGER_H
00002 #define WINDOWMANAGER_H
00003
00004 #ifdef USE_TILE
00005
00006 #include "externs.h"
00007 #include "glwrapper.h"
00008 #include "tilereg.h"
00009 #include "tilesdl.h"
00010 #include "tiletex.h"
00011
00012 enum wm_endianness
00013 {
00014 WM_BIG_ENDIAN,
00015 WM_LIL_ENDIAN,
00016 };
00017
00018 enum wm_event_type
00019 {
00020 WM_NOEVENT = 0,
00021 WM_ACTIVEEVENT,
00022 WM_KEYDOWN,
00023 WM_KEYUP,
00024 WM_MOUSEMOTION,
00025 WM_MOUSEBUTTONUP,
00026 WM_MOUSEBUTTONDOWN,
00027 WM_QUIT,
00028 WM_CUSTOMEVENT,
00029 WM_RESIZE,
00030 WM_EXPOSE,
00031 WM_NUMEVENTS = 15
00032 };
00033
00034 struct wm_keysym
00035 {
00036 unsigned char scancode;
00037 int sym;
00038 unsigned char key_mod;
00039 unsigned int unicode;
00040 };
00041
00042 struct wm_active_event
00043 {
00044 unsigned char type;
00045 unsigned char gain;
00046 unsigned char state;
00047 };
00048
00049 struct wm_keyboard_event
00050 {
00051 unsigned char type;
00052 unsigned char state;
00053 wm_keysym keysym;
00054 };
00055
00056 struct wm_resize_event
00057 {
00058 unsigned char type;
00059 int w, h;
00060 };
00061
00062 struct wm_expose_event
00063 {
00064 unsigned char type;
00065 };
00066
00067 struct wm_quit_event
00068 {
00069 unsigned char type;
00070 };
00071
00072 struct wm_custom_event
00073 {
00074 unsigned char type;
00075 int code;
00076 void *data1;
00077 void *data2;
00078 };
00079
00080
00081 struct wm_event
00082 {
00083 unsigned char type;
00084 wm_active_event active;
00085 wm_keyboard_event key;
00086 MouseEvent mouse_event;
00087 wm_resize_event resize;
00088 wm_expose_event expose;
00089 wm_quit_event quit;
00090 wm_custom_event custom;
00091 };
00092
00093
00094 typedef unsigned int (*wm_timer_callback)(unsigned int interval);
00095
00096 class WindowManager
00097 {
00098 public:
00099
00100 virtual ~WindowManager() {};
00101
00102
00103
00104
00105 static void create();
00106 static void shutdown();
00107
00108
00109 virtual int init(coord_def *m_windowsz) = 0;
00110
00111
00112 virtual void set_window_title(const char *title) = 0;
00113 virtual bool set_window_icon(const char* icon_name) = 0;
00114 virtual key_mod get_mod_state() const = 0;
00115 virtual void set_mod_state(key_mod mod) = 0;
00116 virtual int byte_order() = 0;
00117
00118
00119 virtual void set_timer(unsigned int interval,
00120 wm_timer_callback callback) = 0;
00121 virtual unsigned int get_ticks() const = 0;
00122 virtual void delay(unsigned int ms) = 0;
00123
00124
00125 virtual int raise_custom_event() = 0;
00126 virtual int wait_event(wm_event *event) = 0;
00127 virtual unsigned int get_event_count(wm_event_type type) = 0;
00128
00129
00130 virtual void resize(coord_def &m_windowsz) = 0;
00131 virtual void swap_buffers() = 0;
00132 virtual int screen_width() const = 0;
00133 virtual int screen_height() const = 0;
00134 virtual int desktop_width() const = 0;
00135 virtual int desktop_height() const = 0;
00136
00137
00138 virtual bool load_texture(GenericTexture *tex, const char *filename,
00139 MipMapOptions mip_opt, unsigned int &orig_width,
00140 unsigned int &orig_height,
00141 tex_proc_func proc = NULL,
00142 bool force_power_of_two = true) = 0;
00143
00144 };
00145
00146
00147 extern WindowManager *wm;
00148
00149 #endif //USE_TILE
00150 #endif //include guard