OSDN Git Service

2005-04-27 Roman Kennke <roman@kennke.org>
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Apr 2005 18:01:09 +0000 (18:01 +0000)
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Apr 2005 18:01:09 +0000 (18:01 +0000)
* 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.

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

* javax/swing/plaf/metal/MetalLookAndFeel
(initComponentDefaults): Added some default colors.

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

* javax/swing/plaf/basic/BasicScrollBarUI.java
(configureScrollBarColors: Changed key 'ScrollBar.thumbLightShadow'
to 'ScrollBar.thumbShadow'. The formes does not exist.
(paintThumb): Use BasicGraphicsUtils for painting the thumb.

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

* java/awt/MediaTracker.java: Added 2005 to copyright statement.
* javax/swing/BoxLayout.java: Likewise.
* javax/swing/UIManager.java: Likewise.
* javax/swing/plaf/basic/BasicButtonListener.java: Likewise.
* javax/swing/plaf/basic/BasicGraphicsUtils.java: Likewise.
* javax/swing/plaf/basic/BasicLookAndFeel.java: Likewise.
* javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise.
* javax/swing/plaf/basic/BasicScrollPaneUI.java: Likewise.
* javax/swing/plaf/metal/MetalLookAndFeel.java: Likewise.
* javax/swing/text/Document.java: Likewise.
* javax/swing/text/GapContent.java: Likewise.
* javax/swing/text/SimpleAttributeSet.java: Likewise.
* javax/swing/tree/DefaultTreeSelectionModel.java: Likewise.

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

* javax/swing/plaf/basic/BasicToggleButtonUI.java:
(getPropertyPrefix): Added.

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

* javax/swing/plaf/basic/BasicButtonUI.java
(getPropertyPrefix): Added.
(installDefaults): Use getPropertyPrefix instead of hard-coded
prefix.

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

* javax/swing/JToggleButton.java
(JToggleButton): Removed horizontalAlignment setting, this
was wrong. Added setting of an actionCommand, ToggleButtons
have "" as default actionCommand.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98867 138bc75d-0d04-0410-961f-82ee72b054a4

19 files changed:
libjava/ChangeLog
libjava/java/awt/MediaTracker.java
libjava/javax/swing/BoxLayout.java
libjava/javax/swing/JToggleButton.java
libjava/javax/swing/UIManager.java
libjava/javax/swing/plaf/basic/BasicButtonListener.java
libjava/javax/swing/plaf/basic/BasicButtonUI.java
libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java
libjava/javax/swing/plaf/basic/BasicLookAndFeel.java
libjava/javax/swing/plaf/basic/BasicMenuItemUI.java
libjava/javax/swing/plaf/basic/BasicScrollBarUI.java
libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java
libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java
libjava/javax/swing/plaf/metal/MetalLookAndFeel.java
libjava/javax/swing/plaf/metal/MetalScrollBarUI.java
libjava/javax/swing/text/Document.java
libjava/javax/swing/text/GapContent.java
libjava/javax/swing/text/SimpleAttributeSet.java
libjava/javax/swing/tree/DefaultTreeSelectionModel.java

index 871eae9..35ab1d9 100644 (file)
@@ -1,3 +1,61 @@
+2005-04-27  Roman Kennke  <roman@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.
+
+2005-04-27  Roman Kennke  <roman@kennke.org>
+
+       * javax/swing/plaf/metal/MetalLookAndFeel
+       (initComponentDefaults): Added some default colors.
+
+2005-04-27  Roman Kennke  <roman@kennke.org>
+
+       * javax/swing/plaf/basic/BasicScrollBarUI.java
+       (configureScrollBarColors: Changed key 'ScrollBar.thumbLightShadow'
+       to 'ScrollBar.thumbShadow'. The formes does not exist.
+       (paintThumb): Use BasicGraphicsUtils for painting the thumb.
+
+2005-04-27  Roman Kennke  <roman@kennke.org>
+
+       * java/awt/MediaTracker.java: Added 2005 to copyright statement.
+       * javax/swing/BoxLayout.java: Likewise.
+       * javax/swing/UIManager.java: Likewise.
+       * javax/swing/plaf/basic/BasicButtonListener.java: Likewise.
+       * javax/swing/plaf/basic/BasicGraphicsUtils.java: Likewise.
+       * javax/swing/plaf/basic/BasicLookAndFeel.java: Likewise.
+       * javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise.
+       * javax/swing/plaf/basic/BasicScrollPaneUI.java: Likewise.
+       * javax/swing/plaf/metal/MetalLookAndFeel.java: Likewise.
+       * javax/swing/text/Document.java: Likewise.
+       * javax/swing/text/GapContent.java: Likewise.
+       * javax/swing/text/SimpleAttributeSet.java: Likewise.
+       * javax/swing/tree/DefaultTreeSelectionModel.java: Likewise.
+
+2005-04-27  Roman Kennke  <roman@kennke.org>
+
+       * javax/swing/plaf/basic/BasicToggleButtonUI.java:
+       (getPropertyPrefix): Added.
+
+2005-04-27  Roman Kennke  <roman@kennke.org>
+
+       * javax/swing/plaf/basic/BasicButtonUI.java
+       (getPropertyPrefix): Added.
+       (installDefaults): Use getPropertyPrefix instead of hard-coded
+       prefix.
+
+2005-04-27  Roman Kennke  <roman@kennke.org>
+
+       * javax/swing/JToggleButton.java
+       (JToggleButton): Removed horizontalAlignment setting, this
+       was wrong. Added setting of an actionCommand, ToggleButtons
+       have "" as default actionCommand.
+
 2005-04-27  Michael Koch  <konqueror@gmx.de>
 
        * java/nio/charset/Charset.java (providers2): Renamed from 'providers'
index 2c51fbd..d36461b 100644 (file)
@@ -1,5 +1,5 @@
 /* MediaTracker.java -- Class used for keeping track of images
-   Copyright (C) 1999, 2002i, 2004  Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 1edffe1..fcb4611 100644 (file)
@@ -1,5 +1,5 @@
 /* BoxLayout.java -- A layout for swing components.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 41eab07..4e18c43 100644 (file)
@@ -243,9 +243,9 @@ public class JToggleButton extends AbstractButton implements Accessible
   {
     super(text, icon);
 
-    horizontalAlignment = LEADING;
     setModel(new ToggleButtonModel()); 
     model.setSelected(selected);
+    model.setActionCommand("");
   }
 
   /**
index dee67d9..ba9f490 100644 (file)
@@ -1,5 +1,5 @@
 /* UIManager.java -- 
-   Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 350db3b..3a81e3f 100644 (file)
@@ -1,5 +1,5 @@
 /* BasicButtonListener.java --
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 15b715b..6c0ac38 100644 (file)
@@ -107,17 +107,29 @@ public class BasicButtonUI extends ButtonUI
     textShiftOffset = defaultTextShiftOffset;
   }
 
+  /**
+   * Returns the prefix for the UI defaults property for this UI class.
+   * This is &apos;Button&apos; for this class.
+   *
+   * @return the prefix for the UI defaults property
+   */
+  protected String getPropertyPrefix()
+  {
+    return "Button";
+  }
+
   protected void installDefaults(AbstractButton b)
   {
     UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-    focusColor = defaults.getColor("Button.focus");
-    b.setForeground(defaults.getColor("Button.foreground"));
-    b.setBackground(defaults.getColor("Button.background"));
-    b.setMargin(defaults.getInsets("Button.margin"));
-    b.setBorder(defaults.getBorder("Button.border"));
-    b.setIconTextGap(defaults.getInt("Button.textIconGap"));
+    String prefix = getPropertyPrefix();
+    focusColor = defaults.getColor(prefix + ".focus");
+    b.setForeground(defaults.getColor(prefix + ".foreground"));
+    b.setBackground(defaults.getColor(prefix + ".background"));
+    b.setMargin(defaults.getInsets(prefix + ".margin"));
+    b.setBorder(defaults.getBorder(prefix + ".border"));
+    b.setIconTextGap(defaults.getInt(prefix + ".textIconGap"));
     b.setInputMap(JComponent.WHEN_FOCUSED, 
-                  (InputMap) defaults.get("Button.focusInputMap"));
+                  (InputMap) defaults.get(prefix + ".focusInputMap"));
     b.setOpaque(true);
   }
 
index 07be39d..7eef776 100644 (file)
@@ -1,5 +1,5 @@
 /* BasicGraphicsUtils.java
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 958ce27..ee9f64b 100644 (file)
@@ -1,5 +1,5 @@
 /* BasicLookAndFeel.java --
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 50af23a..ae8b6c5 100644 (file)
@@ -1,5 +1,5 @@
 /* BasicMenuItemUI.java --
-   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index a7de701..b7c5074 100644 (file)
@@ -499,7 +499,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
     thumbColor = defaults.getColor("ScrollBar.thumb");
     thumbHighlightColor = defaults.getColor("ScrollBar.thumbHighlight");
     thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
-    thumbLightShadowColor = defaults.getColor("ScrollBar.thumbLightShadow");
+    thumbLightShadowColor = defaults.getColor("ScrollBar.thumbShadow");
   }
 
   /**
@@ -743,7 +743,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
        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 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
        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;
   }
@@ -1034,53 +1036,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
    */
   protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
   {
-    Color saved = g.getColor();
-    Point x;
-    Point y;
-    Point z;
-    Polygon lines;
-
-    g.setColor(thumbHighlightColor);
-    x = new Point(thumbBounds.x + 1, thumbBounds.y + 1);
-    y = new Point(x);
-    y.translate(thumbBounds.width - 2, 0);
-    z = new Point(x);
-    z.translate(0, thumbBounds.height - 2);
-
-    lines = new Polygon(new int[] { x.x, y.x, z.x },
-                        new int[] { x.y, y.y, z.y }, 3);
-
-    g.drawPolygon(lines);
-
-    g.setColor(thumbLightShadowColor);
-    x = new Point(thumbBounds.x + thumbBounds.width - 1,
-                  thumbBounds.y + thumbBounds.height - 1);
-    y = new Point(x);
-    y.translate(-(thumbBounds.width - 2), 0);
-    z = new Point(x);
-    z.translate(0, -(thumbBounds.height - 2));
-
-    lines = new Polygon(new int[] { x.x, y.x, z.x },
-                        new int[] { x.y, y.y, z.y }, 3);
-    g.drawPolygon(lines);
-
-    g.setColor(thumbDarkShadowColor);
-    x = new Point(thumbBounds.x + thumbBounds.width,
-                  thumbBounds.y + thumbBounds.height);
-    y = new Point(x);
-    y.translate(-thumbBounds.width, 0);
-    z = new Point(x);
-    z.translate(0, -thumbBounds.height);
-
-    lines = new Polygon(new int[] { x.x, y.x, z.x },
-                        new int[] { x.y, y.y, z.y }, 3);
-    g.drawPolygon(lines);
-
     g.setColor(thumbColor);
     g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width,
                thumbBounds.height);
 
-    g.setColor(saved);
+    BasicGraphicsUtils.drawBezel(g, thumbBounds.x, thumbBounds.y,
+                                 thumbBounds.width, thumbBounds.height,
+                                 false, false, thumbDarkShadowColor,
+                                 thumbDarkShadowColor, thumbHighlightColor,
+                                 thumbHighlightColor);
   }
 
   /**
index da924bb..938548a 100644 (file)
@@ -1,5 +1,5 @@
 /* BasicScrollPaneUI.java
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 1dc6423..677e6a5 100644 (file)
@@ -1,5 +1,5 @@
 /* BasicToggleButtonUI.java
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -48,5 +48,15 @@ public class BasicToggleButtonUI extends BasicButtonUI
     return new BasicToggleButtonUI();
   }    
 
+  /**
+   * Returns the prefix for the UI defaults property for this UI class.
+   * This is &apos;ToggleButton&apos; for this class.
+   *
+   * @return the prefix for the UI defaults property
+   */
+  protected String getPropertyPrefix()
+  {
+    return "ToggleButton";
+  }
 }
 
