Panda3D
|
00001 // Filename: winGraphicsWindow.I 00002 // Created by: drose (20Dec02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: WinGraphicsWindow::handle_keypress 00018 // Access: Private 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE void WinGraphicsWindow:: 00022 handle_keypress(ButtonHandle key, int x, int y, double time) { 00023 _input_devices[0].set_pointer_in_window(x, y); 00024 if (key != ButtonHandle::none()) { 00025 _input_devices[0].button_down(key, time); 00026 } 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: WinGraphicsWindow::handle_keyresume 00031 // Access: Private 00032 // Description: Indicates we detected a key was already down when the 00033 // focus is restored to the window. Mainly useful for 00034 // tracking the state of modifier keys. 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE void WinGraphicsWindow:: 00037 handle_keyresume(ButtonHandle key, double time) { 00038 if (key != ButtonHandle::none()) { 00039 _input_devices[0].button_resume_down(key, time); 00040 } 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: WinGraphicsWindow::handle_keyrelease 00045 // Access: Private 00046 // Description: 00047 //////////////////////////////////////////////////////////////////// 00048 INLINE void WinGraphicsWindow:: 00049 handle_keyrelease(ButtonHandle key, double time) { 00050 if (key != ButtonHandle::none()) { 00051 _input_devices[0].button_up(key, time); 00052 } 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: WinGraphicsWindow::translate_mouse 00057 // Access: Private 00058 // Description: Translates the mouse pixel coordinate (either x or y) 00059 // as returned by the Windows message to the signed 00060 // number expected by Panda. 00061 //////////////////////////////////////////////////////////////////// 00062 INLINE int WinGraphicsWindow:: 00063 translate_mouse(int pos) const { 00064 if (pos & 0x8000) { 00065 pos -= 0x10000; 00066 } 00067 return pos; 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: WinGraphicsWindow::set_cursor_in_window 00072 // Access: Private 00073 // Description: Called during the window thread in response to the 00074 // various Windows messages to indicate whether we 00075 // believe the mouse is presently within the window's 00076 // client rectangle or not. This in turn will determine 00077 // whether we should call update_cursor_window() to hide 00078 // or show the cursor (or otherwise change its 00079 // properties) as it moves between the various 00080 // GraphicsWindows that we control. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE void WinGraphicsWindow:: 00083 set_cursor_in_window() { 00084 if (_cursor_window != this) { 00085 update_cursor_window(this); 00086 } 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: WinGraphicsWindow::set_cursor_out_of_window 00091 // Access: Private 00092 // Description: Called during the window thread in response to the 00093 // various Windows messages to indicate whether we 00094 // believe the mouse is presently within the window's 00095 // client rectangle or not. This in turn will determine 00096 // whether we should call update_cursor_window() to hide 00097 // or show the cursor (or otherwise change its 00098 // properties) as it moves between the various 00099 // GraphicsWindows that we control. 00100 //////////////////////////////////////////////////////////////////// 00101 INLINE void WinGraphicsWindow:: 00102 set_cursor_out_of_window() { 00103 if (_cursor_window == this) { 00104 update_cursor_window(NULL); 00105 } 00106 } 00107 00108 //////////////////////////////////////////////////////////////////// 00109 // Function: WinGraphicsWindow::get_message_time 00110 // Access: Private, Static 00111 // Description: May be called only during the servicing of a Windows 00112 // message. This returns the time the message was added 00113 // to the Windows message queue (as reported via 00114 // GetMessageTime()), converted into global clock units. 00115 //////////////////////////////////////////////////////////////////// 00116 INLINE double WinGraphicsWindow:: 00117 get_message_time() { 00118 DWORD now_ticks = GetTickCount(); 00119 double now_time = ClockObject::get_global_clock()->get_real_time(); 00120 DWORD elapsed_ticks = now_ticks - GetMessageTime(); 00121 return now_time - (double)elapsed_ticks / 1000.0; 00122 } 00123 00124 //////////////////////////////////////////////////////////////////// 00125 // Function: WinGraphicsWindow::get_ime_hwnd 00126 // Access: Private 00127 // Description: Return the IME_window handle if open 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE HWND WinGraphicsWindow:: 00130 get_ime_hwnd() { 00131 if (_ime_active) 00132 return _ime_hWnd; 00133 else 00134 return NULL; 00135 } 00136 00137 //////////////////////////////////////////////////////////////////// 00138 // Function: WinGraphicsWindow::WindowClass::Constructor 00139 // Access: Public 00140 // Description: 00141 //////////////////////////////////////////////////////////////////// 00142 INLINE WinGraphicsWindow::WindowClass:: 00143 WindowClass(const WindowProperties &props) : 00144 _icon(0) 00145 { 00146 if (props.has_icon_filename()) { 00147 _icon = get_icon(props.get_icon_filename()); 00148 } 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: WinGraphicsWindow::WindowClass::operator < 00153 // Access: Public 00154 // Description: 00155 //////////////////////////////////////////////////////////////////// 00156 INLINE bool WinGraphicsWindow::WindowClass:: 00157 operator < (const WinGraphicsWindow::WindowClass &other) const { 00158 return _icon < other._icon; 00159 }