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 sun.lwawt.macosx;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.image.VolatileImage;
31
32 import sun.awt.CGraphicsConfig;
33 import sun.lwawt.LWWindowPeer;
34 import sun.lwawt.macosx.event.NSEvent;
35
36 import sun.java2d.SurfaceData;
37 import sun.java2d.opengl.CGLLayer;
38 import sun.java2d.opengl.CGLSurfaceData;
39
40 public class CPlatformView extends CFRetainedResource {
41 private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr);
42
43 private LWWindowPeer peer;
44 private SurfaceData surfaceData;
45 private CGLLayer windowLayer;
46 private CPlatformResponder responder;
47
48 public CPlatformView() {
49 super(0, true);
185 // ----------------------------------------------------------------------
186
187 private void deliverMouseEvent(NSEvent event) {
188 int x = event.getX();
189 int y = getBounds().height - event.getY();
190
191 if (event.getType() == CocoaConstants.NSScrollWheel) {
192 responder.handleScrollEvent(x, y, event.getModifierFlags(),
193 event.getScrollDeltaX(), event.getScrollDeltaY());
194 } else {
195 responder.handleMouseEvent(event.getType(), event.getModifierFlags(), event.getButtonNumber(),
196 event.getClickCount(), x, y, event.getAbsX(), event.getAbsY());
197 }
198 }
199
200 private void deliverKeyEvent(NSEvent event) {
201 responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
202 event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
203 }
204
205 private void deliverWindowDidExposeEvent() {
206 Rectangle r = peer.getBounds();
207 peer.notifyExpose(0, 0, r.width, r.height);
208 }
209
210 private void deliverWindowDidExposeEvent(float x, float y, float w, float h) {
211 peer.notifyExpose((int)x, (int)y, (int)w, (int)h);
212 }
213 }
|
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 sun.lwawt.macosx;
27
28 import java.awt.*;
29 import java.awt.image.VolatileImage;
30
31 import sun.awt.CGraphicsConfig;
32 import sun.lwawt.LWWindowPeer;
33 import sun.lwawt.macosx.event.NSEvent;
34
35 import sun.java2d.SurfaceData;
36 import sun.java2d.opengl.CGLLayer;
37 import sun.java2d.opengl.CGLSurfaceData;
38
39 public class CPlatformView extends CFRetainedResource {
40 private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr);
41
42 private LWWindowPeer peer;
43 private SurfaceData surfaceData;
44 private CGLLayer windowLayer;
45 private CPlatformResponder responder;
46
47 public CPlatformView() {
48 super(0, true);
184 // ----------------------------------------------------------------------
185
186 private void deliverMouseEvent(NSEvent event) {
187 int x = event.getX();
188 int y = getBounds().height - event.getY();
189
190 if (event.getType() == CocoaConstants.NSScrollWheel) {
191 responder.handleScrollEvent(x, y, event.getModifierFlags(),
192 event.getScrollDeltaX(), event.getScrollDeltaY());
193 } else {
194 responder.handleMouseEvent(event.getType(), event.getModifierFlags(), event.getButtonNumber(),
195 event.getClickCount(), x, y, event.getAbsX(), event.getAbsY());
196 }
197 }
198
199 private void deliverKeyEvent(NSEvent event) {
200 responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
201 event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
202 }
203
204 /**
205 * Called by the native delegate in layer backed view mode or in the simple
206 * NSView mode. See NSView.drawRect().
207 */
208 private void deliverWindowDidExposeEvent() {
209 peer.notifyExpose(peer.getSize());
210 }
211 }
|