Panda3D
nativeWindowHandle.h
1 // Filename: nativeWindowHandle.h
2 // Created by: drose (30Sep09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef NATIVEWINDOWHANDLE_H
16 #define NATIVEWINDOWHANDLE_H
17 
18 #include "pandabase.h"
19 
20 #include "windowHandle.h"
21 #include "get_x11.h"
22 
23 #ifdef WIN32
24 #ifndef WIN32_LEAN_AND_MEAN
25 #define WIN32_LEAN_AND_MEAN 1
26 #endif
27 #include <windows.h>
28 #endif
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : NativeWindowHandle
32 // Description : This subclass of WindowHandle exists to allow simple
33 // creation of a WindowHandle of the appropriate type to
34 // the current OS.
35 //
36 // This class exists for name scoping only. Don't use
37 // the constructor directly; use one of the make_*
38 // methods.
39 ////////////////////////////////////////////////////////////////////
40 class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle {
41 private:
42  INLINE NativeWindowHandle();
43  INLINE NativeWindowHandle(const NativeWindowHandle &copy);
44 
45 PUBLISHED:
46  static PT(WindowHandle) make_int(size_t window);
47  static PT(WindowHandle) make_subprocess(const Filename &filename);
48 
49 public:
50 #if defined(HAVE_X11) && !defined(CPPPARSER)
51  static PT(WindowHandle) make_x11(X11_Window window);
52 #endif // HAVE_X11
53 
54 #if defined(WIN32) && !defined(CPPPARSER)
55  static PT(WindowHandle) make_win(HWND window);
56 #endif // WIN32
57 
58 public:
59  class EXPCL_PANDA_DISPLAY IntHandle : public OSHandle {
60  public:
61  INLINE IntHandle(size_t handle);
62  virtual size_t get_int_handle() const;
63  virtual void output(ostream &out) const;
64 
65  INLINE size_t get_handle() const;
66 
67  private:
68  size_t _handle;
69 
70  public:
71  static TypeHandle get_class_type() {
72  return _type_handle;
73  }
74  static void init_type() {
75  OSHandle::init_type();
76  register_type(_type_handle, "NativeWindowHandle::IntHandle",
77  OSHandle::get_class_type());
78  }
79  virtual TypeHandle get_type() const {
80  return get_class_type();
81  }
82  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
83 
84  private:
85  static TypeHandle _type_handle;
86  };
87 
88  class EXPCL_PANDA_DISPLAY SubprocessHandle : public OSHandle {
89  public:
90  INLINE SubprocessHandle(const Filename &filename);
91  virtual void output(ostream &out) const;
92 
93  INLINE const Filename &get_filename() const;
94 
95  private:
96  Filename _filename;
97 
98  public:
99  static TypeHandle get_class_type() {
100  return _type_handle;
101  }
102  static void init_type() {
103  OSHandle::init_type();
104  register_type(_type_handle, "NativeWindowHandle::SubprocessHandle",
105  OSHandle::get_class_type());
106  }
107  virtual TypeHandle get_type() const {
108  return get_class_type();
109  }
110  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
111 
112  private:
113  static TypeHandle _type_handle;
114  };
115 
116 #if defined(HAVE_X11) && !defined(CPPPARSER)
117  class EXPCL_PANDA_DISPLAY X11Handle : public OSHandle {
118  public:
119  INLINE X11Handle(X11_Window handle);
120  virtual size_t get_int_handle() const;
121  virtual void output(ostream &out) const;
122 
123  INLINE X11_Window get_handle() const;
124 
125  private:
126  X11_Window _handle;
127 
128  public:
129  static TypeHandle get_class_type() {
130  return _type_handle;
131  }
132  static void init_type() {
133  OSHandle::init_type();
134  register_type(_type_handle, "NativeWindowHandle::X11Handle",
135  OSHandle::get_class_type());
136  }
137  virtual TypeHandle get_type() const {
138  return get_class_type();
139  }
140  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
141 
142  private:
143  static TypeHandle _type_handle;
144  };
145 #endif // HAVE_X11
146 
147 
148 #if defined(WIN32) && !defined(CPPPARSER)
149  class EXPCL_PANDA_DISPLAY WinHandle : public OSHandle {
150  public:
151  INLINE WinHandle(HWND handle);
152  virtual size_t get_int_handle() const;
153  virtual void output(ostream &out) const;
154 
155  INLINE HWND get_handle() const;
156 
157  private:
158  HWND _handle;
159 
160  public:
161  static TypeHandle get_class_type() {
162  return _type_handle;
163  }
164  static void init_type() {
165  OSHandle::init_type();
166  register_type(_type_handle, "NativeWindowHandle::WinHandle",
167  OSHandle::get_class_type());
168  }
169  virtual TypeHandle get_type() const {
170  return get_class_type();
171  }
172  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
173 
174  private:
175  static TypeHandle _type_handle;
176  };
177 #endif // WIN32
178 
179 public:
180  static TypeHandle get_class_type() {
181  return _type_handle;
182  }
183  static void init_type() {
184  WindowHandle::init_type();
185  register_type(_type_handle, "NativeWindowHandle",
186  WindowHandle::get_class_type());
187 
188  IntHandle::init_type();
189  SubprocessHandle::init_type();
190 #if defined(HAVE_X11) && !defined(CPPPARSER)
191  X11Handle::init_type();
192 #endif
193 #if defined(WIN32) && !defined(CPPPARSER)
194  WinHandle::init_type();
195 #endif
196  }
197  virtual TypeHandle get_type() const {
198  return get_class_type();
199  }
200  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
201 
202 private:
203  static TypeHandle _type_handle;
204 };
205 
206 #include "nativeWindowHandle.I"
207 
208 #endif
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:40
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
This subclass of WindowHandle exists to allow simple creation of a WindowHandle of the appropriate ty...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85