1 /*
   2  * Copyright (c) 2011, 2017, 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 "GlassMenu.h"
  30 #import "GlassView.h"
  31 
  32 // normal Glass window delegate
  33 @interface GlassWindow : NSObject <NSWindowDelegate>
  34 {
  35     jobject             jWindow;
  36 
  37 @public
  38     // A reference to an NSWindow or NSPanel descendant - the native window
  39     NSWindow            *nsWindow;
  40 
  41     NSWindow            *owner;
  42     NSView<GlassView>   *view;
  43     NSScreen            *currentScreen;
  44     GlassMenubar        *menubar;
  45     NSRect              preZoomedRect;
  46     NSWindow            *fullscreenWindow;
  47 
  48     BOOL                isFocusable;
  49     BOOL                isEnabled;
  50     NSUInteger          enabledStyleMask; // valid while the window is disabled
  51     BOOL                isTransparent;
  52     BOOL                isDecorated;
  53     BOOL                isResizable;
  54     BOOL                suppressWindowMoveEvent;
  55     BOOL                suppressWindowResizeEvent;
  56 
  57     NSPoint             lastReportedLocation; // which was sent to Java
  58 
  59     BOOL                isClosed;
  60 
  61     // We track whether an explicit size/location have been assigned to the window
  62     // in order to differentiate between an explicitly assigned zero bounds, and the
  63     // deafult bounds (which are also zeros - see a comment in _createWindowCommon().)
  64     BOOL                isSizeAssigned;
  65     BOOL                isLocationAssigned;
  66 
  67 @private
  68     BOOL                isWindowResizable;
  69 }
  70 
  71 - (void)setFullscreenWindow:(NSWindow *)fsWindow;
  72 
  73 // NSWindow overrides delegate methods
  74 - (void)close;
  75 - (void)sendEvent:(NSEvent *)event;
  76 - (BOOL)canBecomeMainWindow;
  77 - (BOOL)canBecomeKeyWindow;
  78 - (BOOL)hidesOnDeactivate;
  79 - (BOOL)worksWhenModal;
  80 - (NSColor*)setBackgroundColor:(NSColor *)color;
  81 @end
  82 
  83 @interface GlassWindow_Normal : NSWindow
  84 {
  85 @public
  86     GlassWindow* gWindow;
  87 }
  88 
  89 - (id)initWithDelegate:(GlassWindow*)delegate
  90              frameRect:(NSRect)rect
  91              styleMask:(NSUInteger)styleMask
  92                 screen:(NSScreen*)screen;
  93 @end
  94 
  95 @interface GlassWindow_Panel : NSPanel
  96 {
  97 @public
  98     GlassWindow* gWindow;
  99 }
 100 
 101 - (id)initWithDelegate:(GlassWindow*)delegate
 102              frameRect:(NSRect)rect
 103              styleMask:(NSUInteger)styleMask
 104                 screen:(NSScreen*)screen;
 105 @end
 106 
 107 // invisible window for hosting another GlassEmbeddedWindow or remote View representing plugin content
 108 @interface GlassEmbeddedWindow : GlassWindow_Normal
 109 {
 110 @public
 111 
 112     NSWindow            *fullscreenWindow;
 113 
 114     BOOL                isKeyWindow;
 115 
 116     GlassEmbeddedWindow *parent;
 117     GlassEmbeddedWindow *child;
 118 }
 119 
 120 - (id)initWithDelegate:(GlassWindow*)delegate
 121              frameRect:(NSRect)rect
 122              styleMask:(NSUInteger)styleMask
 123                 screen:(NSScreen*)screen;
 124 
 125 + (BOOL)exists:(GlassEmbeddedWindow*)window;
 126 
 127 - (void)setFullscreenWindow:(NSWindow*)fsWindow;
 128 
 129 @end
 130 
 131 extern GlassEmbeddedWindow *getGlassEmbeddedWindow(JNIEnv *env, jlong jPtr);
 132 
 133 extern NSImage* getImage(u_int8_t* data, int jWidth, int jHeight, int jOffset);