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.

From-SVN: r98867
This commit is contained in:
Roman Kennke 2005-04-27 18:01:09 +00:00 committed by Michael Koch
parent 32cd8777cf
commit ba8e51e4e3
19 changed files with 206 additions and 68 deletions

View 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'

View 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.

View 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.

View 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("");
}
/**

View 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.

View 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.

View 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);
}

View 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.

View 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.

View 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.

View 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);
}
/**

View 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.

View 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";
}
}

View 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);

View 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;
}
}

View 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.

View 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.

View 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.

View 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.