src/macosx/classes/sun/lwawt/macosx/CPlatformView.java
Print this page
*** 24,44 ****
--- 24,51 ----
*/
package sun.lwawt.macosx;
import java.awt.*;
+ import java.awt.geom.Rectangle2D;
+ import java.awt.image.VolatileImage;
import sun.awt.CGraphicsConfig;
+ import sun.awt.CGraphicsEnvironment;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.event.NSEvent;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
import sun.java2d.opengl.CGLSurfaceData;
public class CPlatformView extends CFRetainedResource {
private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr);
+ private static native void nativeSetAutoResizable(long awtView, boolean toResize);
+ private static native int nativeGetNSViewDisplayID(long awtView);
+ private static native Rectangle2D nativeGetLocationOnScreen(long awtView);
+ private static native boolean nativeIsViewUnderMouse(long ptr);
private LWWindowPeer peer;
private SurfaceData surfaceData;
private CGLLayer windowLayer;
private CPlatformResponder responder;
*** 156,169 ****
--- 163,212 ----
} else {
return 0;
}
}
+ public void setAutoResizable(boolean toResize) {
+ nativeSetAutoResizable(this.getAWTView(), toResize);
+ }
+
+ public boolean isUnderMouse() {
+ return nativeIsViewUnderMouse(getAWTView());
+ }
+
+ public GraphicsDevice getGraphicsDevice() {
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
+ int displayID = nativeGetNSViewDisplayID(getAWTView());
+ GraphicsDevice gd = cge.getScreenDevice(displayID);
+ if (gd == null) {
+ // this could possibly happen during device removal
+ // use the default screen device in this case
+ gd = ge.getDefaultScreenDevice();
+ }
+ return gd;
+ }
+
+ public Point getLocationOnScreen() {
+ Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds();
+ return new Point(r.x, r.y);
+ }
+
// ----------------------------------------------------------------------
// NATIVE CALLBACKS
// ----------------------------------------------------------------------
+ /*
+ * The callback is called only in the embedded case when the view is
+ * automatically resized by the superview.
+ * In normal mode this method is never called.
+ */
+ private void deliverResize(int x, int y, int w, int h) {
+ peer.notifyReshape(x, y, w, h);
+ }
+
+
private void deliverMouseEvent(NSEvent event) {
int x = event.getX();
int y = getBounds().height - event.getY();
if (event.getType() == CocoaConstants.NSScrollWheel) {