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     // =================================================================================================================
 120     // Functions
 121 
 122     public void requestFocus();
 123     public void toBack();
 124     public void toFront();
 125     public void close();
 126     
 127     public void requestFocus(FocusCause cause);
 128 
 129     /**
 130      * Grabs focus on this window.
 131      *
 132      * All mouse clicks that occur in this window's client area or client-areas
 133      * of any of its unfocusable owned windows are delivered as usual. Whenever
 134      * a click occurs on another app's window (not related via the ownership
 135      * relation with this one, or a focusable owned window), or on non-client
 136      * area of any window (titlebar, etc.), or any third-party app's window, or
 137      * native OS GUI (e.g. a taskbar), the grab is automatically reset, and the
 138      * window that held the grab receives the FOCUS_UNGRAB event.
 139      *
 140      * Note that for this functionality to work correctly, the window must have
 141      * a focus upon calling this method. All owned popup windows that should be
 142      * operable during the grabbed focus state (e.g. nested popup menus) must
 143      * be unfocusable (see {@link #setFocusable}). Clicking a focusable owned
 144      * window will reset the grab due to a focus transfer.
 145      *
 146      * The click that occurs in another window and causes resetting of the grab
 147      * may or may not be delivered to that other window depending on the native
 148      * OS behavior.
 149      *
 150      * If any of the application's windows already holds the grab, it is reset
 151      * prior to grabbing the focus for this window. The method may be called
 152      * multiple times for one window. Subsequent calls do not affect the grab
 153      * status unless it is reset between the calls, in which case the focus
 154      * is grabbed again.
 155      *
 156      * Note that grabbing the focus on an application window may prevent
 157      * delivering certain events to other applications until the grab is reset.
 158      * Therefore, if the application has finished showing popup windows based
 159      * on a user action (e.g. clicking a menu item), and doesn't require the
 160      * grab any more, it should call the {@link #ungrabFocus} method. The
 161      * FOCUS_UNGRAB event signals that the grab has been reset.
 162      *
 163      * A user event handler associated with a menu item must be invoked after
 164      * resetting the grab. Otherwise, if a developer debugs the application and
 165      * has installed a breakpoint in the event handler, the debugger may become
 166      * unoperable due to events blocking for other applications on some
 167      * platforms.
 168      *
 169      * @return {@code true} if the operation is successful
 170      * @throws IllegalStateException if the window isn't focused currently
 171      */
 172     public boolean grabFocus();
 173 
 174     /**
 175      * Manually ungrabs focus grabbed on this window previously.
 176      *
 177      * This method resets the grab, and forces sending of the FOCUS_UNGRAB
 178      * event. It should be used when popup windows (such as menus) should be
 179      * dismissed manually, e.g. when a user clicks a menu item which usually
 180      * causes the menus to hide.
 181      *
 182      * @see #grabFocus
 183      */
 184     public void ungrabFocus();
 185     
 186     /**
 187      * Requests text input in form of native keyboard for text component
 188      * contained by this Window. Native text input component is drawn on the place
 189      * of JavaFX component to cover it completely and to provide native text editing
 190      * techniques. Any change of text is immediately reflected in JavaFX text component.
 191      *
 192      * @param text text to be shown in the native text input component
 193      * @param type type of text input component @see com.sun.javafx.scene.control.behavior.TextInputTypes
 194      * @param width width of JavaFX text input component
 195      * @param height height of JavaFX text input component
 196      * @param M standard transformation matrix for drawing the native text component derived from JavaFX component
 197      */
 198     void requestInput(String text, int type, double width, double height,
 199                         double Mxx, double Mxy, double Mxz, double Mxt,
 200                         double Myx, double Myy, double Myz, double Myt,
 201                         double Mzx, double Mzy, double Mzz, double Mzt);
 202 
 203     /**
 204      * Native keyboard for text input is no longer necessary.
 205      * Keyboard will be hidden and native text input component too.
 206      */
 207     void releaseInput();
 208 
 209     public void setRTL(boolean b);
 210 
 211     /**
 212      * Accessibility methods
 213      */
 214     
 215     /**
 216      * Notify accessibility initialization completion to AT
 217      * 
 218      * @param ac    the FX accessible root/stage node.
 219      */
 220     public void setAccessibilityInitIsComplete(Object ac) ;
 221 
 222     /**
 223      * Create accessible Glass object corresponding to stage
 224      * 
 225      * @param ac    the FX accessible root/stage node.
 226      * 
 227      * @return the Glass AccessibleRoot object.
 228      */
 229     public Object accessibleCreateStageProvider(AccessibleStageProvider ac) ;
 230 
 231     /**
 232      * Create the Glass accessible object corresponding to controls
 233      * 
 234      * @param ac    the FX accessible node
 235      * 
 236      * @return the Glass accessible Object
 237      */
 238     public Object accessibleCreateBasicProvider(AccessibleProvider ac) ;
 239 
 240     /**
 241      * Delete accessible native object corresponding to controls
 242      * 
 243      * @param ac    the FX accessible node
 244      */
 245     public void accessibleDestroyBasicProvider(Object nativeAcc) ;
 246 
 247     /**
 248      * Fire accessible event
 249      * 
 250      * @param eventID   identifies the event.
 251      */
 252     public void accessibleFireEvent(Object nativeAcc, int eventID);
 253     
 254     /** Fire accessible property change event
 255      * 
 256      * @param propertyId    identifies the property
 257      * @param oldProperty   the old value of the property
 258      * @param newProperty   the new value of the property
 259      */
 260     public void accessibleFirePropertyChange(Object nativeAcc, int propertyId, int oldProperty,
 261                                              int newProperty );
 262     public void accessibleFirePropertyChange(Object nativeAcc, int propertyId, boolean oldProperty,
 263                                              boolean newProperty );    
 264 
 265 
 266     public static final KeyCodeCombination defaultFullScreenExitKeycombo =
 267             new KeyCodeCombination(KeyCode.ESCAPE,
 268             ModifierValue.UP,
 269             ModifierValue.UP,
 270             ModifierValue.UP,
 271             ModifierValue.UP,
 272             ModifierValue.UP);
 273 }