1 /*
   2  * Copyright (c) 1995, 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 java.awt.peer;
  27 
  28 import java.awt.*;
  29 
  30 import sun.awt.EmbeddedFrame;
  31 import sun.awt.image.OffScreenImage;
  32 
  33 /**
  34  * The peer interface for {@link Frame}. This adds a couple of frame specific
  35  * methods to the {@link WindowPeer} interface.
  36  *
  37  * The peer interfaces are intended only for use in porting
  38  * the AWT. They are not intended for use by application
  39  * developers, and developers should not implement peers
  40  * nor invoke any of the peer methods directly on the peer
  41  * instances.
  42  */
  43 public interface FramePeer extends WindowPeer {
  44 
  45     /**
  46      * Sets the title on the frame.
  47      *
  48      * @param title the title to set
  49      *
  50      * @see Frame#setTitle(String)
  51      */
  52     void setTitle(String title);
  53 
  54     /**
  55      * Sets the menu bar for the frame.
  56      *
  57      * @param mb the menu bar to set
  58      *
  59      * @see Frame#setMenuBar(MenuBar)
  60      */
  61     void setMenuBar(MenuBar mb);
  62 
  63     /**
  64      * Sets if the frame should be resizable or not.
  65      *
  66      * @param resizeable {@code true} when the frame should be resizable,
  67      *        {@code false} if not
  68      *
  69      * @see Frame#setResizable(boolean)
  70      */
  71     void setResizable(boolean resizeable);
  72 
  73     /**
  74      * Changes the state of the frame.
  75      *
  76      * @param state the new state
  77      *
  78      * @see Frame#setExtendedState(int)
  79      */
  80     void setState(int state);
  81 
  82     /**
  83      * Returns the current state of the frame.
  84      *
  85      * @return the current state of the frame
  86      *
  87      * @see Frame#getExtendedState()
  88      */
  89     int getState();
  90 
  91     /**
  92      * Sets the bounds of the frame when it becomes maximized.
  93      *
  94      * @param bounds the maximized bounds of the frame
  95      *
  96      * @see Frame#setMaximizedBounds(Rectangle)
  97      */
  98     void setMaximizedBounds(Rectangle bounds);
  99 
 100     /**
 101      * Sets the size and location for embedded frames. (On embedded frames,
 102      * setLocation() and setBounds() always set the frame to (0,0) for
 103      * backwards compatibility.
 104      *
 105      * @param x the X location
 106      * @param y the Y location
 107      * @param width the width of the frame
 108      * @param height the height of the frame
 109      *
 110      * @see EmbeddedFrame#setBoundsPrivate(int, int, int, int)
 111      */
 112     // TODO: This is only used in EmbeddedFrame, and should probably be moved
 113     // into an EmbeddedFramePeer which would extend FramePeer
 114     void setBoundsPrivate(int x, int y, int width, int height);
 115 
 116     /**
 117      * Returns the size and location for embedded frames. (On embedded frames,
 118      * setLocation() and setBounds() always set the frame to (0,0) for
 119      * backwards compatibility.
 120      *
 121      * @return the bounds of an embedded frame
 122      *
 123      * @see EmbeddedFrame#getBoundsPrivate()
 124      */
 125     // TODO: This is only used in EmbeddedFrame, and should probably be moved
 126     // into an EmbeddedFramePeer which would extend FramePeer
 127     Rectangle getBoundsPrivate();
 128 
 129     /**
 130      * Requests the peer to emulate window activation.
 131      *
 132      * @param activate activate or deactivate the window
 133      */
 134     void emulateActivation(boolean activate);
 135     
 136     /**
 137      * Notifies that the scale factor has changed.
 138      * The method is used by the LightweightFrame Mac implementation.
 139      */
 140     default void notifyScaleFactorChanged() {}
 141     
 142     /**
 143      * Creates a HiDPI back buffer image with a scale factor matching
 144      * the scale of the frame (which is an internal value).
 145      * The method is currently used by the LightweightFrame Mac implementation.
 146      */
 147     default OffScreenImage createHiDPIImage(int width, int height) { return null; }
 148 }