Panda3D
|
00001 // Filename: windowHandle.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 WINDOWHANDLE_H 00016 #define WINDOWHANDLE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "typedReferenceCount.h" 00021 #include "pointerTo.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : WindowHandle 00025 // Description : This object represents a window on the desktop, not 00026 // necessarily a Panda window. This structure can be 00027 // assigned to a WindowProperties to indicate a parent 00028 // window. 00029 // 00030 // It also has callbacks so the Panda window can 00031 // communicate with its parent window, which is 00032 // particularly important when running embedded in a 00033 // browser. 00034 // 00035 // To create a WindowHandle, you would usually call one 00036 // of the NativeWindowHandle::make_*() methods, 00037 // depending on the kind of native window handle object 00038 // you already have. 00039 //////////////////////////////////////////////////////////////////// 00040 class EXPCL_PANDA_DISPLAY WindowHandle : public TypedReferenceCount { 00041 PUBLISHED: 00042 class OSHandle; 00043 00044 INLINE WindowHandle(OSHandle *os_handle); 00045 INLINE WindowHandle(const WindowHandle ©); 00046 virtual ~WindowHandle(); 00047 00048 INLINE OSHandle *get_os_handle() const; 00049 INLINE void set_os_handle(OSHandle *os_handle); 00050 00051 void send_windows_message(unsigned int msg, int wparam, int lparam); 00052 00053 size_t get_int_handle() const; 00054 00055 void output(ostream &out) const; 00056 00057 public: 00058 // Callbacks for communication with the parent window. 00059 virtual void attach_child(WindowHandle *child); 00060 virtual void detach_child(WindowHandle *child); 00061 00062 virtual void request_keyboard_focus(WindowHandle *child); 00063 virtual void receive_windows_message(unsigned int msg, int wparam, int lparam); 00064 00065 PUBLISHED: 00066 // This internal pointer within WindowHandle stores the actual 00067 // OS-specific window handle type, whatever type that is. It is 00068 // subclassed for each OS. 00069 class EXPCL_PANDA_DISPLAY OSHandle : public TypedReferenceCount { 00070 protected: 00071 INLINE OSHandle(); 00072 00073 PUBLISHED: 00074 virtual ~OSHandle(); 00075 virtual size_t get_int_handle() const; 00076 virtual void output(ostream &out) const; 00077 00078 public: 00079 static TypeHandle get_class_type() { 00080 return _type_handle; 00081 } 00082 static void init_type() { 00083 TypedReferenceCount::init_type(); 00084 register_type(_type_handle, "WindowHandle::OSHandle", 00085 TypedReferenceCount::get_class_type()); 00086 } 00087 virtual TypeHandle get_type() const { 00088 return get_class_type(); 00089 } 00090 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00091 00092 private: 00093 static TypeHandle _type_handle; 00094 }; 00095 00096 protected: 00097 PT(OSHandle) _os_handle; 00098 00099 PT(WindowHandle) _keyboard_window; 00100 00101 public: 00102 static TypeHandle get_class_type() { 00103 return _type_handle; 00104 } 00105 static void init_type() { 00106 TypedReferenceCount::init_type(); 00107 register_type(_type_handle, "WindowHandle", 00108 TypedReferenceCount::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 #include "windowHandle.I" 00120 00121 INLINE ostream &operator << (ostream &out, const WindowHandle &handle) { 00122 handle.output(out); 00123 return out; 00124 } 00125 00126 INLINE ostream &operator << (ostream &out, const WindowHandle::OSHandle &handle) { 00127 handle.output(out); 00128 return out; 00129 } 00130 00131 #endif