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
126
127
128
129
|
package NET.worlds.console;
public abstract class RenderCanvasOverlay {
private RenderCanvas canvas;
private int xPercent;
private int yPercent;
private int xFixed;
private int yFixed;
private boolean isFixed;
private boolean fullscreen;
private int hwnd;
private boolean allowFocus;
public RenderCanvasOverlay(RenderCanvas pCanvas, int pX, int pY, boolean pIsFixed, boolean pAllowFocus) throws NoWebControlException {
assert pX > 0 || pY > 0;
if (pCanvas != null && pCanvas.getWindow() != null) {
this.canvas = pCanvas;
this.isFixed = pIsFixed;
this.allowFocus = pAllowFocus;
if (this.isFixed) {
this.xFixed = pX;
this.yFixed = pY;
this.xPercent = this.yPercent = 1;
} else {
this.xPercent = pX;
this.yPercent = pY;
}
this.fullscreen = false;
} else {
throw new NoWebControlException("RenderCanvas does not exist");
}
}
public RenderCanvasOverlay(RenderCanvas pCanvas) {
assert pCanvas != null;
this.canvas = pCanvas;
this.xPercent = this.yPercent = 100;
this.isFixed = false;
this.allowFocus = true;
this.fullscreen = true;
this.hwnd = this.canvas.getWindow().getHwnd();
}
public void activate() {
this.canvas.addOverlay(this);
}
int getNativeWindowHandle() {
assert this.canvas.getWindow() != null;
if (this.hwnd == 0) {
if (this.fullscreen) {
this.hwnd = this.canvas.getWindow().getHwnd();
} else {
this.hwnd = this.nativeMakeChild(this.canvas.getWindow().getHwnd(), this.xPercent, this.yPercent, this.allowFocus);
}
}
return this.hwnd;
}
int getXPercent() {
return this.xPercent;
}
int getYPercent() {
return this.yPercent;
}
int getFixedWidth() {
return this.xFixed;
}
int getFixedHeight() {
return this.yFixed;
}
boolean getIsFixedSize() {
return this.isFixed;
}
void canvasResized(int parentX, int parentY) {
int w;
int h;
if (this.isFixed) {
w = this.xFixed;
h = this.yFixed;
if (w > parentX) {
w = parentX;
}
if (h > parentY) {
h = parentY;
}
this.xPercent = (int)Math.ceil((double)w / parentX * 100.0);
this.yPercent = (int)Math.ceil((double)h / parentY * 100.0);
} else {
w = (int)(parentX * this.xPercent * 0.01);
h = (int)(parentY * this.yPercent * 0.01);
}
if (this.hwnd != 0) {
this.nativeResizeChild(this.hwnd, w, h);
}
}
boolean isFullscreen() {
return this.fullscreen || !this.isFixed && this.xPercent == 100 && this.yPercent == 100;
}
protected abstract void handleCommand(int var1);
void detach() {
this.canvas.removeOverlay(this);
if (!this.fullscreen && this.hwnd != 0) {
this.nativeKillChild(this.hwnd);
}
}
private native int nativeMakeChild(long var1, int var3, int var4, boolean var5);
private native void nativeKillChild(long var1);
private native void nativeResizeChild(int var1, int var2, int var3);
}
|