Panda3D
 All Classes Functions Variables Enumerations
winGraphicsWindow.I
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::translate_mouse
00018 //       Access: Private
00019 //  Description: Translates the mouse pixel coordinate (either x or y)
00020 //               as returned by the Windows message to the signed
00021 //               number expected by Panda.
00022 ////////////////////////////////////////////////////////////////////
00023 INLINE int WinGraphicsWindow::
00024 translate_mouse(int pos) const {
00025   if (pos & 0x8000) {
00026     pos -= 0x10000;
00027   }
00028   return pos;
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: WinGraphicsWindow::set_cursor_in_window
00033 //       Access: Private
00034 //  Description: Called during the window thread in response to the
00035 //               various Windows messages to indicate whether we
00036 //               believe the mouse is presently within the window's
00037 //               client rectangle or not.  This in turn will determine
00038 //               whether we should call update_cursor_window() to hide
00039 //               or show the cursor (or otherwise change its
00040 //               properties) as it moves between the various
00041 //               GraphicsWindows that we control.
00042 ////////////////////////////////////////////////////////////////////
00043 INLINE void WinGraphicsWindow::
00044 set_cursor_in_window() {
00045   if (_cursor_window != this) {
00046     update_cursor_window(this);
00047   }
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: WinGraphicsWindow::set_cursor_out_of_window
00052 //       Access: Private
00053 //  Description: Called during the window thread in response to the
00054 //               various Windows messages to indicate whether we
00055 //               believe the mouse is presently within the window's
00056 //               client rectangle or not.  This in turn will determine
00057 //               whether we should call update_cursor_window() to hide
00058 //               or show the cursor (or otherwise change its
00059 //               properties) as it moves between the various
00060 //               GraphicsWindows that we control.
00061 ////////////////////////////////////////////////////////////////////
00062 INLINE void WinGraphicsWindow::
00063 set_cursor_out_of_window() {
00064   if (_cursor_window == this) {
00065     update_cursor_window(NULL);
00066   }
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: WinGraphicsWindow::get_message_time
00071 //       Access: Private, Static
00072 //  Description: May be called only during the servicing of a Windows
00073 //               message.  This returns the time the message was added
00074 //               to the Windows message queue (as reported via
00075 //               GetMessageTime()), converted into global clock units.
00076 ////////////////////////////////////////////////////////////////////
00077 INLINE double WinGraphicsWindow::
00078 get_message_time() {
00079   DWORD now_ticks = GetTickCount();
00080   double now_time = ClockObject::get_global_clock()->get_real_time();
00081   DWORD elapsed_ticks = now_ticks - GetMessageTime();
00082   return now_time - (double)elapsed_ticks / 1000.0;
00083 }
00084 
00085 ////////////////////////////////////////////////////////////////////
00086 //     Function: WinGraphicsWindow::get_ime_hwnd
00087 //       Access: Private
00088 //  Description: Return the IME_window handle if open
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE HWND WinGraphicsWindow::
00091 get_ime_hwnd() {
00092   if (_ime_active)
00093     return _ime_hWnd;
00094   else
00095     return NULL;
00096 }
00097 
00098 ////////////////////////////////////////////////////////////////////
00099 //     Function: WinGraphicsWindow::WindowClass::Constructor
00100 //       Access: Public
00101 //  Description: 
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE WinGraphicsWindow::WindowClass::
00104 WindowClass(const WindowProperties &props) :
00105   _icon(0)
00106 {
00107   if (props.has_icon_filename()) {
00108     _icon = get_icon(props.get_icon_filename());
00109   }
00110 }
00111   
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: WinGraphicsWindow::WindowClass::operator <
00114 //       Access: Public
00115 //  Description: 
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE bool WinGraphicsWindow::WindowClass::
00118 operator < (const WinGraphicsWindow::WindowClass &other) const {
00119   return _icon < other._icon;
00120 }
 All Classes Functions Variables Enumerations