aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com
diff options
context:
space:
mode:
authorDmitri Trembovetski <[email protected]>2009-05-25 00:10:13 +0000
committerDmitri Trembovetski <[email protected]>2009-05-25 00:10:13 +0000
commitbeaa6d5d02d747c2eda1a3a81ba5e4030c9c5587 (patch)
tree2e3551c56d2850af07ab6b4890f0a596506d3c55 /src/newt/classes/com
parent1d428d4fce17329e7d3cc212ae45729836c07a25 (diff)
Newt fixes: implemented mouse wheel support - currently only hooked up on Windows platform, others will follow
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1913 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/newt/classes/com')
-rw-r--r--src/newt/classes/com/sun/javafx/newt/InputEvent.java25
-rw-r--r--src/newt/classes/com/sun/javafx/newt/MouseEvent.java22
-rw-r--r--src/newt/classes/com/sun/javafx/newt/MouseListener.java1
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java20
-rw-r--r--src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java8
5 files changed, 58 insertions, 18 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/InputEvent.java b/src/newt/classes/com/sun/javafx/newt/InputEvent.java
index dc36be34d..b49c72e75 100644
--- a/src/newt/classes/com/sun/javafx/newt/InputEvent.java
+++ b/src/newt/classes/com/sun/javafx/newt/InputEvent.java
@@ -35,11 +35,14 @@ package com.sun.javafx.newt;
public abstract class InputEvent extends Event
{
- public static int SHIFT_MASK = 1 << 0;
- public static int CTRL_MASK = 1 << 1;
- public static int META_MASK = 1 << 2;
- public static int ALT_MASK = 1 << 3;
- public static int ALT_GRAPH_MASK = 1 << 5;
+ public static final int SHIFT_MASK = 1 << 0;
+ public static final int CTRL_MASK = 1 << 1;
+ public static final int META_MASK = 1 << 2;
+ public static final int ALT_MASK = 1 << 3;
+ public static final int ALT_GRAPH_MASK = 1 << 5;
+ public static final int BUTTON1_MASK = 1 << 6;
+ public static final int BUTTON2_MASK = 1 << 7;
+ public static final int BUTTON3_MASK = 1 << 8;
protected InputEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers) {
super(sysEvent, eventType, source, when);
@@ -73,6 +76,18 @@ public abstract class InputEvent extends Event
return (modifiers&SHIFT_MASK)!=0;
}
+ public boolean isButton1Down() {
+ return (modifiers&BUTTON1_MASK)!=0;
+ }
+
+ public boolean isButton2Down() {
+ return (modifiers&BUTTON2_MASK)!=0;
+ }
+
+ public boolean isButton3Down() {
+ return (modifiers&BUTTON3_MASK)!=0;
+ }
+
public String toString() {
return "InputEvent[modifiers:"+modifiers+"]";
}
diff --git a/src/newt/classes/com/sun/javafx/newt/MouseEvent.java b/src/newt/classes/com/sun/javafx/newt/MouseEvent.java
index 79e11b875..ede193e1c 100644
--- a/src/newt/classes/com/sun/javafx/newt/MouseEvent.java
+++ b/src/newt/classes/com/sun/javafx/newt/MouseEvent.java
@@ -43,16 +43,21 @@ public class MouseEvent extends InputEvent
public static final int BUTTON6 = 6;
public static final int BUTTON_NUMBER = 6;
- protected MouseEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers, int x, int y, int clickCount, int button)
+ protected MouseEvent(boolean sysEvent, int eventType, Window source, long when,
+ int modifiers, int x, int y, int clickCount, int button,
+ int rotation)
{
super(sysEvent, eventType, source, when, modifiers);
this.x=x;
this.y=y;
this.clickCount=clickCount;
this.button=button;
+ this.wheelRotation = rotation;
}
- public MouseEvent(int eventType, Window source, long when, int modifiers, int x, int y, int clickCount, int button) {
- this(false, eventType, source, when, modifiers, x, y, clickCount, button);
+ public MouseEvent(int eventType, Window source, long when, int modifiers,
+ int x, int y, int clickCount, int button, int rotation) {
+ this(false, eventType, source, when, modifiers, x, y, clickCount, button,
+ rotation);
}
public int getButton() {
@@ -67,10 +72,15 @@ public class MouseEvent extends InputEvent
public int getY() {
return y;
}
+ public int getWheelRotation() {
+ return wheelRotation;
+ }
public String toString() {
return "MouseEvent["+getEventTypeString(getEventType())+
- ", "+x+"/"+y+", button "+button+", count "+clickCount+", "+super.toString()+"]";
+ ", "+x+"/"+y+", button "+button+", count "+clickCount+
+ ", wheel rotation "+wheelRotation+
+ ", "+super.toString()+"]";
}
public static String getEventTypeString(int type) {
@@ -82,11 +92,12 @@ public class MouseEvent extends InputEvent
case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED";
case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED";
case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED";
+ case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED";
default: return "unknown (" + type + ")";
}
}
- private int x, y, clickCount, button;
+ private int x, y, clickCount, button, wheelRotation;
public static final int EVENT_MOUSE_CLICKED = 200;
public static final int EVENT_MOUSE_ENTERED = 201;
@@ -95,4 +106,5 @@ public class MouseEvent extends InputEvent
public static final int EVENT_MOUSE_RELEASED = 204;
public static final int EVENT_MOUSE_MOVED = 205;
public static final int EVENT_MOUSE_DRAGGED = 206;
+ public static final int EVENT_MOUSE_WHEEL_MOVED = 207;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/MouseListener.java b/src/newt/classes/com/sun/javafx/newt/MouseListener.java
index f707979ba..3d2031f2a 100644
--- a/src/newt/classes/com/sun/javafx/newt/MouseListener.java
+++ b/src/newt/classes/com/sun/javafx/newt/MouseListener.java
@@ -42,5 +42,6 @@ public interface MouseListener extends EventListener
public void mouseReleased(MouseEvent e);
public void mouseMoved(MouseEvent e);
public void mouseDragged(MouseEvent e);
+ public void mouseWheelMoved(MouseEvent e);
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 8c6d92fe5..29d4b6195 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -427,7 +427,8 @@ public abstract class Window implements NativeWindow
private int lastMouseClickCount = 0; // last mouse button click count
public static final int ClickTimeout = 300;
- protected void sendMouseEvent(int eventType, int modifiers, int x, int y, int button) {
+ protected void sendMouseEvent(int eventType, int modifiers,
+ int x, int y, int button, int rotation) {
if(DEBUG_MOUSE_EVENT) {
System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
@@ -448,13 +449,13 @@ public abstract class Window implements NativeWindow
lastMousePressed=when;
mouseButtonPressed=button;
e = new MouseEvent(true, eventType, this, when,
- modifiers, x, y, lastMouseClickCount, button);
+ modifiers, x, y, lastMouseClickCount, button, 0);
} else if(MouseEvent.EVENT_MOUSE_RELEASED==eventType) {
e = new MouseEvent(true, eventType, this, when,
- modifiers, x, y, lastMouseClickCount, button);
+ modifiers, x, y, lastMouseClickCount, button, 0);
if(when-lastMousePressed<ClickTimeout) {
eClicked = new MouseEvent(true, MouseEvent.EVENT_MOUSE_CLICKED, this, when,
- modifiers, x, y, lastMouseClickCount, button);
+ modifiers, x, y, lastMouseClickCount, button, 0);
} else {
lastMouseClickCount=0;
lastMousePressed=0;
@@ -463,13 +464,15 @@ public abstract class Window implements NativeWindow
} else if(MouseEvent.EVENT_MOUSE_MOVED==eventType) {
if (mouseButtonPressed>0) {
e = new MouseEvent(true, MouseEvent.EVENT_MOUSE_DRAGGED, this, when,
- modifiers, x, y, 1, mouseButtonPressed);
+ modifiers, x, y, 1, mouseButtonPressed, 0);
} else {
e = new MouseEvent(true, eventType, this, when,
- modifiers, x, y, 0, button);
+ modifiers, x, y, 0, button, 0);
}
+ } else if(MouseEvent.EVENT_MOUSE_WHEEL_MOVED==eventType) {
+ e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button, rotation);
} else {
- e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button);
+ e = new MouseEvent(true, eventType, this, when, modifiers, x, y, 0, button, 0);
}
if(DEBUG_MOUSE_EVENT) {
@@ -510,6 +513,9 @@ public abstract class Window implements NativeWindow
case MouseEvent.EVENT_MOUSE_DRAGGED:
l.mouseDragged(e);
break;
+ case MouseEvent.EVENT_MOUSE_WHEEL_MOVED:
+ l.mouseWheelMoved(e);
+ break;
default:
throw new NativeWindowException("Unexpected mouse event type " + e.getEventType());
}
diff --git a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
index bd29d7576..9e539da8a 100644
--- a/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/awt/AWTWindow.java
@@ -189,10 +189,16 @@ public class AWTWindow extends Window {
case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_RELEASED:
case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_MOVED:
case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_DRAGGED:
+ case com.sun.javafx.newt.MouseEvent.EVENT_MOUSE_WHEEL_MOVED:
if ((eventMask & com.sun.javafx.newt.EventListener.MOUSE) != 0) {
MouseEvent e = (MouseEvent) w.getEvent();
+ int rotation = 0;
+ if (e instanceof MouseWheelEvent) {
+ rotation = ((MouseWheelEvent)e).getWheelRotation();
+ }
sendMouseEvent(w.getType(), convertModifiers(e),
- e.getX(), e.getY(), convertButton(e));
+ e.getX(), e.getY(), convertButton(e),
+ rotation);
}
break;