1 /*
   2  * Copyright (c) 2011, 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 #import <Cocoa/Cocoa.h>
  27 #import <jni.h>
  28 
  29 #import "GlassHostView.h"
  30 #import "GlassFullscreenWindow.h"
  31 #import "GlassDragSource.h"
  32 #import "GlassAccessible.h"
  33 
  34 // helper class that implements the custom GlassView functionality
  35 @interface GlassViewDelegate : NSObject <GlassDragSourceDelegate>
  36 {
  37     NSView                  *nsView;
  38     jobject                 jView;
  39     
  40     NSTrackingRectTag       trackingRect;
  41     
  42     GlassHostView           *parentHost;
  43     NSWindow                *parentWindow;
  44     CGFloat                 parentWindowAlpha;
  45     
  46     GlassHostView           *fullscreenHost;
  47     // not nil when the FS mode is initiated with the OS X 10.7 widget
  48     NSWindow*               nativeFullScreenModeWindow;
  49     
  50     BOOL                    mouseIsDown;
  51     BOOL                    mouseIsOver;
  52     int                     mouseDownMask; // bit 0 - left, 1 - right, 2 - other button
  53     
  54     BOOL                    gestureInProgress;
  55     
  56     NSEvent                 *lastEvent;
  57     NSDragOperation         dragOperation;
  58     NSInteger               lastTrackingNumber;
  59     
  60 @public
  61     // not nil when we create a new FS window ourselves
  62     GlassFullscreenWindow   *fullscreenWindow;
  63 }
  64 
  65 - (id)initWithView:(NSView*)view withJview:(jobject)jview;
  66 
  67 - (void)viewDidMoveToWindow;
  68 - (void)setFrameSize:(NSSize)newSize;
  69 - (void)setFrame:(NSRect)frameRect;
  70 - (void)updateTrackingAreas;
  71 - (void)drawRect:(NSRect)dirtyRect;
  72 
  73 - (void)sendJavaMouseEvent:(NSEvent *)theEvent;
  74 - (void)resetMouseTracking;
  75 - (void)sendJavaMenuEvent:(NSEvent *)theEvent;
  76 - (void)sendJavaKeyEvent:(NSEvent *)event isDown:(BOOL)isDown;
  77 - (void)sendJavaModifierKeyEvent:(NSEvent *)theEvent;
  78 - (void)sendJavaGestureEvent:(NSEvent *)theEvent type:(int)type;
  79 - (void)sendJavaGestureBeginEvent:(NSEvent *)theEvent;
  80 - (void)sendJavaGestureEndEvent:(NSEvent *)theEvent;
  81 
  82 - (NSDragOperation)sendJavaDndEvent:(id <NSDraggingInfo>)info type:(jint)type;
  83 
  84 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
  85 - (void)startDrag:(NSDragOperation)operation;
  86 
  87 - (BOOL)suppressMouseEnterExitOnMouseDown;
  88 
  89 - (void)enterFullscreenWithAnimate:(BOOL)animate withKeepRatio:(BOOL)keepRatio withHideCursor:(BOOL)hideCursor;
  90 - (void)exitFullscreenWithAnimate:(BOOL)animate;
  91 - (void)sendJavaFullScreenEvent:(BOOL)entered withNativeWidget:(BOOL)isNative;
  92 
  93 - (void)notifyInputMethod:(id)aString attr:(int)attr length:(int)length cursor:(int)cursor selectedRange:(NSRange)selectionRange;
  94 - (NSRect)getInputMethodCandidatePosRequest:(int)pos;
  95 
  96 - (void)setFrameOrigin:(NSPoint)newOrigin;
  97 
  98 - (jobject)jView;
  99 
 100 - (GlassAccessible*)getAccessible;
 101 
 102 @end