Mouse wheel can be an event for event handler functions. 34/17434/1
Charlotte HECQUET [Fri, 6 Nov 2015 13:23:16 +0000 (14:23 +0100)]
Change-Id: Iab8b28570199694f88c48180f2cede66e8765029

17 files changed:
scilab/CHANGES_5.5.X
scilab/modules/graphics/help/en_US/interaction/event_handler_functions.xml
scilab/modules/graphics/help/en_US/interaction/xclick.xml
scilab/modules/graphics/help/en_US/interaction/xgetmouse.xml
scilab/modules/graphics/help/fr_FR/interaction/xclick.xml
scilab/modules/graphics/help/ja_JP/interaction/event_handler_functions.xml
scilab/modules/graphics/help/ja_JP/interaction/xclick.xml
scilab/modules/graphics/help/ja_JP/interaction/xgetmouse.xml
scilab/modules/graphics/help/pt_BR/interaction/event_handler_functions.xml
scilab/modules/graphics/help/pt_BR/interaction/xclick.xml
scilab/modules/graphics/help/pt_BR/interaction/xgetmouse.xml
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/canvas/SwingScilabCanvas.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabDockablePanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabStaticPanel.java
scilab/modules/gui/src/java/org/scilab/modules/gui/editor/EditorEventListener.java
scilab/modules/gui/src/java/org/scilab/modules/gui/events/ScilabEventListener.java
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/SciTranslator.java

index 93dedf0..750c76a 100644 (file)
@@ -1,6 +1,12 @@
                      Changes between version 5.5.2 and 5.5.3
                      =======================================
 
+Graphics Evolutions
+===================
+
+* Mouse wheel can be an event for event handler functions.
+
+
 Scilab Bug Fixes
 ================
 
index 55ad3e1..471d6dc 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibut==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibut==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibut &gt; =32</term>
                 <listitem>
                     <para>key with ascii code ascii(ibut) has been pressed</para>
index 548938b..b7d43eb 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibutton==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibutton==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibutton &gt;=32</term>
                 <listitem>
                     <para>
index 66c5be3..7cc96fd 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibutton==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibutton==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibutton &gt; =32</term>
                 <listitem>
                     <para>key with ascii code ascii(ibutton) has been pressed</para>
index 418d0ba..f55c7e2 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibutton==20</term>
+                <listitem>
+                    <para>La molette de la souris a été tournée vers l'avant (la fonction zoom étant toujours active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibutton==-20</term>
+                <listitem>
+                    <para>La molette de la souris a été tournée vers l'arrière (la fonction zoom étant toujours active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibutton &gt;=32</term>
                 <listitem>
                     <para>
index 33f7cc7..8638fe9 100644 (file)
                 </listitem>
                 
             </varlistentry>
-            
+            <varlistentry>
+                <term>ibut==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibut==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
             <varlistentry>
                 
                 <term>ibut &gt; =32</term>
index 6542b55..730ac8f 100644 (file)
                 </listitem>
                 
             </varlistentry>
-            
+            <varlistentry>
+                <term>ibutton==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibutton==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
             <varlistentry>
                 
                 <term>ibutton &gt;=32</term>
index 5556c30..053d8bb 100644 (file)
                 </listitem>
                 
             </varlistentry>
-            
+            <varlistentry>
+                <term>ibut==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibut==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
             <varlistentry>
                 
                 <term>ibutton &gt; =32</term>
index 2f65a89..f67e9f8 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibut==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibut==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibut &gt; =32</term>
                 <listitem>
                     <para>uma tecla com código ascii(ibut) foi pressionada</para>
index fec0914..5aeeb93 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibutton==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibutton==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibutton &gt;=32</term>
                 <listitem>
                     <para>
index 2f011b2..309a7e7 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
+                <term>ibutton==20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled forward (zoom is still active)</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>ibutton==-20</term>
+                <listitem>
+                    <para>Mouse wheel has been scrolled backward (zoom is still active)</para>
+                    <para/>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>ibutton &gt; =32</term>
                 <listitem>
                     <para>uma tecla com código ASCII ascii(ibutton) foi
index 6554a33..3de6fd5 100644 (file)
@@ -28,6 +28,7 @@ import java.awt.event.FocusListener;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelListener;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.awt.image.BufferedImage;
@@ -347,6 +348,22 @@ public class SwingScilabCanvas extends JPanel implements SimpleCanvas {
     }
 
     /**
+     * Adds the listener handling mouse wheel events to the canvas.
+     * @param listener listener to add.
+     */
+    public void addEventHandlerMouseWheelListener(MouseWheelListener listener) {
+        drawableComponent.addMouseWheelListener(listener);
+    }
+
+    /**
+     * Removes the listener handling mouse wheel events from the canvas.
+     * @param listener listener to remove.
+     */
+    public void removeEventHandlerMouseWheelListener(MouseWheelListener listener) {
+        drawableComponent.removeMouseWheelListener(listener);
+    }
+
+    /**
      * Adds the listener handling mouse motion events to the canvas.
      * @param listener listener to add.
      */
index 1008519..7946c58 100644 (file)
@@ -638,6 +638,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
                 contentCanvas.addEventHandlerKeyListener(editorEventHandler);
                 contentCanvas.addEventHandlerMouseListener(editorEventHandler);
                 contentCanvas.addEventHandlerMouseMotionListener(editorEventHandler);
