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