diff options
author | Mark Wielaard <mark@klomp.org> | 2006-02-21 16:37:29 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2006-02-21 16:37:29 +0000 |
commit | 57efe4b85b21c948f48c37ad6baec069346ddee8 (patch) | |
tree | 2f861fb2a25f41df3614bbe72e157b4bdbb538ee | |
parent | d20b58b39aff46e68b488487ba30c44bb32e4797 (diff) | |
download | classpath-57efe4b85b21c948f48c37ad6baec069346ddee8.tar.gz |
* java/awt/Component.java (translateEvent): Translate
AdjustmentEvents to 1.0 Events.
* java/awt/Scrollbar.java (dispatchEventImpl): Set valueIsAdjusting.
Call setValue() before processing event.
* gnu/java/awt/peer/gtk/GtkScrollbarPeer.java (setValues): Check
whether we are currently changing and being called back from the
Scrollbar component.
(setBarValues): New native method.
(postAdjustmentEvent): Mark AdjustmentEvent as user generated.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c
(Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues): Renamed to
Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValue
* include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h: Regenerated.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | gnu/java/awt/peer/gtk/GtkScrollbarPeer.java | 22 | ||||
-rw-r--r-- | include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h | 2 | ||||
-rw-r--r-- | java/awt/Component.java | 23 | ||||
-rw-r--r-- | java/awt/Scrollbar.java | 30 | ||||
-rw-r--r-- | native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c | 4 |
6 files changed, 84 insertions, 13 deletions
@@ -1,3 +1,19 @@ +2006-02-21 Mark Wielaard <mark@klomp.org> + + * java/awt/Component.java (translateEvent): Translate + AdjustmentEvents to 1.0 Events. + * java/awt/Scrollbar.java (dispatchEventImpl): Set valueIsAdjusting. + Call setValue() before processing event. + * gnu/java/awt/peer/gtk/GtkScrollbarPeer.java (setValues): Check + whether we are currently changing and being called back from the + Scrollbar component. + (setBarValues): New native method. + (postAdjustmentEvent): Mark AdjustmentEvent as user generated. + * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c + (Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues): Renamed to + Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValue + * include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h: Regenerated. + 2006-02-21 Roman Kennke <kennke@aicas.com> * javax/swing/text/View.java diff --git a/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java b/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java index aa3a26e34..9b31a7390 100644 --- a/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java +++ b/gnu/java/awt/peer/gtk/GtkScrollbarPeer.java @@ -1,5 +1,5 @@ /* GtkScrollbarPeer.java -- Implements ScrollbarPeer with GTK+ - Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,6 +39,7 @@ exception statement from your version. */ package gnu.java.awt.peer.gtk; import java.awt.Adjustable; +import java.awt.EventQueue; import java.awt.Scrollbar; import java.awt.event.AdjustmentEvent; import java.awt.peer.ScrollbarPeer; @@ -69,12 +70,25 @@ public class GtkScrollbarPeer extends GtkComponentPeer public native void setLineIncrement(int amount); public native void setPageIncrement(int amount); - public native void setValues(int value, int visible, int min, int max); + public void setValues(int value, int visible, int min, int max) + { + Scrollbar sb = (Scrollbar) awtComponent; + if (!sb.getValueIsAdjusting()) + setBarValues(value, visible, min, max); + } + + private native void setBarValues(int value, int visible, int min, int max); + + /** + * Called from the native site when the scrollbar changed. + * Posts a "user generated" AdjustmentEvent to the queue. + */ protected void postAdjustmentEvent (int type, int value) { - q().postEvent (new AdjustmentEvent ((Adjustable)awtComponent, + Scrollbar bar = (Scrollbar) awtComponent; + q().postEvent(new AdjustmentEvent(bar, AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED, - type, value)); + type, value, true)); } } diff --git a/include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h b/include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h index b3e52027b..397035010 100644 --- a/include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h +++ b/include/gnu_java_awt_peer_gtk_GtkScrollbarPeer.h @@ -14,7 +14,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_create (JNIEn JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_connectSignals (JNIEnv *env, jobject); JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setLineIncrement (JNIEnv *env, jobject, jint); JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setPageIncrement (JNIEnv *env, jobject, jint); -JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues (JNIEnv *env, jobject, jint, jint, jint, jint); +JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValues (JNIEnv *env, jobject, jint, jint, jint, jint); #ifdef __cplusplus } diff --git a/java/awt/Component.java b/java/awt/Component.java index b606ca5c4..3c1458814 100644 --- a/java/awt/Component.java +++ b/java/awt/Component.java @@ -1,5 +1,6 @@ /* Component.java -- a graphics component - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006 + Free Software Foundation This file is part of GNU Classpath. @@ -40,6 +41,7 @@ package java.awt; import java.awt.dnd.DropTarget; import java.awt.event.ActionEvent; +import java.awt.event.AdjustmentEvent; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.FocusEvent; @@ -4876,6 +4878,25 @@ p * <li>the set of backward traversal keys 0, 0, oldKey, oldMods); } } + else if (e instanceof AdjustmentEvent) + { + AdjustmentEvent ae = (AdjustmentEvent) e; + int type = ae.getAdjustmentType(); + int oldType; + if (type == AdjustmentEvent.BLOCK_DECREMENT) + oldType = Event.SCROLL_PAGE_UP; + else if (type == AdjustmentEvent.BLOCK_INCREMENT) + oldType = Event.SCROLL_PAGE_DOWN; + else if (type == AdjustmentEvent.TRACK) + oldType = Event.SCROLL_ABSOLUTE; + else if (type == AdjustmentEvent.UNIT_DECREMENT) + oldType = Event.SCROLL_LINE_UP; + else if (type == AdjustmentEvent.UNIT_INCREMENT) + oldType = Event.SCROLL_LINE_DOWN; + else + oldType = type; + translated = new Event(target, oldType, new Integer(ae.getValue())); + } else if (e instanceof ActionEvent) translated = new Event (target, Event.ACTION_EVENT, ((ActionEvent) e).getActionCommand ()); diff --git a/java/awt/Scrollbar.java b/java/awt/Scrollbar.java index 6e506c785..c0788370b 100644 --- a/java/awt/Scrollbar.java +++ b/java/awt/Scrollbar.java @@ -1,5 +1,5 @@ /* Scrollbar.java -- AWT Scrollbar widget - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -593,13 +593,33 @@ public class Scrollbar extends Component implements Accessible, Adjustable adjustment_listeners.adjustmentValueChanged(event); } + /** + * Package private method to determine whether to call + * processEvent() or not. Will handle events from peer and update + * the current value. + */ void dispatchEventImpl(AWTEvent e) { if (e.id <= AdjustmentEvent.ADJUSTMENT_LAST - && e.id >= AdjustmentEvent.ADJUSTMENT_FIRST - && (adjustment_listeners != null - || (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0)) - processEvent(e); + && e.id >= AdjustmentEvent.ADJUSTMENT_FIRST) + { + AdjustmentEvent ae = (AdjustmentEvent) e; + boolean adjusting = ae.getValueIsAdjusting(); + if (adjusting) + setValueIsAdjusting(true); + try + { + setValue(((AdjustmentEvent) e).getValue()); + if (adjustment_listeners != null + || (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0) + processEvent(e); + } + finally + { + if (adjusting) + setValueIsAdjusting(false); + } + } else super.dispatchEventImpl(e); } diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c index c570adc4e..bec1e63c4 100644 --- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c +++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollbarPeer.c @@ -1,5 +1,5 @@ /* gtkscrollbarpeer.c -- Native implementation of GtkScrollbarPeer - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -179,7 +179,7 @@ Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setPageIncrement } JNIEXPORT void JNICALL -Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setValues +Java_gnu_java_awt_peer_gtk_GtkScrollbarPeer_setBarValues (JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max) { void *ptr; |