/*
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 */

#import <Cocoa/Cocoa.h>
#import <jni.h>

#import "GlassHostView.h"
#import "GlassFullscreenWindow.h"
#import "GlassDragSource.h"

// helper class that implements the custom GlassView functionality
@interface GlassViewDelegate : NSObject <GlassDragSourceDelegate>
{
    NSView                  *nsView;
    jobject                 jView;
    
    NSTrackingRectTag       trackingRect;
    
    GlassHostView           *parentHost;
    NSWindow                *parentWindow;
    CGFloat                 parentWindowAlpha;
    
    GlassHostView           *fullscreenHost;
    GlassFullscreenWindow   *fullscreenWindow;
    GlassBackgroundWindow   *backgroundWindow;
    
    BOOL                    mouseIsDown;
    BOOL                    mouseIsOver;
    
    NSEvent                 *lastEvent;
    NSDragOperation         dragOperation;
    NSInteger               lastTrackingNumber;
    
    NSMutableDictionary     *touches;
    NSUInteger              lastTouchId;
}

- (id)initWithView:(NSView*)view withJview:(jobject)jview;

- (void)viewDidMoveToWindow;
- (void)setFrameSize:(NSSize)newSize;
- (void)setFrame:(NSRect)frameRect;
- (void)updateTrackingAreas;
- (void)drawRect:(NSRect)dirtyRect;

- (void)sendJavaMouseEvent:(NSEvent *)theEvent;
- (void)resetMouseTracking;
- (void)sendJavaMenuEvent:(NSEvent *)theEvent;
- (void)sendJavaKeyEvent:(NSEvent *)event isDown:(BOOL)isDown;
- (void)sendJavaModifierKeyEvent:(NSEvent *)theEvent;
- (void)sendJavaGestureEvent:(NSEvent *)theEvent type:(int)type;
- (void)sendJavaGestureEndEvent:(NSEvent *)theEvent;
- (void)sendJavaTouchEvent:(NSEvent *)theEvent;

- (NSDragOperation)sendJavaDndEvent:(id <NSDraggingInfo>)info type:(jint)type;

- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
- (void)startDrag:(NSDragOperation)operation;

- (void)sendJavaLockedEvent;
- (void)sendJavaUnlockedEvent;

- (BOOL)suppressMouseEnterExitOnMouseDown;

- (void)enterFullscreenWithAnimate:(BOOL)animate withKeepRatio:(BOOL)keepRatio withHideCursor:(BOOL)hideCursor;
- (void)exitFullscreenWithAnimate:(BOOL)animate;

- (void)setFrameOrigin:(NSPoint)newOrigin;

- (jobject)jView;

@end
