14#ifndef WINGRAPHICSWINDOW_H
15#define WINGRAPHICSWINDOW_H
19#ifndef WIN32_LEAN_AND_MEAN
20 #define WIN32_LEAN_AND_MEAN 1
26#define PM_ACTIVE (WM_APP+123)
28#define PM_INACTIVE (WM_APP+124)
41typedef struct tagTOUCHINPUT {
49 ULONG_PTR dwExtraInfo;
52} TOUCHINPUT, *PTOUCHINPUT;
64class EXPCL_PANDAWIN WinGraphicsWindow :
public GraphicsWindow {
66 WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
67 const std::string &name,
72 GraphicsOutput *host);
73 virtual ~WinGraphicsWindow();
85 virtual LONG
window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
86 static LONG WINAPI
static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
87 virtual bool handle_mouse_motion(
int x,
int y);
88 virtual void handle_mouse_exit();
103 virtual void close_window();
104 virtual bool open_window();
108 virtual bool do_reshape_request(
int x_origin,
int y_origin,
bool has_origin,
109 int x_size,
int y_size);
111 virtual void handle_reshape();
112 virtual bool do_fullscreen_resize(
int x_size,
int y_size);
114 bool do_fullscreen_switch(
int x_size,
int y_size);
115 virtual bool do_fullscreen_switch();
116 virtual bool do_windowed_switch();
117 bool do_fullscreen_enable(
int x_size,
int y_size);
118 virtual bool do_fullscreen_enable();
119 virtual bool do_fullscreen_disable();
121 virtual bool calculate_metrics(
bool fullscreen, DWORD style,
122 WINDOW_METRICS &metrics,
bool &has_origin);
126 virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size,
129 virtual void support_overlay_window(
bool flag);
132 bool open_graphic_window();
133 void adjust_z_order();
134 void adjust_z_order(WindowProperties::ZOrder last_z_order,
135 WindowProperties::ZOrder this_z_order);
136 void initialize_input_devices();
137 void handle_raw_input(HRAWINPUT hraw);
138 void track_mouse_leaving(HWND hwnd);
139 bool confine_cursor();
142 static void process_1_event();
144 void handle_keypress(
ButtonHandle key,
int x,
int y,
double time);
147 void handle_raw_keypress(
ButtonHandle key,
double time);
148 void handle_raw_keyrelease(
ButtonHandle key,
double time);
152 INLINE
int translate_mouse(
int pos)
const;
153 INLINE
void set_cursor_in_window();
154 INLINE
void set_cursor_out_of_window();
156 INLINE
static double get_message_time();
158 void resend_lost_keypresses();
159 void release_all_buttons();
160 static void update_cursor_window(WinGraphicsWindow *to_window);
161 static void hide_or_show_cursor(
bool hide_cursor);
163 static bool find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight,
164 DWORD bpp, DEVMODE &dm);
165 static void show_error_message(DWORD message_id = 0);
175 bool _tracking_mouse_leaving;
176 bool _in_adjust_z_order =
false;
177 HANDLE _input_device_handle[32];
179 DEVMODE _fullscreen_display_mode;
181 bool _lost_keypresses;
197 typedef pset<GraphicsWindowProc*> WinProcClasses;
198 WinProcClasses _window_proc_classes;
201 TOUCHINPUT _touches[MAX_TOUCHES];
205 typedef std::map<HWND, WinGraphicsWindow *> WindowHandles;
206 static WindowHandles _window_handles;
211 static WinGraphicsWindow *_creating_window;
221 static WinGraphicsWindow *_cursor_window;
222 static bool _cursor_hidden;
223 static bool _got_saved_params;
224 static int _saved_mouse_trails;
225 static BOOL _saved_cursor_shadow;
226 static BOOL _saved_mouse_vanish;
229 static RECT _mouse_unconfined_cliprect;
234 typedef pmap<Filename, HANDLE> IconFilenames;
235 static IconFilenames _icon_filenames;
236 static IconFilenames _cursor_filenames;
238 static HICON get_icon(
const Filename &filename);
239 static HCURSOR get_cursor(
const Filename &filename);
248 INLINE
bool operator < (
const WindowClass &other)
const;
254 typedef pset<WindowClass> WindowClasses;
255 static WindowClasses _window_classes;
256 static int _window_class_index;
258 static const WindowClass ®ister_window_class(
const WindowProperties &props);
266 WinWindowHandle(WinGraphicsWindow *window,
275 WinGraphicsWindow *_window;
281 static void init_type() {
282 WindowHandle::init_type();
284 WindowHandle::get_class_type());
287 return get_class_type();
289 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
299 static void init_type() {
300 GraphicsWindow::init_type();
302 GraphicsWindow::get_class_type());
303 WinWindowHandle::init_type();
306 return get_class_type();
308 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
314#define PRINT_LAST_ERROR 0
315extern EXPCL_PANDAWIN
void PrintErrorMessage(DWORD msgID);
316extern EXPCL_PANDAWIN
void ClearToBlack(HWND hWnd,
const WindowProperties &props);
The name of a file, such as a texture file or an Egg file.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
Encapsulates all the communication with a particular instance of a given rendering backend.
This specialization on CallbackData is passed when the callback is initiated from from an implementat...
Defines an interface for storing platform-specific window processor methods.
virtual bool is_touch_event(GraphicsWindowProcCallbackData *callbackData)
Returns whether the specified event msg is a touch message.
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
virtual MouseData get_pointer(int device) const
See GraphicsWindowInputDevice::enable_pointer_mode.
virtual void close_ime()
Forces the ime window to close if any.
virtual int get_num_touches()
Returns the current number of touches on this window.
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
virtual bool supports_window_procs() const
Returns whether this window supports adding of Windows proc handlers.
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
virtual TouchInfo get_touch_info(int index)
Returns the TouchInfo object describing the specified touch.
virtual ButtonMap * get_keyboard_map() const
Returns a ButtonMap containing the association between raw buttons and virtual buttons.
Stores information for a single touch event.
TypeHandle is the identifier used to differentiate C++ class types.
This is an abstract base class for wglGraphicsPipe and wdxGraphicsPipe; that is, those graphics pipes...
void receive_windows_message(unsigned int msg, int wparam, int lparam)
This is called to receive a keyboard event generated by proxy by another window in a parent process.
HWND get_ime_hwnd()
Return the IME_window handle if open.
virtual LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
This is the nonstatic window_proc function.
static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
This is attached to the window class for all WinGraphicsWindow windows; it is called to handle window...
virtual void remove_window_proc(const GraphicsWindowProc *wnd_proc_object)
Removes the specified Windows proc event handler.
virtual void clear_window_procs()
Removes all Windows proc event handlers.
virtual void add_window_proc(const GraphicsWindowProc *wnd_proc_object)
Adds the specified Windows proc event handler to be called whenever a Windows event occurs.
This object represents a window on the desktop, not necessarily a Panda window.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BEGIN_PUBLISH typedef PointerData MouseData
Deprecated alias for PointerData.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EXPCL_PANDAWIN void get_client_rect_screen(HWND hwnd, RECT *view_rect)
Fills view_rect with the coordinates of the client area of the indicated window, converted to screen ...