Panda3D

Loading...
Searching...
No Matches
windowHandle.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file windowHandle.h
10 * @author drose
11 * @date 2009-09-30
12 */
13
14#ifndef WINDOWHANDLE_H
15#define WINDOWHANDLE_H
16
17#include "pandabase.h"
18
19#include "typedReferenceCount.h"
20#include "pointerTo.h"
21
22/**
23 * This object represents a window on the desktop, not necessarily a Panda
24 * window. This structure can be assigned to a WindowProperties to indicate a
25 * parent window.
26 *
27 * It also has callbacks so the Panda window can communicate with its parent
28 * window, which is particularly important when running embedded in a browser.
29 *
30 * To create a WindowHandle, you would usually call one of the
31 * NativeWindowHandle::make_*() methods, depending on the kind of native
32 * window handle object you already have.
33 */
34 class EXPCL_PANDA_DISPLAY WindowHandle : public TypedReferenceCount {
35PUBLISHED:
36 class OSHandle;
37
38 INLINE WindowHandle(OSHandle *os_handle);
39 INLINE WindowHandle(const WindowHandle &copy);
40 virtual ~WindowHandle();
41
42 INLINE OSHandle *get_os_handle() const;
43 INLINE void set_os_handle(OSHandle *os_handle);
44 MAKE_PROPERTY(os_handle, get_os_handle, set_os_handle);
45
46 void send_windows_message(unsigned int msg, int wparam, int lparam);
47
48 size_t get_int_handle() const;
49
50 void output(std::ostream &out) const;
51
52 public:
53 // Callbacks for communication with the parent window.
54 virtual void attach_child(WindowHandle *child);
55 virtual void detach_child(WindowHandle *child);
56
57 virtual void request_keyboard_focus(WindowHandle *child);
58 virtual void receive_windows_message(unsigned int msg, int wparam, int lparam);
59
60PUBLISHED:
61 // This internal pointer within WindowHandle stores the actual OS-specific
62 // window handle type, whatever type that is. It is subclassed for each OS.
63 class EXPCL_PANDA_DISPLAY OSHandle : public TypedReferenceCount {
64 protected:
65 INLINE OSHandle();
66
67 PUBLISHED:
68 virtual ~OSHandle();
69 virtual size_t get_int_handle() const;
70 virtual void output(std::ostream &out) const;
71
72 public:
73 static TypeHandle get_class_type() {
74 return _type_handle;
75 }
76 static void init_type() {
77 TypedReferenceCount::init_type();
78 register_type(_type_handle, "WindowHandle::OSHandle",
79 TypedReferenceCount::get_class_type());
80 }
81 virtual TypeHandle get_type() const {
82 return get_class_type();
83 }
84 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85
86 private:
87 static TypeHandle _type_handle;
88 };
89
90 protected:
91 PT(OSHandle) _os_handle;
92
93 PT(WindowHandle) _keyboard_window;
94
95 public:
96 static TypeHandle get_class_type() {
97 return _type_handle;
98 }
99 static void init_type() {
100 TypedReferenceCount::init_type();
101 register_type(_type_handle, "WindowHandle",
102 TypedReferenceCount::get_class_type());
103 }
104 virtual TypeHandle get_type() const {
105 return get_class_type();
106 }
107 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
108
109 private:
110 static TypeHandle _type_handle;
111};
112
113#include "windowHandle.I"
114
115INLINE std::ostream &operator << (std::ostream &out, const WindowHandle &handle) {
116 handle.output(out);
117 return out;
118}
119
120INLINE std::ostream &operator << (std::ostream &out, const WindowHandle::OSHandle &handle) {
121 handle.output(out);
122 return out;
123}
124
125#endif
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
WindowHandle::OSHandle
Definition windowHandle.h:63
WindowHandle::OSHandle::get_int_handle
virtual size_t get_int_handle() const
Returns the OS-specific handle converted to an integer, if this is possible for the particular repres...
Definition windowHandle.cxx:112
WindowHandle
This object represents a window on the desktop, not necessarily a Panda window.
Definition windowHandle.h:34
WindowHandle::detach_child
virtual void detach_child(WindowHandle *child)
Called on a parent handle to indicate a child window's intention to detach itself.
Definition windowHandle.cxx:76
WindowHandle::set_os_handle
set_os_handle
Changes the OS-specific handle stored internally to the WindowHandle wrapper.
Definition windowHandle.h:44
WindowHandle::send_windows_message
void send_windows_message(unsigned int msg, int wparam, int lparam)
Call this method on a parent WindowHandle to deliver a Windows message to the current child window,...
Definition windowHandle.cxx:33
WindowHandle::get_int_handle
size_t get_int_handle() const
Returns the OS-specific handle converted to an integer, if this is possible for the particular repres...
Definition windowHandle.cxx:44
WindowHandle::receive_windows_message
virtual void receive_windows_message(unsigned int msg, int wparam, int lparam)
Called on a child handle to deliver a keyboard button event generated in the parent window.
Definition windowHandle.cxx:96
WindowHandle::get_os_handle
get_os_handle
Returns the OS-specific handle stored internally to the WindowHandle wrapper.
Definition windowHandle.h:44
WindowHandle::attach_child
virtual void attach_child(WindowHandle *child)
Called on a parent handle to indicate a child window's intention to attach itself.
Definition windowHandle.cxx:68
WindowHandle::request_keyboard_focus
virtual void request_keyboard_focus(WindowHandle *child)
Called on a parent handle to indicate a child window's wish to receive keyboard button events.
Definition windowHandle.cxx:87
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
typedReferenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
windowHandle.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.