00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef WINGRAPHICSWINDOW_H
00020 #define WINGRAPHICSWINDOW_H
00021
00022
00023
00024
00025 #define _WIN32_WINNT 0x0502
00026
00027 #define WINDOWS_LEAN_AND_MEAN
00028 #include <windows.h>
00029 #undef WINDOWS_LEAN_AND_MEAN
00030
00031 #include "pandabase.h"
00032 #include "graphicsWindow.h"
00033
00034 class WinGraphicsPipe;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 class EXPCL_PANDAWIN WinGraphicsWindow : public GraphicsWindow {
00050 public:
00051 WinGraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg);
00052 virtual ~WinGraphicsWindow();
00053
00054 virtual void begin_flip();
00055
00056 virtual void process_events();
00057 virtual void set_properties_now(WindowProperties &properties);
00058 virtual LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
00059 static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
00060 virtual bool handle_mouse_motion(int x, int y);
00061 virtual void handle_mouse_exit(void);
00062
00063
00064 protected:
00065 virtual void close_window();
00066 virtual bool open_window();
00067 virtual void fullscreen_minimized(WindowProperties &properties);
00068 virtual void fullscreen_restored(WindowProperties &properties);
00069
00070 virtual bool do_reshape_request(int x_origin, int y_origin,
00071 int x_size, int y_size);
00072
00073 virtual void handle_reshape();
00074 virtual bool do_fullscreen_resize(int x_size, int y_size);
00075
00076 virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size,
00077 DWORD &bitdepth);
00078
00079 private:
00080 bool open_fullscreen_window();
00081 bool open_regular_window();
00082 void track_mouse_leaving(HWND hwnd);
00083
00084 static void process_1_event();
00085
00086 INLINE void handle_keypress(ButtonHandle key, int x, int y);
00087 INLINE void handle_keyresume(ButtonHandle key);
00088 INLINE void handle_keyrelease(ButtonHandle key);
00089 ButtonHandle lookup_key(WPARAM wparam) const;
00090 INLINE int translate_mouse(int pos) const;
00091 INLINE void set_cursor_in_window();
00092 INLINE void set_cursor_out_of_window();
00093 static void update_cursor_window(WinGraphicsWindow *to_window);
00094
00095 static void register_window_class();
00096 static bool find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight,
00097 DWORD bpp, DEVMODE &dm);
00098 static void show_error_message(DWORD message_id = 0);
00099
00100 protected:
00101 HWND _hWnd;
00102
00103 private:
00104 bool _ime_open;
00105 bool _ime_active;
00106 bool _ime_composition_w;
00107 bool _tracking_mouse_leaving;
00108 bool _maximized;
00109 bool _bCursor_in_WindowClientArea;
00110 DEVMODE _fullscreen_display_mode;
00111
00112
00113
00114 static const int num_virtual_keys = 256;
00115 BYTE _keyboard_state[num_virtual_keys];
00116
00117 protected:
00118 static bool _loaded_custom_cursor;
00119 static HCURSOR _mouse_cursor;
00120 static const char * const _window_class_name;
00121 static bool _window_class_registered;
00122
00123 private:
00124
00125 typedef map<HWND, WinGraphicsWindow *> WindowHandles;
00126 static WindowHandles _window_handles;
00127
00128
00129
00130
00131 static WinGraphicsWindow *_creating_window;
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 static WinGraphicsWindow *_cursor_window;
00142 static bool _cursor_hidden;
00143 static bool _got_saved_params;
00144 static int _saved_mouse_trails;
00145 static BOOL _saved_cursor_shadow;
00146 static BOOL _saved_mouse_vanish;
00147
00148 public:
00149 static TypeHandle get_class_type() {
00150 return _type_handle;
00151 }
00152 static void init_type() {
00153 GraphicsWindow::init_type();
00154 register_type(_type_handle, "WinGraphicsWindow",
00155 GraphicsWindow::get_class_type());
00156 }
00157 virtual TypeHandle get_type() const {
00158 return get_class_type();
00159 }
00160 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00161
00162 private:
00163 static TypeHandle _type_handle;
00164 };
00165
00166
00167 #define PRINT_LAST_ERROR 0
00168 extern EXPCL_PANDAWIN void PrintErrorMessage(DWORD msgID);
00169 extern EXPCL_PANDAWIN void ClearToBlack(HWND hWnd, const WindowProperties &props);
00170 extern EXPCL_PANDAWIN void get_client_rect_screen(HWND hwnd, RECT *view_rect);
00171
00172 #include "winGraphicsWindow.I"
00173
00174 #endif