1 /* 2 * Copyright (c) 2013, 2015, 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 package sun.lwawt.macosx; 27 28 import java.awt.Font; 29 import java.awt.FontMetrics; 30 import java.awt.Graphics; 31 import java.awt.GraphicsDevice; 32 import java.awt.GraphicsEnvironment; 33 import java.awt.Insets; 34 import java.awt.MenuBar; 35 import java.awt.Point; 36 import java.awt.Rectangle; 37 import java.awt.Window; 38 import sun.awt.CGraphicsDevice; 39 import sun.awt.CGraphicsEnvironment; 40 import sun.awt.LightweightFrame; 41 import sun.java2d.SurfaceData; 42 import sun.lwawt.LWLightweightFramePeer; 43 import sun.lwawt.LWWindowPeer; 44 import sun.lwawt.PlatformWindow; 45 46 public class CPlatformLWWindow extends CPlatformWindow { 47 48 @Override 49 public void initialize(Window target, LWWindowPeer peer, PlatformWindow owner) { 50 initializeBase(target, peer, owner, new CPlatformLWView()); 51 } 52 53 @Override 54 public void toggleFullScreen() { 55 } 56 57 @Override 58 public void setMenuBar(MenuBar mb) { 59 } 60 61 @Override 62 public void dispose() { 63 } 64 65 @Override 66 public FontMetrics getFontMetrics(Font f) { 67 return null; 68 } 69 70 @Override 71 public Insets getInsets() { 72 return new Insets(0, 0, 0, 0); 73 } 74 75 @Override 76 public Point getLocationOnScreen() { 77 return null; 78 } 79 80 @Override 81 public SurfaceData getScreenSurface() { 82 return null; 83 } 84 85 @Override 86 public SurfaceData replaceSurfaceData() { 87 return null; 88 } 89 90 @Override 91 public void setBounds(int x, int y, int w, int h) { 92 if (getPeer() != null) { 93 getPeer().notifyReshape(x, y, w, h); 94 } 95 } 96 97 @Override 98 public void setVisible(boolean visible) { 99 } 100 101 @Override 102 public void setTitle(String title) { 103 } 104 105 @Override 106 public void updateIconImages() { 107 } 108 109 @Override 110 public long getNSWindowPtr() { 111 return 0; 112 } 113 114 @Override 115 public SurfaceData getSurfaceData() { 116 return null; 117 } 118 119 @Override 120 public void toBack() { 121 } 122 123 @Override 124 public void toFront() { 125 } 126 127 @Override 128 public void setResizable(final boolean resizable) { 129 } 130 131 @Override 132 public void setSizeConstraints(int minW, int minH, int maxW, int maxH) { 133 } 134 135 @Override 136 public boolean rejectFocusRequest(FocusEvent.Cause cause) { 137 return false; 138 } 139 140 @Override 141 public boolean requestWindowFocus() { 142 return true; 143 } 144 145 @Override 146 public boolean isActive() { 147 return true; 148 } 149 150 @Override 151 public void updateFocusableWindowState() { 152 } 153 154 @Override 155 public Graphics transformGraphics(Graphics g) { 156 return null; 157 } 158 159 @Override 160 public void setAlwaysOnTop(boolean isAlwaysOnTop) { 161 } 162 163 @Override 164 public void setOpacity(float opacity) { 165 } 166 167 @Override 168 public void setOpaque(boolean isOpaque) { 169 } 170 171 @Override 172 public void enterFullScreenMode() { 173 } 174 175 @Override 176 public void exitFullScreenMode() { 177 } 178 179 @Override 180 public void setWindowState(int windowState) { 181 } 182 183 @Override 184 public LWWindowPeer getPeer() { 185 return super.getPeer(); 186 } 187 188 @Override 189 public CPlatformView getContentView() { 190 return super.getContentView(); 191 } 192 193 @Override 194 public long getLayerPtr() { 195 return 0; 196 } 197 198 @Override 199 public GraphicsDevice getGraphicsDevice() { 200 CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment. 201 getLocalGraphicsEnvironment(); 202 203 LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer(); 204 int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor(); 205 206 Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds(); 207 for (GraphicsDevice d : ge.getScreenDevices()) { 208 if (d.getDefaultConfiguration().getBounds().intersects(bounds) && 209 ((CGraphicsDevice)d).getScaleFactor() == scale) 210 { 211 return d; 212 } 213 } 214 // We shouldn't be here... 215 return ge.getDefaultScreenDevice(); 216 } 217 }