+                contentCanvas.addEventHandlerMouseWheelListener(editorEventHandler);
                 if (eventEnabled) {
                     editorEventHandler.setEnable(false);
                     enableEventHandler();
@@ -1488,6 +1489,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
             contentCanvas.addEventHandlerKeyListener(eventHandler);
             contentCanvas.addEventHandlerMouseListener(eventHandler);
             contentCanvas.addEventHandlerMouseMotionListener(eventHandler);
+            contentCanvas.addEventHandlerMouseWheelListener(eventHandler);
         }
     }
 
@@ -1499,6 +1501,7 @@ public class SwingScilabDockablePanel extends View implements SimpleTab, FocusLi
             contentCanvas.removeEventHandlerKeyListener(eventHandler);
             contentCanvas.removeEventHandlerMouseListener(eventHandler);
             contentCanvas.removeEventHandlerMouseMotionListener(eventHandler);
+            contentCanvas.removeEventHandlerMouseWheelListener(eventHandler);
         }
     }
 
index 8a1a6fe..d76af71 100644 (file)
@@ -162,6 +162,7 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
             contentCanvas.addEventHandlerKeyListener(eventHandler);
             contentCanvas.addEventHandlerMouseListener(eventHandler);
             contentCanvas.addEventHandlerMouseMotionListener(eventHandler);
+            contentCanvas.addEventHandlerMouseWheelListener(eventHandler);
         }
     }
 
@@ -173,7 +174,8 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
             contentCanvas.removeEventHandlerKeyListener(eventHandler);
             contentCanvas.removeEventHandlerMouseListener(eventHandler);
             contentCanvas.removeEventHandlerMouseMotionListener(eventHandler);
-        }
+            contentCanvas.addEventHandlerMouseWheelListener(eventHandler);
+       }
     }
 
     public void setId(Integer id) {
@@ -267,6 +269,7 @@ public class SwingScilabStaticPanel extends SwingScilabScrollPane implements Swi
                 contentCanvas.addEventHandlerKeyListener(editorEventHandler);
                 contentCanvas.addEventHandlerMouseListener(editorEventHandler);
                 contentCanvas.addEventHandlerMouseMotionListener(editorEventHandler);
+                contentCanvas.addEventHandlerMouseWheelListener(editorEventHandler);
                 if (eventEnabled) {
                     editorEventHandler.setEnable(false);
                     enableEventHandler();
index 8313b0c..6eb0cd3 100644 (file)
@@ -16,8 +16,10 @@ package org.scilab.modules.gui.editor;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelListener;
 
 import org.scilab.modules.gui.datatip.DatatipCreate;
 import org.scilab.modules.gui.datatip.DatatipDelete;
@@ -47,7 +49,7 @@ import org.scilab.modules.gui.plotbrowser.PlotBrowser;
  * @since 2012-06-01
  */
 
-public class EditorEventListener implements KeyListener, MouseListener, MouseMotionListener {
+public class EditorEventListener implements KeyListener, MouseWheelListener, MouseListener, MouseMotionListener {
 
     Integer windowUid;
 
@@ -229,5 +231,9 @@ public class EditorEventListener implements KeyListener, MouseListener, MouseMot
 
     public void mouseMoved(MouseEvent arg0) {
     }
+
+
+    public void mouseWheelMoved(MouseWheelEvent arg0) {
+    }
 }
 
index 68c8586..ab874a7 100644 (file)
@@ -16,8 +16,10 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelListener;
 
 import org.scilab.modules.action_binding.InterpreterManagement;
 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
@@ -27,7 +29,7 @@ import org.scilab.modules.gui.utils.SciTranslator;
  * it means call a dedicated scilab function like this :
  * function my_eventhandler(windowsId, mouse X, mouse Y, mouse Button)
  */
-public class ScilabEventListener implements KeyListener, MouseListener, MouseMotionListener {
+public class ScilabEventListener implements KeyListener, MouseListener, MouseWheelListener, MouseMotionListener {
 
     private String callback;
     private Integer windowsUID;
@@ -201,4 +203,17 @@ public class ScilabEventListener implements KeyListener, MouseListener, MouseMot
         eventTranslator.setClickAction(SciTranslator.UNMANAGED);
     }
 
+    public void mouseWheelMoved(MouseWheelEvent arg0) {
+        int notches = arg0.getWheelRotation();
+        if (notches < 0) {
+            eventTranslator.setClickAction(SciTranslator.SCIWHEELUP);
+        } else {
+            eventTranslator.setClickAction(SciTranslator.SCIWHEELDOWN);
+        }
+
+        callScilab();
+        eventTranslator.setClickAction(SciTranslator.UNMANAGED);
+    }
+
+
 }
index fb5eb08..1183e6e 100644 (file)
@@ -49,6 +49,10 @@ public class SciTranslator {
      * other clicks can raise such a code
      */
     public static final int SCIMOVED = -1;
+    /** Internal state WHEEL */
+    public static final int SCIWHEELDOWN = -20;
+    public static final int SCIWHEELUP = 20;
+
     /** Internal state CLOSE */
     public static final int SCICLOSE = -1000;