index edeff18..77f6835 100644 (file)
@@ -1,5 +1,5 @@
 /* MetalLookAndFeel.java
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -465,8 +465,16 @@ public class MetalLookAndFeel extends BasicLookAndFeel
     Object[] myDefaults = new Object[] {
       "Button.background", new ColorUIResource(getControl()),
       "Button.border", MetalBorders.getButtonBorder(),
+      "Button.darkShadow", new ColorUIResource(getControlDarkShadow()),
+      "Button.disabledText", new ColorUIResource(getControlDisabled()),
+      "Button.focus", new ColorUIResource(getFocusColor()),
       "Button.font", getControlTextFont(),
+      "Button.foreground", new ColorUIResource(getSystemTextColor()),
+      "Button.highlight", new ColorUIResource(getControlHighlight()),
+      "Button.light", new ColorUIResource(getControlHighlight()),
       "Button.margin", new Insets(2, 14, 2, 14),
+      "Button.select", new ColorUIResource(getPrimaryControlShadow()),
+      "Button.shadow", new ColorUIResource(getPrimaryControlShadow()),
       "CheckBox.background", new ColorUIResource(getControl()),
       "CheckBoxMenuItem.background", new ColorUIResource(getControl()),
       "ToolBar.background", new ColorUIResource(getControl()),
@@ -478,6 +486,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "TabbedPane.background", new ColorUIResource(getControl()),
       "Label.background", new ColorUIResource(getControl()),
       "Label.font", getControlTextFont(),
+      "Label.disabledForeground", new ColorUIResource(getControlDisabled()),
+      "Label.foreground", new ColorUIResource(getSystemTextColor()),
       "Menu.background", new ColorUIResource(getControl()),
       "Menu.font", getControlTextFont(),
       "MenuBar.background", new ColorUIResource(getControl()),
@@ -485,6 +495,12 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "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 e89ccc6..17ac88b 100644 (file)
@@ -38,9 +38,14 @@ exception statement from your version. */
 
 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 @@ public class MetalScrollBarUI
   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;
@@ -84,4 +92,74 @@ public class MetalScrollBarUI
 
     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;
+  }
 }
index 31aded6..d299f68 100644 (file)
@@ -1,5 +1,5 @@
 /* Document.java --
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index ea088dd..a22aeed 100644 (file)
@@ -1,5 +1,5 @@
 /* GapContent.java --
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 1578a48..c3b7b08 100644 (file)
@@ -1,5 +1,5 @@
 /* SimpleAttributeSet.java --
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
index 77cc0dd..d53de53 100644 (file)
@@ -1,5 +1,5 @@
 /* DefaultTreeSelectionModel.java --
-   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.