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 26package sun.lwawt.macosx; 27 28final class CWrapper { 29 private CWrapper() { } 30 31 static final class NSWindow { 32 // NSWindowOrderingMode 33 static final int NSWindowAbove = 1; 34 static final int NSWindowBelow = -1; 35 static final int NSWindowOut = 0; 36 37 // Window level constants 38 // The number of supported levels: (we'll use more in the future) 39 static final int MAX_WINDOW_LEVELS = 3; 40 // The levels: (these are NOT real constants, these are keys. See native code.) 41 static final int NSNormalWindowLevel = 0; 42 static final int NSFloatingWindowLevel = 1; 43 static final int NSPopUpMenuWindowLevel = 2; 44 45 // 'level' is one of the keys defined above 46 static native void setLevel(long window, int level); 47 48 static native void makeKeyAndOrderFront(long window); 49 static native void makeKeyWindow(long window); 50 static native void makeMainWindow(long window); 51 static native boolean canBecomeMainWindow(long window); 52 static native boolean isKeyWindow(long window); 53 54 static native void orderFront(long window); 55 static native void orderFrontRegardless(long window); 56 static native void orderWindow(long window, int ordered, long relativeTo); 57 58 /** 59 * Removes the window from the screen. 60 * 61 * @param window the pointer of the NSWindow 62 */ 63 static native void orderOut(long window); 64 65 /** 66 * Removes the window from the screen and releases it. According to 67 * documentation this method should be similar to {@link #orderOut}, 68 * because we use ReleasedWhenClosed:NO, so the window shouldn't be 69 * released. But the close method works differently, for example it 70 * close the space if the window was in the full screen via 71 * {@link CPlatformWindow#toggleFullScreen()}. 72 * 73 * @param window the pointer of the NSWindow 74 */ 75 static native void close(long window); 76 77 static native void addChildWindow(long parent, long child, int ordered); 78 static native void removeChildWindow(long parent, long child); 79 80 static native void setAlphaValue(long window, float alpha); 81 static native void setOpaque(long window, boolean opaque); 82 83 /** 84 * Sets background color of the NSWindow. 85 * 86 * @param window the pointer of the NSWindow 87 * @param color the color in argb format 88 */ 89 static native void setBackgroundColor(long window, int color); 90 91 static native void miniaturize(long window); 92 static native void deminiaturize(long window); 93 static native boolean isZoomed(long window); 94 static native void zoom(long window); 95 96 static native void makeFirstResponder(long window, long responder); 97 } 98 99 static final class NSView { 100 static native void addSubview(long view, long subview); 101 static native void removeFromSuperview(long view); 102 103 static native void setFrame(long view, int x, int y, int w, int h); 104 static native long window(long view); 105 106 static native void setHidden(long view, boolean hidden); 107 108 static native void setToolTip(long view, String msg); 109 } 110} 111