src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java

Print this page


   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;
  27 
  28 import java.awt.Graphics;

  29 import java.awt.Insets;
  30 import java.awt.Point;
  31 import java.awt.Rectangle;

  32 import java.awt.Window;
  33 import java.awt.dnd.DropTarget;
  34 
  35 import sun.awt.CausedFocusEvent;
  36 import sun.awt.LightweightFrame;

  37 import sun.swing.JLightweightFrame;
  38 import sun.swing.SwingAccessor;
  39 
  40 public class LWLightweightFramePeer extends LWWindowPeer {
  41 
  42     public LWLightweightFramePeer(LightweightFrame target,
  43                                   PlatformComponent platformComponent,
  44                                   PlatformWindow platformWindow)
  45     {
  46         super(target, platformComponent, platformWindow, LWWindowPeer.PeerType.LW_FRAME);
  47     }
  48 
  49     private LightweightFrame getLwTarget() {
  50         return (LightweightFrame)getTarget();
  51     }
  52 
  53     @Override
  54     public Graphics getGraphics() {
  55         return getLwTarget().getGraphics();
  56     }


  97     }
  98 
  99     @Override
 100     public void removeDropTarget(DropTarget dt) {
 101     }
 102 
 103     @Override
 104     public void grab() {
 105         getLwTarget().grabFocus();
 106     }
 107 
 108     @Override
 109     public void ungrab() {
 110         getLwTarget().ungrabFocus();
 111     }
 112 
 113     @Override
 114     public void updateCursorImmediately() {
 115         SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget());
 116     }













 117 }
   1 /*
   2  * Copyright (c) 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;
  27 
  28 import java.awt.Graphics;
  29 import java.awt.GraphicsConfiguration;
  30 import java.awt.Insets;
  31 import java.awt.Point;
  32 import java.awt.Rectangle;
  33 import java.awt.Transparency;
  34 import java.awt.Window;
  35 import java.awt.dnd.DropTarget;
  36 
  37 import sun.awt.CausedFocusEvent;
  38 import sun.awt.LightweightFrame;
  39 import sun.awt.image.OffScreenImage;
  40 import sun.swing.JLightweightFrame;
  41 import sun.swing.SwingAccessor;
  42 
  43 public class LWLightweightFramePeer extends LWWindowPeer {
  44 
  45     public LWLightweightFramePeer(LightweightFrame target,
  46                                   PlatformComponent platformComponent,
  47                                   PlatformWindow platformWindow)
  48     {
  49         super(target, platformComponent, platformWindow, LWWindowPeer.PeerType.LW_FRAME);
  50     }
  51 
  52     private LightweightFrame getLwTarget() {
  53         return (LightweightFrame)getTarget();
  54     }
  55 
  56     @Override
  57     public Graphics getGraphics() {
  58         return getLwTarget().getGraphics();
  59     }


 100     }
 101 
 102     @Override
 103     public void removeDropTarget(DropTarget dt) {
 104     }
 105 
 106     @Override
 107     public void grab() {
 108         getLwTarget().grabFocus();
 109     }
 110 
 111     @Override
 112     public void ungrab() {
 113         getLwTarget().ungrabFocus();
 114     }
 115 
 116     @Override
 117     public void updateCursorImmediately() {
 118         SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget());
 119     }
 120     
 121     @Override
 122     public OffScreenImage createHiDPIImage(int width, int height) {
 123         OffScreenImage img =  OffScreenImage.create(getLwTarget(), (GraphicsConfiguration)getLWGC(),
 124                                                     width, height, Transparency.OPAQUE,
 125                                                     getLwTarget().getScaleFactor());
 126         return img;
 127     }
 128     
 129     @Override
 130     public void notifyScaleFactorChanged() {
 131         displayChanged();
 132     }
 133 }