diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-27 18:01:09 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-27 18:01:09 +0000 |
commit | cd2c3eea42ea3ce8cb91d7783e99c2c7ba7f4f37 (patch) | |
tree | 7bbfb839ee001e8c93563e05e0d0e3198f0fcf52 /libjava/javax | |
parent | 2e413f4e4712cb3ceeb655e09822ca94c9b262c0 (diff) | |
download | gcc-cd2c3eea42ea3ce8cb91d7783e99c2c7ba7f4f37.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98867 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/javax')
17 files changed, 147 insertions, 67 deletions
diff --git a/libjava/javax/swing/BoxLayout.java b/libjava/javax/swing/BoxLayout.java index 1edffe19973..fcb4611a597 100644 --- a/libjava/javax/swing/BoxLayout.java +++ b/libjava/javax/swing/BoxLayout.java @@ -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. diff --git a/libjava/javax/swing/JToggleButton.java b/libjava/javax/swing/JToggleButton.java index 41eab07b53c..4e18c438a76 100644 --- a/libjava/javax/swing/JToggleButton.java +++ b/libjava/javax/swing/JToggleButton.java @@ -243,9 +243,9 @@ public class JToggleButton extends AbstractButton implements Accessible { super(text, icon); - horizontalAlignment = LEADING; setModel(new ToggleButtonModel()); model.setSelected(selected); + model.setActionCommand(""); } /** diff --git a/libjava/javax/swing/UIManager.java b/libjava/javax/swing/UIManager.java index dee67d9762e..ba9f490da01 100644 --- a/libjava/javax/swing/UIManager.java +++ b/libjava/javax/swing/UIManager.java @@ -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. diff --git a/libjava/javax/swing/plaf/basic/BasicButtonListener.java b/libjava/javax/swing/plaf/basic/BasicButtonListener.java index 350db3bedd8..3a81e3ff91c 100644 --- a/libjava/javax/swing/plaf/basic/BasicButtonListener.java +++ b/libjava/javax/swing/plaf/basic/BasicButtonListener.java @@ -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. diff --git a/libjava/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/javax/swing/plaf/basic/BasicButtonUI.java index 15b715b3a7c..6c0ac38b86b 100644 --- a/libjava/javax/swing/plaf/basic/BasicButtonUI.java +++ b/libjava/javax/swing/plaf/basic/BasicButtonUI.java @@ -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 'Button' 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); } diff --git a/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java b/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java index 07be39d0652..7eef7760f98 100644 --- a/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java +++ b/libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java @@ -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. diff --git a/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java index 958ce277dbc..ee9f64b6f56 100644 --- a/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/libjava/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -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. diff --git a/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java b/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java index 50af23ac641..ae8b6c54c9d 100644 --- a/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java +++ b/libjava/javax/swing/plaf/basic/BasicMenuItemUI.java @@ -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. diff --git a/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java b/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java index a7de70101dc..b7c5074aad5 100644 --- a/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java +++ b/libjava/javax/swing/plaf/basic/BasicScrollBarUI.java @@ -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); } /** diff --git a/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java b/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java index da924bb49c8..938548aeb58 100644 --- a/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java +++ b/libjava/javax/swing/plaf/basic/BasicScrollPaneUI.java @@ -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. diff --git a/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java b/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java index 1dc6423ee76..677e6a575d3 100644 --- a/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java +++ b/libjava/javax/swing/plaf/basic/BasicToggleButtonUI.java @@ -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 'ToggleButton' for this class. + * + * @return the prefix for the UI defaults property + */ + protected String getPropertyPrefix() + { + return "ToggleButton"; + } } diff --git a/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java index edeff18247a..77f683516d4 100644 --- a/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java +++ b/libjava/javax/swing/plaf/metal/MetalLookAndFeel.java @@ -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); diff --git a/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java b/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java index e89ccc6a422..17ac88bc79d 100644 --- a/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java +++ b/libjava/javax/swing/plaf/metal/MetalScrollBarUI.java @@ -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; + } } diff --git a/libjava/javax/swing/text/Document.java b/libjava/javax/swing/text/Document.java index 31aded6584c..d299f68a24f 100644 --- a/libjava/javax/swing/text/Document.java +++ b/libjava/javax/swing/text/Document.java @@ -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. diff --git a/libjava/javax/swing/text/GapContent.java b/libjava/javax/swing/text/GapContent.java index ea088dd2ade..a22aeed51a7 100644 --- a/libjava/javax/swing/text/GapContent.java +++ b/libjava/javax/swing/text/GapContent.java @@ -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. diff --git a/libjava/javax/swing/text/SimpleAttributeSet.java b/libjava/javax/swing/text/SimpleAttributeSet.java index 1578a48ab27..c3b7b082048 100644 --- a/libjava/javax/swing/text/SimpleAttributeSet.java +++ b/libjava/javax/swing/text/SimpleAttributeSet.java @@ -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. diff --git a/libjava/javax/swing/tree/DefaultTreeSelectionModel.java b/libjava/javax/swing/tree/DefaultTreeSelectionModel.java index 77cc0dd5d43..d53de53aa5e 100644 --- a/libjava/javax/swing/tree/DefaultTreeSelectionModel.java +++ b/libjava/javax/swing/tree/DefaultTreeSelectionModel.java @@ -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. |