1 /* 2 * Copyright (c) 2012, 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 26 package sun.lwawt.macosx; 27 28 import java.awt.BufferCapabilities.FlipContents; 29 import java.awt.Font; 30 import java.awt.FontMetrics; 31 import java.awt.Graphics; 32 import java.awt.GraphicsDevice; 33 import java.awt.Image; 34 import java.awt.Insets; 35 import java.awt.MenuBar; 36 import java.awt.Point; 37 import java.awt.Rectangle; 38 import java.awt.Transparency; 39 import java.awt.Window; 40 import sun.awt.CausedFocusEvent.Cause; 41 import sun.java2d.SurfaceData; 42 import sun.lwawt.LWWindowPeer; 43 import sun.lwawt.PlatformWindow; 44 45 public class CViewPlatformEmbeddedFrame implements PlatformWindow { 46 47 private CPlatformView view; 48 private LWWindowPeer peer; 49 private CViewEmbeddedFrame target; 50 private CPlatformResponder responder; 51 52 @Override // PlatformWindow 53 public void initialize(Window target, final LWWindowPeer peer, PlatformWindow owner) { 54 this.peer = peer; 55 this.target = (CViewEmbeddedFrame) target; 56 responder = new CPlatformResponder(peer, false); 57 58 view = new CPlatformView(); 59 view.initialize(peer, responder); 60 61 CWrapper.NSView.addSubview(this.target.getEmbedderHandle(), view.getAWTView()); 62 view.setAutoResizable(true); 63 } 64 65 public long getNSViewPtr() { 66 return view.getAWTView(); 67 } 68 69 @Override 70 public long getLayerPtr() { 71 return view.getWindowLayerPtr(); 72 } 73 74 @Override 75 public LWWindowPeer getPeer() { 76 return peer; 77 } 78 79 @Override 80 public void dispose() { 81 CWrapper.NSView.removeFromSuperview(view.getAWTView()); 82 view.dispose(); 83 } 84 85 @Override 86 public void setVisible(boolean visible) { 87 CWrapper.NSView.setHidden(view.getAWTView(), !visible); 88 } 89 90 @Override 91 public void setTitle(String title) { 92 } 93 94 @Override 95 public void setBounds(int x, int y, int w, int h) { 96 view.setBounds(x, y, w, h); 97 peer.notifyReshape(x, y, w, h); 98 } 99 100 @Override 101 public GraphicsDevice getGraphicsDevice() { 102 return view.getGraphicsDevice(); 103 } 104 105 @Override 106 public Point getLocationOnScreen() { 107 return view.getLocationOnScreen(); 108 } 109 110 @Override 111 public Insets getInsets() { 112 return new Insets(0, 0, 0, 0); 113 } 114 115 @Override 116 public FontMetrics getFontMetrics(Font f) { 117 throw new RuntimeException("Not implemented"); 118 } 119 120 @Override 121 public SurfaceData getScreenSurface() { 122 return view.getSurfaceData(); 123 } 124 125 @Override 126 public SurfaceData replaceSurfaceData() { 127 return view.replaceSurfaceData(); 128 } 129 130 @Override 131 public void setModalBlocked(boolean blocked) { 132 } 133 134 @Override 135 public void toFront() { 136 } 137 138 @Override 139 public void toBack() { 140 } 141 142 @Override 143 public void setMenuBar(MenuBar mb) { 144 } 145 146 @Override 147 public void setAlwaysOnTop(boolean value) { 148 } 149 150 @Override 151 public PlatformWindow getTopmostPlatformWindowUnderMouse() { 152 return null; 153 } 154 155 @Override 156 public void updateFocusableWindowState() { 157 } 158 159 @Override 160 public boolean rejectFocusRequest(Cause cause) { 161 return false; 162 } 163 164 @Override 165 public boolean requestWindowFocus() { 166 return true; 167 } 168 169 @Override 170 public boolean isActive() { 171 return target.isParentWindowActive(); 172 } 173 174 @Override 175 public void setResizable(boolean resizable) { 176 } 177 178 @Override 179 public void setSizeConstraints(int minW, int minH, int maxW, int maxH) { 180 } 181 182 @Override 183 public Graphics transformGraphics(Graphics g) { 184 return g; 185 } 186 187 @Override 188 public void updateIconImages() { 189 } 190 191 @Override 192 public void setOpacity(float opacity) { 193 } 194 195 @Override 196 public void setOpaque(boolean isOpaque) { 197 } 198 199 @Override 200 public void enterFullScreenMode() { 201 } 202 203 @Override 204 public void exitFullScreenMode() { 205 } 206 207 @Override 208 public boolean isFullScreenMode() { 209 return false; 210 } 211 212 @Override 213 public void setWindowState(int windowState) { 214 } 215 216 @Override 217 public boolean isUnderMouse() { 218 return view.isUnderMouse(); 219 } 220 221 @Override 222 public Image createBackBuffer() { 223 return view.createBackBuffer(); 224 } 225 226 @Override 227 public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) { 228 throw new RuntimeException("Not implemented"); 229 } 230 }