1 /*
   2  * Copyright (c) 2010, 2016, 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.embed;
  27 
  28 import java.nio.IntBuffer;
  29 
  30 import com.sun.javafx.scene.traversal.Direction;
  31 import javafx.collections.ObservableList;
  32 import javafx.event.EventType;
  33 import javafx.scene.image.PixelFormat;
  34 import javafx.scene.input.InputMethodEvent;
  35 import javafx.scene.input.InputMethodRequests;
  36 import javafx.scene.input.InputMethodTextRun;
  37 
  38 /**
  39  * An interface for embedded FX scene peer. It is used by HostInterface
  40  * object to send various notifications to the scene, for example, when
  41  * an input event is received in the host application and should be
  42  * forwarded to FX.
  43  *
  44  */
  45 public interface EmbeddedSceneInterface {
  46 
  47     /*
  48      * A notification about the embedded container is resized.
  49      */
  50     public void setSize(int width, int height);
  51 
  52     /*
  53      * A notification about the scale factor is changed.
  54      */
  55     public void setPixelScaleFactors(float scalex, float scaley);
  56 
  57     /*
  58      * A request to fetch all the FX scene pixels into a offscreen buffer.
  59      */
  60     public boolean getPixels(IntBuffer dest, int width, int height);
  61 
  62     /*
  63      * A request to get the FX scene's pixel format.
  64      */
  65     public PixelFormat<?> getPixelFormat();
  66 
  67     /*
  68      * A notification about mouse event received by host container.
  69      */
  70     public void mouseEvent(int type, int button,
  71                            boolean primaryBtnDown, boolean middleBtnDown, boolean secondaryBtnDown,
  72                            int x, int y, int xAbs, int yAbs,
  73                            boolean shift, boolean ctrl, boolean alt, boolean meta,
  74                            boolean popupTrigger);
  75     /*
  76      * A notification about mouse wheel scroll events received by the host container;
  77      */
  78     public void scrollEvent(int type, double scrollX, double scrollY,
  79                             double x, double y, double screenX, double screenY,
  80                             boolean shift, boolean ctrl,
  81                             boolean alt, boolean meta);
  82     /*
  83      * A notification about key event received by host container.
  84      */
  85     public void keyEvent(int type, int key, char[] chars, int modifiers);
  86 
  87     /*
  88      * A notification about menu event received by host container.
  89      */
  90     public void menuEvent(int x, int y, int xAbs, int yAbs, boolean isKeyboardTrigger);
  91 
  92     public boolean traverseOut(Direction dir);
  93 
  94     public void setDragStartListener(HostDragStartListener l);
  95 
  96     public EmbeddedSceneDTInterface createDropTarget();
  97 
  98     public void inputMethodEvent(EventType<InputMethodEvent> type,
  99                                  ObservableList<InputMethodTextRun> composed, String committed,
 100                                  int caretPosition);
 101 
 102     public InputMethodRequests getInputMethodRequests();
 103 }