00001 // Filename: nativeWindowHandle.cxx 00002 // Created by: drose (30Sep09) 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 #include "nativeWindowHandle.h" 00016 00017 TypeHandle NativeWindowHandle::_type_handle; 00018 TypeHandle NativeWindowHandle::IntHandle::_type_handle; 00019 TypeHandle NativeWindowHandle::SubprocessHandle::_type_handle; 00020 00021 #if defined(HAVE_X11) && !defined(CPPPARSER) 00022 TypeHandle NativeWindowHandle::X11Handle::_type_handle; 00023 #endif 00024 #if defined(WIN32) && !defined(CPPPARSER) 00025 TypeHandle NativeWindowHandle::WinHandle::_type_handle; 00026 #endif 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: NativeWindowHandle::make_int 00030 // Access: Published, Static 00031 // Description: Constructs a new WindowHandle with an int value, 00032 // which is understood to be either an HWND or a Window, 00033 // cast to int. This method exists for the convenience 00034 // of Python, which likes to deal with ints; C++ code 00035 // should use one of the more specific make_x11() or 00036 // make_win32() methods instead. 00037 //////////////////////////////////////////////////////////////////// 00038 PT(WindowHandle) NativeWindowHandle:: 00039 make_int(size_t window) { 00040 return new WindowHandle(new IntHandle(window)); 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: NativeWindowHandle::make_subprocess 00045 // Access: Published, Static 00046 // Description: Constructs a new WindowHandle that references a 00047 // SubprocessWindowBuffer read in another process, with 00048 // the named pipe filename that it uses for 00049 // communication. 00050 // 00051 // This is (at present, and maybe always) useful only on 00052 // the OS X platform, where parenting child windows is 00053 // particularly problematic. 00054 //////////////////////////////////////////////////////////////////// 00055 PT(WindowHandle) NativeWindowHandle:: 00056 make_subprocess(const Filename &filename) { 00057 return new WindowHandle(new SubprocessHandle(filename)); 00058 } 00059 00060 #if defined(HAVE_X11) && !defined(CPPPARSER) 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: NativeWindowHandle::make_x11 00063 // Access: Published, Static 00064 // Description: Constructs a new WindowHandle that references an 00065 // X11 window. 00066 //////////////////////////////////////////////////////////////////// 00067 PT(WindowHandle) NativeWindowHandle:: 00068 make_x11(X11_Window window) { 00069 return new WindowHandle(new X11Handle(window)); 00070 } 00071 #endif // HAVE_X11 00072 00073 #if defined(WIN32) && !defined(CPPPARSER) 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: NativeWindowHandle::make_win 00076 // Access: Published, Static 00077 // Description: Constructs a new WindowHandle that references a 00078 // window on Windows. 00079 //////////////////////////////////////////////////////////////////// 00080 PT(WindowHandle) NativeWindowHandle:: 00081 make_win(HWND window) { 00082 return new WindowHandle(new WinHandle(window)); 00083 } 00084 #endif // WIN32 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function: NativeWindowHandle::IntHandle::get_int_handle 00088 // Access: Public, Virtual 00089 // Description: Returns the OS-specific handle converted to an 00090 // integer, if this is possible for the particular 00091 // representation. Returns 0 if it is not. 00092 //////////////////////////////////////////////////////////////////// 00093 size_t NativeWindowHandle::IntHandle:: 00094 get_int_handle() const { 00095 return _handle; 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: NativeWindowHandle::IntHandle::output 00100 // Access: Public 00101 // Description: 00102 //////////////////////////////////////////////////////////////////// 00103 void NativeWindowHandle::IntHandle:: 00104 output(ostream &out) const { 00105 out << "(" << _handle << ")"; 00106 } 00107 00108 //////////////////////////////////////////////////////////////////// 00109 // Function: NativeWindowHandle::SubprocessHandle::output 00110 // Access: Public 00111 // Description: 00112 //////////////////////////////////////////////////////////////////// 00113 void NativeWindowHandle::SubprocessHandle:: 00114 output(ostream &out) const { 00115 out << "(" << _filename << ")"; 00116 } 00117 00118 #if defined(HAVE_X11) && !defined(CPPPARSER) 00119 //////////////////////////////////////////////////////////////////// 00120 // Function: NativeWindowHandle::X11Handle::get_int_handle 00121 // Access: Public, Virtual 00122 // Description: Returns the OS-specific handle converted to an 00123 // integer, if this is possible for the particular 00124 // representation. Returns 0 if it is not. 00125 //////////////////////////////////////////////////////////////////// 00126 size_t NativeWindowHandle::X11Handle:: 00127 get_int_handle() const { 00128 return (size_t)_handle; 00129 } 00130 #endif // HAVE_X11 00131 00132 #if defined(HAVE_X11) && !defined(CPPPARSER) 00133 //////////////////////////////////////////////////////////////////// 00134 // Function: NativeWindowHandle::X11Handle::output 00135 // Access: Public 00136 // Description: 00137 //////////////////////////////////////////////////////////////////// 00138 void NativeWindowHandle::X11Handle:: 00139 output(ostream &out) const { 00140 out << _handle; 00141 } 00142 #endif // HAVE_X11 00143 00144 #if defined(WIN32) && !defined(CPPPARSER) 00145 //////////////////////////////////////////////////////////////////// 00146 // Function: NativeWindowHandle::WinHandle::get_int_handle 00147 // Access: Public, Virtual 00148 // Description: Returns the OS-specific handle converted to an 00149 // integer, if this is possible for the particular 00150 // representation. Returns 0 if it is not. 00151 //////////////////////////////////////////////////////////////////// 00152 size_t NativeWindowHandle::WinHandle:: 00153 get_int_handle() const { 00154 return (size_t)_handle; 00155 } 00156 #endif // WIN32 00157 00158 #if defined(WIN32) && !defined(CPPPARSER) 00159 //////////////////////////////////////////////////////////////////// 00160 // Function: NativeWindowHandle::WinHandle::output 00161 // Access: Public 00162 // Description: 00163 //////////////////////////////////////////////////////////////////// 00164 void NativeWindowHandle::WinHandle:: 00165 output(ostream &out) const { 00166 out << _handle; 00167 } 00168 #endif // WIN32