Add 'src/jexer/' from commit 'cf01c92f5809a0732409e280fb0f32f27393618d'
[nikiroo-utils.git] / src / jexer / event / TMouseEvent.java
index e4b44833fe4a0893e58de6c53df28858069a6ca8..496d8bc06422baa3014a95a98ae953f60cd4325e 100644 (file)
@@ -3,7 +3,7 @@
  *
  * The MIT License (MIT)
  *
- * Copyright (C) 2017 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -33,7 +33,11 @@ package jexer.event;
  * the relative (x,y) ARE MUTABLE: TWidget's onMouse() handlers perform that
  * update during event dispatching.
  */
-public final class TMouseEvent extends TInputEvent {
+public class TMouseEvent extends TInputEvent {
+
+    // ------------------------------------------------------------------------
+    // Constants --------------------------------------------------------------
+    // ------------------------------------------------------------------------
 
     /**
      * The type of event generated.
@@ -60,11 +64,99 @@ public final class TMouseEvent extends TInputEvent {
         MOUSE_DOUBLE_CLICK
     }
 
+    // ------------------------------------------------------------------------
+    // Variables --------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Type of event, one of MOUSE_MOTION, MOUSE_UP, or MOUSE_DOWN.
      */
     private Type type;
 
+    /**
+     * Mouse X - relative coordinates.
+     */
+    private int x;
+
+    /**
+     * Mouse Y - relative coordinates.
+     */
+    private int y;
+
+    /**
+     * Mouse X - absolute screen coordinates.
+     */
+    private int absoluteX;
+
+    /**
+     * Mouse Y - absolute screen coordinate.
+     */
+    private int absoluteY;
+
+    /**
+     * Mouse button 1 (left button).
+     */
+    private boolean mouse1;
+
+    /**
+     * Mouse button 2 (right button).
+     */
+    private boolean mouse2;
+
+    /**
+     * Mouse button 3 (middle button).
+     */
+    private boolean mouse3;
+
+    /**
+     * Mouse wheel UP (button 4).
+     */
+    private boolean mouseWheelUp;
+
+    /**
+     * Mouse wheel DOWN (button 5).
+     */
+    private boolean mouseWheelDown;
+
+    // ------------------------------------------------------------------------
+    // Constructors -----------------------------------------------------------
+    // ------------------------------------------------------------------------
+
+    /**
+     * Public contructor.
+     *
+     * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP
+     * @param x relative column
+     * @param y relative row
+     * @param absoluteX absolute column
+     * @param absoluteY absolute row
+     * @param mouse1 if true, left button is down
+     * @param mouse2 if true, right button is down
+     * @param mouse3 if true, middle button is down
+     * @param mouseWheelUp if true, mouse wheel (button 4) is down
+     * @param mouseWheelDown if true, mouse wheel (button 5) is down
+     */
+    public TMouseEvent(final Type type, final int x, final int y,
+        final int absoluteX, final int absoluteY,
+        final boolean mouse1, final boolean mouse2, final boolean mouse3,
+        final boolean mouseWheelUp, final boolean mouseWheelDown) {
+
+        this.type               = type;
+        this.x                  = x;
+        this.y                  = y;
+        this.absoluteX          = absoluteX;
+        this.absoluteY          = absoluteY;
+        this.mouse1             = mouse1;
+        this.mouse2             = mouse2;
+        this.mouse3             = mouse3;
+        this.mouseWheelUp       = mouseWheelUp;
+        this.mouseWheelDown     = mouseWheelDown;
+    }
+
+    // ------------------------------------------------------------------------
+    // TMouseEvent ------------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Get type.
      *
@@ -74,11 +166,6 @@ public final class TMouseEvent extends TInputEvent {
         return type;
     }
 
-    /**
-     * Mouse X - relative coordinates.
-     */
-    private int x;
-
     /**
      * Get x.
      *
@@ -100,11 +187,6 @@ public final class TMouseEvent extends TInputEvent {
         this.x = x;
     }
 
-    /**
-     * Mouse Y - relative coordinates.
-     */
-    private int y;
-
     /**
      * Get y.
      *
@@ -126,11 +208,6 @@ public final class TMouseEvent extends TInputEvent {
         this.y = y;
     }
 
-    /**
-     * Mouse X - absolute screen coordinates.
-     */
-    private int absoluteX;
-
     /**
      * Get absoluteX.
      *
@@ -149,11 +226,6 @@ public final class TMouseEvent extends TInputEvent {
         this.absoluteX = absoluteX;
     }
 
-    /**
-     * Mouse Y - absolute screen coordinate.
-     */
-    private int absoluteY;
-
     /**
      * Get absoluteY.
      *
@@ -172,11 +244,6 @@ public final class TMouseEvent extends TInputEvent {
         this.absoluteY = absoluteY;
     }
 
-    /**
-     * Mouse button 1 (left button).
-     */
-    private boolean mouse1;
-
     /**
      * Get mouse1.
      *
@@ -186,11 +253,6 @@ public final class TMouseEvent extends TInputEvent {
         return mouse1;
     }
 
-    /**
-     * Mouse button 2 (right button).
-     */
-    private boolean mouse2;
-
     /**
      * Get mouse2.
      *
@@ -200,11 +262,6 @@ public final class TMouseEvent extends TInputEvent {
         return mouse2;
     }
 
-    /**
-     * Mouse button 3 (middle button).
-     */
-    private boolean mouse3;
-
     /**
      * Get mouse3.
      *
@@ -214,11 +271,6 @@ public final class TMouseEvent extends TInputEvent {
         return mouse3;
     }
 
-    /**
-     * Mouse wheel UP (button 4).
-     */
-    private boolean mouseWheelUp;
-
     /**
      * Get mouseWheelUp.
      *
@@ -228,11 +280,6 @@ public final class TMouseEvent extends TInputEvent {
         return mouseWheelUp;
     }
 
-    /**
-     * Mouse wheel DOWN (button 5).
-     */
-    private boolean mouseWheelDown;
-
     /**
      * Get mouseWheelDown.
      *
@@ -242,37 +289,6 @@ public final class TMouseEvent extends TInputEvent {
         return mouseWheelDown;
     }
 
-    /**
-     * Public contructor.
-     *
-     * @param type the type of event, MOUSE_MOTION, MOUSE_DOWN, or MOUSE_UP
-     * @param x relative column
-     * @param y relative row
-     * @param absoluteX absolute column
-     * @param absoluteY absolute row
-     * @param mouse1 if true, left button is down
-     * @param mouse2 if true, right button is down
-     * @param mouse3 if true, middle button is down
-     * @param mouseWheelUp if true, mouse wheel (button 4) is down
-     * @param mouseWheelDown if true, mouse wheel (button 5) is down
-     */
-    public TMouseEvent(final Type type, final int x, final int y,
-        final int absoluteX, final int absoluteY,
-        final boolean mouse1, final boolean mouse2, final boolean mouse3,
-        final boolean mouseWheelUp, final boolean mouseWheelDown) {
-
-        this.type               = type;
-        this.x                  = x;
-        this.y                  = y;
-        this.absoluteX          = absoluteX;
-        this.absoluteY          = absoluteY;
-        this.mouse1             = mouse1;
-        this.mouse2             = mouse2;
-        this.mouse3             = mouse3;
-        this.mouseWheelUp       = mouseWheelUp;
-        this.mouseWheelDown     = mouseWheelDown;
-    }
-
     /**
      * Create a duplicate instance.
      *