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