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