Panda3D

nativeWindowHandle.h

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