Panda3D
nativeWindowHandle.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file nativeWindowHandle.cxx
10  * @author drose
11  * @date 2009-09-30
12  */
13 
14 #include "nativeWindowHandle.h"
15 
16 using std::ostream;
17 
18 TypeHandle NativeWindowHandle::_type_handle;
19 TypeHandle NativeWindowHandle::IntHandle::_type_handle;
20 TypeHandle NativeWindowHandle::SubprocessHandle::_type_handle;
21 
22 #if defined(HAVE_X11) && !defined(CPPPARSER)
23 TypeHandle NativeWindowHandle::X11Handle::_type_handle;
24 #endif
25 #if defined(WIN32) && !defined(CPPPARSER)
26 TypeHandle NativeWindowHandle::WinHandle::_type_handle;
27 #endif
28 
29 /**
30  * Constructs a new WindowHandle with an int value, which is understood to be
31  * either an HWND or a Window, cast to int. This method exists for the
32  * convenience of Python, which likes to deal with ints; C++ code should use
33  * one of the more specific make_x11() or make_win32() methods instead.
34  */
35 PT(WindowHandle) NativeWindowHandle::
36 make_int(size_t window) {
37  return new WindowHandle(new IntHandle(window));
38 }
39 
40 /**
41  * Constructs a new WindowHandle that references a SubprocessWindowBuffer read
42  * in another process, with the named pipe filename that it uses for
43  * communication.
44  *
45  * This is (at present, and maybe always) useful only on the OS X platform,
46  * where parenting child windows is particularly problematic.
47  */
48 PT(WindowHandle) NativeWindowHandle::
49 make_subprocess(const Filename &filename) {
50  return new WindowHandle(new SubprocessHandle(filename));
51 }
52 
53 #if defined(HAVE_X11) && !defined(CPPPARSER)
54 /**
55  * Constructs a new WindowHandle that references an X11 window.
56  */
57 PT(WindowHandle) NativeWindowHandle::
58 make_x11(X11_Window window) {
59  return new WindowHandle(new X11Handle(window));
60 }
61 #endif // HAVE_X11
62 
63 #if defined(WIN32) && !defined(CPPPARSER)
64 /**
65  * Constructs a new WindowHandle that references a window on Windows.
66  */
67 PT(WindowHandle) NativeWindowHandle::
68 make_win(HWND window) {
69  return new WindowHandle(new WinHandle(window));
70 }
71 #endif // WIN32
72 
73 /**
74  * Returns the OS-specific handle converted to an integer, if this is possible
75  * for the particular representation. Returns 0 if it is not.
76  */
78 get_int_handle() const {
79  return _handle;
80 }
81 
82 /**
83  *
84  */
85 void NativeWindowHandle::IntHandle::
86 output(ostream &out) const {
87  out << "(" << _handle << ")";
88 }
89 
90 /**
91  *
92  */
93 void NativeWindowHandle::SubprocessHandle::
94 output(ostream &out) const {
95  out << "(" << _filename << ")";
96 }
97 
98 #if defined(HAVE_X11) && !defined(CPPPARSER)
99 /**
100  * Returns the OS-specific handle converted to an integer, if this is possible
101  * for the particular representation. Returns 0 if it is not.
102  */
103 size_t NativeWindowHandle::X11Handle::
104 get_int_handle() const {
105  return (size_t)_handle;
106 }
107 #endif // HAVE_X11
108 
109 #if defined(HAVE_X11) && !defined(CPPPARSER)
110 /**
111  *
112  */
113 void NativeWindowHandle::X11Handle::
114 output(ostream &out) const {
115  out << _handle;
116 }
117 #endif // HAVE_X11
118 
119 #if defined(WIN32) && !defined(CPPPARSER)
120 /**
121  * Returns the OS-specific handle converted to an integer, if this is possible
122  * for the particular representation. Returns 0 if it is not.
123  */
124 size_t NativeWindowHandle::WinHandle::
125 get_int_handle() const {
126  return (size_t)_handle;
127 }
128 #endif // WIN32
129 
130 #if defined(WIN32) && !defined(CPPPARSER)
131 /**
132  *
133  */
134 void NativeWindowHandle::WinHandle::
135 output(ostream &out) const {
136  out << _handle;
137 }
138 #endif // WIN32
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual size_t get_int_handle() const
Returns the OS-specific handle converted to an integer, if this is possible for the particular repres...
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PT(WindowHandle) NativeWindowHandle
Constructs a new WindowHandle with an int value, which is understood to be either an HWND or a Window...