Panda3D
winGraphicsWindow.I
1 // Filename: winGraphicsWindow.I
2 // Created by: drose (20Dec02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: WinGraphicsWindow::translate_mouse
18 // Access: Private
19 // Description: Translates the mouse pixel coordinate (either x or y)
20 // as returned by the Windows message to the signed
21 // number expected by Panda.
22 ////////////////////////////////////////////////////////////////////
23 INLINE int WinGraphicsWindow::
24 translate_mouse(int pos) const {
25  if (pos & 0x8000) {
26  pos -= 0x10000;
27  }
28  return pos;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: WinGraphicsWindow::set_cursor_in_window
33 // Access: Private
34 // Description: Called during the window thread in response to the
35 // various Windows messages to indicate whether we
36 // believe the mouse is presently within the window's
37 // client rectangle or not. This in turn will determine
38 // whether we should call update_cursor_window() to hide
39 // or show the cursor (or otherwise change its
40 // properties) as it moves between the various
41 // GraphicsWindows that we control.
42 ////////////////////////////////////////////////////////////////////
43 INLINE void WinGraphicsWindow::
44 set_cursor_in_window() {
45  if (_cursor_window != this) {
46  update_cursor_window(this);
47  }
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: WinGraphicsWindow::set_cursor_out_of_window
52 // Access: Private
53 // Description: Called during the window thread in response to the
54 // various Windows messages to indicate whether we
55 // believe the mouse is presently within the window's
56 // client rectangle or not. This in turn will determine
57 // whether we should call update_cursor_window() to hide
58 // or show the cursor (or otherwise change its
59 // properties) as it moves between the various
60 // GraphicsWindows that we control.
61 ////////////////////////////////////////////////////////////////////
62 INLINE void WinGraphicsWindow::
63 set_cursor_out_of_window() {
64  if (_cursor_window == this) {
65  update_cursor_window(NULL);
66  }
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: WinGraphicsWindow::get_message_time
71 // Access: Private, Static
72 // Description: May be called only during the servicing of a Windows
73 // message. This returns the time the message was added
74 // to the Windows message queue (as reported via
75 // GetMessageTime()), converted into global clock units.
76 ////////////////////////////////////////////////////////////////////
77 INLINE double WinGraphicsWindow::
78 get_message_time() {
79  DWORD now_ticks = GetTickCount();
80  double now_time = ClockObject::get_global_clock()->get_real_time();
81  DWORD elapsed_ticks = now_ticks - GetMessageTime();
82  return now_time - (double)elapsed_ticks / 1000.0;
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function: WinGraphicsWindow::get_ime_hwnd
87 // Access: Private
88 // Description: Return the IME_window handle if open
89 ////////////////////////////////////////////////////////////////////
90 INLINE HWND WinGraphicsWindow::
92  if (_ime_active)
93  return _ime_hWnd;
94  else
95  return NULL;
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: WinGraphicsWindow::WindowClass::Constructor
100 // Access: Public
101 // Description:
102 ////////////////////////////////////////////////////////////////////
103 INLINE WinGraphicsWindow::WindowClass::
104 WindowClass(const WindowProperties &props) :
105  _icon(0)
106 {
107  if (props.has_icon_filename()) {
108  _icon = get_icon(props.get_icon_filename());
109  }
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: WinGraphicsWindow::WindowClass::operator <
114 // Access: Public
115 // Description:
116 ////////////////////////////////////////////////////////////////////
117 INLINE bool WinGraphicsWindow::WindowClass::
118 operator < (const WinGraphicsWindow::WindowClass &other) const {
119  return _icon < other._icon;
120 }
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
Definition: clockObject.I:271
bool has_icon_filename() const
Returns true if set_icon_filename() has been specified.
HWND get_ime_hwnd()
Return the IME_window handle if open.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
double get_real_time() const
Returns the actual number of seconds elapsed since the ClockObject was created, or since it was last ...
Definition: clockObject.I:68
const Filename & get_icon_filename() const
Returns the icon filename associated with the window.