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); }