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