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