rev 8703 : RT-40186: Update copyright header for files modified in 2015
1 /*
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.glass.ui.monocle;
27
28 import com.sun.glass.ui.Pixels;
29 import com.sun.glass.ui.View;
30 import com.sun.glass.ui.Window;
31
32 import java.util.Map;
33
34 final class MonocleView extends View {
35
36 MonocleView() {
37 }
38
39 private boolean cursorVisibility;
40 private boolean resetCursorVisibility = false;
41
42 // Constants
43 private static long multiClickTime = 500;
44 private static int multiClickMaxX = 20;
45 private static int multiClickMaxY = 20;
46
47 // view variables
48 private int x;
49 private int y;
50
51 static long _getMultiClickTime() {
52 return multiClickTime;
53 }
54
55 static int _getMultiClickMaxX() {
56 return multiClickMaxX;
57 }
58
59 static int _getMultiClickMaxY() {
60 return multiClickMaxY;
61 }
62
63 @Override
64 protected void _enableInputMethodEvents(long ptr, boolean enable) {
65 }
66
67 @Override
68 protected long _getNativeView(long ptr) {
69 return ptr;
70 }
71
72 @Override
73 protected int _getX(long ptr) {
74 return x;
75 }
76
77 @Override
78 protected int _getY(long ptr) {
79 return y;
80 }
81
82
83
84 @Override
85 protected void _scheduleRepaint(long ptr) {
86 }
87
88
89
90 @Override protected void _uploadPixels(long nativeViewPtr, Pixels pixels) {
91 if (getWindow() != null) {
92 NativeScreen screen =
93 NativePlatformFactory.getNativePlatform().getScreen();
94 Window window = getWindow();
95 screen.uploadPixels(pixels.getPixels(),
96 x + window.getX(), y + window.getY(),
97 pixels.getWidth(), pixels.getHeight(),
98 window.getAlpha());
99 }
100 }
101
102 /**
103 * Events
104 */
105
106 @Override
107 protected void notifyKey(int type, int keyCode, char[] keyChars,
108 int modifiers) {
109 super.notifyKey(type, keyCode, keyChars, modifiers);
110 }
111
112 @Override
113 protected void notifyMouse(int type, int button,
114 int x, int y, int xAbs, int yAbs, int modifiers,
115 boolean isPopupTrigger, boolean isSynthesized) {
116 super.notifyMouse(type, button, x, y, xAbs, yAbs, modifiers,
117 isPopupTrigger,
118 isSynthesized);
119 }
120
121 @Override
122 protected void notifyScroll(int x, int y, int xAbs, int yAbs,
123 double deltaX, double deltaY, int modifiers,
124 int lines, int chars,
125 int defaultLines, int defaultChars,
126 double xMultiplier, double yMultiplier) {
127 super.notifyScroll(x, y, xAbs, yAbs, deltaX, deltaY,
128 modifiers, lines, chars,
129 defaultLines, defaultChars, xMultiplier,
130 yMultiplier);
131 }
132
133 void notifyRepaint() {
134 super.notifyRepaint(x, y, getWidth(), getHeight());
135 }
136
137 @Override
138 protected void notifyResize(int width, int height) {
139 super.notifyResize(width, height);
140 }
141
142 @Override
143 protected void notifyView(int viewEvent) {
144 super.notifyView(viewEvent);
145 }
146
147 //DnD
148 @Override
149 protected int notifyDragEnter(int x, int y, int absx, int absy, int recommendedDropAction) {
150 return super.notifyDragEnter(x, y, absx, absy, recommendedDropAction);
151 }
152
153 @Override
154 protected void notifyDragLeave() {
155 super.notifyDragLeave();
156 }
157
158 @Override
159 protected int notifyDragDrop(int x, int y, int absx, int absy, int recommendedDropAction) {
160 return super.notifyDragDrop(x, y, absx, absy, recommendedDropAction);
161 }
162
163 @Override
164 protected int notifyDragOver(int x, int y, int absx, int absy, int recommendedDropAction) {
165 return super.notifyDragOver(x, y, absx, absy, recommendedDropAction);
166 }
167
168 @Override
169 protected void notifyDragEnd(int performedAction) {
170 super.notifyDragEnd(performedAction);
171 }
172
173 //Menu event - i.e context menu hint (usually mouse right click)
174 @Override
175 protected void notifyMenu(int x, int y, int xAbs, int yAbs, boolean isKeyboardTrigger) {
176 super.notifyMenu(x, y, xAbs, yAbs, isKeyboardTrigger);
177 }
178
179 @Override
180 protected int _getNativeFrameBuffer(long ptr) {
181 return 0;
182 }
183
184 @Override
185 protected long _create(Map caps) {
186 return 1l;
187 }
188
189 @Override
190 protected void _setParent(long ptr, long parentPtr) {
191 }
192
193 @Override
194 protected boolean _close(long ptr) {
195 return true;
196 }
197
198 @Override
199 protected boolean _enterFullscreen(long ptr, boolean animate,
200 boolean keepRatio,
201 boolean hideCursor) {
202 MonocleWindowManager wm = MonocleWindowManager.getInstance();
203 MonocleWindow focusedWindow = wm.getFocusedWindow();
204 focusedWindow.setFullScreen(true);
205 if (hideCursor) {
206 resetCursorVisibility = true;
207 NativeCursor nativeCursor =
208 NativePlatformFactory.getNativePlatform().getCursor();
209 cursorVisibility = nativeCursor.getVisiblity();
210 nativeCursor.setVisibility(false);
211 }
212 return true;
213 }
214
215 @Override
216 protected void _exitFullscreen(long ptr, boolean animate) {
217 MonocleWindowManager wm = MonocleWindowManager.getInstance();
218 MonocleWindow focusedWindow = wm.getFocusedWindow();
219 focusedWindow.setFullScreen(false);
220 if (resetCursorVisibility) {
221 resetCursorVisibility = false;
222 NativeCursor nativeCursor =
223 NativePlatformFactory.getNativePlatform().getCursor();
224 nativeCursor.setVisibility(cursorVisibility);
225 }
226 }
227
228 @Override
229 public String toString() {
230 return "MonocleView["
231 + x + "," + y
232 + "+" + getWidth() + "x" + getHeight()
233 + "]";
234 }
235
236 /**
237 * Assuming this is used to lock the surface for painting
238 */
239 @Override
240 protected void _begin(long ptr) {
241 }
242
243 /**
244 * Assuming this is used to unlock the surface after painting is
245 * done
246 */
247 @Override
248 protected void _end(long ptr) {
249 }
250 }
--- EOF ---