Panda3D
Loading...
Searching...
No Matches
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
16using std::ostream;
17
18TypeHandle NativeWindowHandle::_type_handle;
19TypeHandle NativeWindowHandle::IntHandle::_type_handle;
20TypeHandle NativeWindowHandle::SubprocessHandle::_type_handle;
21
22#if defined(HAVE_X11) && !defined(CPPPARSER)
23TypeHandle NativeWindowHandle::X11Handle::_type_handle;
24#endif
25#if defined(WIN32) && !defined(CPPPARSER)
26TypeHandle 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 */
35PT(WindowHandle) NativeWindowHandle::
36make_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 */
48PT(WindowHandle) NativeWindowHandle::
49make_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 */
57PT(WindowHandle) NativeWindowHandle::
58make_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 */
67PT(WindowHandle) NativeWindowHandle::
68make_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 */
78get_int_handle() const {
79 return _handle;
80}
81
82/**
83 *
84 */
85void NativeWindowHandle::IntHandle::
86output(ostream &out) const {
87 out << "(" << _handle << ")";
88}
89
90/**
91 *
92 */
93void NativeWindowHandle::SubprocessHandle::
94output(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 */
103size_t NativeWindowHandle::X11Handle::
104get_int_handle() const {
105 return (size_t)_handle;
106}
107#endif // HAVE_X11
108
109#if defined(HAVE_X11) && !defined(CPPPARSER)
110/**
111 *
112 */
113void NativeWindowHandle::X11Handle::
114output(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 */
124size_t NativeWindowHandle::WinHandle::
125get_int_handle() const {
126 return (size_t)_handle;
127}
128#endif // WIN32
129
130#if defined(WIN32) && !defined(CPPPARSER)
131/**
132 *
133 */
134void NativeWindowHandle::WinHandle::
135output(ostream &out) const {
136 out << _handle;
137}
138#endif // WIN32
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
virtual size_t get_int_handle() const
Returns the OS-specific handle converted to an integer, if this is possible for the particular repres...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This object represents a window on the desktop, not necessarily a Panda window.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.