Panda3D
|
00001 // Filename: nativeWindowHandle.h 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 #ifndef NATIVEWINDOWHANDLE_H 00016 #define NATIVEWINDOWHANDLE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "windowHandle.h" 00021 #include "get_x11.h" 00022 00023 #ifdef WIN32 00024 #ifndef WIN32_LEAN_AND_MEAN 00025 #define WIN32_LEAN_AND_MEAN 1 00026 #endif 00027 #include <windows.h> 00028 #endif 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : NativeWindowHandle 00032 // Description : This subclass of WindowHandle exists to allow simple 00033 // creation of a WindowHandle of the appropriate type to 00034 // the current OS. 00035 // 00036 // This class exists for name scoping only. Don't use 00037 // the constructor directly; use one of the make_* 00038 // methods. 00039 //////////////////////////////////////////////////////////////////// 00040 class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle { 00041 private: 00042 INLINE NativeWindowHandle(); 00043 INLINE NativeWindowHandle(const NativeWindowHandle ©); 00044 00045 PUBLISHED: 00046 static PT(WindowHandle) make_int(size_t window); 00047 static PT(WindowHandle) make_subprocess(const Filename &filename); 00048 00049 public: 00050 #if defined(HAVE_X11) && !defined(CPPPARSER) 00051 static PT(WindowHandle) make_x11(X11_Window window); 00052 #endif // HAVE_X11 00053 00054 #if defined(WIN32) && !defined(CPPPARSER) 00055 static PT(WindowHandle) make_win(HWND window); 00056 #endif // WIN32 00057 00058 public: 00059 class EXPCL_PANDA_DISPLAY IntHandle : public OSHandle { 00060 public: 00061 INLINE IntHandle(size_t handle); 00062 virtual size_t get_int_handle() const; 00063 virtual void output(ostream &out) const; 00064 00065 INLINE size_t get_handle() const; 00066 00067 private: 00068 size_t _handle; 00069 00070 public: 00071 static TypeHandle get_class_type() { 00072 return _type_handle; 00073 } 00074 static void init_type() { 00075 OSHandle::init_type(); 00076 register_type(_type_handle, "NativeWindowHandle::IntHandle", 00077 OSHandle::get_class_type()); 00078 } 00079 virtual TypeHandle get_type() const { 00080 return get_class_type(); 00081 } 00082 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00083 00084 private: 00085 static TypeHandle _type_handle; 00086 }; 00087 00088 class EXPCL_PANDA_DISPLAY SubprocessHandle : public OSHandle { 00089 public: 00090 INLINE SubprocessHandle(const Filename &filename); 00091 virtual void output(ostream &out) const; 00092 00093 INLINE const Filename &get_filename() const; 00094 00095 private: 00096 Filename _filename; 00097 00098 public: 00099 static TypeHandle get_class_type() { 00100 return _type_handle; 00101 } 00102 static void init_type() { 00103 OSHandle::init_type(); 00104 register_type(_type_handle, "NativeWindowHandle::SubprocessHandle", 00105 OSHandle::get_class_type()); 00106 } 00107 virtual TypeHandle get_type() const { 00108 return get_class_type(); 00109 } 00110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00111 00112 private: 00113 static TypeHandle _type_handle; 00114 }; 00115 00116 #if defined(HAVE_X11) && !defined(CPPPARSER) 00117 class EXPCL_PANDA_DISPLAY X11Handle : public OSHandle { 00118 public: 00119 INLINE X11Handle(X11_Window handle); 00120 virtual size_t get_int_handle() const; 00121 virtual void output(ostream &out) const; 00122 00123 INLINE X11_Window get_handle() const; 00124 00125 private: 00126 X11_Window _handle; 00127 00128 public: 00129 static TypeHandle get_class_type() { 00130 return _type_handle; 00131 } 00132 static void init_type() { 00133 OSHandle::init_type(); 00134 register_type(_type_handle, "NativeWindowHandle::X11Handle", 00135 OSHandle::get_class_type()); 00136 } 00137 virtual TypeHandle get_type() const { 00138 return get_class_type(); 00139 } 00140 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00141 00142 private: 00143 static TypeHandle _type_handle; 00144 }; 00145 #endif // HAVE_X11 00146 00147 00148 #if defined(WIN32) && !defined(CPPPARSER) 00149 class EXPCL_PANDA_DISPLAY WinHandle : public OSHandle { 00150 public: 00151 INLINE WinHandle(HWND handle); 00152 virtual size_t get_int_handle() const; 00153 virtual void output(ostream &out) const; 00154 00155 INLINE HWND get_handle() const; 00156 00157 private: 00158 HWND _handle; 00159 00160 public: 00161 static TypeHandle get_class_type() { 00162 return _type_handle; 00163 } 00164 static void init_type() { 00165 OSHandle::init_type(); 00166 register_type(_type_handle, "NativeWindowHandle::WinHandle", 00167 OSHandle::get_class_type()); 00168 } 00169 virtual TypeHandle get_type() const { 00170 return get_class_type(); 00171 } 00172 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00173 00174 private: 00175 static TypeHandle _type_handle; 00176 }; 00177 #endif // WIN32 00178 00179 public: 00180 static TypeHandle get_class_type() { 00181 return _type_handle; 00182 } 00183 static void init_type() { 00184 WindowHandle::init_type(); 00185 register_type(_type_handle, "NativeWindowHandle", 00186 WindowHandle::get_class_type()); 00187 00188 IntHandle::init_type(); 00189 SubprocessHandle::init_type(); 00190 #if defined(HAVE_X11) && !defined(CPPPARSER) 00191 X11Handle::init_type(); 00192 #endif 00193 #if defined(WIN32) && !defined(CPPPARSER) 00194 WinHandle::init_type(); 00195 #endif 00196 } 00197 virtual TypeHandle get_type() const { 00198 return get_class_type(); 00199 } 00200 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00201 00202 private: 00203 static TypeHandle _type_handle; 00204 }; 00205 00206 #include "nativeWindowHandle.I" 00207 00208 #endif