[kaffe] CVS kaffe (robilad): resynced with gnu classpath: swing fixes

Kaffe CVS cvs-commits at kaffe.org
Sun May 15 04:27:05 PDT 2005


PatchSet 6485 
Date: 2005/05/15 11:20:50
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
resynced with gnu classpath: swing fixes

2005-05-15  Dalibor Topic  <robilad at kaffe.org>

        Resynced with GNU Classpath.

        2005-04-27  Roman Kennke  <roman at kennke.org>

        * javax/swing/plaf/basic/BasicScrollBarUI
        (getThumbBounds): Do not make thumb smaller than
        minimumThumbSize.
        * javax/swing/plaf/metal/MetalLookAndFeel
        (initComponentDefaults): Added color defaults for ScrollBar.
        * javax/swing/plaf/metal/MetalScrollBarUI
        (paintThumb): Added.
        (getMinimumThumbSize): Added.

Members: 
	libraries/javalib/javax/swing/plaf/basic/BasicScrollBarUI.java:1.13->1.14 
	libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java:1.8->1.9 
	libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java:1.1->1.2 

Index: kaffe/libraries/javalib/javax/swing/plaf/basic/BasicScrollBarUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/basic/BasicScrollBarUI.java:1.13 kaffe/libraries/javalib/javax/swing/plaf/basic/BasicScrollBarUI.java:1.14
--- kaffe/libraries/javalib/javax/swing/plaf/basic/BasicScrollBarUI.java:1.13	Sun May 15 11:07:04 2005
+++ kaffe/libraries/javalib/javax/swing/plaf/basic/BasicScrollBarUI.java	Sun May 15 11:20:50 2005
@@ -743,7 +743,8 @@
 	thumbRect.x += (value - min) * trackRect.width / (max - min);
 	thumbRect.y = trackRect.y;
 
-	thumbRect.width = extent * trackRect.width / (max - min);
+	thumbRect.width = Math.max(extent * trackRect.width / (max - min),
+                                   getMinimumThumbSize().width);
 	thumbRect.height = trackRect.height;
       }
     else
@@ -752,7 +753,8 @@
 	thumbRect.y = trackRect.y + value * trackRect.height / (max - min);
 
 	thumbRect.width = trackRect.width;
-	thumbRect.height = extent * trackRect.height / (max - min);
+	thumbRect.height = Math.max(extent * trackRect.height / (max - min),
+                                    getMinimumThumbSize().height);
       }
     return thumbRect;
   }
Index: kaffe/libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java:1.8 kaffe/libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java:1.9
--- kaffe/libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java:1.8	Sun May 15 11:15:55 2005
+++ kaffe/libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java	Sun May 15 11:20:50 2005
@@ -494,6 +494,12 @@
       "MenuItem.background", new ColorUIResource(getControl()),
       "MenuItem.font", getControlTextFont(),
       "ScrollBar.background", new ColorUIResource(getControl()),
+      "ScrollBar.shadow", new ColorUIResource(getControlShadow()),
+      "ScrollBar.thumb", new ColorUIResource(getPrimaryControlShadow()),
+      "ScrollBar.thumbDarkShadow",
+      new ColorUIResource(getPrimaryControlDarkShadow()),
+      "ScrollBar.thumbHighlight",
+      new ColorUIResource(getPrimaryControl()),
       "PopupMenu.border", new MetalBorders.PopupMenuBorder()
     };
     defaults.putDefaults(myDefaults);
Index: kaffe/libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java
diff -u kaffe/libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java:1.1 kaffe/libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java:1.2
--- kaffe/libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java:1.1	Tue Apr 19 18:43:23 2005
+++ kaffe/libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java	Sun May 15 11:20:50 2005
@@ -38,9 +38,14 @@
 
 package javax.swing.plaf.metal;
 
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
 import java.util.HashMap;
 
 import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicScrollBarUI;
 
@@ -48,6 +53,9 @@
   extends BasicScrollBarUI
 {
 
+  /** The minimum thumb size */
+  private static final Dimension MIN_THUMB_SIZE = new Dimension(18, 18);
+
   // FIXME: maybe replace by a Map of instances when this becomes stateful
   /** The shared UI instance for JScrollBars. */
   private static HashMap instances = null;
@@ -83,5 +91,75 @@
       instance = (MetalScrollBarUI) o;
 
     return instance;
+  }
+
+  /**
+   * Paints the slider button of the ScrollBar.
+   *
+   * @param g the Graphics context to use
+   * @param c the JComponent on which we paint
+   * @param thumbBounds the rectangle that is the slider button
+   */
+  protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
+  {
+    // first we fill the background
+    g.setColor(thumbColor);
+    g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width,
+               thumbBounds.height);
+
+    // draw the outer dark line
+    g.setColor(thumbDarkShadowColor);
+    g.drawRect(thumbBounds.x, thumbBounds.y, thumbBounds.width - 1,
+               thumbBounds.height - 1);
+
+    // draw the inner light line
+    g.setColor(thumbHighlightColor);
+    g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1,
+               thumbBounds.x + thumbBounds.width - 2,
+               thumbBounds.y + 1);
+    g.drawLine(thumbBounds.x + 1, thumbBounds.y + 1,
+               thumbBounds.x + 1,
+               thumbBounds.y + thumbBounds.height - 2);
+
+    // draw the shadow line
+    UIDefaults def = UIManager.getLookAndFeelDefaults();
+    g.setColor(def.getColor("ScrollBar.shadow"));
+    g.drawLine(thumbBounds.x + 1, thumbBounds.y + thumbBounds.height,
+               thumbBounds.x + thumbBounds.width,
+               thumbBounds.y + thumbBounds.height);
+
+    // draw the pattern
+    int xOff = 0;
+    for (int y = thumbBounds.y + 4;
+         y < (thumbBounds.y + thumbBounds.height - 4); y++)
+      {
+        // set color alternating with every line
+        if ((y % 2) == 0)
+          g.setColor(thumbHighlightColor);
+        else
+          g.setColor(thumbDarkShadowColor);
+
+        for (int x = thumbBounds.x + 3 + (xOff);
+             x < (thumbBounds.x + thumbBounds.width - 3); x = x + 4)
+          {
+            g.drawLine(x, y, x, y);
+          }
+
+        // increase x offset
+        xOff++;
+        if (xOff > 3)
+          xOff = 0;
+
+      }
+  }
+
+  /**
+   * This method returns the minimum thumb size.
+   *
+   * @return The minimum thumb size.
+   */
+  protected Dimension getMinimumThumbSize()
+  {
+    return MIN_THUMB_SIZE;
   }
 }




More information about the kaffe mailing list