diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-08-14 23:12:35 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-08-14 23:12:35 +0000 |
commit | ac1ed908de999523efc36f38e69bca1aadfe0808 (patch) | |
tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/javax/swing/plaf/metal | |
parent | abab460491408e05ea93fb85e1975296a87df504 (diff) | |
download | gcc-ac1ed908de999523efc36f38e69bca1aadfe0808.tar.gz |
Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
From-SVN: r116139
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/metal')
8 files changed, 408 insertions, 162 deletions
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java index 6a528de2b6b..265ea7ef6ae 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java @@ -259,7 +259,9 @@ public class MetalComboBoxButton Component comp = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false); comp.setFont(rendererPane.getFont()); - if (model.isArmed() && model.isPressed()) + + if ((model.isArmed() && model.isPressed()) + || (comboBox.isFocusOwner() && !comboBox.isPopupVisible())) { if (isOpaque()) { diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java index 1219ad9fd11..824f1d8021b 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java @@ -42,6 +42,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.Graphics; import java.awt.GridLayout; import java.awt.Insets; import java.awt.LayoutManager; @@ -303,8 +304,9 @@ public class MetalFileChooserUI if (file == null) setFileName(null); - else - setFileName(file.getName()); + else if (file.isFile() || filechooser.getFileSelectionMode() + != JFileChooser.FILES_ONLY) + setFileName(file.getName()); int index = -1; index = getModel().indexOf(file); if (index >= 0) @@ -567,10 +569,17 @@ public class MetalFileChooserUI extends DefaultListCellRenderer { /** + * This is the icon that is displayed in the combobox. This wraps + * the standard icon and adds indendation. + */ + private IndentIcon indentIcon; + + /** * Creates a new renderer. */ public DirectoryComboBoxRenderer(JFileChooser fc) - { + { + indentIcon = new IndentIcon(); } /** @@ -586,31 +595,86 @@ public class MetalFileChooserUI * @return The list cell renderer. */ public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) + int index, + boolean isSelected, + boolean cellHasFocus) { - FileView fileView = getFileView(getFileChooser()); + super.getListCellRendererComponent(list, value, index, isSelected, + cellHasFocus); File file = (File) value; - setIcon(fileView.getIcon(file)); - setText(fileView.getName(file)); - - if (isSelected) - { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } - else - { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } + setText(getFileChooser().getName(file)); + + // Install indented icon. + Icon icon = getFileChooser().getIcon(file); + indentIcon.setIcon(icon); + int depth = directoryModel.getDepth(index); + indentIcon.setDepth(depth); + setIcon(indentIcon); - setEnabled(list.isEnabled()); - setFont(list.getFont()); return this; } } /** + * An icon that wraps another icon and adds indentation. + */ + class IndentIcon + implements Icon + { + + /** + * The indentation level. + */ + private static final int INDENT = 10; + + /** + * The wrapped icon. + */ + private Icon icon; + + /** + * The current depth. + */ + private int depth; + + /** + * Sets the icon to be wrapped. + * + * @param i the icon + */ + void setIcon(Icon i) + { + icon = i; + } + + /** + * Sets the indentation depth. + * + * @param d the depth to set + */ + void setDepth(int d) + { + depth = d; + } + + public int getIconHeight() + { + return icon.getIconHeight(); + } + + public int getIconWidth() + { + return icon.getIconWidth() + depth * INDENT; + } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + icon.paintIcon(c, g, x + depth * INDENT, y); + } + + } + + /** * A renderer for the files and directories in the file chooser. */ protected class FileRenderer @@ -956,9 +1020,12 @@ public class MetalFileChooserUI { String text = editField.getText(); if (text != null && text != "" && !text.equals(fc.getName(editFile))) - if (editFile.renameTo(fc.getFileSystemView().createFileObject( - fc.getCurrentDirectory(), text))) + { + File f = fc.getFileSystemView(). + createFileObject(fc.getCurrentDirectory(), text); + if ( editFile.renameTo(f) ) rescanCurrentDirectory(fc); + } list.remove(editField); } startEditing = false; @@ -982,17 +1049,8 @@ public class MetalFileChooserUI */ public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("notify-field-accept")) + if (editField != null) completeEditing(); - else if (editField != null) - { - list.remove(editField); - startEditing = false; - editFile = null; - lastSelected = null; - editField = null; - list.repaint(); - } } } } @@ -1101,7 +1159,7 @@ public class MetalFileChooserUI lastSelected = selVal; if (f.isFile()) setFileName(path.substring(path.lastIndexOf("/") + 1)); - else if (fc.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) + else if (fc.getFileSelectionMode() != JFileChooser.FILES_ONLY) setFileName(path); } fileTable.repaint(); @@ -1171,16 +1229,8 @@ public class MetalFileChooserUI */ public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("notify-field-accept")) + if (editField != null) completeEditing(); - else if (editField != null) - { - table.remove(editField); - startEditing = false; - editFile = null; - editField = null; - table.repaint(); - } } } diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java index a317e3fc00d..30ec7e72b28 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java @@ -1,5 +1,5 @@ /* MetalIconFactory.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -54,6 +54,7 @@ import javax.swing.JRadioButtonMenuItem; import javax.swing.JSlider; import javax.swing.SwingConstants; import javax.swing.UIManager; +import javax.swing.plaf.IconUIResource; import javax.swing.plaf.UIResource; @@ -78,7 +79,8 @@ public class MetalIconFactory implements Serializable /** * An icon displayed for {@link JCheckBoxMenuItem} components. */ - private static class CheckBoxMenuItemIcon implements Icon, Serializable + private static class CheckBoxMenuItemIcon + implements Icon, UIResource, Serializable { /** * Creates a new icon instance. @@ -153,7 +155,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getFileChooserDetailViewIcon() */ - private static class FileChooserDetailViewIcon implements Icon, Serializable + private static class FileChooserDetailViewIcon + implements Icon, UIResource, Serializable { /** @@ -233,7 +236,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getFileChooserHomeFolderIcon() */ - private static class FileChooserHomeFolderIcon implements Icon, Serializable + private static class FileChooserHomeFolderIcon + implements Icon, UIResource, Serializable { /** @@ -322,7 +326,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getFileChooserListViewIcon() */ - private static class FileChooserListViewIcon implements Icon, Serializable + private static class FileChooserListViewIcon + implements Icon, UIResource, Serializable { /** * Creates a new icon. @@ -418,7 +423,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getFileChooserNewFolderIcon() */ - private static class FileChooserNewFolderIcon implements Icon, Serializable + private static class FileChooserNewFolderIcon + implements Icon, UIResource, Serializable { /** * Creates a new icon. @@ -490,8 +496,7 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getFileChooserNewFolderIcon() */ - private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon - implements Icon, Serializable + private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon { /** * Creates a new icon. @@ -883,7 +888,8 @@ public class MetalIconFactory implements Serializable /** * An icon displayed for {@link JRadioButtonMenuItem} components. */ - private static class RadioButtonMenuItemIcon implements Icon, Serializable + private static class RadioButtonMenuItemIcon + implements Icon, UIResource, Serializable { /** * Creates a new icon instance. @@ -960,7 +966,8 @@ public class MetalIconFactory implements Serializable * The icon used to display the thumb control on a horizontally oriented * {@link JSlider} component. */ - private static class HorizontalSliderThumbIcon implements Icon, Serializable + private static class HorizontalSliderThumbIcon + implements Icon, UIResource, Serializable { /** @@ -1102,7 +1109,8 @@ public class MetalIconFactory implements Serializable * An icon used for the 'close' button in the title frame of a * {@link JInternalFrame}. */ - private static class InternalFrameCloseIcon implements Icon, Serializable + private static class InternalFrameCloseIcon + implements Icon, UIResource, Serializable { /** The icon size in pixels. */ private int size; @@ -1219,7 +1227,7 @@ public class MetalIconFactory implements Serializable * The icon displayed at the top-left corner of a {@link JInternalFrame}. */ private static class InternalFrameDefaultMenuIcon - implements Icon, Serializable + implements Icon, UIResource, Serializable { /** @@ -1291,7 +1299,7 @@ public class MetalIconFactory implements Serializable * provide a 'restore' option. */ private static class InternalFrameAltMaximizeIcon - implements Icon, Serializable + implements Icon, UIResource, Serializable { /** The icon size in pixels. */ private int size; @@ -1401,7 +1409,8 @@ public class MetalIconFactory implements Serializable * An icon used for the 'maximize' button in the title frame of a * {@link JInternalFrame}. */ - private static class InternalFrameMaximizeIcon implements Icon, Serializable + private static class InternalFrameMaximizeIcon + implements Icon, UIResource, Serializable { /** @@ -1513,7 +1522,8 @@ public class MetalIconFactory implements Serializable /** * An icon used in the title frame of a {@link JInternalFrame}. */ - private static class InternalFrameMinimizeIcon implements Icon, Serializable + private static class InternalFrameMinimizeIcon + implements Icon, UIResource, Serializable { /** @@ -1617,7 +1627,8 @@ public class MetalIconFactory implements Serializable * The icon used to display the thumb control on a horizontally oriented * {@link JSlider} component. */ - private static class VerticalSliderThumbIcon implements Icon, Serializable + private static class VerticalSliderThumbIcon + implements Icon, UIResource, Serializable { /** * This mask is used to paint the gradient in the shape of the thumb. @@ -1801,78 +1812,36 @@ public class MetalIconFactory implements Serializable /** * Paints the icon at the location (x, y). * - * @param c the component. - * @param g the graphics device. - * @param x the x coordinate. - * @param y the y coordinate. + * @param c the component. + * @param g the graphics device. + * @param x the x coordinate. + * @param y the y coordinate. */ - public void paintIcon(Component c, Graphics g, int x, int y) + public void paintIcon(Component c, Graphics g, int x, int y) { - x = x + 5; - y = y + 5; - if (collapsed) - { - // TODO: pick up appropriate UI colors - g.setColor(Color.black); - g.drawLine(x + 2, y, x + 5, y); - g.drawLine(x + 6, y + 1, x + 7, y + 2); - g.fillRect(x + 7, y + 3, 5, 2); - g.drawLine(x + 7, y + 5, x + 6, y + 6); - g.drawLine(x + 1, y + 1, x + 1, y + 1); - g.drawLine(x, y + 2, x, y + 5); - g.drawLine(x + 1, y + 6, x + 1, y + 6); - g.drawLine(x + 2, y + 7, x + 5, y + 7); - g.fillRect(x + 3, y + 3, 2, 2); - - g.setColor(new Color(204, 204, 255)); - g.drawLine(x + 3, y + 2, x + 4, y + 2); - g.drawLine(x + 2, y + 3, x + 2, y + 4); - g.drawLine(x + 3, y + 5, x + 3, y + 5); - g.drawLine(x + 5, y + 3, x + 5, y + 3); - - g.setColor(new Color(153, 153, 204)); - g.drawLine(x + 2, y + 2, x + 2, y + 2); - g.drawLine(x + 2, y + 5, x + 2, y + 5); - g.drawLine(x + 2, y + 6, x + 5, y + 6); - g.drawLine(x + 5, y + 2, x + 5, y + 2); - g.drawLine(x + 6, y + 2, x + 6, y + 5); - - g.setColor(new Color(102, 102, 153)); - g.drawLine(x + 2, y + 1, x + 5, y + 1); - g.drawLine(x + 1, y + 2, x + 1, y + 5); - } + // TODO: pick up appropriate UI colors + Color dark = new Color(99, 130, 191); + Color light = new Color(163, 184, 204); + Color white = Color.white; + + x += 8; + y += 6; + + final int w = 6; + final int wHalf = (w >> 2); + g.setColor(light); + g.drawOval(x, y, w, w); + g.setColor(dark); + g.fillOval(x + 1, y + 1, w - 1, w - 1); + + if (collapsed) + g.fillRect(x + w, y + wHalf + 1, w, 2); else - { - // TODO: pick up appropriate UI colors - g.setColor(Color.black); - g.drawLine(x + 2, y, x + 5, y); - g.drawLine(x + 6, y + 1, x + 7, y + 2); - g.drawLine(x + 7, y + 2, x + 7, y + 5); - g.fillRect(x + 3, y + 7, 2, 5); - g.drawLine(x + 7, y + 5, x + 6, y + 6); - g.drawLine(x + 1, y + 1, x + 1, y + 1); - g.drawLine(x, y + 2, x, y + 5); - g.drawLine(x + 1, y + 6, x + 1, y + 6); - g.drawLine(x + 2, y + 7, x + 5, y + 7); - g.fillRect(x + 3, y + 3, 2, 2); - - g.setColor(new Color(204, 204, 255)); - g.drawLine(x + 3, y + 2, x + 4, y + 2); - g.drawLine(x + 2, y + 3, x + 2, y + 4); - g.drawLine(x + 3, y + 5, x + 3, y + 5); - g.drawLine(x + 5, y + 3, x + 5, y + 3); - - g.setColor(new Color(153, 153, 204)); - g.drawLine(x + 2, y + 2, x + 2, y + 2); - g.drawLine(x + 2, y + 5, x + 2, y + 5); - g.drawLine(x + 2, y + 6, x + 5, y + 6); - g.drawLine(x + 5, y + 2, x + 5, y + 2); - g.drawLine(x + 6, y + 2, x + 6, y + 5); - - g.setColor(new Color(102, 102, 153)); - g.drawLine(x + 2, y + 1, x + 5, y + 1); - g.drawLine(x + 1, y + 2, x + 1, y + 5); - } + g.fillRect(x + wHalf + 1, y + w, 2, w); + + g.setColor(white); + g.fillRect(x + wHalf + 1, y + wHalf + 1, 2, 2); + } /** @@ -1964,7 +1933,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getTreeHardDriveIcon() */ - private static class TreeHardDriveIcon implements Icon, Serializable + private static class TreeHardDriveIcon + implements Icon, UIResource, Serializable { /** @@ -2074,7 +2044,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getTreeFloppyDriveIcon() */ - private static class TreeFloppyDriveIcon implements Icon, Serializable + private static class TreeFloppyDriveIcon + implements Icon, UIResource, Serializable { /** @@ -2150,7 +2121,8 @@ public class MetalIconFactory implements Serializable * * @see MetalIconFactory#getTreeComputerIcon() */ - private static class TreeComputerIcon implements Icon, Serializable + private static class TreeComputerIcon + implements Icon, UIResource, Serializable { /** @@ -2255,6 +2227,12 @@ public class MetalIconFactory implements Serializable /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */ private static Icon treeHardDriveIcon; + /** The icon instance returned by {@link #getHorizontalSliderThumbIcon()}. */ + private static Icon horizontalSliderThumbIcon; + + /** The icon instance returned by {@link #getVerticalSliderThumbIcon()}. */ + private static Icon verticalSliderThumbIcon; + /** * Creates a new instance. All the methods are static, so creating an * instance isn't necessary. @@ -2383,7 +2361,9 @@ public class MetalIconFactory implements Serializable */ public static Icon getHorizontalSliderThumbIcon() { - return new HorizontalSliderThumbIcon(); + if (horizontalSliderThumbIcon == null) + horizontalSliderThumbIcon = new HorizontalSliderThumbIcon(); + return horizontalSliderThumbIcon; } /** @@ -2462,7 +2442,9 @@ public class MetalIconFactory implements Serializable */ public static Icon getVerticalSliderThumbIcon() { - return new VerticalSliderThumbIcon(); + if (verticalSliderThumbIcon == null) + verticalSliderThumbIcon = new VerticalSliderThumbIcon(); + return verticalSliderThumbIcon; } /** diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java index 09eafd40fe9..8a5a61107c1 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java @@ -85,7 +85,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel } /** - * Sets the current theme to a new instance of {@link DefaultMetalTheme}. + * Sets the current theme to a new instance of {@link OceanTheme}. */ protected void createDefaultTheme() { @@ -709,6 +709,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel * @param theme the theme (<code>null</code> not permitted). * * @throws NullPointerException if <code>theme</code> is <code>null</code>. + * + * @see #getCurrentTheme() */ public static void setCurrentTheme(MetalTheme theme) { @@ -1183,20 +1185,26 @@ public class MetalLookAndFeel extends BasicLookAndFeel "SplitPaneDivider.draggingColor", Color.DARK_GRAY, "TabbedPane.background", getControlShadow(), + "TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3), + "TabbedPane.contentOpaque", Boolean.TRUE, "TabbedPane.darkShadow", getControlDarkShadow(), "TabbedPane.focus", getPrimaryControlDarkShadow(), "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12), "TabbedPane.foreground", getControlTextColor(), "TabbedPane.highlight", getControlHighlight(), "TabbedPane.light", getControl(), - "TabbedPane.selected", getControl(), + "TabbedPane.selected", getControl(), // overridden in OceanTheme "TabbedPane.selectHighlight", getControlHighlight(), "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1), "TabbedPane.shadow", getControlShadow(), - "TabbedPane.tabAreaBackground", getControl(), - "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), + "TabbedPane.tabAreaBackground", getControl(), // overridden in OceanTheme + "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6), // dito "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9), + // new properties in OceanTheme: + // TabbedPane.contentAreaColor + // TabbedPane.unselectedBackground + "Table.background", getWindowBackground(), "Table.focusCellBackground", getWindowBackground(), "Table.focusCellForeground", getControlTextColor(), @@ -1243,6 +1251,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel "TextPane.selectionBackground", getTextHighlightColor(), "TextPane.selectionForeground", getHighlightedTextColor(), + "TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1), "TitledBorder.font", new FontUIResource("Dialog", Font.BOLD, 12), "TitledBorder.titleColor", getSystemTextColor(), @@ -1335,12 +1344,17 @@ public class MetalLookAndFeel extends BasicLookAndFeel } /** - * Returns the current theme setting for the Metal L&F. + * Returns the current theme for the Metal look and feel. The default is + * an instance of {@link OceanTheme}. * - * @return the current theme setting for the Metal L&F + * @return The current theme (never <code>null</code>). + * + * @see #setCurrentTheme(MetalTheme) */ public static MetalTheme getCurrentTheme() { + if (theme == null) + theme = new OceanTheme(); return theme; } diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java index 31d8d671fa1..ff763ea9da9 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java @@ -44,6 +44,7 @@ import javax.swing.JComponent; import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicMenuBarUI; /** @@ -75,7 +76,9 @@ public class MetalMenuBarUI extends BasicMenuBarUI */ public void update(Graphics g, JComponent c) { - if (c.isOpaque() && UIManager.get("MenuBar.gradient") != null) + if (c.isOpaque() + && UIManager.get("MenuBar.gradient") != null + && c.getBackground() instanceof UIResource) { MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(), SwingConstants.VERTICAL, "MenuBar.gradient"); diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java b/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java index 84f9cfe494e..a55dc091665 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java @@ -84,6 +84,7 @@ public class MetalScrollButton extends BasicArrowButton super(direction); buttonWidth = width; this.freeStanding = freeStanding; + setFocusable(false); } /** diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java index c49abe832e4..20135fc857e 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java @@ -1,5 +1,5 @@ /* MetalTabbedPaneUI.java - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -170,7 +170,9 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI */ protected LayoutManager createLayoutManager() { - return new TabbedPaneLayout(); + return (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) + ? new MetalTabbedPaneUI.TabbedPaneLayout() + : super.createLayoutManager(); } /** @@ -326,7 +328,6 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI int bottom = h - 1; int right = w - 1; - int tabCount = tabPane.getTabCount(); int currentRun = getRunForTab(tabCount, tabIndex); int firstIndex = tabRuns[currentRun]; @@ -396,14 +397,17 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { if (tabPane.getSelectedIndex() == tabIndex - 1) { - g.drawLine(0, 5, 0, bottom); - g.setColor(oceanSelectedBorder); - g.drawLine(0, 0, 0, 5); + g.drawLine(0, 6, 0, bottom); + if (tabIndex != firstIndex) + { + g.setColor(oceanSelectedBorder); + g.drawLine(0, 0, 0, 5); + } } else if (isSelected) { g.drawLine(0, 5, 0, bottom); - if (tabIndex != 0) + if (tabIndex != firstIndex) { g.setColor(darkShadow); g.drawLine(0, 0, 0, 5); @@ -463,9 +467,10 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI { Color c; if (tabPane.getSelectedIndex() == tabIndex - 1) - c = UIManager.getColor("TabbedPane.tabAreaBackground"); + c = selectColor; else c = getUnselectedBackground(tabIndex - 1); + g.setColor(c); g.fillRect(right - 5, 0, 5, 3); g.fillRect(right - 2, 3, 2, 2); } @@ -522,10 +527,13 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI } else if (isOcean && tabPane.getSelectedIndex() == tabIndex - 1) { - g.setColor(oceanSelectedBorder); - g.drawLine(right, 0, right, 6); + if (tabIndex != firstIndex) + { + g.setColor(oceanSelectedBorder); + g.drawLine(right, 0, right, 6); + } g.setColor(darkShadow); - g.drawLine(right, 6, right, bottom); + g.drawLine(right, 7, right, bottom); } else if (tabIndex != firstIndex) { @@ -598,8 +606,10 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI if (isOcean && isSelected) { g.drawLine(0, 0, 0, bottom - 5); - if ((currentRun == 0 && tabIndex != 0) - || (currentRun > 0 && tabIndex != tabRuns[currentRun - 1])) + + // Paint a connecting line to the tab below for all + // but the first tab in the last run. + if (tabIndex != tabRuns[runCount-1]) { g.setColor(darkShadow); g.drawLine(0, bottom - 5, 0, bottom); @@ -688,6 +698,103 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI } /** + * This method paints the focus rectangle around the selected tab. + * + * @param g The Graphics object to paint with. + * @param tabPlacement The JTabbedPane's tab placement. + * @param rects The array of rectangles keeping track of size and position. + * @param tabIndex The tab index. + * @param iconRect The icon bounds. + * @param textRect The text bounds. + * @param isSelected Whether this tab is selected. + */ + protected void paintFocusIndicator(Graphics g, int tabPlacement, + Rectangle[] rects, int tabIndex, + Rectangle iconRect, Rectangle textRect, + boolean isSelected) + { + if (tabPane.hasFocus() && isSelected) + { + Rectangle rect = rects[tabIndex]; + + g.setColor(focus); + g.translate(rect.x, rect.y); + + switch (tabPlacement) + { + case LEFT: + // Top line + g.drawLine(7, 2, rect.width-2, 2); + + // Right line + g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3); + + // Bottom line + g.drawLine(rect.width-2, rect.height-2, 3, rect.height-2); + + // Left line + g.drawLine(2, rect.height-3, 2, 7); + + // Slant + g.drawLine(2, 6, 6, 2); + break; + case RIGHT: + // Top line + g.drawLine(1, 2, rect.width-8, 2); + + // Slant + g.drawLine(rect.width-7, 2, rect.width-3, 6); + + // Right line + g.drawLine(rect.width-3, 7, rect.width-3, rect.height-3); + + // Bottom line + g.drawLine(rect.width-3, rect.height-2, 2, rect.height-2); + + // Left line + g.drawLine(1, rect.height-2, 1, 2); + break; + case BOTTOM: + // Top line + g.drawLine(2, 1, rect.width-2, 1); + + // Right line + g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3); + + // Bottom line + g.drawLine(7, rect.height-3, rect.width-2, rect.height-3); + + // Slant + g.drawLine(6, rect.height-3, 2, rect.height-7); + + // Left line + g.drawLine(2, rect.height-8, 2, 2); + + break; + case TOP: + default: + // Top line + g.drawLine(6, 2, rect.width-2, 2); + + // Right line + g.drawLine(rect.width-1, 2, rect.width-1, rect.height-3); + + // Bottom line + g.drawLine(3, rect.height-3, rect.width-2, rect.height-3); + + // Left line + g.drawLine(2, rect.height-3, 2, 7); + + // Slant + g.drawLine(2, 6, 6, 2); + + } + + g.translate(-rect.x, -rect.y); + } + } + + /** * Returns <code>true</code> if the tabs in the specified run should be * padded to make the run fill the width/height of the {@link JTabbedPane}. * @@ -1144,4 +1251,19 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI bg = unselectedBackground; return bg; } + + protected int getTabLabelShiftX(int tabPlacement, + int index, + boolean isSelected) + { + return 0; + } + + protected int getTabLabelShiftY(int tabPlacement, + int index, + boolean isSelected) + { + return 0; + } + } diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java index 72cbb34a6dc..0c3a38d5cc3 100644 --- a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java +++ b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java @@ -41,6 +41,7 @@ import gnu.classpath.SystemProperties; import java.awt.Color; import java.awt.Component; +import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.TexturePaint; @@ -106,7 +107,7 @@ class MetalUtils for (int mX = x + xOff; mX < (x + w); mX += 4) { - g.drawLine(mX, mY, mX, mY); + g.fillRect(mX, mY, 1, 1); } // increase x offset @@ -305,6 +306,15 @@ class MetalUtils float g1, float g2, Color c1, Color c2, Color c3, int[][] mask) { + + if (g instanceof Graphics2D + && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") == null) + { + paintHorizontalGradient2D((Graphics2D) g, x, y, w, h, g1, g2, c1, c2, + c3, mask); + return; + } + // Calculate the coordinates. int y0 = y; int y1 = y + h; @@ -339,7 +349,7 @@ class MetalUtils y0 = mask[xc - x0][0] + y; y1 = mask[xc - x0][1] + y; } - g.drawLine(xc, y0, xc, y1); + g.fillRect(xc, y0, 1, y1 - y0); } // Paint solid c2 area. g.setColor(c2); @@ -353,7 +363,7 @@ class MetalUtils { y0 = mask[xc - x0][0] + y; y1 = mask[xc - x0][1] + y; - g.drawLine(xc, y0, xc, y1); + g.fillRect(xc, y0, 1, y1 - y0); } } @@ -377,7 +387,7 @@ class MetalUtils y0 = mask[xc - x0][0] + y; y1 = mask[xc - x0][1] + y; } - g.drawLine(xc, y0, xc, y1); + g.fillRect(xc, y0, 1, y1 - y0); } // Paint third gradient area (c1->c3). @@ -421,9 +431,17 @@ class MetalUtils * described above */ static void paintVerticalGradient(Graphics g, int x, int y, int w, int h, - double g1, double g2, Color c1, Color c2, + float g1, float g2, Color c1, Color c2, Color c3, int[][] mask) { + if (g instanceof Graphics2D + && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") == null) + { + paintVerticalGradient2D((Graphics2D) g, x, y, w, h, g1, g2, c1, c2, + c3, mask); + return; + } + // Calculate the coordinates. int x0 = x; int x1 = x + w; @@ -458,7 +476,7 @@ class MetalUtils x0 = mask[yc - y0][0] + x; x1 = mask[yc - y0][1] + x; } - g.drawLine(x0, yc, x1, yc); + g.fillRect(x0, yc, x1 - x0, 1); } // Paint solid c2 area. g.setColor(c2); @@ -472,7 +490,7 @@ class MetalUtils { x0 = mask[yc - y0][0] + x; x1 = mask[yc - y0][1] + x; - g.drawLine(x0, yc, x1, yc); + g.fillRect(x0, yc, x1 - x0, 1); } } @@ -496,7 +514,7 @@ class MetalUtils x0 = mask[yc - y0][0] + x; x1 = mask[yc - y0][1] + x; } - g.drawLine(x0, yc, x1, yc); + g.fillRect(x0, yc, x1 - x0, 1); } // Paint third gradient area (c1->c3). @@ -519,7 +537,61 @@ class MetalUtils x0 = mask[yc - y0][0] + x; x1 = mask[yc - y0][1] + x; } - g.drawLine(x0, yc, x1, yc); + g.fillRect(x0, yc, x1 - x0, 1); } } + + /** + * Paints a horizontal gradient using Graphics2D functionality. + * + * @param g the Graphics2D instance + * @param x the X coordinate of the upper left corner of the rectangle + * @param y the Y coordinate of the upper left corner of the rectangle + * @param w the width of the rectangle + * @param h the height of the rectangle + * @param g1 the relative width of the c1->c2 gradients + * @param g2 the relative width of the c2 solid area + * @param c1 the color 1 + * @param c2 the color 2 + * @param c3 the color 3 + * @param mask the mask that should be used when painting the gradient as + * described above + */ + private static void paintHorizontalGradient2D(Graphics2D g, int x, int y, + int w, int h, float g1, + float g2, Color c1, + Color c2, Color c3, + int[][] mask) + { + // FIXME: Handle the mask somehow, or do Graphics2D clipping instead. + GradientPaint p1 = new GradientPaint(x, y, c1, x + w * g1, y, c2); + g.setPaint(p1); + // This fills the first gradient and the solid area in one go. + g.fillRect(x, y, (int) (w * (g1 + g2)), h); + + GradientPaint p2 = new GradientPaint(x + (w * (g1 + g2)), y, c2, x + w, y, + c3); + g.setPaint(p2); + g.fillRect((int) (x + (w * (g1 + g2))), y, + (int) (w * (1. - (g1 + g2))), h); + } + + private static void paintVerticalGradient2D(Graphics2D g, int x, int y, + int w, int h, float g1, + float g2, Color c1, + Color c2, Color c3, + int[][] mask) + { + // FIXME: Handle the mask somehow, or do Graphics2D clipping instead. + GradientPaint p1 = new GradientPaint(x, y, c1, x, y + h * g1, c2); + g.setPaint(p1); + // This fills the first gradient and the solid area in one go. + g.fillRect(x, y, w, (int) (h * (g1 + g2))); + + GradientPaint p2 = new GradientPaint(x, y + (h * (g1 + g2)), c2, x, y + h, + c3); + g.setPaint(p2); + g.fillRect(x, (int) (y + (h * (g1 + g2))), w, + (int) (h * (1. - (g1 + g2)))); + } } |