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
|
#include "XPCDisplay.h"
XPCKeySniffer::XPCKeySniffer(int inBeforeWindows) : mBeforeWindows(inBeforeWindows)
{
XPLMRegisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast<void *>(this));
}
XPCKeySniffer::~XPCKeySniffer()
{
XPLMUnregisterKeySniffer(KeySnifferCB, mBeforeWindows, reinterpret_cast<void *>(this));
}
int XPCKeySniffer::KeySnifferCB(
char inCharKey,
XPLMKeyFlags inFlags,
char inVirtualKey,
void * inRefCon)
{
XPCKeySniffer * me = reinterpret_cast<XPCKeySniffer *>(inRefCon);
return me->HandleKeyStroke(inCharKey, inFlags, inVirtualKey);
}
XPCWindow::XPCWindow(
int inLeft,
int inTop,
int inRight,
int inBottom,
int inIsVisible)
{
mWindow = XPLMCreateWindow(inLeft, inTop, inRight, inBottom, inIsVisible,
DrawCB, HandleKeyCB, MouseClickCB,
reinterpret_cast<void *>(this));
}
XPCWindow::~XPCWindow()
{
XPLMDestroyWindow(mWindow);
}
void XPCWindow::GetWindowGeometry(
int * outLeft,
int * outTop,
int * outRight,
int * outBottom)
{
XPLMGetWindowGeometry(mWindow, outLeft, outTop, outRight, outBottom);
}
void XPCWindow::SetWindowGeometry(
int inLeft,
int inTop,
int inRight,
int inBottom)
{
XPLMSetWindowGeometry(mWindow, inLeft, inTop, inRight, inBottom);
}
int XPCWindow::GetWindowIsVisible(void)
{
return XPLMGetWindowIsVisible(mWindow);
}
void XPCWindow::SetWindowIsVisible(
int inIsVisible)
{
XPLMSetWindowIsVisible(mWindow, inIsVisible);
}
void XPCWindow::TakeKeyboardFocus(void)
{
XPLMTakeKeyboardFocus(mWindow);
}
void XPCWindow::BringWindowToFront(void)
{
XPLMBringWindowToFront(mWindow);
}
int XPCWindow::IsWindowInFront(void)
{
return XPLMIsWindowInFront(mWindow);
}
void XPCWindow::DrawCB(XPLMWindowID inWindowID, void * inRefcon)
{
XPCWindow * me = reinterpret_cast<XPCWindow *>(inRefcon);
me->DoDraw();
}
void XPCWindow::HandleKeyCB(XPLMWindowID inWindowID, char inKey, XPLMKeyFlags inFlags, char inVirtualKey, void * inRefcon, int losingFocus)
{
XPCWindow * me = reinterpret_cast<XPCWindow *>(inRefcon);
if (losingFocus)
me->LoseFocus();
else
me->HandleKey(inKey, inFlags, inVirtualKey);
}
int XPCWindow::MouseClickCB(XPLMWindowID inWindowID, int x, int y, XPLMMouseStatus inMouse, void * inRefcon)
{
XPCWindow * me = reinterpret_cast<XPCWindow *>(inRefcon);
return me->HandleClick(x, y, inMouse);
}
|