Panda3D
windowHandle.cxx
1 // Filename: windowHandle.cxx
2 // Created by: drose (30Sep09)
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 #include "windowHandle.h"
16 
17 TypeHandle WindowHandle::_type_handle;
18 TypeHandle WindowHandle::OSHandle::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: WindowHandle::Destructor
22 // Access: Published, Virtual
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 WindowHandle::
26 ~WindowHandle() {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: WindowHandle::send_windows_message
31 // Access: Published
32 // Description: Call this method on a parent WindowHandle to deliver
33 // a Windows message to the current child window, if any.
34 // This is used in the web plugin system to deliver
35 // button events detected directly by the browser system
36 // into Panda, which is particularly necessary on Vista.
37 ////////////////////////////////////////////////////////////////////
38 void WindowHandle::
39 send_windows_message(unsigned int msg, int wparam, int lparam) {
40  if (_keyboard_window != NULL) {
41  _keyboard_window->receive_windows_message(msg, wparam, lparam);
42  }
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: WindowHandle::get_int_handle
47 // Access: Published
48 // Description: Returns the OS-specific handle converted to an
49 // integer, if this is possible for the particular
50 // representation. Returns 0 if it is not.
51 ////////////////////////////////////////////////////////////////////
52 size_t WindowHandle::
53 get_int_handle() const {
54  if (_os_handle != NULL) {
55  return _os_handle->get_int_handle();
56  }
57  return 0;
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: WindowHandle::output
62 // Access: Published
63 // Description:
64 ////////////////////////////////////////////////////////////////////
65 void WindowHandle::
66 output(ostream &out) const {
67  if (_os_handle == NULL) {
68  out << "(null)";
69  } else {
70  out << *_os_handle;
71  }
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: WindowHandle::attach_child
76 // Access: Public, Virtual
77 // Description: Called on a parent handle to indicate a child
78 // window's intention to attach itself.
79 ////////////////////////////////////////////////////////////////////
80 void WindowHandle::
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: WindowHandle::detach_child
86 // Access: Public, Virtual
87 // Description: Called on a parent handle to indicate a child
88 // window's intention to detach itself.
89 ////////////////////////////////////////////////////////////////////
90 void WindowHandle::
92  if (_keyboard_window == child) {
93  _keyboard_window = NULL;
94  }
95 }
96 
97 ////////////////////////////////////////////////////////////////////
98 // Function: WindowHandle::request_keyboard_focus
99 // Access: Public, Virtual
100 // Description: Called on a parent handle to indicate a child
101 // window's wish to receive keyboard button events.
102 ////////////////////////////////////////////////////////////////////
103 void WindowHandle::
105  _keyboard_window = child;
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: WindowHandle::receive_windows_message
110 // Access: Public, Virtual
111 // Description: Called on a child handle to deliver a keyboard button
112 // event generated in the parent window.
113 ////////////////////////////////////////////////////////////////////
114 void WindowHandle::
115 receive_windows_message(unsigned int msg, int wparam, int lparam) {
116  nout << "receive_windows_message(" << msg << ", " << wparam << ", " << lparam << ")\n";
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: WindowHandle::OSHandle::Destructor
121 // Access: Published, Virtual
122 // Description:
123 ////////////////////////////////////////////////////////////////////
124 WindowHandle::OSHandle::
125 ~OSHandle() {
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: WindowHandle::OSHandle::get_int_handle
130 // Access: Published, Virtual
131 // Description: Returns the OS-specific handle converted to an
132 // integer, if this is possible for the particular
133 // representation. Returns 0 if it is not.
134 ////////////////////////////////////////////////////////////////////
136 get_int_handle() const {
137  return 0;
138 }
139 
140 ////////////////////////////////////////////////////////////////////
141 // Function: WindowHandle::OSHandle::output
142 // Access: Published, Virtual
143 // Description:
144 ////////////////////////////////////////////////////////////////////
145 void WindowHandle::OSHandle::
146 output(ostream &out) const {
147  out << "(no type)";
148 }
virtual void receive_windows_message(unsigned int msg, int wparam, int lparam)
Called on a child handle to deliver a keyboard button event generated in the parent window...
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:40
virtual void request_keyboard_focus(WindowHandle *child)
Called on a parent handle to indicate a child window&#39;s wish to receive keyboard button events...
virtual void detach_child(WindowHandle *child)
Called on a parent handle to indicate a child window&#39;s intention to detach itself.
size_t get_int_handle() const
Returns the OS-specific handle converted to an integer, if this is possible for the particular repres...
void send_windows_message(unsigned int msg, int wparam, int lparam)
Call this method on a parent WindowHandle to deliver a Windows message to the current child window...
virtual size_t get_int_handle() const
Returns the OS-specific handle converted to an integer, if this is possible for the particular repres...
virtual void attach_child(WindowHandle *child)
Called on a parent handle to indicate a child window&#39;s intention to attach itself.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85