forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowHandle.h
More file actions
125 lines (102 loc) · 3.46 KB
/
windowHandle.h
File metadata and controls
125 lines (102 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file windowHandle.h
* @author drose
* @date 2009-09-30
*/
#ifndef WINDOWHANDLE_H
#define WINDOWHANDLE_H
#include "pandabase.h"
#include "typedReferenceCount.h"
#include "pointerTo.h"
/**
* This object represents a window on the desktop, not necessarily a Panda
* window. This structure can be assigned to a WindowProperties to indicate a
* parent window.
*
* It also has callbacks so the Panda window can communicate with its parent
* window, which is particularly important when running embedded in a browser.
*
* To create a WindowHandle, you would usually call one of the
* NativeWindowHandle::make_*() methods, depending on the kind of native
* window handle object you already have.
*/
class EXPCL_PANDA_DISPLAY WindowHandle : public TypedReferenceCount {
PUBLISHED:
class OSHandle;
INLINE WindowHandle(OSHandle *os_handle);
INLINE WindowHandle(const WindowHandle ©);
virtual ~WindowHandle();
INLINE OSHandle *get_os_handle() const;
INLINE void set_os_handle(OSHandle *os_handle);
MAKE_PROPERTY(os_handle, get_os_handle, set_os_handle);
void send_windows_message(unsigned int msg, int wparam, int lparam);
size_t get_int_handle() const;
void output(std::ostream &out) const;
public:
// Callbacks for communication with the parent window.
virtual void attach_child(WindowHandle *child);
virtual void detach_child(WindowHandle *child);
virtual void request_keyboard_focus(WindowHandle *child);
virtual void receive_windows_message(unsigned int msg, int wparam, int lparam);
PUBLISHED:
// This internal pointer within WindowHandle stores the actual OS-specific
// window handle type, whatever type that is. It is subclassed for each OS.
class EXPCL_PANDA_DISPLAY OSHandle : public TypedReferenceCount {
protected:
INLINE OSHandle();
PUBLISHED:
virtual ~OSHandle();
virtual size_t get_int_handle() const;
virtual void output(std::ostream &out) const;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedReferenceCount::init_type();
register_type(_type_handle, "WindowHandle::OSHandle",
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
protected:
PT(OSHandle) _os_handle;
PT(WindowHandle) _keyboard_window;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedReferenceCount::init_type();
register_type(_type_handle, "WindowHandle",
TypedReferenceCount::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#include "windowHandle.I"
INLINE std::ostream &operator << (std::ostream &out, const WindowHandle &handle) {
handle.output(out);
return out;
}
INLINE std::ostream &operator << (std::ostream &out, const WindowHandle::OSHandle &handle) {
handle.output(out);
return out;
}
#endif