[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: AWT fixes from 30th
Kaffe CVS
cvs-commits at kaffe.org
Mon Oct 4 04:11:54 PDT 2004
PatchSet 5242
Date: 2004/10/04 11:03:04
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: AWT fixes from 30th
2004-10-04 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/awt/image/RescaleOp.java,
libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java,
libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java:
Resynced with GNU Classpath.
2004-09-30 Olga Rodimina <rodimina at redhat.com>
* javax/swing/plaf/basic/BasicComboPopup.java
(SCROLL_DOWN): made final.
(SCROLL_UP): made final.
2004-09-30 Jerry Quinn <jlquinn at optonline.net>
* java/awt/image/RescaleOp.java: Fix formatting.
2004-09-30 Tom Tromey <tromey at redhat.com>
* javax/swing/plaf/basic/BasicOptionPaneUI.java (MessageIcon):
Renamed from 'messageIcon'.
(errorIcon, infoIcon, warningIcon, questionIcon): Updated.
Members:
ChangeLog:1.2796->1.2797
libraries/javalib/java/awt/image/RescaleOp.java:1.1->1.2
libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java:1.2->1.3
libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java:1.3->1.4
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2796 kaffe/ChangeLog:1.2797
--- kaffe/ChangeLog:1.2796 Mon Oct 4 10:13:43 2004
+++ kaffe/ChangeLog Mon Oct 4 11:03:04 2004
@@ -1,5 +1,28 @@
2004-10-04 Dalibor Topic <robilad at kaffe.org>
+ * libraries/javalib/java/awt/image/RescaleOp.java,
+ libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java,
+ libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java:
+ Resynced with GNU Classpath.
+
+ 2004-09-30 Olga Rodimina <rodimina at redhat.com>
+
+ * javax/swing/plaf/basic/BasicComboPopup.java
+ (SCROLL_DOWN): made final.
+ (SCROLL_UP): made final.
+
+ 2004-09-30 Jerry Quinn <jlquinn at optonline.net>
+
+ * java/awt/image/RescaleOp.java: Fix formatting.
+
+ 2004-09-30 Tom Tromey <tromey at redhat.com>
+
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java (MessageIcon):
+ Renamed from 'messageIcon'.
+ (errorIcon, infoIcon, warningIcon, questionIcon): Updated.
+
+2004-10-04 Dalibor Topic <robilad at kaffe.org>
+
* libraries/javalib/java/net/URLConnection.java,
libraries/javalib/java/text/MessageFormat.java,
libraries/javalib/javax/crypto/MacSpi.java:
Index: kaffe/libraries/javalib/java/awt/image/RescaleOp.java
diff -u kaffe/libraries/javalib/java/awt/image/RescaleOp.java:1.1 kaffe/libraries/javalib/java/awt/image/RescaleOp.java:1.2
--- kaffe/libraries/javalib/java/awt/image/RescaleOp.java:1.1 Mon Oct 4 09:01:37 2004
+++ kaffe/libraries/javalib/java/awt/image/RescaleOp.java Mon Oct 4 11:03:10 2004
@@ -85,17 +85,24 @@
return offsets;
}
- public final int getNumFactors() { return scale.length; }
+ public final int getNumFactors()
+ {
+ return scale.length;
+ }
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getRenderingHints()
*/
- public RenderingHints getRenderingHints() { return hints; }
+ public RenderingHints getRenderingHints()
+ {
+ return hints;
+ }
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
*/
- public BufferedImage filter(BufferedImage src, BufferedImage dst) {
+ public BufferedImage filter(BufferedImage src, BufferedImage dst)
+ {
// TODO Make sure premultiplied alpha is handled correctly.
// TODO See that color conversion is handled.
// TODO figure out how to use rendering hints.
@@ -127,7 +134,8 @@
/* (non-Javadoc)
* @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
*/
- public WritableRaster filter(Raster src, WritableRaster dest) {
+ public WritableRaster filter(Raster src, WritableRaster dest)
+ {
if (dest == null) dest = src.createCompatibleWritableRaster();
// Required sanity checks
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java:1.2 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java:1.3
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java:1.2 Mon Sep 27 17:41:12 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicComboPopup.java Mon Oct 4 11:03:10 2004
@@ -39,6 +39,7 @@
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@@ -58,10 +59,12 @@
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPopupMenu;
+import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
@@ -78,37 +81,32 @@
*/
public class BasicComboPopup extends JPopupMenu implements ComboPopup
{
+ /* Timer for autoscrolling */
protected Timer autoscrollTimer;
- /**
- * ComboBox associated with this popup
- */
+ /** ComboBox associated with this popup */
protected JComboBox comboBox;
- /*
- * FIXME: Document fields below
- */
+ /** FIXME: Need to document */
protected boolean hasEntered;
- protected boolean isAutoScrolling;
/**
- * ItemListener listening to the selection changes in the combo box
+ * Indicates whether the scroll bar located in popup menu with comboBox's
+ * list of items is currently autoscrolling. This happens when mouse event
+ * originated in the combo box and is dragged outside of its bounds
*/
+ protected boolean isAutoScrolling;
+
+ /** ItemListener listening to the selection changes in the combo box */
protected ItemListener itemListener;
- /**
- * This listener is not used
- */
+ /** This listener is not used */
protected KeyListener keyListener;
- /**
- * JList which is used to display item is the combo box
- */
+ /** JList which is used to display item is the combo box */
protected JList list;
- /**
- * This listener is not used
- */
+ /** This listener is not used */
protected ListDataListener listDataListener;
/**
@@ -123,14 +121,10 @@
*/
protected MouseMotionListener listMouseMotionListener;
- /**
- * This listener is not used
- */
+ /** This listener is not used */
protected ListSelectionListener listSelectionListener;
- /**
- * MouseListener listening to mouse events occuring in the combo box
- */
+ /** MouseListener listening to mouse events occuring in the combo box */
protected MouseListener mouseListener;
/**
@@ -145,21 +139,19 @@
*/
protected PropertyChangeListener propertyChangeListener;
- /*
- * FIXME: Document fields below
- */
- protected static int SCROLL_DOWN = 1;
- protected static int SCROLL_UP = 0;
+ /** direction for scrolling down list of combo box's items */
+ protected static final int SCROLL_DOWN = 1;
+
+ /** direction for scrolling up list of combo box's items */
+ protected static final int SCROLL_UP = 0;
+
+ /** Indicates auto scrolling direction */
protected int scrollDirection;
- /**
- * JScrollPane that contains list portion of the combo box
- */
+ /** JScrollPane that contains list portion of the combo box */
protected JScrollPane scroller;
- /**
- * This field is not used
- */
+ /** This field is not used */
protected boolean valueIsAdjusting;
/**
@@ -184,13 +176,21 @@
// popup should have same width as the comboBox and should be hight anough
// to display number of rows equal to 'maximumRowCount' property
- int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount())
- + 4;
+ int popupHeight = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
- // FIXME: Uncomment this out once preferred size of JList will be working
- // list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
+ list.setPreferredSize(new Dimension(cbBounds.width, popupHeight));
super.setPopupSize(cbBounds.width, popupHeight);
+ // Highlight selected item in the combo box's drop down list
+ if (comboBox.getSelectedIndex() != -1)
+ list.setSelectedIndex(comboBox.getSelectedIndex());
+
+ //scroll scrollbar s.t. selected item is visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int selectedIndex = comboBox.getSelectedIndex();
+ if (selectedIndex > comboBox.getMaximumRowCount())
+ scrollbar.setValue(getPopupHeightForRowCount(selectedIndex));
+
// location specified is relative to comboBox
super.show(comboBox, 0, cbBounds.height);
}
@@ -557,37 +557,68 @@
}
/**
- * DOCUMENT ME!
+ * This method start scrolling combo box's list of items either up or down
+ * depending on the specified 'direction'
*
- * @param direction DOCUMENT ME!
+ * @param direction of the scrolling.
*/
protected void startAutoScrolling(int direction)
{
- // FIXME: Need to implement
+ // FIXME: add timer
+ isAutoScrolling = true;
+
+ if (direction == SCROLL_UP)
+ autoScrollUp();
+ else
+ autoScrollDown();
}
/**
- * DOCUMENT ME!
+ * This method stops scrolling the combo box's list of items
*/
protected void stopAutoScrolling()
{
- // FIXME: Need to implement
+ // FIXME: add timer
+ isAutoScrolling = false;
}
/**
- * DOCUMENT ME!
+ * This method scrolls up list of combo box's items up and highlights that
+ * just became visible.
*/
protected void autoScrollUp()
{
- // FIXME: Need to implement
+ // scroll up the scroll bar to make the item above visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int scrollToNext = list.getScrollableUnitIncrement(super.getBounds(),
+ SwingConstants.VERTICAL,
+ SCROLL_UP);
+
+ scrollbar.setValue(scrollbar.getValue() - scrollToNext);
+
+ // If we haven't reached the begging of the combo box's list of items,
+ // then highlight next element above currently highlighted element
+ if (list.getSelectedIndex() != 0)
+ list.setSelectedIndex(list.getSelectedIndex() - 1);
}
/**
- * DOCUMENT ME!
+ * This method scrolls down list of combo box's and highlights item in the
+ * list that just became visible.
*/
protected void autoScrollDown()
{
- // FIXME: Need to implement
+ // scroll scrollbar down to make next item visible
+ JScrollBar scrollbar = scroller.getVerticalScrollBar();
+ int scrollToNext = list.getScrollableUnitIncrement(super.getBounds(),
+ SwingConstants.VERTICAL,
+ SCROLL_DOWN);
+ scrollbar.setValue(scrollbar.getValue() + scrollToNext);
+
+ // If we haven't reached the end of the combo box's list of items
+ // then highlight next element below currently highlighted element
+ if (list.getSelectedIndex() + 1 != comboBox.getItemCount())
+ list.setSelectedIndex(list.getSelectedIndex() + 1);
}
/**
@@ -717,15 +748,36 @@
}
/**
- * This method is invoked whenever mouse is released
+ * This method is invoked whenever mouse event was originated in the combo
+ * box and released either in the combBox list of items or in the combo
+ * box itself.
*
* @param e MouseEvent that should be handled
*/
public void mouseReleased(MouseEvent e)
{
- // FIXME: should handle dragging events here, if
- // mouse was dragged and released over the list of combobox's items,
- // then item over which it was released should be selected.
+ // Get component over which mouse was released
+ Component src = (Component) e.getSource();
+ int x = e.getX();
+ int y = e.getY();
+ Component releasedComponent = SwingUtilities.getDeepestComponentAt(src,
+ x, y);
+
+ // if mouse was released inside the bounds of combo box then do nothing,
+ // Otherwise if mouse was released inside the list of combo box items
+ // then change selection and close popup
+ if (! (releasedComponent instanceof JComboBox))
+ {
+ // List model contains the item over which mouse is released,
+ // since it is updated every time the mouse is moved over a different
+ // item in the list. Now that the mouse is released we need to
+ // update model of the combo box as well.
+ comboBox.setSelectedIndex(list.getSelectedIndex());
+
+ if (isAutoScrolling)
+ stopAutoScrolling();
+ hide();
+ }
}
}
@@ -742,13 +794,70 @@
{
}
+ /**
+ * This method is responsible for highlighting item in the drop down list
+ * over which the mouse is currently being dragged.
+ */
public void mouseDragged(MouseEvent e)
{
+ // convert point of the drag event relative to combo box list component
+ // figure out over which list cell the mouse is currently being dragged
+ // and highlight the cell. The list model is changed but the change has
+ // no effect on combo box's data model. The list model is changed so
+ // that the appropriate item would be highlighted in the combo box's
+ // list.
+ if (BasicComboPopup.this.isVisible())
+ {
+ int cbHeight = (int) comboBox.getPreferredSize().getHeight();
+ int popupHeight = BasicComboPopup.this.getSize().height;
+
+ // if mouse is dragged inside the the combo box's items list.
+ if (e.getY() > cbHeight && ! (e.getY() - cbHeight >= popupHeight))
+ {
+ int index = list.locationToIndex(new Point(e.getX(),
+ (int) (e.getY()
+ - cbHeight)));
+
+ int firstVisibleIndex = list.getFirstVisibleIndex();
+
+ // list.locationToIndex returns item's index that would
+ // be located at the specified point if the first item that
+ // is visible is item 0. However in the JComboBox it is not
+ // necessarily the case since list is contained in the
+ // JScrollPane so we need to adjust the index returned.
+ if (firstVisibleIndex != 0)
+ // FIXME: adjusted index here is off by one. I am adding one
+ // here to compensate for that. This should be
+ // index += firstVisibleIndex. Remove +1 once the bug is fixed.
+ index += firstVisibleIndex + 1;
+
+ list.setSelectedIndex(index);
+ }
+ else
+ {
+ // if mouse is being dragged at the bottom of combo box's list
+ // of items or at the very top then scroll the list in the
+ // desired direction.
+ boolean movingUP = e.getY() < cbHeight;
+ boolean movingDown = e.getY() > cbHeight;
+
+ if (movingUP)
+ {
+ scrollDirection = SCROLL_UP;
+ startAutoScrolling(SCROLL_UP);
+ }
+ else if (movingDown)
+ {
+ scrollDirection = SCROLL_DOWN;
+ startAutoScrolling(SCROLL_DOWN);
+ }
+ }
+ }
}
}
/**
- * ItemHandler is an item listener that listens to selection event occuring
+ * ItemHandler is an item listener that listens to selection events occuring
* in the combo box. FIXME: should specify here what it does when item is
* selected or deselected in the combo box list.
*/
Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java:1.3 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java:1.4
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java:1.3 Sun Aug 8 19:46:07 2004
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicOptionPaneUI.java Mon Oct 4 11:03:10 2004
@@ -475,7 +475,7 @@
* A helper class that implements Icon. This is used temporarily until
* ImageIcons are fixed.
*/
- private static class messageIcon implements Icon
+ private static class MessageIcon implements Icon
{
/**
* This method returns the width of the icon.
@@ -512,7 +512,7 @@
}
/** The icon displayed for ERROR_MESSAGE. */
- private static messageIcon errorIcon = new messageIcon()
+ private static MessageIcon errorIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
@@ -534,7 +534,7 @@
};
/** The icon displayed for INFORMATION_MESSAGE. */
- private static messageIcon infoIcon = new messageIcon()
+ private static MessageIcon infoIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
@@ -560,7 +560,7 @@
};
/** The icon displayed for WARNING_MESSAGE. */
- private static messageIcon warningIcon = new messageIcon()
+ private static MessageIcon warningIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
@@ -585,7 +585,7 @@
};
/** The icon displayed for MESSAGE_ICON. */
- private static messageIcon questionIcon = new messageIcon()
+ private static MessageIcon questionIcon = new MessageIcon()
{
public void paintIcon(Component c, Graphics g, int x, int y)
{
More information about the kaffe
mailing list