1 /* 2 * Copyright (c) 2009, 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 com.sun.javafx.tk; 27 28 import java.security.AccessControlContext; 29 import javafx.scene.input.KeyCode; 30 import javafx.scene.input.KeyCodeCombination; 31 import javafx.scene.input.KeyCombination.ModifierValue; 32 33 /** 34 * TKStage - Peer interface for a Stage 35 * 36 */ 37 public interface TKStage { 38 /** 39 * Listener for this stage peer to pass updates and events back to the stage 40 * 41 * @param listener The listener provided by the stage 42 */ 43 public void setTKStageListener(TKStageListener listener); 44 45 /** 46 * Creates a Scene peer that can be displayed in this Stage peer. 47 * 48 * @return scenePeer The peer of the scene to be displayed 49 */ 50 public TKScene createTKScene(boolean depthBuffer, boolean msaa, AccessControlContext acc); 51 52 /** 53 * Set the scene to be displayed in this stage 54 * 55 * @param scene The peer of the scene to be displayed 56 */ 57 public void setScene(TKScene scene); 58 59 /** 60 * Sets the window bounds to the specified values. 61 * 62 * Gravity values specify how to correct window location if only its size 63 * changes (for example when stage decorations are added). User initiated 64 * resizing should be ignored and must not influence window location through 65 * this mechanism. 66 * 67 * The corresponding correction formulas are: 68 * 69 * {@code x -= xGravity * deltaW} 70 * {@code y -= yGravity * deltaH} 71 * 72 * @param x the new window horizontal position, ignored if xSet is set to 73 * false 74 * @param y the new window vertical position, ignored if ySet is set to 75 * false 76 * @param xSet indicates whether the x parameter is valid 77 * @param ySet indicates whether the y parameter is valid 78 * @param w the new window width, ignored if set to -1 79 * @param h the new window height, ignored if set to -1 80 * @param cw the new window content width, ignored if set to -1 81 * @param ch the new window content height, ignored if set to -1 82 * @param xGravity the xGravity coefficient 83 * @param yGravity the yGravity coefficient 84 * @param renderScaleX new rendering scale, ignored if < 1 85 * @param renderScaleY new rendering scale, ignored if < 1 86 */ 87 public void setBounds(float x, float y, boolean xSet, boolean ySet, 88 float w, float h, float cw, float ch, 89 float xGravity, float yGravity, 90 float renderScaleX, float renderScaleY); 91 92 public float getPlatformScaleX(); 93 public float getPlatformScaleY(); 94 public float getOutputScaleX(); 95 public float getOutputScaleY(); 96 97 public void setIcons(java.util.List icons); 98 99 public void setTitle(String title); 100 101 /** 102 * Set if the stage is visible on screen 103 * 104 * @param visible True if the stage should be visible 105 */ 106 public void setVisible(boolean visible); 107 108 public void setOpacity(float opacity); 109 110 public void setIconified(boolean iconified); 111 112 public void setMaximized(boolean maximized); 113 114 public void setAlwaysOnTop(boolean alwaysOnTop); 115 116 public void setResizable(boolean resizable); 117 118 public void setImportant(boolean important); 119 120 public void setMinimumSize(int minWidth, int minHeight); 121 122 public void setMaximumSize(int maxWidth, int maxHeight); 123 124 public void setFullScreen(boolean fullScreen); 125 126 // ================================================================================================================= 127 // Functions 128 129 public void requestFocus(); 130 public void toBack(); 131 public void toFront(); 132 public void close(); 133 134 public void requestFocus(FocusCause cause); 135 136 /** 137 * Grabs focus on this window. 138 * 139 * All mouse clicks that occur in this window's client area or client-areas 140 * of any of its unfocusable owned windows are delivered as usual. Whenever 141 * a click occurs on another app's window (not related via the ownership 142 * relation with this one, or a focusable owned window), or on non-client 143 * area of any window (titlebar, etc.), or any third-party app's window, or 144 * native OS GUI (e.g. a taskbar), the grab is automatically reset, and the 145 * window that held the grab receives the FOCUS_UNGRAB event. 146 * 147 * Note that for this functionality to work correctly, the window must have 148 * a focus upon calling this method. All owned popup windows that should be 149 * operable during the grabbed focus state (e.g. nested popup menus) must 150 * be unfocusable (see {@link #setFocusable}). Clicking a focusable owned 151 * window will reset the grab due to a focus transfer. 152 * 153 * The click that occurs in another window and causes resetting of the grab 154 * may or may not be delivered to that other window depending on the native 155 * OS behavior. 156 * 157 * If any of the application's windows already holds the grab, it is reset 158 * prior to grabbing the focus for this window. The method may be called 159 * multiple times for one window. Subsequent calls do not affect the grab 160 * status unless it is reset between the calls, in which case the focus 161 * is grabbed again. 162 * 163 * Note that grabbing the focus on an application window may prevent 164 * delivering certain events to other applications until the grab is reset. 165 * Therefore, if the application has finished showing popup windows based 166 * on a user action (e.g. clicking a menu item), and doesn't require the 167 * grab any more, it should call the {@link #ungrabFocus} method. The 168 * FOCUS_UNGRAB event signals that the grab has been reset. 169 * 170 * A user event handler associated with a menu item must be invoked after 171 * resetting the grab. Otherwise, if a developer debugs the application and 172 * has installed a breakpoint in the event handler, the debugger may become 173 * unoperable due to events blocking for other applications on some 174 * platforms. 175 * 176 * @return {@code true} if the operation is successful 177 * @throws IllegalStateException if the window isn't focused currently 178 */ 179 public boolean grabFocus(); 180 181 /** 182 * Manually ungrabs focus grabbed on this window previously. 183 * 184 * This method resets the grab, and forces sending of the FOCUS_UNGRAB 185 * event. It should be used when popup windows (such as menus) should be 186 * dismissed manually, e.g. when a user clicks a menu item which usually 187 * causes the menus to hide. 188 * 189 * @see #grabFocus 190 */ 191 public void ungrabFocus(); 192 193 /** 194 * Requests text input in form of native keyboard for text component 195 * contained by this Window. Native text input component is drawn on the place 196 * of JavaFX component to cover it completely and to provide native text editing 197 * techniques. Any change of text is immediately reflected in JavaFX text component. 198 * 199 * @param text text to be shown in the native text input component 200 * @param type type of text input component @see com.sun.javafx.scene.control.behavior.TextInputTypes 201 * @param width width of JavaFX text input component 202 * @param height height of JavaFX text input component 203 * @param M standard transformation matrix for drawing the native text component derived from JavaFX component 204 */ 205 void requestInput(String text, int type, double width, double height, 206 double Mxx, double Mxy, double Mxz, double Mxt, 207 double Myx, double Myy, double Myz, double Myt, 208 double Mzx, double Mzy, double Mzz, double Mzt); 209 210 /** 211 * Native keyboard for text input is no longer necessary. 212 * Keyboard will be hidden and native text input component too. 213 */ 214 void releaseInput(); 215 216 public void setRTL(boolean b); 217 218 public static final KeyCodeCombination defaultFullScreenExitKeycombo = 219 new KeyCodeCombination(KeyCode.ESCAPE, 220 ModifierValue.UP, 221 ModifierValue.UP, 222 ModifierValue.UP, 223 ModifierValue.UP, 224 ModifierValue.UP); 225 }