[llvm-commits] [llvm-gcc-4.2] r43913 [53/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,2617 @@
+/* MetalIconFactory.java --
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.AbstractButton;
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JFileChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JRadioButton;
+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;
+
+
+/**
+ * Creates icons for the {@link MetalLookAndFeel}.
+ */
+public class MetalIconFactory implements Serializable
+{
+
+ /** A constant representing "dark". */
+ public static final boolean DARK = false;
+
+ /** A constant representing "light". */
+ public static final boolean LIGHT = true;
+
+ /** A shared instance of the MenuArrowIcon. */
+ private static Icon menuArrow;
+
+ /** A shared instance of the MenuItemArrowIcon. */
+ private static Icon menuItemArrow;
+
+ /**
+ * An icon displayed for {@link JCheckBoxMenuItem} components.
+ */
+ private static class CheckBoxMenuItemIcon
+ implements Icon, UIResource, Serializable
+ {
+ /**
+ * Creates a new icon instance.
+ */
+ public CheckBoxMenuItemIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon (10 pixels).
+ */
+ public int getIconWidth()
+ {
+ return 10;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon (10 pixels).
+ */
+ public int getIconHeight()
+ {
+ return 10;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @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)
+ {
+ JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
+
+ if (item.isArmed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y, x + 8, y);
+ g.drawLine(x, y + 1, x, y + 8);
+ g.drawLine(x + 2, y + 8, x + 8, y + 8);
+ g.drawLine(x + 8, y + 2, x + 8, y + 7);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 7, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 7);
+ g.drawLine(x + 1, y + 9, x + 9, y + 9);
+ g.drawLine(x + 9, y + 1, x + 9, y + 8);
+
+ // if the item is selected, we should draw a tick
+ if (item.isSelected())
+ {
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.fillRect(x + 2, y + 2, 2, 5);
+ for (int i = 0; i < 6; i++)
+ g.drawLine(x + 8 - i, y + i, x + 9 - i, y + i);
+ }
+
+ }
+ }
+
+ /**
+ * An icon used for the "detail view" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserDetailViewIcon()
+ */
+ private static class FileChooserDetailViewIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserDetailViewIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ // file 1 outline
+ g.drawLine(x + 2, y + 2, x + 5, y + 2);
+ g.drawLine(x + 6, y + 3, x + 6, y + 7);
+ g.drawLine(x + 2, y + 7, x + 6, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 7);
+
+ // file 2 outline
+ g.drawLine(x + 2, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 11, x + 6, y + 15);
+ g.drawLine(x + 2, y + 15, x + 6, y + 15);
+ g.drawLine(x + 2, y + 10, x + 2, y + 15);
+
+ // detail lines
+ g.drawLine(x + 8, y + 5, x + 15, y + 5);
+ g.drawLine(x + 8, y + 13, x + 15, y + 13);
+
+ // fill files
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 3, y + 3, 3, 4);
+ g.fillRect(x + 3, y + 11, 3, 4);
+
+ // highlight files
+ g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
+ g.drawLine(x + 4, y + 4, x + 4, y + 5);
+ g.drawLine(x + 4, y + 12, x + 4, y + 13);
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "home folder" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserHomeFolderIcon()
+ */
+ private static class FileChooserHomeFolderIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserHomeFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ // roof
+ g.drawLine(x + 1, y + 8, x + 8, y + 1);
+ g.drawLine(x + 8, y + 1, x + 15, y + 8);
+
+ // base of house
+ g.drawLine(x + 3, y + 6, x + 3, y + 15);
+ g.drawLine(x + 3, y + 15, x + 13, y + 15);
+ g.drawLine(x + 13, y + 6, x + 13, y + 15);
+
+ // door frame
+ g.drawLine(x + 6, y + 9, x + 6, y + 15);
+ g.drawLine(x + 6, y + 9, x + 10, y + 9);
+ g.drawLine(x + 10, y + 9, x + 10, y + 15);
+
+ // chimney
+ g.drawLine(x + 11, y + 2, x + 11, y + 4);
+ g.drawLine(x + 12, y + 2, x + 12, y + 5);
+
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+ // roof paint
+ int xx = x + 8;
+ for (int i = 0; i < 4; i++)
+ g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
+ g.fillRect(x + 4, y + 6, 9, 2);
+
+ // door knob
+ g.drawLine(x + 9, y + 12, x + 9, y + 12);
+
+ // house paint
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.drawLine(x + 4, y + 8, x + 12, y + 8);
+ g.fillRect(x + 4, y + 9, 2, 6);
+ g.fillRect(x + 11, y + 9, 2, 6);
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "list view" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserListViewIcon()
+ */
+ private static class FileChooserListViewIcon
+ implements Icon, UIResource, Serializable
+ {
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserListViewIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ // file 1 outline
+ g.drawLine(x + 2, y + 2, x + 5, y + 2);
+ g.drawLine(x + 6, y + 3, x + 6, y + 7);
+ g.drawLine(x + 2, y + 7, x + 6, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 7);
+
+ // file 2 outline
+ g.drawLine(x + 2, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 11, x + 6, y + 15);
+ g.drawLine(x + 2, y + 15, x + 6, y + 15);
+ g.drawLine(x + 2, y + 10, x + 2, y + 15);
+
+ // file 3 outline
+ g.drawLine(x + 10, y + 2, x + 13, y + 2);
+ g.drawLine(x + 14, y + 3, x + 14, y + 7);
+ g.drawLine(x + 10, y + 7, x + 14, y + 7);
+ g.drawLine(x + 10, y + 2, x + 10, y + 7);
+
+ // file 4 outline
+ g.drawLine(x + 10, y + 10, x + 13, y + 10);
+ g.drawLine(x + 14, y + 11, x + 14, y + 15);
+ g.drawLine(x + 10, y + 15, x + 14, y + 15);
+ g.drawLine(x + 10, y + 10, x + 10, y + 15);
+
+ g.drawLine(x + 8, y + 5, x + 8, y + 5);
+ g.drawLine(x + 8, y + 13, x + 8, y + 13);
+ g.drawLine(x + 16, y + 5, x + 16, y + 5);
+ g.drawLine(x + 16, y + 13, x + 16, y + 13);
+
+ // fill files
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 3, y + 3, 3, 4);
+ g.fillRect(x + 3, y + 11, 3, 4);
+ g.fillRect(x + 11, y + 3, 3, 4);
+ g.fillRect(x + 11, y + 11, 3, 4);
+
+ // highlight files
+ g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
+ g.drawLine(x + 4, y + 4, x + 4, y + 5);
+ g.drawLine(x + 4, y + 12, x + 4, y + 13);
+ g.drawLine(x + 12, y + 4, x + 12, y + 5);
+ g.drawLine(x + 12, y + 12, x + 12, y + 13);
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "new folder" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserNewFolderIcon()
+ */
+ private static class FileChooserNewFolderIcon
+ implements Icon, UIResource, Serializable
+ {
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserNewFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+
+ g.drawLine(x + 2, y + 5, x + 9, y + 5);
+ g.drawLine(x + 10, y + 6, x + 15, y + 6);
+ g.drawLine(x + 15, y + 5, x + 15, y + 14);
+ g.drawLine(x + 2, y + 14, x + 15, y + 14);
+ g.drawLine(x + 1, y + 6, x + 1, y + 14);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ g.drawLine(x + 11, y + 3, x + 15, y + 3);
+ g.drawLine(x + 10, y + 4, x + 15, y + 4);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 3, y + 7, 7, 7);
+ g.fillRect(x + 10, y + 8, 5, 6);
+ g.drawLine(x + 10, y + 5, x + 14, y + 5);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
+ g.drawLine(x + 10, y + 7, x + 14, y + 7);
+ g.drawLine(x + 2, y + 6, x + 9, y + 6);
+ g.drawLine(x + 2, y + 6, x + 2, y + 13);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the "up folder" button on a {@link JFileChooser} under
+ * the {@link MetalLookAndFeel}.
+ *
+ * @see MetalIconFactory#getFileChooserNewFolderIcon()
+ */
+ private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
+ {
+ /**
+ * Creates a new icon.
+ */
+ public FileChooserUpFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+
+ // draw the folder
+ super.paintIcon(c, g, x, y);
+
+ // now draw the up arrow
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 8, y + 9, x + 8, y + 16);
+ int xx = x + 8;
+ for (int i = 0; i < 4; i++)
+ g.drawLine(xx - i, y + 9 + i, xx + i, y + 9 + i);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon representing a file (drawn as a piece of paper with the top-right
+ * corner turned down).
+ */
+ public static class FileIcon16 implements Icon, Serializable
+ {
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels. The height returned is
+ * <code>16</code> plus the value returned by
+ * {@link #getAdditionalHeight()}.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16 + getAdditionalHeight();
+ }
+
+ /**
+ * Paints the icon at the location (x, y).
+ *
+ * @param c the component.
+ * @param g the graphics context.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // TODO: pick up appropriate UI colors
+ g.setColor(Color.black);
+ g.drawLine(x, y, x + 9, y);
+ g.drawLine(x, y + 1, x, y + 15);
+ g.drawLine(x, y + 15, x + 12, y + 15);
+ g.drawLine(x + 12, y + 15, x + 12, y + 6);
+ g.drawLine(x + 12, y + 6, x + 9, y);
+
+ g.drawLine(x + 7, y + 2, x + 11, y + 6);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+
+ g.setColor(new Color(204, 204, 255));
+ g.drawLine(x + 1, y + 1, x + 7, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + 14);
+ g.drawLine(x + 1, y + 14, x + 11, y + 14);
+ g.drawLine(x + 11, y + 14, x + 11, y + 7);
+ g.drawLine(x + 8, y + 2, x + 10, y + 4);
+ }
+
+ /**
+ * Returns the additional height for the icon. The
+ * {@link #getIconHeight()} method adds this value to the icon height it
+ * returns. Subclasses can override this method to adjust the icon height.
+ *
+ * @return The additional height (<code>0</code> unless overridden).
+ */
+ public int getAdditionalHeight()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return 0;
+ }
+
+ }
+
+ /**
+ * An icon representing a folder.
+ */
+ public static class FolderIcon16 implements Icon, Serializable
+ {
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels. The height returned is
+ * <code>16</code> plus the value returned by
+ * {@link #getAdditionalHeight()}.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16 + getAdditionalHeight();
+ }
+
+ /**
+ * 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.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // TODO: pick up appropriate UI colors
+ g.setColor(Color.black);
+ g.drawLine(x, y + 3, x, y + 12);
+ g.drawLine(x, y + 12, x + 15, y + 12);
+ g.drawLine(x + 15, y + 12, x + 15, y + 2);
+ g.drawLine(x + 14, y + 3, x + 9, y + 3);
+ g.drawLine(x + 8, y + 2, x + 1, y + 2);
+ g.setColor(new Color(204, 204, 255));
+ g.fillRect(x + 2, y + 4, 7, 8);
+ g.fillRect(x + 9, y + 5, 6, 7);
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 9, y + 2, x + 14, y + 2);
+ g.setColor(new Color(50, 50, 120));
+ g.drawLine(x + 9, y + 1, x + 15, y + 1);
+ g.drawLine(x + 10, y, x + 15, y);
+ }
+
+ /**
+ * Returns the additional height for the icon. The
+ * {@link #getIconHeight()} method adds this value to the icon height it
+ * returns. Subclasses can override this method to adjust the icon height.
+ *
+ * @return The additional height (<code>0</code> unless overridden).
+ */
+ public int getAdditionalHeight()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return 0;
+ }
+
+ }
+
+ /**
+ * An icon used by the {@link MetalInternalFrameUI} class when the frame
+ * is displayed as a palette.
+ *
+ * @since 1.3
+ */
+ public static class PaletteCloseIcon
+ implements Icon, Serializable, UIResource
+ {
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 7;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 7;
+ }
+
+ /**
+ * Paints the icon using colors from the {@link MetalLookAndFeel}.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ AbstractButton button = (AbstractButton) c;
+ if (button.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.fillRect(x + 2, y + 2, 3, 3);
+ g.drawLine(x + 1, y, x + 1, y + 2);
+ g.drawLine(x, y + 1, x + 2, y + 1);
+ g.drawLine(x + 5, y, x + 5, y + 2);
+ g.drawLine(x + 4, y + 1, x + 6, y + 1);
+ g.drawLine(x + 1, y + 4, x + 1, y + 6);
+ g.drawLine(x, y + 5, x + 2, y + 5);
+ g.drawLine(x + 5, y + 4, x + 5, y + 6);
+ g.drawLine(x + 4, y + 5, x + 6, y + 5);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 2, y + 6, x + 3, y + 5);
+ g.drawLine(x + 5, y + 3, x + 6, y + 2);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An {@link Icon} implementation for {@link JCheckBox}es in the
+ * Metal Look & Feel.
+ *
+ * @author Roman Kennke (roman at kennke.org)
+ */
+ static class RadioButtonIcon implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * This is used as a mask when painting the gradient. See
+ * {@link MetalUtils#paintGradient(java.awt.Graphics, int, int, int, int,
+ * float, float, java.awt.Color, java.awt.Color, java.awt.Color, int,
+ * int[][])} for details.
+ */
+ private static int[][] gradientMask = new int[][] {{3, 7}, {1, 9}, {1, 9},
+ {0, 10}, {0, 10}, {0, 10},
+ {0, 10}, {1, 9}, {1, 9},
+ {3, 7}};
+
+ /**
+ * Returns the width of the icon in pixels.
+ *
+ * @return the width of the icon in pixels
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the height of the icon in pixels.
+ *
+ * @return the height of the icon in pixels
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon, taking into account whether or not the component is
+ * enabled, selected and/or armed.
+ *
+ * @param c the Component to draw on (must be an instance of
+ * {@link JRadioButton})
+ * @param g the Graphics context to draw with
+ * @param x the X position
+ * @param y the Y position
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ if (UIManager.get("RadioButton.gradient") != null)
+ MetalUtils.paintGradient(g, x + 2, y + 2, 8, 8,
+ SwingConstants.VERTICAL, "RadioButton.gradient",
+ gradientMask);
+
+ Color savedColor = g.getColor();
+ JRadioButton b = (JRadioButton) c;
+
+ // draw outer circle
+ if (b.isEnabled())
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x + 2, y + 1, x + 3, y + 1);
+ g.drawLine(x + 4, y, x + 7, y);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+ g.drawLine(x + 10, y + 2, x + 10, y + 3);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+ g.drawLine(x + 10, y + 8, x + 10, y + 9);
+ g.drawLine(x + 8, y + 10, x + 9, y + 10);
+ g.drawLine(x + 4, y + 11, x + 7, y + 11);
+ g.drawLine(x + 2, y + 10, x + 3, y + 10);
+ g.drawLine(x + 1, y + 9, x + 1, y + 8);
+ g.drawLine(x, y + 7, x, y + 4);
+ g.drawLine(x + 1, y + 2, x + 1, y + 3);
+
+ if (b.getModel().isArmed())
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 4, y + 10, x + 7, y + 10);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 10, y + 4, x + 10, y + 7);
+ g.fillRect(x + 2, y + 2, 8, 8);
+ }
+ else
+ {
+ // only draw inner highlight if not filled
+ if (b.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+
+ g.drawLine(x + 2, y + 8, x + 2, y + 9);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 3);
+ g.drawLine(x + 3, y + 2, x + 3, y + 2);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 9, y + 2);
+ }
+ }
+
+ // draw outer highlight
+ if (b.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+
+ // outer
+ g.drawLine(x + 10, y + 1, x + 10, y + 1);
+ g.drawLine(x + 11, y + 2, x + 11, y + 3);
+ g.drawLine(x + 12, y + 4, x + 12, y + 7);
+ g.drawLine(x + 11, y + 8, x + 11, y + 9);
+ g.drawLine(x + 10, y + 10, x + 10, y + 10);
+ g.drawLine(x + 8, y + 11, x + 9, y + 11);
+ g.drawLine(x + 4, y + 12, x + 7, y + 12);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ }
+
+ if (b.isSelected())
+ {
+ if (b.isEnabled())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x + 4, y + 3, x + 7, y + 3);
+ g.fillRect(x + 3, y + 4, 6, 4);
+ g.drawLine(x + 4, y + 8, x + 7, y + 8);
+ }
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon displayed for {@link JRadioButtonMenuItem} components.
+ */
+ private static class RadioButtonMenuItemIcon
+ implements Icon, UIResource, Serializable
+ {
+ /**
+ * Creates a new icon instance.
+ */
+ public RadioButtonMenuItemIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 10;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 10;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @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)
+ {
+ Color savedColor = g.getColor();
+ JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 2, y, x + 6, y);
+ g.drawLine(x + 7, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 8, y + 6);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 2, y + 8, x + 6, y + 8);
+ g.drawLine(x + 1, y + 7, x + 1, y + 7);
+ g.drawLine(x, y + 2, x, y + 6);
+ g.drawLine(x + 1, y + 1, x + 1, y + 1);
+
+ if (item.isSelected())
+ {
+ g.drawLine(x + 3, y + 2, x + 5, y + 2);
+ g.fillRect(x + 2, y + 3, 5, 3);
+ g.drawLine(x + 3, y + 6, x + 5, y + 6);
+ }
+
+ // highlight
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 3, y + 1, x + 6, y + 1);
+ g.drawLine(x + 8, y + 1, x + 8, y + 1);
+ g.drawLine(x + 9, y + 2, x + 9, y + 7);
+ g.drawLine(x + 8, y + 8, x + 8, y + 8);
+ g.drawLine(x + 2, y + 9, x + 7, y + 9);
+ g.drawLine(x + 1, y + 8, x + 1, y + 8);
+ g.drawLine(x + 1, y + 3, x + 1, y + 6);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * The icon used to display the thumb control on a horizontally oriented
+ * {@link JSlider} component.
+ */
+ private static class HorizontalSliderThumbIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * This mask is used to paint the gradient in the shape of the thumb.
+ */
+ int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
+ {0, 12}, {0, 12}, {0, 12}, {1, 11},
+ {2, 10}, {3, 9}, {4, 8}, {5, 7},
+ {6, 6}};
+
+ /**
+ * Creates a new instance.
+ */
+ public HorizontalSliderThumbIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 15;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon, taking into account whether or not the component has
+ * the focus.
+ *
+ * @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)
+ {
+ boolean enabled = false;
+ boolean focus = false;
+ if (c != null)
+ {
+ enabled = c.isEnabled();
+ focus = c.hasFocus();
+ }
+
+ // draw the outline
+ if (enabled)
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x + 1, y, x + 13, y);
+ g.drawLine(x + 14, y + 1, x + 14, y + 7);
+ g.drawLine(x + 14, y + 8, x + 7, y + 15);
+ g.drawLine(x + 6, y + 14, x, y + 8);
+ g.drawLine(x, y + 7, x, y + 1);
+
+ // Fill the icon.
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
+ && enabled)
+ {
+ String gradient;
+ if (focus)
+ gradient = "Slider.focusGradient";
+ else
+ gradient = "Slider.gradient";
+ MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13,
+ SwingConstants.VERTICAL, gradient,
+ gradientMask);
+ }
+ else
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x + 1, y + 2, 13, 7);
+ g.drawLine(x + 2, y + 9, x + 12, y + 9);
+ g.drawLine(x + 3, y + 10, x + 11, y + 10);
+ g.drawLine(x + 4, y + 11, x + 10, y + 11);
+ g.drawLine(x + 5, y + 12, x + 9, y + 12);
+ g.drawLine(x + 6, y + 13, x + 8, y + 13);
+ g.drawLine(x + 7, y + 14, x + 7, y + 14);
+ }
+
+ // If the slider is enabled, draw dots and highlights.
+ if (c.isEnabled()
+ && !(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
+
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 9, y + 5, x + 9, y + 5);
+
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 11, y + 7, x + 11, y + 7);
+
+ // Draw highlights
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ else
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 10, y + 2, x + 10, y + 2);
+
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
+
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 10, y + 6, x + 10, y + 6);
+ }
+
+ }
+ }
+
+ /**
+ * An icon used for the 'close' button in the title frame of a
+ * {@link JInternalFrame}.
+ */
+ private static class InternalFrameCloseIcon
+ implements Icon, UIResource, Serializable
+ {
+ /** The icon size in pixels. */
+ private int size;
+
+ /**
+ * Creates a new icon.
+ *
+ * @param size the icon size (width and height) in pixels.
+ */
+ public InternalFrameCloseIcon(int size)
+ {
+ this.size = size;
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return size;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return size;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component (an {@link JInternalFrame} is expected).
+ * @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)
+ {
+ Color savedColor = g.getColor();
+ AbstractButton b = (AbstractButton) c;
+
+ // fill the interior
+ if (b.getModel().isPressed())
+ // FIXME: also need to take into account whether the internal frame is
+ // selected
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 2, 10, 10);
+
+ // draw the outline box and the cross
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ {
+ // FIXME: also need to take into account whether the internal frame is
+ // selected
+ boolean selected = true;
+ if (selected)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ }
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 12);
+ g.drawLine(x + 1, y + 13, x + 13, y + 13);
+ g.drawLine(x + 13, y + 2, x + 13, y + 12);
+ g.drawLine(x + 2, y + 12, x + 2, y + 12);
+ g.drawLine(x + 12, y + 2, x + 12, y + 2);
+
+ g.fillRect(x + 4, y + 4, 2, 2);
+ g.fillRect(x + 5, y + 5, 4, 4);
+ g.drawLine(x + 9, y + 4, x + 10, y + 4);
+ g.drawLine(x + 9, y + 4, x + 9, y + 5);
+ g.drawLine(x + 4, y + 9, x + 4, y + 10);
+ g.drawLine(x + 4, y + 9, x + 5, y + 9);
+ g.drawLine(x + 9, y + 8, x + 9, y + 10);
+ g.drawLine(x + 8, y + 9, x + 10, y + 9);
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x, y, x + 13, y);
+ g.drawLine(x, y + 1, x, y + 13);
+ g.drawLine(x + 3, y + 4, x + 4, y + 3);
+ g.drawLine(x + 3, y + 9, x + 5, y + 7);
+ g.drawLine(x + 7, y + 5, x + 9, y + 3);
+
+ g.drawLine(x + 12, y + 3, x + 12, y + 11);
+ g.drawLine(x + 3, y + 12, x + 12, y + 12);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 14, x + 14, y + 14);
+ g.drawLine(x + 14, y + 1, x + 14, y + 14);
+
+ if (!b.getModel().isPressed())
+ {
+ g.drawLine(x + 5, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 9, x + 7, y + 9);
+ g.drawLine(x + 10, y + 5, x + 10, y + 5);
+ g.drawLine(x + 9, y + 6, x + 9, y + 7);
+ g.drawLine(x + 10, y + 10, x + 11, y + 10);
+ g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ }
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * The icon displayed at the top-left corner of a {@link JInternalFrame}.
+ */
+ private static class InternalFrameDefaultMenuIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameDefaultMenuIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @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)
+ {
+ g.setColor(new Color(102, 102, 153));
+ g.fillRect(x + 1, y, 14, 2);
+ g.fillRect(x, y + 1, 2, 14);
+ g.fillRect(x + 1, y + 14, 14, 2);
+ g.fillRect(x + 14, y + 1, 2, 14);
+ g.drawLine(x + 2, y + 5, x + 14, y + 5);
+
+ g.setColor(new Color(204, 204, 255));
+ g.fillRect(x + 2, y + 2, 12, 3);
+
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 6, y + 3, x + 6, y + 3);
+ g.drawLine(x + 9, y + 3, x + 9, y + 3);
+ g.drawLine(x + 12, y + 3, x + 12, y + 3);
+
+ g.setColor(Color.white);
+ g.fillRect(x + 2, y + 6, 12, 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 5, y + 2, x + 5, y + 2);
+ g.drawLine(x + 8, y + 2, x + 8, y + 2);
+ g.drawLine(x + 11, y + 2, x + 11, y + 2);
+ }
+ }
+
+ /**
+ * An icon used in the title frame of a {@link JInternalFrame}. When you
+ * maximise an internal frame, this icon will replace the 'maximise' icon to
+ * provide a 'restore' option.
+ */
+ private static class InternalFrameAltMaximizeIcon
+ implements Icon, UIResource, Serializable
+ {
+ /** The icon size in pixels. */
+ private int size;
+
+ /**
+ * Creates a new icon.
+ *
+ * @param size the icon size in pixels.
+ */
+ public InternalFrameAltMaximizeIcon(int size)
+ {
+ this.size = size;
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return size;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return size;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @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)
+ {
+ Color savedColor = g.getColor();
+
+ AbstractButton b = (AbstractButton) c;
+
+ // fill the small box interior
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 6, 7, 7);
+
+
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+
+ g.drawLine(x + 12, y + 1, x + 13, y + 1);
+ g.drawLine(x + 11, y + 2, x + 12, y + 2);
+ g.drawLine(x + 10, y + 3, x + 11, y + 3);
+ g.drawLine(x + 8, y + 2, x + 8, y + 3);
+ g.fillRect(x + 8, y + 4, 3, 3);
+ g.drawLine(x + 11, y + 6, x + 12, y + 6);
+
+ g.drawLine(x + 1, y + 5, x + 5, y + 5);
+ g.drawLine(x + 1, y + 6, x + 1, y + 12);
+ g.drawLine(x + 9, y + 9, x + 9, y + 12);
+ g.drawLine(x + 1, y + 13, x + 9, y + 13);
+
+ g.drawLine(x + 2, y + 12, x + 2, y + 12);
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 12, y, x + 9, y + 3);
+ g.drawLine(x + 7, y + 1, x + 8, y + 1);
+ g.drawLine(x + 7, y + 2, x + 7, y + 6);
+ g.drawLine(x + 11, y + 5, x + 12, y + 5);
+ g.drawLine(x, y + 4, x + 5, y + 4);
+ g.drawLine(x, y + 5, x, y + 13);
+ g.drawLine(x + 3, y + 12, x + 8, y + 12);
+ g.drawLine(x + 8, y + 8, x + 8, y + 11);
+ g.drawLine(x + 9, y + 8, x + 9, y + 8);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 9, y + 2, x + 9, y + 2);
+ g.drawLine(x + 11, y + 4, x + 13, y + 2);
+ g.drawLine(x + 13, y + 6, x + 13, y + 6);
+ g.drawLine(x + 8, y + 7, x + 13, y + 7);
+ g.drawLine(x + 6, y + 5, x + 6, y + 5);
+ g.drawLine(x + 10, y + 8, x + 10, y + 13);
+ g.drawLine(x + 1, y + 14, x + 10, y + 14);
+
+ if (!b.getModel().isPressed())
+ {
+ g.drawLine(x + 2, y + 6, x + 6, y + 6);
+ g.drawLine(x + 2, y + 6, x + 2, y + 11);
+ }
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used for the 'maximize' button in the title frame of a
+ * {@link JInternalFrame}.
+ */
+ private static class InternalFrameMaximizeIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameMaximizeIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @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)
+ {
+ Color savedColor = g.getColor();
+
+ AbstractButton b = (AbstractButton) c;
+
+ // fill the interior
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 6, 7, 7);
+
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+
+ g.drawLine(x + 9, y + 1, x + 10, y + 1);
+ g.fillRect(x + 11, y + 1, 3, 3);
+ g.fillRect(x + 12, y + 4, 2, 2);
+ g.drawLine(x + 10, y + 3, x + 10, y + 3);
+ g.drawLine(x + 9, y + 4, x + 10, y + 4);
+ g.drawLine(x + 1, y + 5, x + 9, y + 5);
+ g.drawLine(x + 1, y + 6, x + 1, y + 12);
+ g.drawLine(x + 9, y + 6, x + 9, y + 12);
+ g.drawLine(x + 1, y + 13, x + 9, y + 13);
+
+ // fill
+ g.drawLine(x + 7, y + 6, x + 8, y + 6);
+ g.drawLine(x + 6, y + 7, x + 8, y + 7);
+ g.drawLine(x + 5, y + 8, x + 6, y + 8);
+ g.drawLine(x + 4, y + 9, x + 5, y + 9);
+ g.drawLine(x + 3, y + 10, x + 4, y + 10);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ g.drawLine(x + 2, y + 12, x + 4, y + 12);
+ g.drawLine(x + 8, y + 8, x + 8, y + 8);
+
+ // draw black
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 8, y, x + 13, y);
+ g.drawLine(x + 8, y + 1, x + 8, y + 1);
+ g.drawLine(x + 10, y + 2, x + 9, y + 3);
+ g.drawLine(x, y + 4, x + 8, y + 4);
+ g.drawLine(x, y + 5, x, y + 13);
+
+ g.drawLine(x + 2, y + 10, x + 6, y + 6);
+ g.drawLine(x + 8, y + 9, x + 8, y + 11);
+ g.drawLine(x + 5, y + 12, x + 8, y + 12);
+
+ // draw white
+ g.setColor(MetalLookAndFeel.getWhite());
+ if (!b.getModel().isPressed())
+ {
+ g.drawLine(x + 2, y + 6, x + 5, y + 6);
+ g.drawLine(x + 2, y + 7, x + 2, y + 9);
+ g.drawLine(x + 4, y + 11, x + 7, y + 8);
+ }
+
+ g.drawLine(x + 1, y + 14, x + 10, y + 14);
+ g.drawLine(x + 10, y + 5, x + 10, y + 13);
+
+ g.drawLine(x + 9, y + 2, x + 9, y + 2);
+ g.drawLine(x + 11, y + 4, x + 11, y + 5);
+ g.drawLine(x + 13, y + 6, x + 14, y + 6);
+ g.drawLine(x + 14, y + 1, x + 14, y + 5);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * An icon used in the title frame of a {@link JInternalFrame}.
+ */
+ private static class InternalFrameMinimizeIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameMinimizeIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @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)
+ {
+ Color savedColor = g.getColor();
+
+ AbstractButton b = (AbstractButton) c;
+
+ if (b.getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ // FIXME: here the color depends on whether or not the internal frame
+ // is selected
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+
+ g.drawLine(x + 12, y + 1, x + 13, y + 1);
+ g.drawLine(x + 11, y + 2, x + 12, y + 2);
+ g.drawLine(x + 10, y + 3, x + 11, y + 3);
+ g.drawLine(x + 8, y + 2, x + 8, y + 3);
+ g.fillRect(x + 8, y + 4, 3, 3);
+ g.drawLine(x + 11, y + 6, x + 12, y + 6);
+
+ g.drawLine(x + 1, y + 8, x + 6, y + 8);
+ g.drawLine(x + 1, y + 9, x + 1, y + 12);
+ g.drawLine(x + 6, y + 9, x + 6, y + 12);
+ g.drawLine(x + 1, y + 13, x + 6, y + 13);
+
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
+ g.drawLine(x + 2, y + 12, x + 2, y + 12);
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 12, y, x + 9, y + 3);
+ g.drawLine(x + 7, y + 1, x + 8, y + 1);
+ g.drawLine(x + 7, y + 2, x + 7, y + 6);
+ g.drawLine(x, y + 7, x + 6, y + 7);
+ g.drawLine(x, y + 8, x, y + 13);
+ g.drawLine(x + 3, y + 12, x + 5, y + 12);
+ g.drawLine(x + 5, y + 10, x + 5, y + 11);
+ g.drawLine(x + 11, y + 5, x + 12, y + 5);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 9, y + 2, x + 9, y + 2);
+ g.drawLine(x + 11, y + 4, x + 13, y + 2);
+ g.drawLine(x + 13, y + 6, x + 13, y + 6);
+ g.drawLine(x + 8, y + 7, x + 13, y + 7);
+ g.drawLine(x + 7, y + 9, x + 7, y + 13);
+ g.drawLine(x + 1, y + 14, x + 7, y + 14);
+
+ if (b.getModel().isPressed())
+ {
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.fillRect(x + 2, y + 9, 3, 3);
+ }
+ else
+ {
+ g.drawLine(x + 2, y + 9, x + 4, y + 9);
+ g.drawLine(x + 2, y + 10, x + 2, y + 11);
+ }
+
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
+ * The icon used to display the thumb control on a horizontally oriented
+ * {@link JSlider} component.
+ */
+ private static class VerticalSliderThumbIcon
+ implements Icon, UIResource, Serializable
+ {
+ /**
+ * This mask is used to paint the gradient in the shape of the thumb.
+ */
+ int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
+ {0, 12}, {0, 12}, {0, 12}, {1, 11},
+ {2, 10}, {3, 9}, {4, 8}, {5, 7},
+ {6, 6}};
+
+ /**
+ * Creates a new instance.
+ */
+ public VerticalSliderThumbIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 15;
+ }
+
+ /**
+ * Paints the icon taking into account whether the slider control has the
+ * focus or not.
+ *
+ * @param c the slider (must be a non-<code>null</code> instance of
+ * {@link JSlider}.
+ * @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)
+ {
+ boolean enabled = false;
+ boolean focus = false;
+ if (c != null)
+ {
+ enabled = c.isEnabled();
+ focus = c.hasFocus();
+ }
+
+ // draw the outline
+ if (enabled)
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x + 1, y, x + 7, y);
+ g.drawLine(x + 8, y, x + 15, y + 7);
+ g.drawLine(x + 14, y + 8, x + 8, y + 14);
+ g.drawLine(x + 8, y + 14, x + 1, y + 14);
+ g.drawLine(x, y + 13, x, y + 1);
+
+ // Fill the icon.
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
+ && enabled)
+ {
+ String gradient;
+ if (focus)
+ gradient = "Slider.focusGradient";
+ else
+ gradient = "Slider.gradient";
+ MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12,
+ SwingConstants.HORIZONTAL, gradient,
+ gradientMask);
+ }
+ else
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x + 2, y + 1, 7, 13);
+ g.drawLine(x + 9, y + 2, x + 9, y + 12);
+ g.drawLine(x + 10, y + 3, x + 10, y + 11);
+ g.drawLine(x + 11, y + 4, x + 11, y + 10);
+ g.drawLine(x + 12, y + 5, x + 12, y + 9);
+ g.drawLine(x + 13, y + 6, x + 13, y + 8);
+ g.drawLine(x + 14, y + 7, x + 14, y + 7);
+ }
+
+ // if the slider is enabled, draw dots and highlights
+ if (enabled
+ && ! (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 3, y + 11, x + 3, y + 11);
+
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
+
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 7, y + 11, x + 7, y + 11);
+
+ // draw highlights
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ else
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 8, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 13);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 2, y + 10, x + 2, y + 10);
+
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 4, y + 8, x + 4, y + 8);
+
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 6, y + 10, x + 6, y + 10);
+
+ }
+ }
+ }
+
+ /**
+ * A tree control icon. This icon can be in one of two states: expanded and
+ * collapsed.
+ */
+ public static class TreeControlIcon implements Icon, Serializable
+ {
+
+ /** ???. */
+ protected boolean isLight;
+
+ /** A flag that controls whether or not the icon is collapsed. */
+ private boolean collapsed;
+
+ /**
+ * Creates a new icon.
+ *
+ * @param isCollapsed a flag that controls whether the icon is in the
+ * collapsed state or the expanded state.
+ */
+ public TreeControlIcon(boolean isCollapsed)
+ {
+ collapsed = isCollapsed;
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * 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.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // 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
+ g.fillRect(x + wHalf + 1, y + w, 2, w);
+
+ g.setColor(white);
+ g.fillRect(x + wHalf + 1, y + wHalf + 1, 2, 2);
+
+ }
+
+ /**
+ * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintMe(Component c, Graphics g, int x, int y)
+ {
+ paintIcon(c, g, x, y);
+ }
+ }
+
+ /**
+ * A tree folder icon.
+ */
+ public static class TreeFolderIcon extends FolderIcon16
+ {
+ /**
+ * Creates a new instance.
+ */
+ public TreeFolderIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the additional height for this icon, in this case <code>2</code>
+ * pixels.
+ *
+ * @return <code>2</code>.
+ */
+ public int getAdditionalHeight()
+ {
+ return 2;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * A tree leaf icon.
+ */
+ public static class TreeLeafIcon extends FileIcon16
+ {
+ /**
+ * Creates a new instance.
+ */
+ public TreeLeafIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the additional height for this icon, in this case <code>4</code>
+ * pixels.
+ *
+ * @return <code>4</code>.
+ */
+ public int getAdditionalHeight()
+ {
+ return 4;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return 2;
+ }
+ }
+
+ /**
+ * An icon representing a hard disk.
+ *
+ * @see MetalIconFactory#getTreeHardDriveIcon()
+ */
+ private static class TreeHardDriveIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeHardDriveIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 1, y + 4, x + 1, y + 5);
+ g.drawLine(x + 14, y + 4, x + 14, y + 5);
+ g.drawLine(x + 1, y + 7, x + 1, y + 8);
+ g.drawLine(x + 14, y + 7, x + 14, y + 8);
+ g.drawLine(x + 1, y + 10, x + 1, y + 11);
+ g.drawLine(x + 14, y + 10, x + 14, y + 11);
+
+ g.drawLine(x + 2, y + 3, x + 3, y + 3);
+ g.drawLine(x + 12, y + 3, x + 13, y + 3);
+ g.drawLine(x + 2, y + 6, x + 3, y + 6);
+ g.drawLine(x + 12, y + 6, x + 13, y + 6);
+ g.drawLine(x + 2, y + 9, x + 3, y + 9);
+ g.drawLine(x + 12, y + 9, x + 13, y + 9);
+ g.drawLine(x + 2, y + 12, x + 3, y + 12);
+ g.drawLine(x + 12, y + 12, x + 13, y + 12);
+
+ g.drawLine(x + 4, y + 2, x + 11, y + 2);
+ g.drawLine(x + 4, y + 7, x + 11, y + 7);
+ g.drawLine(x + 4, y + 10, x + 11, y + 10);
+ g.drawLine(x + 4, y + 13, x + 11, y + 13);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.fillRect(x + 4, y + 3, 2, 2);
+ g.drawLine(x + 6, y + 4, x + 6, y + 4);
+ g.drawLine(x + 7, y + 3, x + 9, y + 3);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
+ g.fillRect(x + 2, y + 4, 2, 2);
+ g.fillRect(x + 2, y + 7, 2, 2);
+ g.fillRect(x + 2, y + 10, 2, 2);
+ g.drawLine(x + 4, y + 6, x + 4, y + 6);
+ g.drawLine(x + 4, y + 9, x + 4, y + 9);
+ g.drawLine(x + 4, y + 12, x + 4, y + 12);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 13, y + 4, x + 13, y + 4);
+ g.drawLine(x + 12, y + 5, x + 13, y + 5);
+ g.drawLine(x + 13, y + 7, x + 13, y + 7);
+ g.drawLine(x + 12, y + 8, x + 13, y + 8);
+ g.drawLine(x + 13, y + 10, x + 13, y + 10);
+ g.drawLine(x + 12, y + 11, x + 13, y + 11);
+
+ g.drawLine(x + 10, y + 5, x + 10, y + 5);
+ g.drawLine(x + 7, y + 6, x + 7, y + 6);
+ g.drawLine(x + 9, y + 6, x + 9, y + 6);
+ g.drawLine(x + 11, y + 6, x + 11, y + 6);
+
+ g.drawLine(x + 10, y + 8, x + 10, y + 8);
+ g.drawLine(x + 7, y + 9, x + 7, y + 9);
+ g.drawLine(x + 9, y + 9, x + 9, y + 9);
+ g.drawLine(x + 11, y + 9, x + 11, y + 9);
+
+ g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ g.drawLine(x + 7, y + 12, x + 7, y + 12);
+ g.drawLine(x + 9, y + 12, x + 9, y + 12);
+ g.drawLine(x + 11, y + 12, x + 11, y + 12);
+
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * An icon representing a floppy disk.
+ *
+ * @see MetalIconFactory#getTreeFloppyDriveIcon()
+ */
+ private static class TreeFloppyDriveIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeFloppyDriveIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + 14);
+ g.drawLine(x + 1, y + 14, x + 14, y + 14);
+ g.drawLine(x + 14, y + 2, x + 14, y + 14);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 2, 12, 12);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(x + 5, y + 2, 6, 5);
+ g.drawLine(x + 4, y + 8, x + 11, y + 8);
+ g.drawLine(x + 3, y + 9, x + 3, y + 13);
+ g.drawLine(x + 12, y + 9, x + 12, y + 13);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.fillRect(x + 8, y + 3, 2, 3);
+ g.fillRect(x + 4, y + 9, 8, 5);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.drawLine(x + 5, y + 10, x + 9, y + 10);
+ g.drawLine(x + 5, y + 12, x + 8, y + 12);
+
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * An icon representing a computer.
+ *
+ * @see MetalIconFactory#getTreeComputerIcon()
+ */
+ private static class TreeComputerIcon
+ implements Icon, UIResource, Serializable
+ {
+
+ /**
+ * Creates a new icon instance.
+ */
+ public TreeComputerIcon()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return <code>16</code>.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location, using colors from the
+ * current theme.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate for the top-left of the icon.
+ * @param y the y-coordinate for the top-left of the icon.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 1, x + 12, y + 1);
+ g.drawLine(x + 2, y + 2, x + 2, y + 8);
+ g.drawLine(x + 13, y + 2, x + 13, y + 8);
+ g.drawLine(x + 3, y + 9, x + 3, y + 9);
+ g.drawLine(x + 12, y + 9, x + 12, y + 9);
+ g.drawRect(x + 1, y + 10, 13, 4);
+ g.drawLine(x + 5, y + 3, x + 10, y + 3);
+ g.drawLine(x + 5, y + 8, x + 10, y + 8);
+ g.drawLine(x + 4, y + 4, x + 4, y + 7);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 5, y + 4, 6, 4);
+
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 6, y + 12, x + 8, y + 12);
+ g.drawLine(x + 10, y + 12, x + 12, y + 12);
+ g.setColor(saved);
+ }
+ }
+
+ /** The icon returned by {@link #getCheckBoxIcon()}. */
+ private static Icon checkBoxIcon;
+
+ /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
+ private static Icon checkBoxMenuItemIcon;
+
+ /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
+ private static Icon fileChooserDetailViewIcon;
+
+ /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
+ private static Icon fileChooserHomeFolderIcon;
+
+ /** The icon returned by {@link #getFileChooserListViewIcon()}. */
+ private static Icon fileChooserListViewIcon;
+
+ /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
+ private static Icon fileChooserNewFolderIcon;
+
+ /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
+ private static Icon fileChooserUpFolderIcon;
+
+ /** The cached RadioButtonIcon instance. */
+ private static RadioButtonIcon radioButtonIcon;
+
+ /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
+ private static Icon radioButtonMenuItemIcon;
+
+ /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
+ private static Icon internalFrameDefaultMenuIcon;
+
+ /** The icon returned by {@link #getTreeComputerIcon()}. */
+ private static Icon treeComputerIcon;
+
+ /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
+ private static Icon treeFloppyDriveIcon;
+
+ /** 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.
+ */
+ public MetalIconFactory()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns an icon for use when rendering the {@link JCheckBox} component.
+ *
+ * @return A check box icon.
+ *
+ * @since 1.3
+ */
+ public static Icon getCheckBoxIcon()
+ {
+ if (checkBoxIcon == null)
+ checkBoxIcon = new MetalCheckBoxIcon();
+ return checkBoxIcon;
+ }
+
+ /**
+ * Returns an icon for use when rendering the {@link JCheckBoxMenuItem}
+ * component.
+ *
+ * @return An icon.
+ */
+ public static Icon getCheckBoxMenuItemIcon()
+ {
+ if (checkBoxMenuItemIcon == null)
+ checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
+ return checkBoxMenuItemIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserDetailViewIcon()
+ {
+ if (fileChooserDetailViewIcon == null)
+ fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
+ return fileChooserDetailViewIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserHomeFolderIcon()
+ {
+ if (fileChooserHomeFolderIcon == null)
+ fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
+ return fileChooserHomeFolderIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserListViewIcon()
+ {
+ if (fileChooserListViewIcon == null)
+ fileChooserListViewIcon = new FileChooserListViewIcon();
+ return fileChooserListViewIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserNewFolderIcon()
+ {
+ if (fileChooserNewFolderIcon == null)
+ fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
+ return fileChooserNewFolderIcon;
+ }
+
+ /**
+ * Returns an icon for use by the {@link JFileChooser} component.
+ *
+ * @return An icon.
+ */
+ public static Icon getFileChooserUpFolderIcon()
+ {
+ if (fileChooserUpFolderIcon == null)
+ fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
+ return fileChooserUpFolderIcon;
+ }
+
+ /**
+ * Returns an icon for RadioButtons in the Metal L&F.
+ *
+ * @return an icon for RadioButtons in the Metal L&F
+ */
+ public static Icon getRadioButtonIcon()
+ {
+ if (radioButtonIcon == null)
+ radioButtonIcon = new RadioButtonIcon();
+ return radioButtonIcon;
+ }
+
+ /**
+ * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
+ *
+ * @return A new icon instance.
+ */
+ public static Icon getRadioButtonMenuItemIcon()
+ {
+ if (radioButtonMenuItemIcon == null)
+ radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
+ return radioButtonMenuItemIcon;
+ }
+
+ /**
+ * Returns the icon used to display the thumb for a horizontally oriented
+ * {@link JSlider}.
+ *
+ * @return The icon.
+ */
+ public static Icon getHorizontalSliderThumbIcon()
+ {
+ if (horizontalSliderThumbIcon == null)
+ horizontalSliderThumbIcon = new HorizontalSliderThumbIcon();
+ return horizontalSliderThumbIcon;
+ }
+
+ /**
+ * Creates a new icon used to represent the 'close' button in the title
+ * pane of a {@link JInternalFrame}.
+ *
+ * @param size the icon size.
+ *
+ * @return A close icon.
+ */
+ public static Icon getInternalFrameCloseIcon(int size)
+ {
+ return new InternalFrameCloseIcon(size);
+ }
+
+ /**
+ * Creates a new icon for the menu in a {@link JInternalFrame}. This is the
+ * icon displayed at the top left of the frame.
+ *
+ * @return A menu icon.
+ */
+ public static Icon getInternalFrameDefaultMenuIcon()
+ {
+ if (internalFrameDefaultMenuIcon == null)
+ internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
+ return internalFrameDefaultMenuIcon;
+ }
+
+ /**
+ * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
+ *
+ * @param size the icon size in pixels.
+ *
+ * @return The icon.
+ *
+ * @see #getInternalFrameAltMaximizeIcon(int)
+ */
+ public static Icon getInternalFrameMaximizeIcon(int size)
+ {
+ return new InternalFrameMaximizeIcon();
+ }
+
+ /**
+ * Returns the icon used for the minimize button in the frame title for a
+ * {@link JInternalFrame}.
+ *
+ * @param size the icon size in pixels (ignored by this implementation).
+ *
+ * @return The icon.
+ */
+ public static Icon getInternalFrameMinimizeIcon(int size)
+ {
+ return new InternalFrameMinimizeIcon();
+ }
+
+ /**
+ * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
+ * that has been maximised.
+ *
+ * @param size the icon size in pixels.
+ *
+ * @return The icon.
+ *
+ * @see #getInternalFrameMaximizeIcon(int)
+ */
+ public static Icon getInternalFrameAltMaximizeIcon(int size)
+ {
+ return new InternalFrameAltMaximizeIcon(size);
+ }
+
+ /**
+ * Returns the icon used to display the thumb for a vertically oriented
+ * {@link JSlider}.
+ *
+ * @return The icon.
+ */
+ public static Icon getVerticalSliderThumbIcon()
+ {
+ if (verticalSliderThumbIcon == null)
+ verticalSliderThumbIcon = new VerticalSliderThumbIcon();
+ return verticalSliderThumbIcon;
+ }
+
+ /**
+ * Creates and returns a new tree folder icon.
+ *
+ * @return A new tree folder icon.
+ */
+ public static Icon getTreeFolderIcon()
+ {
+ return new TreeFolderIcon();
+ }
+
+ /**
+ * Creates and returns a new tree leaf icon.
+ *
+ * @return A new tree leaf icon.
+ */
+ public static Icon getTreeLeafIcon()
+ {
+ return new TreeLeafIcon();
+ }
+
+ /**
+ * Creates and returns a tree control icon.
+ *
+ * @param isCollapsed a flag that controls whether the icon is in the
+ * collapsed or expanded state.
+ *
+ * @return A tree control icon.
+ */
+ public static Icon getTreeControlIcon(boolean isCollapsed)
+ {
+ return new TreeControlIcon(isCollapsed);
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a computer.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeComputerIcon()
+ {
+ if (treeComputerIcon == null)
+ treeComputerIcon = new TreeComputerIcon();
+ return treeComputerIcon;
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a floppy disk.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeFloppyDriveIcon()
+ {
+ if (treeFloppyDriveIcon == null)
+ treeFloppyDriveIcon = new TreeFloppyDriveIcon();
+ return treeFloppyDriveIcon;
+ }
+
+ /**
+ * Returns a <code>16x16</code> icon representing a hard disk.
+ *
+ * @return The icon.
+ */
+ public static Icon getTreeHardDriveIcon()
+ {
+ if (treeHardDriveIcon == null)
+ treeHardDriveIcon = new TreeHardDriveIcon();
+ return treeHardDriveIcon;
+ }
+
+ /**
+ * Returns a new instance of a 4 x 8 icon showing a small black triangle that
+ * points to the right. This is displayed in menu items that have a
+ * sub menu.
+ *
+ * @return The icon.
+ */
+ public static Icon getMenuArrowIcon()
+ {
+ if (menuArrow == null)
+ menuArrow = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return 8;
+ }
+
+ public int getIconWidth()
+ {
+ return 4;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ for (int i = 0; i < 4; i++)
+ g.drawLine(x + i, y + i, x + i, y + 7 - i);
+ g.setColor(saved);
+ }
+ };
+ return menuArrow;
+ }
+
+ /**
+ * Returns a new instance of a 4 x 8 icon showing a small black triangle that
+ * points to the right. This is displayed in menu items that have a sub menu.
+ *
+ * @return The icon.
+ */
+ public static Icon getMenuItemArrowIcon()
+ {
+ if (menuItemArrow == null)
+ menuItemArrow = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return 8;
+ }
+
+ public int getIconWidth()
+ {
+ return 4;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ for (int i = 0; i < 4; i++)
+ g.drawLine(x + i, y + i, x + i, y + 7 - i);
+ g.setColor(saved);
+ }
+ };
+ return menuItemArrow;
+ }
+
+ /**
+ * Returns a new instance of a 13 x 13 icon showing a small black check mark.
+ *
+ * @return The icon.
+ */
+ public static Icon getMenuItemCheckIcon()
+ {
+ return new Icon()
+ {
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+ g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
+ g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
+ g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
+ g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
+ g.setColor(saved);
+ }
+ };
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,458 @@
+/* MetalInternalFrameTitlePane.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.Icon;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
+
+
+/**
+ * The title pane for a {@link JInternalFrame} (see
+ * {@link MetalInternalFrameUI#createNorthPane(JInternalFrame)}). This can
+ * be displayed in two styles: one for regular internal frames, and the other
+ * for "palette" style internal frames.
+ */
+public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
+{
+
+ /**
+ * A property change handler that listens for changes to the
+ * <code>JInternalFrame.isPalette</code> property and updates the title
+ * pane as appropriate.
+ */
+ class MetalInternalFrameTitlePanePropertyChangeHandler
+ extends PropertyChangeHandler
+ {
+ /**
+ * Creates a new handler.
+ */
+ public MetalInternalFrameTitlePanePropertyChangeHandler()
+ {
+ super();
+ }
+
+ /**
+ * Handles <code>JInternalFrame.isPalette</code> property changes, with all
+ * other property changes being passed to the superclass.
+ *
+ * @param e the event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ String propName = e.getPropertyName();
+ if (e.getPropertyName().equals(JInternalFrame.FRAME_ICON_PROPERTY))
+ {
+ title.setIcon(frame.getFrameIcon());
+ }
+ else if (propName.equals("JInternalFrame.isPalette"))
+ {
+ if (e.getNewValue().equals(Boolean.TRUE))
+ setPalette(true);
+ else
+ setPalette(false);
+ }
+ else
+ super.propertyChange(e);
+ }
+ }
+
+ /**
+ * A layout manager for the title pane.
+ *
+ * @see #createLayout()
+ */
+ private class MetalTitlePaneLayout implements LayoutManager
+ {
+ /**
+ * Creates a new <code>TitlePaneLayout</code> object.
+ */
+ public MetalTitlePaneLayout()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * Adds a Component to the Container.
+ *
+ * @param name The name to reference the added Component by.
+ * @param c The Component to add.
+ */
+ public void addLayoutComponent(String name, Component c)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method is called to lay out the children of the Title Pane.
+ *
+ * @param c The Container to lay out.
+ */
+ public void layoutContainer(Container c)
+ {
+
+ Dimension size = c.getSize();
+ Insets insets = c.getInsets();
+ int width = size.width - insets.left - insets.right;
+ int height = size.height - insets.top - insets.bottom;
+
+
+ int loc = width - insets.right - 1;
+ int top = insets.top + 2;
+ int buttonHeight = height - 4;
+ if (closeButton.isVisible())
+ {
+ int buttonWidth = closeIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ loc -= 6;
+ }
+
+ if (maxButton.isVisible())
+ {
+ int buttonWidth = maxIcon.getIconWidth();
+ loc -= buttonWidth + 4;
+ maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ }
+
+ if (iconButton.isVisible())
+ {
+ int buttonWidth = minIcon.getIconWidth();
+ loc -= buttonWidth + 4;
+ iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ loc -= 2;
+ }
+
+ Dimension titlePreferredSize = title.getPreferredSize();
+ title.setBounds(insets.left + 5, insets.top,
+ Math.min(titlePreferredSize.width, loc - insets.left - 10),
+ height);
+
+ }
+
+ /**
+ * This method returns the minimum size of the given Container given the
+ * children that it has.
+ *
+ * @param c The Container to get a minimum size for.
+ *
+ * @return The minimum size of the Container.
+ */
+ public Dimension minimumLayoutSize(Container c)
+ {
+ return preferredLayoutSize(c);
+ }
+
+ /**
+ * Returns the preferred size of the given Container taking
+ * into account the children that it has.
+ *
+ * @param c The Container to lay out.
+ *
+ * @return The preferred size of the Container.
+ */
+ public Dimension preferredLayoutSize(Container c)
+ {
+ if (isPalette)
+ return new Dimension(paletteTitleHeight, paletteTitleHeight);
+ else
+ return new Dimension(22, 22);
+ }
+
+ /**
+ * Removes a Component from the Container.
+ *
+ * @param c The Component to remove.
+ */
+ public void removeLayoutComponent(Component c)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /** A flag indicating whether the title pane uses the palette style. */
+ protected boolean isPalette;
+
+ /**
+ * The icon used for the close button - this is fetched from the look and
+ * feel defaults using the key <code>InternalFrame.paletteCloseIcon</code>.
+ */
+ protected Icon paletteCloseIcon;
+
+ /**
+ * The height of the title pane when <code>isPalette</code> is
+ * <code>true</code>. This value is fetched from the look and feel defaults
+ * using the key <code>InternalFrame.paletteTitleHeight</code>.
+ */
+ protected int paletteTitleHeight;
+
+ /** The label used to display the title for the internal frame. */
+ JLabel title;
+
+ /**
+ * Creates a new title pane for the specified frame.
+ *
+ * @param f the internal frame.
+ */
+ public MetalInternalFrameTitlePane(JInternalFrame f)
+ {
+ super(f);
+ isPalette = false;
+ }
+
+ /**
+ * Fetches the colors used in the title pane.
+ */
+ protected void installDefaults()
+ {
+ super.installDefaults();
+ selectedTextColor = MetalLookAndFeel.getControlTextColor();
+ selectedTitleColor = MetalLookAndFeel.getWindowTitleBackground();
+ notSelectedTextColor = MetalLookAndFeel.getInactiveControlTextColor();
+ notSelectedTitleColor = MetalLookAndFeel.getWindowTitleInactiveBackground();
+
+ paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
+ paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
+ minIcon = MetalIconFactory.getInternalFrameAltMaximizeIcon(16);
+
+ title = new JLabel(frame.getTitle(),
+ MetalIconFactory.getInternalFrameDefaultMenuIcon(),
+ SwingConstants.LEFT);
+ }
+
+ /**
+ * Clears the colors used for the title pane.
+ */
+ protected void uninstallDefaults()
+ {
+ super.uninstallDefaults();
+ selectedTextColor = null;
+ selectedTitleColor = null;
+ notSelectedTextColor = null;
+ notSelectedTitleColor = null;
+ paletteCloseIcon = null;
+ minIcon = null;
+ title = null;
+ }
+
+ /**
+ * Calls the super class to create the buttons, then calls
+ * <code>setBorderPainted(false)</code> and
+ * <code>setContentAreaFilled(false)</code> for each button.
+ */
+ protected void createButtons()
+ {
+ super.createButtons();
+ closeButton.setBorderPainted(false);
+ closeButton.setContentAreaFilled(false);
+ iconButton.setBorderPainted(false);
+ iconButton.setContentAreaFilled(false);
+ maxButton.setBorderPainted(false);
+ maxButton.setContentAreaFilled(false);
+ }
+
+ /**
+ * Overridden to do nothing.
+ */
+ protected void addSystemMenuItems(JMenu systemMenu)
+ {
+ // do nothing
+ }
+
+ /**
+ * Overridden to do nothing.
+ */
+ protected void showSystemMenu()
+ {
+ // do nothing
+ }
+
+ /**
+ * Adds the sub components of the title pane.
+ */
+ protected void addSubComponents()
+ {
+ // FIXME: this method is probably overridden to only add the required
+ // buttons
+ add(title);
+ add(closeButton);
+ add(iconButton);
+ add(maxButton);
+ }
+
+ /**
+ * Creates a new instance of <code>MetalTitlePaneLayout</code> (not part of
+ * the public API).
+ *
+ * @return A new instance of <code>MetalTitlePaneLayout</code>.
+ */
+ protected LayoutManager createLayout()
+ {
+ return new MetalTitlePaneLayout();
+ }
+
+ /**
+ * Draws the title pane in the palette style.
+ *
+ * @param g the graphics device.
+ *
+ * @see #paintComponent(Graphics)
+ */
+ public void paintPalette(Graphics g)
+ {
+ Color savedColor = g.getColor();
+ Rectangle b = SwingUtilities.getLocalBounds(this);
+
+ if (UIManager.get("InternalFrame.activeTitleGradient") != null
+ && frame.isSelected())
+ {
+ MetalUtils.paintGradient(g, b.x, b.y, b.width, b.height,
+ SwingConstants.VERTICAL,
+ "InternalFrame.activeTitleGradient");
+ }
+ MetalUtils.fillMetalPattern(this, g, b.x + 4, b.y + 2, b.width
+ - paletteCloseIcon.getIconWidth() - 13, b.height - 5,
+ MetalLookAndFeel.getPrimaryControlHighlight(),
+ MetalLookAndFeel.getBlack());
+
+ // draw a line separating the title pane from the frame content
+ Dimension d = getSize();
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
+
+ g.setColor(savedColor);
+ }
+
+ /**
+ * Paints a representation of the current state of the internal frame.
+ *
+ * @param g the graphics device.
+ */
+ public void paintComponent(Graphics g)
+ {
+ Color savedColor = g.getColor();
+ if (isPalette)
+ paintPalette(g);
+ else
+ {
+ paintTitleBackground(g);
+ paintChildren(g);
+ Dimension d = getSize();
+ if (frame.isSelected())
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+ // put a dot in each of the top corners
+ g.drawLine(0, 0, 0, 0);
+ g.drawLine(d.width - 1, 0, d.width - 1, 0);
+
+ g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
+
+ // draw the metal pattern
+ if (UIManager.get("InternalFrame.activeTitleGradient") != null
+ && frame.isSelected())
+ {
+ MetalUtils.paintGradient(g, 0, 0, getWidth(), getHeight(),
+ SwingConstants.VERTICAL,
+ "InternalFrame.activeTitleGradient");
+ }
+
+ Rectangle b = title.getBounds();
+ int startX = b.x + b.width + 5;
+ int endX = startX;
+ if (iconButton.isVisible())
+ endX = Math.max(iconButton.getX(), endX);
+ else if (maxButton.isVisible())
+ endX = Math.max(maxButton.getX(), endX);
+ else if (closeButton.isVisible())
+ endX = Math.max(closeButton.getX(), endX);
+ endX -= 7;
+ if (endX > startX)
+ MetalUtils.fillMetalPattern(this, g, startX, 3, endX - startX,
+ getHeight() - 6, Color.white, Color.gray);
+ }
+ g.setColor(savedColor);
+ }
+
+ /**
+ * Sets the flag that controls whether the title pane is drawn in the
+ * palette style or the regular style.
+ *
+ * @param b the new value of the flag.
+ */
+ public void setPalette(boolean b)
+ {
+ isPalette = b;
+ title.setVisible(!isPalette);
+ iconButton.setVisible(!isPalette && frame.isIconifiable());
+ maxButton.setVisible(!isPalette && frame.isMaximizable());
+ if (isPalette)
+ closeButton.setIcon(paletteCloseIcon);
+ else
+ closeButton.setIcon(closeIcon);
+ }
+
+ /**
+ * Creates and returns a property change handler for the title pane.
+ *
+ * @return The property change handler.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new MetalInternalFrameTitlePanePropertyChangeHandler();
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,183 @@
+/* MetalInternalFrameUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.ActionMap;
+import javax.swing.JComponent;
+import javax.swing.JInternalFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicInternalFrameUI;
+
+/**
+ * A UI delegate for the {@link JInternalFrame} component.
+ */
+public class MetalInternalFrameUI
+ extends BasicInternalFrameUI
+{
+ /**
+ * The key (<code>JInternalFrame.isPalette</code>) for the client property
+ * that controls whether the internal frame is displayed using the palette
+ * style.
+ */
+ protected static String IS_PALETTE = "JInternalFrame.isPalette";
+
+ /**
+ * Constructs a new instance of <code>MetalInternalFrameUI</code>.
+ *
+ * @param frame the frame.
+ */
+ public MetalInternalFrameUI(JInternalFrame frame)
+ {
+ super(frame);
+ }
+
+ /**
+ * Returns an instance of <code>MetalInternalFrameUI</code>.
+ *
+ * @param component the internal frame.
+ *
+ * @return an instance of <code>MetalInternalFrameUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalInternalFrameUI((JInternalFrame) component);
+ }
+
+ /**
+ * Sets the fields and properties for the component.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ JInternalFrame f = (JInternalFrame) c;
+ boolean isPalette = false;
+ Boolean p = (Boolean) f.getClientProperty(IS_PALETTE);
+ if (p != null)
+ isPalette = p.booleanValue();
+ setPalette(isPalette);
+ }
+
+ /**
+ * Creates and returns the component that will be used for the north pane
+ * of the {@link JInternalFrame}.
+ *
+ * @param w the internal frame.
+ *
+ * @return A new instance of {@link MetalInternalFrameTitlePane}.
+ */
+ protected JComponent createNorthPane(JInternalFrame w)
+ {
+ titlePane = new MetalInternalFrameTitlePane(w);
+ return titlePane;
+ }
+
+ /**
+ * Sets the state of the {@link JInternalFrame} to reflect whether or not
+ * it is using the palette style. When a frame is displayed as a palette,
+ * it uses a different border and the title pane is drawn differently.
+ *
+ * @param isPalette use the palette style?
+ */
+ public void setPalette(boolean isPalette)
+ {
+ MetalInternalFrameTitlePane title = (MetalInternalFrameTitlePane) northPane;
+ title.setPalette(isPalette);
+ if (isPalette)
+ frame.setBorder(new MetalBorders.PaletteBorder());
+ else
+ frame.setBorder(new MetalBorders.InternalFrameBorder());
+ }
+
+ /** A listener that is used to handle IS_PALETTE property changes. */
+ private PropertyChangeListener paletteListener;
+
+ /**
+ * Adds the required listeners.
+ */
+ protected void installListeners()
+ {
+ super.installListeners();
+ paletteListener = new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(IS_PALETTE))
+ {
+ if (Boolean.TRUE.equals(e.getNewValue()))
+ setPalette(true);
+ else
+ setPalette(false);
+ }
+ }
+ };
+ frame.addPropertyChangeListener(paletteListener);
+ }
+
+ /**
+ * Removes the listeners used.
+ */
+ protected void uninstallListeners()
+ {
+ super.uninstallListeners();
+ frame.removePropertyChangeListener(IS_PALETTE, paletteListener);
+ paletteListener = null;
+ }
+
+ /**
+ * Installs keyboard actions. This is overridden to remove the
+ * <code>showSystemMenu</code> Action that is installed by the
+ * <code>BasicInternalFrameUI</code>, since Metal JInternalFrames don't have
+ * a system menu.
+ */
+ protected void installKeyboardActions()
+ {
+ super.installKeyboardActions();
+ ActionMap am = SwingUtilities.getUIActionMap(frame);
+ if (am != null)
+ {
+ am.remove("showSystemMenu");
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,108 @@
+/* MetalLabelUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Graphics;
+
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicGraphicsUtils;
+import javax.swing.plaf.basic.BasicLabelUI;
+
+/**
+ * A UI delegate for the {@link JLabel} component.
+ */
+public class MetalLabelUI
+ extends BasicLabelUI
+{
+
+ /** The shared instance of the UI delegate. */
+ protected static MetalLabelUI metalLabelUI;
+
+ /**
+ * Constructs a new instance of <code>MetalLabelUI</code>.
+ */
+ public MetalLabelUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a shared instance of <code>MetalLabelUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A shared instance of <code>MetalLabelUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ if (metalLabelUI == null)
+ metalLabelUI = new MetalLabelUI();
+ return metalLabelUI;
+ }
+
+ /**
+ * Draws the text for a disabled label, using the color defined in the
+ * {@link UIManager} defaults with the key
+ * <code>Label.disabledForeground</code>.
+ *
+ * @param l the label.
+ * @param g the graphics device.
+ * @param s the label text.
+ * @param textX the x-coordinate for the label.
+ * @param textY the y-coordinate for the label.
+ */
+ protected void paintDisabledText(JLabel l, Graphics g, String s, int textX,
+ int textY)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(UIManager.getColor("Label.disabledForeground"));
+ int mnemIndex = l.getDisplayedMnemonicIndex();
+ if (mnemIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
+ textY);
+ else
+ g.drawString(s, textX, textY);
+
+ g.setColor(savedColor);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1372 @@
+/* MetalLookAndFeel.java
+ Copyright (C) 2002, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import javax.swing.LookAndFeel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.BorderUIResource;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.FontUIResource;
+import javax.swing.plaf.InsetsUIResource;
+import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+
+/**
+ * A custom look and feel that is designed to look similar across different
+ * operating systems. To install this look and feel, add the following code
+ * (or something similar) near the start of your application:</p>
+ * <pre>
+ * try
+ * {
+ * UIManager.setLookAndFeel(new MetalLookAndFeel());
+ * }
+ * catch (UnsupportedLookAndFeelException e)
+ * {
+ * e.printStackTrace();
+ * }</pre>
+ */
+public class MetalLookAndFeel extends BasicLookAndFeel
+{
+ private static final long serialVersionUID = 6680646159193457980L;
+
+ /** The current theme. */
+ private static MetalTheme theme;
+
+ /** The look and feel defaults. */
+ private UIDefaults LAF_defaults;
+
+ /**
+ * Creates a new instance of the Metal look and feel.
+ */
+ public MetalLookAndFeel()
+ {
+ createDefaultTheme();
+ }
+
+ /**
+ * Sets the current theme to a new instance of {@link OceanTheme}.
+ */
+ protected void createDefaultTheme()
+ {
+ if (theme == null)
+ setCurrentTheme(new OceanTheme());
+ }
+
+ /**
+ * Returns <code>false</code> to indicate that this look and feel does not
+ * attempt to emulate the look and feel of native applications on the host
+ * platform.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> to indicate that this look and feel is supported
+ * on all platforms.
+ *
+ * @return <code>true</code>.
+ */
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
+
+ /**
+ * Returns a string describing the look and feel. In this case, the method
+ * returns "Metal look and feel".
+ *
+ * @return A string describing the look and feel.
+ */
+ public String getDescription()
+ {
+ return "The Java(tm) Look and Feel";
+ }
+
+ /**
+ * Returns the look and feel identifier.
+ *
+ * @return "MetalLookAndFeel".
+ */
+ public String getID()
+ {
+ return "Metal";
+ }
+
+ /**
+ * Returns the look and feel name.
+ *
+ * @return "MetalLookAndFeel".
+ */
+ public String getName()
+ {
+ return "Metal";
+ }
+
+ public UIDefaults getDefaults()
+ {
+ if (LAF_defaults == null)
+ {
+ LAF_defaults = super.getDefaults();
+
+ // add custom theme entries to the table
+ if (theme != null)
+ theme.addCustomEntriesToTable(LAF_defaults);
+ }
+
+ // Returns the default values for this look and feel.
+ return LAF_defaults;
+ }
+
+ /**
+ * Returns the accelerator foreground color from the installed theme.
+ *
+ * @return The accelerator foreground color.
+ */
+ public static ColorUIResource getAcceleratorForeground()
+ {
+ if (theme != null)
+ return theme.getAcceleratorForeground();
+ return null;
+ }
+
+ /**
+ * Returns the accelerator selected foreground color from the installed
+ * theme.
+ *
+ * @return The accelerator selected foreground color.
+ */
+ public static ColorUIResource getAcceleratorSelectedForeground()
+ {
+ if (theme != null)
+ return theme.getAcceleratorSelectedForeground();
+ return null;
+ }
+
+ /**
+ * Returns the color black from the installed theme.
+ *
+ * @return The color black.
+ */
+ public static ColorUIResource getBlack()
+ {
+ if (theme != null)
+ return theme.getBlack();
+ return null;
+ }
+
+ /**
+ * Returns the control color from the installed theme.
+ *
+ * @return The control color.
+ */
+ public static ColorUIResource getControl()
+ {
+ if (theme != null)
+ return theme.getControl();
+ return null;
+ }
+
+ /**
+ * Returns the color used for dark shadows on controls, from the installed
+ * theme.
+ *
+ * @return The color used for dark shadows on controls.
+ */
+ public static ColorUIResource getControlDarkShadow()
+ {
+ if (theme != null)
+ return theme.getControlDarkShadow();
+ return null;
+ }
+
+ /**
+ * Returns the color used for disabled controls, from the installed theme.
+ *
+ * @return The color used for disabled controls.
+ */
+ public static ColorUIResource getControlDisabled()
+ {
+ if (theme != null)
+ return theme.getControlDisabled();
+ return null;
+ }
+
+ /**
+ * Returns the color used to draw highlights for controls, from the installed
+ * theme.
+ *
+ * @return The color used to draw highlights for controls.
+ */
+ public static ColorUIResource getControlHighlight()
+ {
+ if (theme != null)
+ return theme.getControlHighlight();
+ return null;
+ }
+
+ /**
+ * Returns the color used to display control info, from the installed
+ * theme.
+ *
+ * @return The color used to display control info.
+ */
+ public static ColorUIResource getControlInfo()
+ {
+ if (theme != null)
+ return theme.getControlInfo();
+ return null;
+ }
+
+ /**
+ * Returns the color used to draw shadows for controls, from the installed
+ * theme.
+ *
+ * @return The color used to draw shadows for controls.
+ */
+ public static ColorUIResource getControlShadow()
+ {
+ if (theme != null)
+ return theme.getControlShadow();
+ return null;
+ }
+
+ /**
+ * Returns the color used for text on controls, from the installed theme.
+ *
+ * @return The color used for text on controls.
+ */
+ public static ColorUIResource getControlTextColor()
+ {
+ if (theme != null)
+ return theme.getControlTextColor();
+ return null;
+ }
+
+ /**
+ * Returns the font used for text on controls, from the installed theme.
+ *
+ * @return The font used for text on controls.
+ */
+ public static FontUIResource getControlTextFont()
+ {
+ if (theme != null)
+ return theme.getControlTextFont();
+ return null;
+ }
+
+ /**
+ * Returns the color used for the desktop background, from the installed
+ * theme.
+ *
+ * @return The color used for the desktop background.
+ */
+ public static ColorUIResource getDesktopColor()
+ {
+ if (theme != null)
+ return theme.getDesktopColor();
+ return null;
+ }
+
+ /**
+ * Returns the color used to draw focus highlights, from the installed
+ * theme.
+ *
+ * @return The color used to draw focus highlights.
+ */
+ public static ColorUIResource getFocusColor()
+ {
+ if (theme != null)
+ return theme.getFocusColor();
+ return null;
+ }
+
+ /**
+ * Returns the color used to draw highlighted text, from the installed
+ * theme.
+ *
+ * @return The color used to draw highlighted text.
+ */
+ public static ColorUIResource getHighlightedTextColor()
+ {
+ if (theme != null)
+ return theme.getHighlightedTextColor();
+ return null;
+ }
+
+ /**
+ * Returns the color used to draw text on inactive controls, from the
+ * installed theme.
+ *
+ * @return The color used to draw text on inactive controls.
+ */
+ public static ColorUIResource getInactiveControlTextColor()
+ {
+ if (theme != null)
+ return theme.getInactiveControlTextColor();
+ return null;
+ }
+
+ /**
+ * Returns the color used to draw inactive system text, from the installed
+ * theme.
+ *
+ * @return The color used to draw inactive system text.
+ */
+ public static ColorUIResource getInactiveSystemTextColor()
+ {
+ if (theme != null)
+ return theme.getInactiveSystemTextColor();
+ return null;
+ }
+
+ /**
+ * Returns the background color for menu items, from the installed theme.
+ *
+ * @return The background color for menu items.
+ *
+ * @see #getMenuSelectedBackground()
+ */
+ public static ColorUIResource getMenuBackground()
+ {
+ if (theme != null)
+ return theme.getMenuBackground();
+ return null;
+ }
+
+ /**
+ * Returns the foreground color for disabled menu items, from the installed
+ * theme.
+ *
+ * @return The foreground color for disabled menu items.
+ *
+ * @see #getMenuForeground()
+ */
+ public static ColorUIResource getMenuDisabledForeground()
+ {
+ if (theme != null)
+ return theme.getMenuDisabledForeground();
+ return null;
+ }
+
+ /**
+ * Returns the foreground color for menu items, from the installed theme.
+ *
+ * @return The foreground color for menu items.
+ *
+ * @see #getMenuDisabledForeground()
+ * @see #getMenuSelectedForeground()
+ */
+ public static ColorUIResource getMenuForeground()
+ {
+ if (theme != null)
+ return theme.getMenuForeground();
+ return null;
+ }
+
+ /**
+ * Returns the background color for selected menu items, from the installed
+ * theme.
+ *
+ * @return The background color for selected menu items.
+ *
+ * @see #getMenuBackground()
+ */
+ public static ColorUIResource getMenuSelectedBackground()
+ {
+ if (theme != null)
+ return theme.getMenuSelectedBackground();
+ return null;
+ }
+
+ /**
+ * Returns the foreground color for selected menu items, from the installed
+ * theme.
+ *
+ * @return The foreground color for selected menu items.
+ *
+ * @see #getMenuForeground()
+ */
+ public static ColorUIResource getMenuSelectedForeground()
+ {
+ if (theme != null)
+ return theme.getMenuSelectedForeground();
+ return null;
+ }
+
+ /**
+ * Returns the font used for text in menus, from the installed theme.
+ *
+ * @return The font used for text in menus.
+ */
+ public static FontUIResource getMenuTextFont()
+ {
+ if (theme != null)
+ return theme.getMenuTextFont();
+ return null;
+ }
+
+ /**
+ * Returns the primary color for controls, from the installed theme.
+ *
+ * @return The primary color for controls.
+ */
+ public static ColorUIResource getPrimaryControl()
+ {
+ if (theme != null)
+ return theme.getPrimaryControl();
+ return null;
+ }
+
+ /**
+ * Returns the primary color for the dark shadow on controls, from the
+ * installed theme.
+ *
+ * @return The primary color for the dark shadow on controls.
+ */
+ public static ColorUIResource getPrimaryControlDarkShadow()
+ {
+ if (theme != null)
+ return theme.getPrimaryControlDarkShadow();
+ return null;
+ }
+
+ /**
+ * Returns the primary color for the highlight on controls, from the
+ * installed theme.
+ *
+ * @return The primary color for the highlight on controls.
+ */
+ public static ColorUIResource getPrimaryControlHighlight()
+ {
+ if (theme != null)
+ return theme.getPrimaryControlHighlight();
+ return null;
+ }
+
+ /**
+ * Returns the primary color for the information on controls, from the
+ * installed theme.
+ *
+ * @return The primary color for the information on controls.
+ */
+ public static ColorUIResource getPrimaryControlInfo()
+ {
+ if (theme != null)
+ return theme.getPrimaryControlInfo();
+ return null;
+ }
+
+ /**
+ * Returns the primary color for the shadow on controls, from the installed
+ * theme.
+ *
+ * @return The primary color for the shadow on controls.
+ */
+ public static ColorUIResource getPrimaryControlShadow()
+ {
+ if (theme != null)
+ return theme.getPrimaryControlShadow();
+ return null;
+ }
+
+ /**
+ * Returns the background color for separators, from the installed theme.
+ *
+ * @return The background color for separators.
+ */
+ public static ColorUIResource getSeparatorBackground()
+ {
+ if (theme != null)
+ return theme.getSeparatorBackground();
+ return null;
+ }
+
+ /**
+ * Returns the foreground color for separators, from the installed theme.
+ *
+ * @return The foreground color for separators.
+ */
+ public static ColorUIResource getSeparatorForeground()
+ {
+ if (theme != null)
+ return theme.getSeparatorForeground();
+ return null;
+ }
+
+ /**
+ * Returns the font used for sub text, from the installed theme.
+ *
+ * @return The font used for sub text.
+ */
+ public static FontUIResource getSubTextFont()
+ {
+ if (theme != null)
+ return theme.getSubTextFont();
+ return null;
+ }
+
+ /**
+ * Returns the color used for system text, from the installed theme.
+ *
+ * @return The color used for system text.
+ */
+ public static ColorUIResource getSystemTextColor()
+ {
+ if (theme != null)
+ return theme.getSystemTextColor();
+ return null;
+ }
+
+ /**
+ * Returns the font used for system text, from the installed theme.
+ *
+ * @return The font used for system text.
+ */
+ public static FontUIResource getSystemTextFont()
+ {
+ if (theme != null)
+ return theme.getSystemTextFont();
+ return null;
+ }
+
+ /**
+ * Returns the color used to highlight text, from the installed theme.
+ *
+ * @return The color used to highlight text.
+ */
+ public static ColorUIResource getTextHighlightColor()
+ {
+ if (theme != null)
+ return theme.getTextHighlightColor();
+ return null;
+ }
+
+ /**
+ * Returns the color used to display user text, from the installed theme.
+ *
+ * @return The color used to display user text.
+ */
+ public static ColorUIResource getUserTextColor()
+ {
+ if (theme != null)
+ return theme.getUserTextColor();
+ return null;
+ }
+
+ /**
+ * Returns the font used for user text, obtained from the current theme.
+ *
+ * @return The font used for user text.
+ */
+ public static FontUIResource getUserTextFont()
+ {
+ if (theme != null)
+ return theme.getUserTextFont();
+ return null;
+ }
+
+ /**
+ * Returns the color used for white, from the installed theme.
+ *
+ * @return The color used for white.
+ */
+ public static ColorUIResource getWhite()
+ {
+ if (theme != null)
+ return theme.getWhite();
+ return null;
+ }
+
+ /**
+ * Returns the window background color, from the installed theme.
+ *
+ * @return The window background color.
+ */
+ public static ColorUIResource getWindowBackground()
+ {
+ if (theme != null)
+ return theme.getWindowBackground();
+ return null;
+ }
+
+ /**
+ * Returns the window title background color, from the installed theme.
+ *
+ * @return The window title background color.
+ */
+ public static ColorUIResource getWindowTitleBackground()
+ {
+ if (theme != null)
+ return theme.getWindowTitleBackground();
+ return null;
+ }
+
+ /**
+ * Returns the window title font from the current theme.
+ *
+ * @return The window title font.
+ *
+ * @see MetalTheme
+ */
+ public static FontUIResource getWindowTitleFont()
+ {
+ if (theme != null)
+ return theme.getWindowTitleFont();
+ return null;
+ }
+
+ /**
+ * Returns the window title foreground color, from the installed theme.
+ *
+ * @return The window title foreground color.
+ */
+ public static ColorUIResource getWindowTitleForeground()
+ {
+ if (theme != null)
+ return theme.getWindowTitleForeground();
+ return null;
+ }
+
+ /**
+ * Returns the background color for an inactive window title, from the
+ * installed theme.
+ *
+ * @return The background color for an inactive window title.
+ */
+ public static ColorUIResource getWindowTitleInactiveBackground()
+ {
+ if (theme != null)
+ return theme.getWindowTitleInactiveBackground();
+ return null;
+ }
+
+ /**
+ * Returns the foreground color for an inactive window title, from the
+ * installed theme.
+ *
+ * @return The foreground color for an inactive window title.
+ */
+ public static ColorUIResource getWindowTitleInactiveForeground()
+ {
+ if (theme != null)
+ return theme.getWindowTitleInactiveForeground();
+ return null;
+ }
+
+ /**
+ * Sets the current theme for the look and feel. Note that the theme must be
+ * set <em>before</em> the look and feel is installed. To change the theme
+ * for an already running application that is using the
+ * {@link MetalLookAndFeel}, first set the theme with this method, then
+ * create a new instance of {@link MetalLookAndFeel} and install it in the
+ * usual way (see {@link UIManager#setLookAndFeel(LookAndFeel)}).
+ *
+ * @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)
+ {
+ if (theme == null)
+ throw new NullPointerException("Null 'theme' not permitted.");
+ MetalLookAndFeel.theme = theme;
+ }
+
+ /**
+ * Sets the ComponentUI classes for all Swing components to the Metal
+ * implementations.
+ *
+ * In particular this sets the following keys:
+ *
+ * <table>
+ * <tr>
+ * <th>Key</th><th>Value</th>
+ * </tr><tr>
+ * <td>ButtonUI</td><td>{@link MetalButtonUI}</td>
+ * </tr><tr>
+ * <td>CheckBoxUI</td><td>{@link MetalCheckBoxUI}</td>
+ * </tr><tr>
+ * <td>ComboBoxUI</td><td>{@link MetalComboBoxUI}</td>
+ * </tr><tr>
+ * <td>DesktopIconUI</td><td>{@link MetalDesktopIconUI}</td>
+ * </tr><tr>
+ * <td>InternalFrameUI</td><td>{@link MetalInternalFrameUI}</td>
+ * </tr><tr>
+ * <td>LabelUI</td><td>{@link MetalLabelUI}</td>
+ * </tr><tr>
+ * <td>PopupMenuSeparatorUI</td><td>{@link MetalPopupMenuSeparatorUI}</td>
+ * </tr><tr>
+ * <td>ProgressBarUI</td><td>{@link MetalProgressBarUI}</td>
+ * </tr><tr>
+ * <td>RadioButtonUI</td><td>{@link MetalRadioButtonUI}</td>
+ * </tr><tr>
+ * <td>RootPaneUI</td><td>{@link MetalRootPaneUI}</td>
+ * </tr><tr>
+ * <td>ScrollBarUI</td><td>{@link MetalScrollBarUI}</td>
+ * </tr><tr>
+ * <td>ScrollPaneUI</td><td>{@link MetalScrollPaneUI}</td>
+ * </tr><tr>
+ * <td>SeparatorUI</td><td>{@link MetalSeparatorUI}</td>
+ * </tr><tr>
+ * <td>SliderUI</td><td>{@link MetalSliderUI}</td>
+ * </tr><tr>
+ * <td>SplitPaneUI</td><td>{@link MetalSplitPaneUI}</td>
+ * </tr><tr>
+ * <td>TabbedPaneUI</td><td>{@link MetalTabbedPaneUI}</td>
+ * </tr><tr>
+ * <td>TextFieldUI</td><td>{@link MetalTextFieldUI}</td>
+ * </tr><tr>
+ * <td>ToggleButtonUI</td><td>{@link MetalToggleButtonUI}</td>
+ * </tr><tr>
+ * <td>ToolBarUI</td><td>{@link MetalToolBarUI}</td>
+ * </tr><tr>
+ * <td>ToolTipUI</td><td>{@link MetalToolTipUI}</td>
+ * </tr><tr>
+ * <td>TreeUI</td><td>{@link MetalTreeUI}</td>
+ * </tr><tr>
+ * </table>
+ *
+ * @param defaults the UIDefaults where the class defaults are added
+ */
+ protected void initClassDefaults(UIDefaults defaults)
+ {
+ super.initClassDefaults(defaults);
+
+ // Variables
+ Object[] uiDefaults;
+ // Initialize Class Defaults
+ uiDefaults = new Object[] {
+ "ButtonUI", "javax.swing.plaf.metal.MetalButtonUI",
+ "CheckBoxUI", "javax.swing.plaf.metal.MetalCheckBoxUI",
+ "ComboBoxUI", "javax.swing.plaf.metal.MetalComboBoxUI",
+ "DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
+ "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI",
+ "InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
+ "LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
+ "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
+ "PopupMenuSeparatorUI",
+ "javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
+ "ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
+ "RadioButtonUI", "javax.swing.plaf.metal.MetalRadioButtonUI",
+ "RootPaneUI", "javax.swing.plaf.metal.MetalRootPaneUI",
+ "ScrollBarUI", "javax.swing.plaf.metal.MetalScrollBarUI",
+ "ScrollPaneUI", "javax.swing.plaf.metal.MetalScrollPaneUI",
+ "SeparatorUI", "javax.swing.plaf.metal.MetalSeparatorUI",
+ "SliderUI", "javax.swing.plaf.metal.MetalSliderUI",
+ "SplitPaneUI", "javax.swing.plaf.metal.MetalSplitPaneUI",
+ "TabbedPaneUI", "javax.swing.plaf.metal.MetalTabbedPaneUI",
+ "TextFieldUI", "javax.swing.plaf.metal.MetalTextFieldUI",
+ "ToggleButtonUI", "javax.swing.plaf.metal.MetalToggleButtonUI",
+ "ToolBarUI", "javax.swing.plaf.metal.MetalToolBarUI",
+ "ToolTipUI", "javax.swing.plaf.metal.MetalToolTipUI",
+ "TreeUI", "javax.swing.plaf.metal.MetalTreeUI",
+ };
+ // Add Class Defaults to UI Defaults table
+ defaults.putDefaults(uiDefaults);
+ }
+
+ /**
+ * Initializes the component defaults for the Metal Look & Feel.
+ *
+ * In particular this sets the following keys (the colors are given
+ * as RGB hex values):
+ *
+ * <table>
+ * <tr>
+ * <th>Key</th><th>Value</th>
+ * </tr><tr>
+ * <td>Button.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
+ * </tr><tr>
+ * <td>Button.font</td><td>{@link #getControlTextFont}</td>
+ * </tr><tr>
+ * <td>Button.margin</td><td><code>new java.awt.Insets(2, 14, 2, 14)</code>
+ * </td>
+ * </tr><tr>
+ * <td>CheckBox.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>CheckBoxMenuItem.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>ToolBar.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>Panel.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>Slider.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>OptionPane.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>ProgressBar.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>TabbedPane.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>Label.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>Label.font</td><td>{@link #getControlTextFont}</td>
+ * </tr><tr>
+ * <td>Menu.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>MenuBar.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>MenuItem.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>ScrollBar.background</td><td>0xcccccc</td>
+ * </tr><tr>
+ * <td>PopupMenu.border</td>
+ * <td><code>new javax.swing.plaf.metal.MetalBorders.PopupMenuBorder()</td>
+ * </tr><tr>
+ * </table>
+ *
+ * @param defaults the UIDefaults instance to which the values are added
+ */
+ protected void initComponentDefaults(UIDefaults defaults)
+ {
+ super.initComponentDefaults(defaults);
+ Object[] myDefaults = new Object[] {
+ "Button.background", getControl(),
+ "Button.border", MetalBorders.getButtonBorder(),
+ "Button.darkShadow", getControlDarkShadow(),
+ "Button.disabledText", getInactiveControlTextColor(),
+ "Button.focus", getFocusColor(),
+ "Button.font", getControlTextFont(),
+ "Button.foreground", getControlTextColor(),
+ "Button.highlight", getControlHighlight(),
+ "Button.light", getControlHighlight(),
+ "Button.margin", new InsetsUIResource(2, 14, 2, 14),
+ "Button.select", getControlShadow(),
+ "Button.shadow", getControlShadow(),
+
+ "CheckBox.background", getControl(),
+ "CheckBox.border", MetalBorders.getButtonBorder(),
+ "CheckBox.disabledText", getInactiveControlTextColor(),
+ "CheckBox.focus", getFocusColor(),
+ "CheckBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "CheckBox.foreground", getControlTextColor(),
+ "CheckBox.icon",
+ new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
+ "CheckBox.checkIcon",
+ new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
+ "Checkbox.select", getControlShadow(),
+
+ "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
+ "CheckBoxMenuItem.acceleratorForeground", getAcceleratorForeground(),
+ "CheckBoxMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
+ "CheckBoxMenuItem.background", getMenuBackground(),
+ "CheckBoxMenuItem.borderPainted", Boolean.TRUE,
+ "CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
+ "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
+ "CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
+ "CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "CheckBoxMenuItem.foreground", getMenuForeground(),
+ "CheckBoxMenuItem.selectionBackground", getMenuSelectedBackground(),
+ "CheckBoxMenuItem.selectionForeground", getMenuSelectedForeground(),
+
+ "ColorChooser.background", getControl(),
+ "ColorChooser.foreground", getControlTextColor(),
+ "ColorChooser.rgbBlueMnemonic", new Integer(0),
+ "ColorChooser.rgbGreenMnemonic", new Integer(0),
+ "ColorChooser.rgbRedMnemonic", new Integer(0),
+ "ColorChooser.swatchesDefaultRecentColor", getControl(),
+
+ "ComboBox.background", getControl(),
+ "ComboBox.buttonBackground", getControl(),
+ "ComboBox.buttonDarkShadow", getControlDarkShadow(),
+ "ComboBox.buttonHighlight", getControlHighlight(),
+ "ComboBox.buttonShadow", getControlShadow(),
+ "ComboBox.disabledBackground", getControl(),
+ "ComboBox.disabledForeground", getInactiveSystemTextColor(),
+ "ComboBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "ComboBox.foreground", getControlTextColor(),
+ "ComboBox.selectionBackground", getPrimaryControlShadow(),
+ "ComboBox.selectionForeground", getControlTextColor(),
+
+ "Desktop.background", getDesktopColor(),
+
+ "DesktopIcon.background", getControl(),
+ "DesktopIcon.foreground", getControlTextColor(),
+ "DesktopIcon.width", new Integer(160),
+ "DesktopIcon.border", MetalBorders.getDesktopIconBorder(),
+
+ "EditorPane.background", getWindowBackground(),
+ "EditorPane.caretForeground", getUserTextColor(),
+ "EditorPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "EditorPane.foreground", getUserTextColor(),
+ "EditorPane.inactiveForeground", getInactiveSystemTextColor(),
+ "EditorPane.selectionBackground", getTextHighlightColor(),
+ "EditorPane.selectionForeground", getHighlightedTextColor(),
+
+ "FormattedTextField.background", getWindowBackground(),
+ "FormattedTextField.border",
+ new BorderUIResource(MetalBorders.getTextFieldBorder()),
+ "FormattedTextField.caretForeground", getUserTextColor(),
+ "FormattedTextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "FormattedTextField.foreground", getUserTextColor(),
+ "FormattedTextField.inactiveBackground", getControl(),
+ "FormattedTextField.inactiveForeground", getInactiveSystemTextColor(),
+ "FormattedTextField.selectionBackground", getTextHighlightColor(),
+ "FormattedTextField.selectionForeground", getHighlightedTextColor(),
+
+ "FileChooser.upFolderIcon",
+ MetalIconFactory.getFileChooserUpFolderIcon(),
+ "FileChooser.listViewIcon",
+ MetalIconFactory.getFileChooserListViewIcon(),
+ "FileChooser.newFolderIcon",
+ MetalIconFactory.getFileChooserNewFolderIcon(),
+ "FileChooser.homeFolderIcon",
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ "FileChooser.detailsViewIcon",
+ MetalIconFactory.getFileChooserDetailViewIcon(),
+ "FileChooser.fileNameLabelMnemonic", new Integer(78),
+ "FileChooser.filesOfTypeLabelMnemonic", new Integer(84),
+ "FileChooser.lookInLabelMnemonic", new Integer(73),
+ "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
+ "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
+ "FileView.fileIcon", MetalIconFactory.getTreeLeafIcon(),
+ "FileView.floppyDriveIcon", MetalIconFactory.getTreeFloppyDriveIcon(),
+ "FileView.hardDriveIcon", MetalIconFactory.getTreeHardDriveIcon(),
+
+ "InternalFrame.activeTitleBackground", getWindowTitleBackground(),
+ "InternalFrame.activeTitleForeground", getWindowTitleForeground(),
+ "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
+ "InternalFrame.borderColor", getControl(),
+ "InternalFrame.borderDarkShadow", getControlDarkShadow(),
+ "InternalFrame.borderHighlight", getControlHighlight(),
+ "InternalFrame.borderLight", getControlHighlight(),
+ "InternalFrame.borderShadow", getControlShadow(),
+ "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
+ "InternalFrame.closeIcon",
+ MetalIconFactory.getInternalFrameCloseIcon(16),
+ "InternalFrame.closeSound", "sounds/FrameClose.wav",
+ "InternalFrame.inactiveTitleBackground", getWindowTitleInactiveBackground(),
+ "InternalFrame.inactiveTitleForeground", getWindowTitleInactiveForeground(),
+ "InternalFrame.maximizeIcon",
+ MetalIconFactory.getInternalFrameMaximizeIcon(16),
+ "InternalFrame.maximizeSound", "sounds/FrameMaximize.wav",
+ "InternalFrame.iconifyIcon",
+ MetalIconFactory.getInternalFrameMinimizeIcon(16),
+ "InternalFrame.minimizeSound", "sounds/FrameMinimize.wav",
+ "InternalFrame.paletteBorder", new MetalBorders.PaletteBorder(),
+ "InternalFrame.paletteCloseIcon", new MetalIconFactory.PaletteCloseIcon(),
+ "InternalFrame.paletteTitleHeight", new Integer(11),
+ "InternalFrame.restoreDownSound", "sounds/FrameRestoreDown.wav",
+ "InternalFrame.restoreUpSound", "sounds/FrameRestoreUp.wav",
+
+ "Label.background", getControl(),
+ "Label.disabledForeground", getInactiveSystemTextColor(),
+ "Label.disabledShadow", getControlShadow(),
+ "Label.font", getControlTextFont(),
+ "Label.foreground", getSystemTextColor(),
+
+ "List.font", getControlTextFont(),
+ "List.background", getWindowBackground(),
+ "List.foreground", getUserTextColor(),
+ "List.selectionBackground", getTextHighlightColor(),
+ "List.selectionForeground", getHighlightedTextColor(),
+ "List.focusCellHighlightBorder",
+ new LineBorderUIResource(MetalLookAndFeel.getFocusColor()),
+
+ "Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
+ "Menu.acceleratorForeground", getAcceleratorForeground(),
+ "Menu.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
+ "Menu.arrowIcon", MetalIconFactory.getMenuArrowIcon(),
+ "Menu.background", getMenuBackground(),
+ "Menu.border", new MetalBorders.MenuItemBorder(),
+ "Menu.borderPainted", Boolean.TRUE,
+ "MenuItem.commandSound", "sounds/MenuItemCommand.wav",
+ "Menu.disabledForeground", getMenuDisabledForeground(),
+ "Menu.font", getControlTextFont(),
+ "Menu.foreground", getMenuForeground(),
+ "Menu.selectionBackground", getMenuSelectedBackground(),
+ "Menu.selectionForeground", getMenuSelectedForeground(),
+ "Menu.submenuPopupOffsetX", new Integer(-4),
+ "Menu.submenuPopupOffsetY", new Integer(-3),
+
+ "MenuBar.background", getMenuBackground(),
+ "MenuBar.border", new MetalBorders.MenuBarBorder(),
+ "MenuBar.font", getControlTextFont(),
+ "MenuBar.foreground", getMenuForeground(),
+ "MenuBar.highlight", getControlHighlight(),
+ "MenuBar.shadow", getControlShadow(),
+
+ "MenuItem.acceleratorDelimiter", "-",
+ "MenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
+ "MenuItem.acceleratorForeground", getAcceleratorForeground(),
+ "MenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
+ "MenuItem.arrowIcon", MetalIconFactory.getMenuItemArrowIcon(),
+ "MenuItem.background", getMenuBackground(),
+ "MenuItem.border", new MetalBorders.MenuItemBorder(),
+ "MenuItem.borderPainted", Boolean.TRUE,
+ "MenuItem.disabledForeground", getMenuDisabledForeground(),
+ "MenuItem.font", getControlTextFont(),
+ "MenuItem.foreground", getMenuForeground(),
+ "MenuItem.selectionBackground", getMenuSelectedBackground(),
+ "MenuItem.selectionForeground", getMenuSelectedForeground(),
+
+ "OptionPane.background", getControl(),
+ "OptionPane.errorSound", "sounds/OptionPaneError.wav",
+ "OptionPane.informationSound", "sounds/OptionPaneInformation.wav",
+ "OptionPane.questionSound", "sounds/OptionPaneQuestion.wav",
+ "OptionPane.warningSound", "sounds/OptionPaneWarning.wav",
+ "OptionPane.errorDialog.border.background", new ColorUIResource(153, 51, 51),
+ "OptionPane.errorDialog.titlePane.background", new ColorUIResource(255, 153, 153),
+ "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(51, 0, 0),
+ "OptionPane.errorDialog.titlePane.shadow", new ColorUIResource(204, 102, 102),
+ "OptionPane.foreground", getControlTextColor(),
+ "OptionPane.messageForeground", getControlTextColor(),
+ "OptionPane.questionDialog.border.background", new ColorUIResource(51, 102, 51),
+ "OptionPane.questionDialog.titlePane.background", new ColorUIResource(153, 204, 153),
+ "OptionPane.questionDialog.titlePane.foreground", new ColorUIResource(0, 51, 0),
+ "OptionPane.questionDialog.titlePane.shadow", new ColorUIResource(102, 153, 102),
+ "OptionPane.warningDialog.border.background", new ColorUIResource(153, 102, 51),
+ "OptionPane.warningDialog.titlePane.background", new ColorUIResource(255, 204, 153),
+ "OptionPane.warningDialog.titlePane.foreground", new ColorUIResource(102, 51, 0),
+ "OptionPane.warningDialog.titlePane.shadow", new ColorUIResource(204, 153, 102),
+
+ "Panel.background", getControl(),
+ "Panel.foreground", getUserTextColor(),
+
+ "PasswordField.background", getWindowBackground(),
+ "PasswordField.border",
+ new BorderUIResource(MetalBorders.getTextFieldBorder()),
+ "PasswordField.caretForeground", getUserTextColor(),
+ "PasswordField.foreground", getUserTextColor(),
+ "PasswordField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "PasswordField.inactiveBackground", getControl(),
+ "PasswordField.inactiveForeground", getInactiveSystemTextColor(),
+ "PasswordField.selectionBackground", getTextHighlightColor(),
+ "PasswordField.selectionForeground", getHighlightedTextColor(),
+
+ "PopupMenu.background", getMenuBackground(),
+ "PopupMenu.border", new MetalBorders.PopupMenuBorder(),
+ "PopupMenu.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "PopupMenu.foreground", getMenuForeground(),
+ "PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
+
+ "ProgressBar.background", getControl(),
+ "ProgressBar.border", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
+ "ProgressBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "ProgressBar.foreground", getPrimaryControlShadow(),
+ "ProgressBar.selectionBackground", getPrimaryControlDarkShadow(),
+ "ProgressBar.selectionForeground", getControl(),
+
+ "RadioButton.background", getControl(),
+ "RadioButton.darkShadow", getControlDarkShadow(),
+ "RadioButton.disabledText", getInactiveControlTextColor(),
+ "RadioButton.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return MetalIconFactory.getRadioButtonIcon();
+ }
+ },
+ "RadioButton.focus", MetalLookAndFeel.getFocusColor(),
+ "RadioButton.font", MetalLookAndFeel.getControlTextFont(),
+ "RadioButton.foreground", getControlTextColor(),
+ "RadioButton.highlight", getControlHighlight(),
+ "RadioButton.light", getControlHighlight(),
+ "RadioButton.select", getControlShadow(),
+ "RadioButton.shadow", getControlShadow(),
+
+ "RadioButtonMenuItem.acceleratorFont", new Font("Dialog", Font.PLAIN, 10),
+ "RadioButtonMenuItem.acceleratorForeground", getAcceleratorForeground(),
+ "RadioButtonMenuItem.acceleratorSelectionForeground", getAcceleratorSelectedForeground(),
+ "RadioButtonMenuItem.background", getMenuBackground(),
+ "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
+ "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
+ "RadioButtonMenuItem.checkIcon",
+ MetalIconFactory.getRadioButtonMenuItemIcon(),
+ "RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
+ "RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
+ "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
+ "RadioButtonMenuItem.foreground", getMenuForeground(),
+ "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
+ "RadioButtonMenuItem.selectionBackground",
+ MetalLookAndFeel.getMenuSelectedBackground(),
+ "RadioButtonMenuItem.selectionForeground",
+ MetalLookAndFeel.getMenuSelectedForeground(),
+
+ "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
+ "ScrollBar.background", getControl(),
+ "ScrollBar.darkShadow", getControlDarkShadow(),
+ "ScrollBar.foreground", getControl(),
+ "ScrollBar.highlight", getControlHighlight(),
+ "ScrollBar.shadow", getControlShadow(),
+ "ScrollBar.thumb", getPrimaryControlShadow(),
+ "ScrollBar.thumbDarkShadow", getControlDarkShadow(),
+ "ScrollBar.thumbHighlight", getPrimaryControl(),
+ "ScrollBar.thumbShadow", getPrimaryControlDarkShadow(),
+ "ScrollBar.track", getControl(),
+ "ScrollBar.trackHighlight", getControlDarkShadow(),
+ "ScrollBar.width", new Integer(17),
+
+ "ScrollPane.background", getControl(),
+ "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
+ "ScrollPane.foreground", getControlTextColor(),
+
+ "Separator.background", getSeparatorBackground(),
+ "Separator.foreground", getSeparatorForeground(),
+ "Separator.highlight", getControlHighlight(),
+ "Separator.shadow", getControlShadow(),
+
+ "Slider.background", getControl(),
+ "Slider.focus", getFocusColor(),
+ "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
+ "Slider.foreground", getPrimaryControlShadow(),
+ "Slider.highlight", getControlHighlight(),
+ "Slider.horizontalThumbIcon",
+ MetalIconFactory.getHorizontalSliderThumbIcon(),
+ "Slider.majorTickLength", new Integer(6),
+ "Slider.shadow", getControlShadow(),
+ "Slider.trackWidth", new Integer(7),
+ "Slider.verticalThumbIcon",
+ MetalIconFactory.getVerticalSliderThumbIcon(),
+
+ "Spinner.arrowButtonInsets", new InsetsUIResource(0, 0, 0, 0),
+ "Spinner.background", getControl(),
+ "Spinner.border", MetalBorders.getTextFieldBorder(),
+ "Spinner.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "Spinner.foreground", getControl(),
+
+ "SplitPane.background", getControl(),
+ "SplitPane.darkShadow", getControlDarkShadow(),
+ "SplitPane.dividerFocusColor", getPrimaryControl(),
+ "SplitPane.dividerSize", new Integer(10),
+ "SplitPane.highlight", getControlHighlight(),
+ "SplitPane.shadow", getControlShadow(),
+
+ "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(), // overridden in OceanTheme
+ "TabbedPane.selectHighlight", getControlHighlight(),
+ "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
+ "TabbedPane.shadow", getControlShadow(),
+ "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(),
+ "Table.foreground", getControlTextColor(),
+ "Table.focusCellHighlightBorder",
+ new BorderUIResource.LineBorderUIResource(getFocusColor()),
+ "Table.focusCellBackground", getWindowBackground(),
+ "Table.gridColor", getControlDarkShadow(),
+ "Table.selectionBackground", new ColorUIResource(204, 204, 255),
+ "Table.selectionForeground", new ColorUIResource(0, 0, 0),
+
+ "TableHeader.background", getControl(),
+ "TableHeader.cellBorder", new MetalBorders.TableHeaderBorder(),
+ "TableHeader.foreground", getControlTextColor(),
+
+ "TextArea.background", getWindowBackground(),
+ "TextArea.caretForeground", getUserTextColor(),
+ "TextArea.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "TextArea.foreground", getUserTextColor(),
+ "TextArea.inactiveForeground", getInactiveSystemTextColor(),
+ "TextArea.selectionBackground", getTextHighlightColor(),
+ "TextArea.selectionForeground", getHighlightedTextColor(),
+
+ "TextField.background", getWindowBackground(),
+ "TextField.border",
+ new BorderUIResource(MetalBorders.getTextFieldBorder()),
+ "TextField.caretForeground", getUserTextColor(),
+ "TextField.darkShadow", getControlDarkShadow(),
+ "TextField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "TextField.foreground", getUserTextColor(),
+ "TextField.highlight", getControlHighlight(),
+ "TextField.inactiveBackground", getControl(),
+ "TextField.inactiveForeground", getInactiveSystemTextColor(),
+ "TextField.light", getControlHighlight(),
+ "TextField.selectionBackground", getTextHighlightColor(),
+ "TextField.selectionForeground", getHighlightedTextColor(),
+ "TextField.shadow", getControlShadow(),
+
+ "TextPane.background", getWindowBackground(),
+ "TextPane.caretForeground", getUserTextColor(),
+ "TextPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "TextPane.foreground", getUserTextColor(),
+ "TextPane.inactiveForeground", getInactiveSystemTextColor(),
+ "TextPane.selectionBackground", getTextHighlightColor(),
+ "TextPane.selectionForeground", getHighlightedTextColor(),
+
+ "TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1),
+ "TitledBorder.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "TitledBorder.titleColor", getSystemTextColor(),
+
+ "ToggleButton.background", getControl(),
+ "ToggleButton.border", MetalBorders.getToggleButtonBorder(),
+ "ToggleButton.darkShadow", getControlDarkShadow(),
+ "ToggleButton.disabledText", getInactiveControlTextColor(),
+ "ToggleButton.focus", getFocusColor(),
+ "ToggleButton.font", getControlTextFont(),
+ "ToggleButton.foreground", getControlTextColor(),
+ "ToggleButton.highlight", getControlHighlight(),
+ "ToggleButton.light", getControlHighlight(),
+ "ToggleButton.margin", new InsetsUIResource(2, 14, 2, 14),
+ "ToggleButton.select", getControlShadow(),
+ "ToggleButton.shadow", getControlShadow(),
+
+ "ToolBar.background", getMenuBackground(),
+ "ToolBar.darkShadow", getControlDarkShadow(),
+ "ToolBar.dockingBackground", getMenuBackground(),
+ "ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
+ "ToolBar.floatingBackground", getMenuBackground(),
+ "ToolBar.floatingForeground", getPrimaryControl(),
+ "ToolBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "ToolBar.foreground", getMenuForeground(),
+ "ToolBar.highlight", getControlHighlight(),
+ "ToolBar.light", getControlHighlight(),
+ "ToolBar.shadow", getControlShadow(),
+ "ToolBar.border", new MetalBorders.ToolBarBorder(),
+ "ToolBar.rolloverBorder", MetalBorders.getToolbarButtonBorder(),
+ "ToolBar.nonrolloverBorder", MetalBorders.getToolbarButtonBorder(),
+
+ "ToolTip.background", getPrimaryControl(),
+ "ToolTip.backgroundInactive", getControl(),
+ "ToolTip.border", new BorderUIResource.LineBorderUIResource(getPrimaryControlDarkShadow(), 1),
+ "ToolTip.borderInactive", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
+ "ToolTip.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "ToolTip.foreground", getPrimaryControlInfo(),
+ "ToolTip.foregroundInactive", getControlDarkShadow(),
+ "ToolTip.hideAccelerator", Boolean.FALSE,
+
+ "Tree.background", getWindowBackground(),
+ "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
+ "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
+ "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
+ "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "Tree.foreground", getUserTextColor(),
+ "Tree.hash", getPrimaryControl(),
+ "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
+ "Tree.leftChildIndent", new Integer(7),
+ "Tree.line", getPrimaryControl(),
+ "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
+ "Tree.rightChildIndent", new Integer(13),
+ "Tree.rowHeight", new Integer(0),
+ "Tree.scrollsOnExpand", Boolean.TRUE,
+ "Tree.selectionBackground", getTextHighlightColor(),
+ "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
+ "Tree.selectionBorderColor", getFocusColor(),
+ "Tree.selectionForeground", getHighlightedTextColor(),
+ "Tree.textBackground", getWindowBackground(),
+ "Tree.textForeground", getUserTextColor(),
+
+ "Viewport.background", getControl(),
+ "Viewport.foreground", getUserTextColor()
+ };
+ defaults.putDefaults(myDefaults);
+ }
+
+ /**
+ * Initializes the system color defaults.
+ *
+ * In particular this sets the following keys:
+ *
+ * <table>
+ * <tr>
+ * <th>Key</th><th>Value</th><th>Description</th>
+ * </tr><tr>
+ * <td>control</td><td>0xcccccc</td><td>The default color for components</td>
+ * </tr>
+ * </table>
+ */
+ protected void initSystemColorDefaults(UIDefaults defaults)
+ {
+ super.initSystemColorDefaults(defaults);
+ Object[] uiDefaults;
+ uiDefaults = new Object[] {
+ "control", new ColorUIResource(getControl()),
+ "desktop", new ColorUIResource(getDesktopColor())
+ };
+ defaults.putDefaults(uiDefaults);
+ }
+
+ /**
+ * Returns the current theme for the Metal look and feel. The default is
+ * an instance of {@link OceanTheme}.
+ *
+ * @return The current theme (never <code>null</code>).
+ *
+ * @see #setCurrentTheme(MetalTheme)
+ */
+ public static MetalTheme getCurrentTheme()
+ {
+ if (theme == null)
+ theme = new OceanTheme();
+ return theme;
+ }
+
+ /**
+ * Returns <code>true</code> because the Metal look
+ * and feel supports window decorations for toplevel
+ * containers.
+ *
+ * @return <code>true</code>
+ */
+ public boolean getSupportsWindowDecorations()
+ {
+ return true;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,91 @@
+/* MetalMenuBarUI.java -- MenuBar UI for the Metal L&F
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Graphics;
+
+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;
+
+/**
+ * A UI implementation for MenuBar in the Metal Look & Feel.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public class MetalMenuBarUI extends BasicMenuBarUI
+{
+ /**
+ * Creates and returns a new instance of this UI for the specified component.
+ *
+ * @param c the component to create a UI for
+ *
+ * @return the UI for the component
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new MetalMenuBarUI();
+ }
+
+
+ /**
+ * If the property <code>MenuBar.gradient</code> is set, then a gradient
+ * is painted as background, otherwise the normal superclass behaviour is
+ * called.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ 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");
+ paint(g, c);
+ }
+ else
+ super.update(g, c);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* MetalPopupMenuSeparatorUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate for the {@link JPopupMenu.Separator} component.
+ */
+public class MetalPopupMenuSeparatorUI
+ extends MetalSeparatorUI
+{
+
+ // FIXME: maybe replace by a Map of instances when this becomes stateful
+ /** The shared UI instance for MetalPopupMenuSeparatorUIs */
+ private static MetalPopupMenuSeparatorUI instance;
+
+ /**
+ * Constructs a new instance of <code>MetalPopupMenuSeparatorUI</code>.
+ */
+ public MetalPopupMenuSeparatorUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a shared instance of <code>MetalPopupMenuSeparatorUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A shared instance of <code>MetalPopupMenuSeparatorUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ if (instance == null)
+ instance = new MetalPopupMenuSeparatorUI();
+ return instance;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalProgressBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalProgressBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalProgressBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalProgressBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,147 @@
+/* MetalProgressBarUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Insets;
+
+import javax.swing.JComponent;
+import javax.swing.JProgressBar;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicProgressBarUI;
+
+/**
+ * A UI delegate for the {@link JProgressBar} component.
+ */
+public class MetalProgressBarUI extends BasicProgressBarUI
+{
+ /**
+ * Constructs a new instance of <code>MetalProgressBarUI</code>.
+ */
+ public MetalProgressBarUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalProgressBarUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalProgressBarUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalProgressBarUI();
+ }
+
+ /**
+ * Performs the painting for determinate progress bars. This calls the
+ * superclass behaviour and then adds some highlighting to the upper and left
+ * edge of the progress bar.
+ *
+ * @param g the graphics context
+ * @param c not used here
+ */
+ public void paintDeterminate(Graphics g, JComponent c)
+ {
+ super.paintDeterminate(g, c);
+ Color saved = g.getColor();
+ Insets i = progressBar.getInsets();
+ int w = progressBar.getWidth();
+ int h = progressBar.getHeight();
+ int orientation = progressBar.getOrientation();
+
+ Color shadow = MetalLookAndFeel.getControlShadow();
+ g.setColor(shadow);
+
+ g.drawLine(i.left, i.top, w - i.right, i.top);
+ g.drawLine(i.left, i.top, i.left, h - i.bottom);
+ int full = getAmountFull(i, w, h);
+ if (full > 0)
+ {
+ Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
+ g.setColor(darkShadow);
+ if (orientation == JProgressBar.HORIZONTAL)
+ {
+ g.drawLine(i.left, i.top, i.left, h - i.bottom);
+ g.drawLine(i.left, i.top, i.left + full - 1, i.top);
+ }
+ else
+ {
+ if (full >= (h - i.top - i.bottom))
+ g.drawLine(i.left, i.top, w - i.right, i.top);
+ g.drawLine(i.left, h - i.bottom, i.left, h - i.bottom - full);
+ }
+ }
+ g.setColor(saved);
+ }
+
+ /**
+ * Performs the painting for indeterminate progress bars. This calls the
+ * superclass behaviour and then adds some highlighting to the upper and left
+ * edge of the progress bar.
+ *
+ * @param g the graphics context
+ * @param c not used here
+ */
+ public void paintIndeterminate(Graphics g, JComponent c)
+ {
+ super.paintIndeterminate(g, c);
+ Color saved = g.getColor();
+ Insets i = progressBar.getInsets();
+ int w = progressBar.getWidth();
+ int h = progressBar.getHeight();
+ Color shadow = MetalLookAndFeel.getControlShadow();
+ g.setColor(shadow);
+ g.drawLine(i.left, i.top, w - i.right, i.top);
+ g.drawLine(i.left, i.top, i.left, h - i.bottom);
+
+ boxRect = getBox(boxRect);
+ Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();
+ g.setColor(darkShadow);
+ int orientation = progressBar.getOrientation();
+ if (orientation == JProgressBar.HORIZONTAL)
+ g.drawLine(boxRect.x, i.top, boxRect.x + boxRect.width - 1, i.top);
+ else
+ g.drawLine(i.left, boxRect.y, i.left, boxRect.y + boxRect.height - 1);
+ g.setColor(saved);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,183 @@
+/* MetalRadioButtonUI.java
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.JRadioButton;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicRadioButtonUI;
+
+
+/**
+ * A UI delegate for the {@link JRadioButton} component.
+ */
+public class MetalRadioButtonUI
+ extends BasicRadioButtonUI
+{
+
+ /** Used to draw the focus rectangle. */
+ protected Color focusColor;
+
+ /** Used to fill the icon when the button is pressed. */
+ protected Color selectColor;
+
+ /** Used to draw disabled text. */
+ protected Color disabledTextColor;
+
+ /**
+ * Constructs a new instance of <code>MetalRadioButtonUI</code>.
+ */
+ public MetalRadioButtonUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalRadioButtonUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalRadioButtonUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalRadioButtonUI();
+ }
+
+ /**
+ * Sets the default values for the specified button.
+ *
+ * @param b the button.
+ */
+ public void installDefaults(AbstractButton b)
+ {
+ super.installDefaults(b);
+ String prefix = getPropertyPrefix();
+ disabledTextColor = UIManager.getColor(prefix + "disabledText");
+ focusColor = UIManager.getColor(prefix + "focus");
+ selectColor = UIManager.getColor(prefix + "select");
+ }
+
+ /**
+ * Clears any defaults set in the installDefaults() method.
+ *
+ * @param b the {@link JRadioButton}.
+ */
+ protected void uninstallDefaults(AbstractButton b)
+ {
+ super.uninstallDefaults(b);
+ disabledTextColor = null;
+ focusColor = null;
+ selectColor = null;
+ }
+
+ /**
+ * Returns the color used to fill the {@link JRadioButton}'s icon when the
+ * button is pressed. The default color is obtained from the
+ * {@link UIManager} defaults via an entry with the key
+ * <code>RadioButton.select</code>.
+ *
+ * @return The select color.
+ */
+ protected Color getSelectColor()
+ {
+ return selectColor;
+ }
+
+ /**
+ * Returns the color for the {@link JRadioButton}'s text when the button is
+ * disabled. The default color is obtained from the {@link UIManager}
+ * defaults via an entry with the key <code>RadioButton.disabledText</code>.
+ *
+ * @return The disabled text color.
+ */
+ protected Color getDisabledTextColor()
+ {
+ return disabledTextColor;
+ }
+
+ /**
+ * Returns the color used to draw the focus rectangle when the
+ * {@link JRadioButton} has the focus. The default color is obtained from
+ * the {@link UIManager} defaults via an entry with the key
+ * <code>RadioButton.focus</code>.
+ *
+ * @return The color used to draw the focus rectangle.
+ *
+ * @see #paintFocus(Graphics, Rectangle, Dimension)
+ */
+ protected Color getFocusColor()
+ {
+ return focusColor;
+ }
+
+ /**
+ * Paints the {@link JRadioButton}.
+ *
+ * @param g the graphics device.
+ * @param c the component (an instance of {@link JRadioButton}).
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ super.paint(g, c);
+ // FIXME: disabled text isn't being drawn correctly, it's possible that
+ // it could be done here...
+ }
+
+ /**
+ * Paints the focus rectangle for the {@link JRadioButton}.
+ *
+ * @param g the graphics device.
+ * @param t the bounding rectangle for the text.
+ * @param d ???
+ */
+ protected void paintFocus(Graphics g, Rectangle t, Dimension d)
+ {
+ g.setColor(focusColor);
+ g.drawRect(t.x - 1, t.y - 1, t.width + 2, t.height + 2);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1075 @@
+/* MetalRootPaneUI.java
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.LayoutManager2;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JRootPane;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.AbstractBorder;
+import javax.swing.event.MouseInputAdapter;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicRootPaneUI;
+
+/**
+ * A UI delegate for the {@link JRootPane} component. This implementation
+ * supports the JRootPane <code>windowDecorationStyle</code> property.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.4
+ */
+public class MetalRootPaneUI
+ extends BasicRootPaneUI
+{
+
+ /**
+ * The border that is used on JRootPane when the windowDecorationStyle
+ * property of the JRootPane is set to a different value than NONE.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private static class MetalFrameBorder
+ extends AbstractBorder
+ {
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component
+ * @param newInsets the insets to be filled with the return value, may be
+ * <code>null</code> in which case a new object is created
+ *
+ * @return the border insets
+ */
+ public Insets getBorderInsets(Component c, Insets newInsets)
+ {
+ if (newInsets == null)
+ newInsets = new Insets(5, 5, 5, 5);
+ else
+ {
+ newInsets.top = 5;
+ newInsets.left = 5;
+ newInsets.bottom = 5;
+ newInsets.right = 5;
+ }
+ return newInsets;
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component
+ *
+ * @return the border insets
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component
+ * @param g the graphics device
+ * @param x the x-coordinate
+ * @param y the y-coordinate
+ * @param w the width
+ * @param h the height
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ JRootPane f = (JRootPane) c;
+ Window frame = SwingUtilities.getWindowAncestor(f);
+ if (frame.isActive())
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+ // Fill the border background.
+ g.fillRect(x, y, w, 5);
+ g.fillRect(x, y, 5, h);
+ g.fillRect(x + w - 5, y, 5, h);
+ g.fillRect(x, y + h - 5, w, 5);
+
+ // Draw a dot in each corner.
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x, y, 1, 1);
+ g.fillRect(x + w - 1, y, 1, 1);
+ g.fillRect(x + w - 1, y + h - 1, 1, 1);
+ g.fillRect(x, y + h - 1, 1, 1);
+
+ // Draw the lines.
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 14, y + 2, x + w - 15, y + 2);
+ g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3);
+ g.drawLine(x + 2, y + 14, x + 2, y + h - 15);
+ g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
+
+ // Draw the line highlights.
+ if (frame.isActive())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
+ g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
+ g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
+ g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14);
+ }
+ }
+
+ /**
+ * The component that renders the title bar for frames. This duplicates
+ * most of {@link MetalInternalFrameTitlePane}. It is not reasonably possible
+ * to reuse that class because that is bound to the JInternalFrame and we
+ * need to handle JFrames/JRootPanes here.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private static class MetalTitlePane extends JComponent
+ {
+
+ /**
+ * Handles dragging of the title pane and moves the window accordingly.
+ */
+ private class MouseHandler
+ extends MouseInputAdapter
+ {
+ /**
+ * The point where the dragging started.
+ */
+ Point lastDragLocation;
+
+ /**
+ * Receives notification when the mouse gets pressed on the title pane.
+ * This updates the lastDragLocation.
+ *
+ * @param ev the mouse event
+ */
+ public void mousePressed(MouseEvent ev)
+ {
+ lastDragLocation = ev.getPoint();
+ }
+
+ /**
+ * Receives notification when the mouse is dragged on the title pane.
+ * This will move the nearest window accordingly.
+ *
+ * @param ev the mouse event
+ */
+ public void mouseDragged(MouseEvent ev)
+ {
+ Point dragLocation = ev.getPoint();
+ int deltaX = dragLocation.x - lastDragLocation.x;
+ int deltaY = dragLocation.y - lastDragLocation.y;
+ Window window = SwingUtilities.getWindowAncestor(rootPane);
+ Point loc = window.getLocation();
+ window.setLocation(loc.x + deltaX, loc.y + deltaY);
+ // Note that we do not update the lastDragLocation. This is because
+ // we move the underlying window while dragging the component, which
+ // results in having the same lastDragLocation under the mouse while
+ // dragging.
+ }
+ }
+
+ /**
+ * The Action responsible for closing the JInternalFrame.
+ */
+ private class CloseAction extends AbstractAction
+ {
+ /**
+ * Creates a new action.
+ */
+ public CloseAction()
+ {
+ super("Close");
+ }
+
+ /**
+ * This method is called when something closes the frame.
+ *
+ * @param e the ActionEvent
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Window frame = SwingUtilities.getWindowAncestor(rootPane);
+ if (frame instanceof JFrame)
+ {
+ JFrame jframe = (JFrame) frame;
+ switch (jframe.getDefaultCloseOperation())
+ {
+ case JFrame.EXIT_ON_CLOSE:
+ jframe.setVisible(false);
+ jframe.dispose();
+ System.exit(0);
+ break;
+ case JFrame.DISPOSE_ON_CLOSE:
+ jframe.setVisible(false);
+ jframe.dispose();
+ break;
+ case JFrame.HIDE_ON_CLOSE:
+ jframe.setVisible(false);
+ break;
+ case JFrame.DO_NOTHING_ON_CLOSE:
+ default:
+ break;
+ }
+ }
+ else if (frame instanceof JDialog)
+ {
+ JDialog jdialog = (JDialog) frame;
+ switch (jdialog.getDefaultCloseOperation())
+ {
+ case JFrame.DISPOSE_ON_CLOSE:
+ jdialog.setVisible(false);
+ jdialog.dispose();
+ break;
+ case JFrame.HIDE_ON_CLOSE:
+ jdialog.setVisible(false);
+ break;
+ case JFrame.DO_NOTHING_ON_CLOSE:
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * This action is performed when the iconify button is pressed.
+ */
+ private class IconifyAction
+ extends AbstractAction
+ {
+
+ public void actionPerformed(ActionEvent event)
+ {
+ Window w = SwingUtilities.getWindowAncestor(rootPane);
+ if (w instanceof Frame)
+ {
+ Frame f = (Frame) w;
+ int state = f.getExtendedState();
+ f.setExtendedState(Frame.ICONIFIED);
+ }
+ }
+
+ }
+
+ /**
+ * This action is performed when the maximize button is pressed.
+ */
+ private class MaximizeAction
+ extends AbstractAction
+ {
+
+ public void actionPerformed(ActionEvent event)
+ {
+ Window w = SwingUtilities.getWindowAncestor(rootPane);
+ if (w instanceof Frame)
+ {
+ Frame f = (Frame) w;
+ int state = f.getExtendedState();
+ f.setExtendedState(Frame.MAXIMIZED_BOTH);
+ }
+ }
+ }
+
+ /**
+ * This helper class is used to create the minimize, maximize and close
+ * buttons in the top right corner of the Title Pane. These buttons are
+ * special since they cannot be given focus and have no border.
+ */
+ private class PaneButton extends JButton
+ {
+ /**
+ * Creates a new PaneButton object with the given Action.
+ *
+ * @param a The Action that the button uses.
+ */
+ public PaneButton(Action a)
+ {
+ super(a);
+ setMargin(new Insets(0, 0, 0, 0));
+ }
+
+ /**
+ * This method returns true if the Component can be focused.
+ *
+ * @return false.
+ */
+ public boolean isFocusable()
+ {
+ // These buttons cannot be given focus.
+ return false;
+ }
+
+ }
+
+ /**
+ * The layout for the JRootPane when the <code>windowDecorationStyle</code>
+ * property is set. In addition to the usual JRootPane.RootLayout behaviour
+ * this lays out the titlePane.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ */
+ private class MetalTitlePaneLayout implements LayoutManager
+ {
+ /**
+ * Creates a new <code>TitlePaneLayout</code> object.
+ */
+ public MetalTitlePaneLayout()
+ {
+ // Do nothing.
+ }
+
+ /**
+ * Adds a Component to the Container.
+ *
+ * @param name The name to reference the added Component by.
+ * @param c The Component to add.
+ */
+ public void addLayoutComponent(String name, Component c)
+ {
+ // Do nothing.
+ }
+
+ /**
+ * This method is called to lay out the children of the Title Pane.
+ *
+ * @param c The Container to lay out.
+ */
+ public void layoutContainer(Container c)
+ {
+
+ Dimension size = c.getSize();
+ Insets insets = c.getInsets();
+ int width = size.width - insets.left - insets.right;
+ int height = size.height - insets.top - insets.bottom;
+
+ int loc = width - insets.right - 1;
+ int top = insets.top + 2;
+ int buttonHeight = height - 4;
+ if (closeButton.isVisible())
+ {
+ int buttonWidth = closeIcon.getIconWidth();
+ loc -= buttonWidth + 2;
+ closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ loc -= 6;
+ }
+
+ if (maxButton.isVisible())
+ {
+ int buttonWidth = maxIcon.getIconWidth();
+ loc -= buttonWidth + 4;
+ maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ }
+
+ if (iconButton.isVisible())
+ {
+ int buttonWidth = minIcon.getIconWidth();
+ loc -= buttonWidth + 4;
+ iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
+ loc -= 2;
+ }
+
+ Dimension titlePreferredSize = title.getPreferredSize();
+ title.setBounds(insets.left + 5, insets.top,
+ Math.min(titlePreferredSize.width, loc - insets.left - 10),
+ height);
+
+ }
+
+ /**
+ * This method returns the minimum size of the given Container given the
+ * children that it has.
+ *
+ * @param c The Container to get a minimum size for.
+ *
+ * @return The minimum size of the Container.
+ */
+ public Dimension minimumLayoutSize(Container c)
+ {
+ return preferredLayoutSize(c);
+ }
+
+ /**
+ * Returns the preferred size of the given Container taking
+ * into account the children that it has.
+ *
+ * @param c The Container to lay out.
+ *
+ * @return The preferred size of the Container.
+ */
+ public Dimension preferredLayoutSize(Container c)
+ {
+ return new Dimension(22, 22);
+ }
+
+ /**
+ * Removes a Component from the Container.
+ *
+ * @param c The Component to remove.
+ */
+ public void removeLayoutComponent(Component c)
+ {
+ // Nothing to do here.
+ }
+ }
+
+ JRootPane rootPane;
+
+ /** The button that closes the JInternalFrame. */
+ JButton closeButton;
+
+ /** The button that iconifies the JInternalFrame. */
+ JButton iconButton;
+
+ /** The button that maximizes the JInternalFrame. */
+ JButton maxButton;
+
+ Icon minIcon;
+
+ /** The icon displayed in the maximize button. */
+ Icon maxIcon;
+
+ /** The icon displayed in the iconify button. */
+ private Icon iconIcon;
+
+ /** The icon displayed in the close button. */
+ Icon closeIcon;
+
+ /**
+ * The background color of the TitlePane when the JInternalFrame is not
+ * selected.
+ */
+ private Color notSelectedTitleColor;
+
+ /**
+ * The background color of the TitlePane when the JInternalFrame is
+ * selected.
+ */
+ private Color selectedTitleColor;
+
+ /**
+ * The label used to display the title. This label is not added to the
+ * TitlePane.
+ */
+ JLabel title;
+
+ /** The action associated with closing the JInternalFrame. */
+ private Action closeAction;
+
+ /** The action associated with iconifying the JInternalFrame. */
+ private Action iconifyAction;
+
+ /** The action associated with maximizing the JInternalFrame. */
+ private Action maximizeAction;
+
+ /** The JMenuBar that is located at the top left of the Title Pane. */
+ private JMenuBar menuBar;
+
+ /** The JMenu inside the menuBar. */
+ protected JMenu windowMenu;
+
+ MetalTitlePane(JRootPane rp)
+ {
+ rootPane = rp;
+ setLayout(createLayout());
+ title = new JLabel();
+ title.setHorizontalAlignment(SwingConstants.LEFT);
+ title.setHorizontalTextPosition(SwingConstants.LEFT);
+ title.setOpaque(false);
+ installTitlePane();
+ }
+
+ protected LayoutManager createLayout()
+ {
+ return new MetalTitlePaneLayout();
+ }
+
+ /**
+ * This method installs the TitlePane onto the JInternalFrameTitlePane. It
+ * also creates any children components that need to be created and adds
+ * listeners to the appropriate components.
+ */
+ protected void installTitlePane()
+ {
+ installDefaults();
+ installListeners();
+ createActions();
+ assembleSystemMenu();
+ createButtons();
+ setButtonIcons();
+ addSubComponents();
+ enableActions();
+ }
+
+ private void enableActions()
+ {
+ // TODO: Implement this.
+ }
+
+ private void addSubComponents()
+ {
+ add(menuBar);
+ add(closeButton);
+ add(iconButton);
+ add(maxButton);
+ }
+
+ private void installListeners()
+ {
+ MouseInputAdapter mouseHandler = new MouseHandler();
+ addMouseListener(mouseHandler);
+ addMouseMotionListener(mouseHandler);
+ }
+
+ private void createActions()
+ {
+ closeAction = new CloseAction();
+ iconifyAction = new IconifyAction();
+ maximizeAction = new MaximizeAction();
+ }
+
+ private void assembleSystemMenu()
+ {
+ menuBar = createSystemMenuBar();
+ windowMenu = createSystemMenu();
+ menuBar.add(windowMenu);
+ addSystemMenuItems(windowMenu);
+ enableActions();
+ }
+
+ protected JMenuBar createSystemMenuBar()
+ {
+ if (menuBar == null)
+ menuBar = new JMenuBar();
+ menuBar.removeAll();
+ return menuBar;
+ }
+
+ protected JMenu createSystemMenu()
+ {
+ if (windowMenu == null)
+ windowMenu = new JMenu();
+ windowMenu.removeAll();
+ return windowMenu;
+ }
+
+ private void addSystemMenuItems(JMenu menu)
+ {
+ // TODO: Implement this.
+ }
+
+ protected void createButtons()
+ {
+ closeButton = new PaneButton(closeAction);
+ closeButton.setText(null);
+ iconButton = new PaneButton(iconifyAction);
+ iconButton.setText(null);
+ maxButton = new PaneButton(maximizeAction);
+ maxButton.setText(null);
+ closeButton.setBorderPainted(false);
+ closeButton.setContentAreaFilled(false);
+ iconButton.setBorderPainted(false);
+ iconButton.setContentAreaFilled(false);
+ maxButton.setBorderPainted(false);
+ maxButton.setContentAreaFilled(false);
+ }
+
+ protected void setButtonIcons()
+ {
+ if (closeIcon != null && closeButton != null)
+ closeButton.setIcon(closeIcon);
+ if (iconIcon != null && iconButton != null)
+ iconButton.setIcon(iconIcon);
+ if (maxIcon != null && maxButton != null)
+ maxButton.setIcon(maxIcon);
+ }
+
+ /**
+ * Paints a representation of the current state of the internal frame.
+ *
+ * @param g the graphics device.
+ */
+ public void paintComponent(Graphics g)
+ {
+ Window frame = SwingUtilities.getWindowAncestor(rootPane);
+ Color savedColor = g.getColor();
+ paintTitleBackground(g);
+ paintChildren(g);
+ Dimension d = getSize();
+ if (frame.isActive())
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+ // put a dot in each of the top corners
+ g.drawLine(0, 0, 0, 0);
+ g.drawLine(d.width - 1, 0, d.width - 1, 0);
+
+ g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
+
+ // draw the metal pattern
+ if (UIManager.get("InternalFrame.activeTitleGradient") != null
+ && frame.isActive())
+ {
+ MetalUtils.paintGradient(g, 0, 0, getWidth(), getHeight(),
+ SwingConstants.VERTICAL,
+ "InternalFrame.activeTitleGradient");
+ }
+
+ Rectangle b = title.getBounds();
+ int startX = b.x + b.width + 5;
+ int endX = startX;
+ if (iconButton.isVisible())
+ endX = Math.max(iconButton.getX(), endX);
+ else if (maxButton.isVisible())
+ endX = Math.max(maxButton.getX(), endX);
+ else if (closeButton.isVisible())
+ endX = Math.max(closeButton.getX(), endX);
+ endX -= 7;
+ if (endX > startX)
+ MetalUtils.fillMetalPattern(this, g, startX, 3, endX - startX, getHeight() - 6, Color.white, Color.gray);
+ g.setColor(savedColor);
+ }
+
+ /**
+ * This method paints the TitlePane's background.
+ *
+ * @param g The Graphics object to paint with.
+ */
+ protected void paintTitleBackground(Graphics g)
+ {
+ Window frame = SwingUtilities.getWindowAncestor(rootPane);
+
+ if (!isOpaque())
+ return;
+
+ Color saved = g.getColor();
+ Dimension dims = getSize();
+
+ Color bg = getBackground();
+ if (frame.isActive())
+ bg = selectedTitleColor;
+ else
+ bg = notSelectedTitleColor;
+ g.setColor(bg);
+ g.fillRect(0, 0, dims.width, dims.height);
+ g.setColor(saved);
+ }
+
+ /**
+ * This method installs the defaults determined by the look and feel.
+ */
+ private void installDefaults()
+ {
+ title.setFont(UIManager.getFont("InternalFrame.titleFont"));
+ selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
+ notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
+ closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
+ iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
+ maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
+ minIcon = MetalIconFactory.getInternalFrameAltMaximizeIcon(16);
+ Frame frame = (Frame) SwingUtilities.getWindowAncestor(rootPane);
+ title = new JLabel(frame.getTitle(),
+ MetalIconFactory.getInternalFrameDefaultMenuIcon(),
+ SwingConstants.LEFT);
+ }
+ }
+
+ private static class MetalRootLayout
+ implements LayoutManager2
+ {
+
+ /**
+ * The cached layout info for the glass pane.
+ */
+ private Rectangle glassPaneBounds;
+
+ /**
+ * The cached layout info for the layered pane.
+ */
+ private Rectangle layeredPaneBounds;
+
+ /**
+ * The cached layout info for the content pane.
+ */
+ private Rectangle contentPaneBounds;
+
+ /**
+ * The cached layout info for the menu bar.
+ */
+ private Rectangle menuBarBounds;
+
+ /**
+ * The cached layout info for the title pane.
+ */
+ private Rectangle titlePaneBounds;
+
+ /**
+ * The cached preferred size.
+ */
+ private Dimension prefSize;
+
+ /**
+ * The title pane for l&f decorated frames.
+ */
+ private MetalTitlePane titlePane;
+
+ /**
+ * Creates a new MetalRootLayout.
+ *
+ * @param tp the title pane
+ */
+ MetalRootLayout(MetalTitlePane tp)
+ {
+ titlePane = tp;
+ }
+
+ public void addLayoutComponent(Component component, Object constraints)
+ {
+ // Nothing to do here.
+ }
+
+ public Dimension maximumLayoutSize(Container target)
+ {
+ return preferredLayoutSize(target);
+ }
+
+ public float getLayoutAlignmentX(Container target)
+ {
+ return 0.0F;
+ }
+
+ public float getLayoutAlignmentY(Container target)
+ {
+ return 0.0F;
+ }
+
+ public void invalidateLayout(Container target)
+ {
+ synchronized (this)
+ {
+ glassPaneBounds = null;
+ layeredPaneBounds = null;
+ contentPaneBounds = null;
+ menuBarBounds = null;
+ titlePaneBounds = null;
+ prefSize = null;
+ }
+ }
+
+ public void addLayoutComponent(String name, Component component)
+ {
+ // Nothing to do here.
+ }
+
+ public void removeLayoutComponent(Component component)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Dimension preferredLayoutSize(Container parent)
+ {
+ JRootPane rp = (JRootPane) parent;
+ JLayeredPane layeredPane = rp.getLayeredPane();
+ Component contentPane = rp.getContentPane();
+ Component menuBar = rp.getJMenuBar();
+
+ // We must synchronize here, otherwise we cannot guarantee that the
+ // prefSize is still non-null when returning.
+ synchronized (this)
+ {
+ if (prefSize == null)
+ {
+ Insets i = parent.getInsets();
+ prefSize = new Dimension(i.left + i.right, i.top + i.bottom);
+ Dimension contentPrefSize = contentPane.getPreferredSize();
+ prefSize.width += contentPrefSize.width;
+ prefSize.height += contentPrefSize.height
+ + titlePane.getPreferredSize().height;
+ if (menuBar != null)
+ {
+ Dimension menuBarSize = menuBar.getPreferredSize();
+ if (menuBarSize.width > contentPrefSize.width)
+ prefSize.width += menuBarSize.width - contentPrefSize.width;
+ prefSize.height += menuBarSize.height;
+ }
+ }
+ // Return a copy here so the cached value won't get trashed by some
+ // other component.
+ return new Dimension(prefSize);
+ }
+ }
+
+ public Dimension minimumLayoutSize(Container parent)
+ {
+ return preferredLayoutSize(parent);
+ }
+
+ public void layoutContainer(Container parent)
+ {
+ JRootPane rp = (JRootPane) parent;
+ JLayeredPane layeredPane = rp.getLayeredPane();
+ Component contentPane = rp.getContentPane();
+ Component menuBar = rp.getJMenuBar();
+ Component glassPane = rp.getGlassPane();
+
+ if (glassPaneBounds == null || layeredPaneBounds == null
+ || contentPaneBounds == null || menuBarBounds == null)
+ {
+ Insets i = rp.getInsets();
+ int containerWidth = parent.getBounds().width - i.left - i.right;
+ int containerHeight = parent.getBounds().height - i.top - i.bottom;
+
+ // 1. The glassPane fills entire viewable region (bounds - insets).
+ // 2. The layeredPane filles entire viewable region.
+ // 3. The titlePane is placed at the upper edge of the layeredPane.
+ // 4. The menuBar is positioned at the upper edge of layeredPane.
+ // 5. The contentPane fills viewable region minus menuBar minus
+ // titlePane, if present.
+
+ // +-------------------------------+
+ // | JLayeredPane |
+ // | +--------------------------+ |
+ // | | titlePane + |
+ // | +--------------------------+ |
+ // | +--------------------------+ |
+ // | | menuBar | |
+ // | +--------------------------+ |
+ // | +--------------------------+ |
+ // | |contentPane | |
+ // | | | |
+ // | | | |
+ // | | | |
+ // | +--------------------------+ |
+ // +-------------------------------+
+
+ // Setup titlePaneBounds.
+ if (titlePaneBounds == null)
+ titlePaneBounds = new Rectangle();
+ titlePaneBounds.width = containerWidth;
+ titlePaneBounds.height = titlePane.getPreferredSize().height;
+
+ // Setup menuBarBounds.
+ if (menuBarBounds == null)
+ menuBarBounds = new Rectangle();
+ menuBarBounds.setBounds(0,
+ titlePaneBounds.y + titlePaneBounds.height,
+ containerWidth, 0);
+ if (menuBar != null)
+ {
+ Dimension menuBarSize = menuBar.getPreferredSize();
+ if (menuBarSize.height > containerHeight)
+ menuBarBounds.height = containerHeight;
+ else
+ menuBarBounds.height = menuBarSize.height;
+ }
+
+ // Setup contentPaneBounds.
+ if (contentPaneBounds == null)
+ contentPaneBounds = new Rectangle();
+ contentPaneBounds.setBounds(0,
+ menuBarBounds.y + menuBarBounds.height,
+ containerWidth,
+ containerHeight - menuBarBounds.y
+ - menuBarBounds.height);
+ glassPaneBounds = new Rectangle(i.left, i.top, containerWidth, containerHeight);
+ layeredPaneBounds = new Rectangle(i.left, i.top, containerWidth, containerHeight);
+ }
+
+ // Layout components.
+ glassPane.setBounds(glassPaneBounds);
+ layeredPane.setBounds(layeredPaneBounds);
+ if (menuBar != null)
+ menuBar.setBounds(menuBarBounds);
+ contentPane.setBounds(contentPaneBounds);
+ titlePane.setBounds(titlePaneBounds);
+ }
+
+ }
+
+ /**
+ * The shared UI instance for MetalRootPaneUIs.
+ */
+ private static MetalRootPaneUI instance;
+
+ /**
+ * Constructs a shared instance of <code>MetalRootPaneUI</code>.
+ */
+ public MetalRootPaneUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a shared instance of <code>MetalRootPaneUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A shared instance of <code>MetalRootPaneUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ if (instance == null)
+ instance = new MetalRootPaneUI();
+ return instance;
+ }
+
+ /**
+ * Installs this UI to the root pane. If the
+ * <code>windowDecorationsStyle</code> property is set on the root pane,
+ * the Metal window decorations are installed on the root pane.
+ *
+ * @param c
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ JRootPane rp = (JRootPane) c;
+ if (rp.getWindowDecorationStyle() != JRootPane.NONE)
+ installWindowDecorations(rp);
+ }
+
+ /**
+ * Uninstalls the UI from the root pane. This performs the superclass
+ * behaviour and uninstalls the window decorations that have possibly been
+ * installed by {@link #installUI}.
+ *
+ * @param c the root pane
+ */
+ public void uninstallUI(JComponent c)
+ {
+ JRootPane rp = (JRootPane) c;
+ if (rp.getWindowDecorationStyle() != JRootPane.NONE)
+ uninstallWindowDecorations(rp);
+ super.uninstallUI(c);
+ }
+
+ /**
+ * Receives notification if any of the JRootPane's property changes. In
+ * particular this catches changes to the <code>windowDecorationStyle</code>
+ * property and installs the window decorations accordingly.
+ *
+ * @param ev the property change event
+ */
+ public void propertyChange(PropertyChangeEvent ev)
+ {
+ super.propertyChange(ev);
+ String propertyName = ev.getPropertyName();
+ if (propertyName.equals("windowDecorationStyle"))
+ {
+ JRootPane rp = (JRootPane) ev.getSource();
+ if (rp.getWindowDecorationStyle() != JRootPane.NONE)
+ installWindowDecorations(rp);
+ else
+ uninstallWindowDecorations(rp);
+ }
+ }
+
+ /**
+ * Installs the window decorations to the root pane. This sets up a border,
+ * a title pane and a layout manager that can layout the root pane with that
+ * title pane.
+ *
+ * @param rp the root pane.
+ */
+ private void installWindowDecorations(JRootPane rp)
+ {
+ rp.setBorder(new MetalFrameBorder());
+ MetalTitlePane titlePane = new MetalTitlePane(rp);
+ rp.setLayout(new MetalRootLayout(titlePane));
+ // We should have a contentPane already.
+ assert rp.getLayeredPane().getComponentCount() > 0
+ : "We should have a contentPane already";
+
+ rp.getLayeredPane().add(titlePane,
+ JLayeredPane.FRAME_CONTENT_LAYER, 1);
+ }
+
+ /**
+ * Uninstalls the window decorations from the root pane. This should rarely
+ * be necessary, but we do it anyway.
+ *
+ * @param rp the root pane
+ */
+ private void uninstallWindowDecorations(JRootPane rp)
+ {
+ rp.setBorder(null);
+ JLayeredPane lp = rp.getLayeredPane();
+ for (int i = lp.getComponentCount() - 1; i >= 0; --i)
+ {
+ if (lp.getComponent(i) instanceof MetalTitlePane)
+ {
+ lp.remove(i);
+ break;
+ }
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,580 @@
+/* MetalScrollBarUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JScrollBar;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicScrollBarUI;
+
+/**
+ * A UI delegate for the {@link JScrollBar} component.
+ */
+public class MetalScrollBarUI extends BasicScrollBarUI
+{
+
+ /**
+ * A property change handler for the UI delegate that monitors for
+ * changes to the "JScrollBar.isFreeStanding" property, and updates
+ * the buttons and track rendering as appropriate.
+ */
+ class MetalScrollBarPropertyChangeHandler
+ extends BasicScrollBarUI.PropertyChangeHandler
+ {
+ /**
+ * Creates a new handler.
+ *
+ * @see #createPropertyChangeListener()
+ */
+ public MetalScrollBarPropertyChangeHandler()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Handles a property change event. If the event name is
+ * <code>JSlider.isFreeStanding</code>, this method updates the
+ * delegate, otherwise the event is passed up to the super class.
+ *
+ * @param e the property change event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(FREE_STANDING_PROP))
+ {
+ Boolean prop = (Boolean) e.getNewValue();
+ isFreeStanding = prop == null ? true : prop.booleanValue();
+ if (increaseButton != null)
+ increaseButton.setFreeStanding(isFreeStanding);
+ if (decreaseButton != null)
+ decreaseButton.setFreeStanding(isFreeStanding);
+ }
+ else
+ super.propertyChange(e);
+ }
+ }
+
+ /** The name for the 'free standing' property. */
+ public static final String FREE_STANDING_PROP = "JScrollBar.isFreeStanding";
+
+ /** The minimum thumb size for a scroll bar that is not free standing. */
+ private static final Dimension MIN_THUMB_SIZE = new Dimension(15, 15);
+
+ /** The minimum thumb size for a scroll bar that is free standing. */
+ private static final Dimension MIN_THUMB_SIZE_FREE_STANDING
+ = new Dimension(17, 17);
+
+ /** The button that increases the value in the scroll bar. */
+ protected MetalScrollButton increaseButton;
+
+ /** The button that decreases the value in the scroll bar. */
+ protected MetalScrollButton decreaseButton;
+
+ /**
+ * The scroll bar width.
+ */
+ protected int scrollBarWidth;
+
+ /**
+ * A flag that indicates whether the scroll bar is "free standing", which
+ * means it has complete borders and can be used anywhere in the UI. A
+ * scroll bar which is not free standing has borders missing from one
+ * side, and relies on being part of another container with its own borders
+ * to look right visually. */
+ protected boolean isFreeStanding = true;
+
+ /**
+ * The color for the scroll bar shadow (this is read from the UIDefaults in
+ * the installDefaults() method).
+ */
+ Color scrollBarShadowColor;
+
+ /**
+ * Constructs a new instance of <code>MetalScrollBarUI</code>, with no
+ * specific initialisation.
+ */
+ public MetalScrollBarUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalScrollBarUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return An instance of MetalScrollBarUI
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalScrollBarUI();
+ }
+
+ /**
+ * Installs the defaults.
+ */
+ protected void installDefaults()
+ {
+ // need to initialise isFreeStanding before calling the super class,
+ // so that the value is set when createIncreaseButton() and
+ // createDecreaseButton() are called (unless there is somewhere earlier
+ // that we can do this).
+ Boolean prop = (Boolean) scrollbar.getClientProperty(FREE_STANDING_PROP);
+ isFreeStanding = prop == null ? true : prop.booleanValue();
+ scrollBarShadowColor = UIManager.getColor("ScrollBar.shadow");
+ super.installDefaults();
+ }
+
+ /**
+ * Creates a property change listener for the delegate to use. This
+ * overrides the method to provide a custom listener for the
+ * {@link MetalLookAndFeel} that can handle the
+ * <code>JScrollBar.isFreeStanding</code> property.
+ *
+ * @return A property change listener.
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new MetalScrollBarPropertyChangeHandler();
+ }
+
+ /**
+ * Creates a new button to use as the control at the lower end of the
+ * {@link JScrollBar}.
+ *
+ * @param orientation the orientation of the button ({@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} or {@link #WEST}).
+ *
+ * @return The button.
+ */
+ protected JButton createDecreaseButton(int orientation)
+ {
+ scrollBarWidth = UIManager.getInt("ScrollBar.width");
+ decreaseButton = new MetalScrollButton(orientation, scrollBarWidth,
+ isFreeStanding);
+ return decreaseButton;
+ }
+
+ /**
+ * Creates a new button to use as the control at the upper end of the
+ * {@link JScrollBar}.
+ *
+ * @param orientation the orientation of the button ({@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} or {@link #WEST}).
+ *
+ * @return The button.
+ */
+ protected JButton createIncreaseButton(int orientation)
+ {
+ scrollBarWidth = UIManager.getInt("ScrollBar.width");
+ increaseButton = new MetalScrollButton(orientation, scrollBarWidth,
+ isFreeStanding);
+ return increaseButton;
+ }
+
+ /**
+ * Paints the track for the scrollbar.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ * @param trackBounds the track bounds.
+ */
+ protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
+ {
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width,
+ trackBounds.height);
+ if (scrollbar.getOrientation() == HORIZONTAL)
+ paintTrackHorizontal(g, c, trackBounds.x, trackBounds.y,
+ trackBounds.width, trackBounds.height);
+ else
+ paintTrackVertical(g, c, trackBounds.x, trackBounds.y,
+ trackBounds.width, trackBounds.height);
+
+ }
+
+ /**
+ * Paints the track for a horizontal scrollbar.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ * @param x the x-coordinate for the track bounds.
+ * @param y the y-coordinate for the track bounds.
+ * @param w the width for the track bounds.
+ * @param h the height for the track bounds.
+ */
+ private void paintTrackHorizontal(Graphics g, JComponent c,
+ int x, int y, int w, int h)
+ {
+ if (c.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+
+ g.setColor(scrollBarShadowColor);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
+ g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
+
+ if (isFreeStanding)
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y + h - 2, x + w - 1, y + h - 2);
+ g.setColor(scrollBarShadowColor);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ }
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 1, h - 1);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+ }
+ }
+ }
+
+ /**
+ * Paints the track for a vertical scrollbar.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ * @param x the x-coordinate for the track bounds.
+ * @param y the y-coordinate for the track bounds.
+ * @param w the width for the track bounds.
+ * @param h the height for the track bounds.
+ */
+ private void paintTrackVertical(Graphics g, JComponent c,
+ int x, int y, int w, int h)
+ {
+ if (c.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+
+ g.setColor(scrollBarShadowColor);
+ g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
+
+ if (isFreeStanding)
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x + w - 2, y, x + w - 2, y + h - 1);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+ }
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 1, h - 1);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ }
+ }
+ }
+
+ /**
+ * 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)
+ {
+ // a disabled scrollbar has no thumb in the metal look and feel
+ if (!c.isEnabled())
+ return;
+ if (scrollbar.getOrientation() == HORIZONTAL)
+ paintThumbHorizontal(g, c, thumbBounds);
+ else
+ paintThumbVertical(g, c, thumbBounds);
+
+ // Draw the pattern when the theme is not Ocean.
+ if (! (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
+ {
+ MetalUtils.fillMetalPattern(c, g, thumbBounds.x + 3, thumbBounds.y + 3,
+ thumbBounds.width - 6,
+ thumbBounds.height - 6,
+ thumbHighlightColor,
+ thumbLightShadowColor);
+ }
+ }
+
+ /**
+ * Paints the thumb for a horizontal scroll bar.
+ *
+ * @param g the graphics device.
+ * @param c the scroll bar component.
+ * @param thumbBounds the thumb bounds.
+ */
+ private void paintThumbHorizontal(Graphics g, JComponent c,
+ Rectangle thumbBounds)
+ {
+ int x = thumbBounds.x;
+ int y = thumbBounds.y;
+ int w = thumbBounds.width;
+ int h = thumbBounds.height;
+
+ // First we fill the background.
+ MetalTheme theme = MetalLookAndFeel.getCurrentTheme();
+ if (theme instanceof OceanTheme
+ && UIManager.get("ScrollBar.gradient") != null)
+ {
+ MetalUtils.paintGradient(g, x + 2, y + 2, w - 4, h - 2,
+ SwingConstants.VERTICAL,
+ "ScrollBar.gradient");
+ }
+ else
+ {
+ g.setColor(thumbColor);
+ if (isFreeStanding)
+ g.fillRect(x, y, w, h - 1);
+ else
+ g.fillRect(x, y, w, h);
+ }
+
+ // then draw the dark box
+ g.setColor(thumbLightShadowColor);
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 1, h - 2);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+ }
+
+ // then the highlight
+ g.setColor(thumbHighlightColor);
+ if (isFreeStanding)
+ {
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
+ }
+ else
+ {
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
+ }
+
+ // draw the shadow line
+ g.setColor(UIManager.getColor("ScrollBar.shadow"));
+ g.drawLine(x + w, y + 1, x + w, y + h - 1);
+
+ // For the OceanTheme, draw the 3 lines in the middle.
+ if (theme instanceof OceanTheme)
+ {
+ g.setColor(thumbLightShadowColor);
+ int middle = x + w / 2;
+ g.drawLine(middle - 2, y + 4, middle - 2, y + h - 5);
+ g.drawLine(middle, y + 4, middle, y + h - 5);
+ g.drawLine(middle + 2, y + 4, middle + 2, y + h - 5);
+ g.setColor(UIManager.getColor("ScrollBar.highlight"));
+ g.drawLine(middle - 1, y + 5, middle - 1, y + h - 4);
+ g.drawLine(middle + 1, y + 5, middle + 1, y + h - 4);
+ g.drawLine(middle + 3, y + 5, middle + 3, y + h - 4);
+ }
+ }
+
+ /**
+ * Paints the thumb for a vertical scroll bar.
+ *
+ * @param g the graphics device.
+ * @param c the scroll bar component.
+ * @param thumbBounds the thumb bounds.
+ */
+ private void paintThumbVertical(Graphics g, JComponent c,
+ Rectangle thumbBounds)
+ {
+ int x = thumbBounds.x;
+ int y = thumbBounds.y;
+ int w = thumbBounds.width;
+ int h = thumbBounds.height;
+
+ // First we fill the background.
+ MetalTheme theme = MetalLookAndFeel.getCurrentTheme();
+ if (theme instanceof OceanTheme
+ && UIManager.get("ScrollBar.gradient") != null)
+ {
+ MetalUtils.paintGradient(g, x + 2, y + 2, w - 2, h - 4,
+ SwingConstants.HORIZONTAL,
+ "ScrollBar.gradient");
+ }
+ else
+ {
+ g.setColor(thumbColor);
+ if (isFreeStanding)
+ g.fillRect(x, y, w - 1, h);
+ else
+ g.fillRect(x, y, w, h);
+ }
+
+ // then draw the dark box
+ g.setColor(thumbLightShadowColor);
+ if (isFreeStanding)
+ g.drawRect(x, y, w - 2, h - 1);
+ else
+ {
+ g.drawLine(x, y, x + w - 1, y);
+ g.drawLine(x, y, x, y + h - 1);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ }
+
+ // then the highlight
+ g.setColor(thumbHighlightColor);
+ if (isFreeStanding)
+ {
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
+ }
+ else
+ {
+ g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
+ }
+
+ // draw the shadow line
+ g.setColor(UIManager.getColor("ScrollBar.shadow"));
+ g.drawLine(x + 1, y + h, x + w - 2, y + h);
+
+ // For the OceanTheme, draw the 3 lines in the middle.
+ if (theme instanceof OceanTheme)
+ {
+ g.setColor(thumbLightShadowColor);
+ int middle = y + h / 2;
+ g.drawLine(x + 4, middle - 2, x + w - 5, middle - 2);
+ g.drawLine(x + 4, middle, x + w - 5, middle);
+ g.drawLine(x + 4, middle + 2, x + w - 5, middle + 2);
+ g.setColor(UIManager.getColor("ScrollBar.highlight"));
+ g.drawLine(x + 5, middle - 1, x + w - 4, middle - 1);
+ g.drawLine(x + 5, middle + 1, x + w - 4, middle + 1);
+ g.drawLine(x + 5, middle + 3, x + w - 4, middle + 3);
+ }
+ }
+
+ /**
+ * Returns the minimum thumb size. For a free standing scroll bar the
+ * minimum size is <code>17 x 17</code> pixels, whereas for a non free
+ * standing scroll bar the minimum size is <code>15 x 15</code> pixels.
+ *
+ * @return The minimum thumb size.
+ */
+ protected Dimension getMinimumThumbSize()
+ {
+ Dimension retVal;
+ if (scrollbar != null)
+ {
+ if (isFreeStanding)
+ retVal = MIN_THUMB_SIZE_FREE_STANDING;
+ else
+ retVal = MIN_THUMB_SIZE;
+ }
+ else
+ retVal = new Dimension(0, 0);
+ return retVal;
+ }
+
+ /**
+ * Returns the <code>preferredSize</code> for the specified scroll bar.
+ * For a vertical scrollbar the height is the sum of the preferred heights
+ * of the buttons plus <code>30</code>. The width is fetched from the
+ * <code>UIManager</code> property <code>ScrollBar.width</code>.
+ *
+ * For horizontal scrollbars the width is the sum of the preferred widths
+ * of the buttons plus <code>30</code>. The height is fetched from the
+ * <code>UIManager</code> property <code>ScrollBar.height</code>.
+ *
+ * @param c the scrollbar for which to calculate the preferred size
+ *
+ * @return the <code>preferredSize</code> for the specified scroll bar
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ int height;
+ int width;
+ height = width = 0;
+
+ if (scrollbar.getOrientation() == SwingConstants.HORIZONTAL)
+ {
+ width += incrButton.getPreferredSize().getWidth();
+ width += decrButton.getPreferredSize().getWidth();
+ width += 30;
+ height = UIManager.getInt("ScrollBar.width");
+ }
+ else
+ {
+ height += incrButton.getPreferredSize().getHeight();
+ height += decrButton.getPreferredSize().getHeight();
+ height += 30;
+ width = UIManager.getInt("ScrollBar.width");
+ }
+
+ Insets insets = scrollbar.getInsets();
+
+ height += insets.top + insets.bottom;
+ width += insets.left + insets.right;
+
+ return new Dimension(width, height);
+ }
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollButton.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,484 @@
+/* MetalScrollButton.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.basic.BasicArrowButton;
+
+/**
+ * A button used by the {@link MetalScrollBarUI}. The button appearance
+ * varies according to the button direction, whether or not it is part of a
+ * "free standing" scroll bar, and the current state of the button.
+ */
+public class MetalScrollButton extends BasicArrowButton
+{
+
+ /**
+ * The maximum size for buttons.
+ * @see #getMaximumSize()
+ */
+ private static Dimension maximumSize;
+
+ /** The width of the button. */
+ private int buttonWidth;
+
+ /**
+ * A flag that indicates whether the button is part of a free standing
+ * scroll bar. This affects how the border is drawn.
+ */
+ private boolean freeStanding;
+
+ /**
+ * Creates a new button.
+ *
+ * @param direction the direction (this should be one of {@link #NORTH},
+ * {@link #SOUTH}, {@link #EAST} and {@link #WEST}, but
+ * this is not enforced).
+ * @param width the button width.
+ * @param freeStanding a flag indicating whether the scroll button is free
+ * standing or not.
+ */
+ public MetalScrollButton(int direction, int width, boolean freeStanding)
+ {
+ super(direction);
+ buttonWidth = width;
+ this.freeStanding = freeStanding;
+ setFocusable(false);
+ }
+
+ /**
+ * Returns the button width.
+ *
+ * @return The button width.
+ */
+ public int getButtonWidth()
+ {
+ return buttonWidth;
+ }
+
+ /**
+ * Sets the free standing flag. This controls how the button border is
+ * drawn.
+ *
+ * @param freeStanding the new value of the flag.
+ */
+ public void setFreeStanding(boolean freeStanding)
+ {
+ this.freeStanding = freeStanding;
+ }
+
+ /**
+ * Paints the button.
+ *
+ * @param g the graphics device.
+ */
+ public void paint(Graphics g)
+ {
+ Rectangle bounds = SwingUtilities.getLocalBounds(this);
+
+ // fill the background
+ if (getModel().isPressed())
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(0, 0, bounds.width, bounds.height);
+
+ paintArrow(g, bounds.width, bounds.height);
+
+ // paint a border manually - I tried using a real (custom) Border
+ // but couldn't get it to stay set for the button, something was
+ // overwriting it...
+ if (freeStanding)
+ {
+ if (direction == WEST)
+ paintWestBorderFreeStanding(g, bounds.width, bounds.height);
+ else if (direction == EAST)
+ paintEastBorderFreeStanding(g, bounds.width, bounds.height);
+ else if (direction == SOUTH)
+ paintSouthBorderFreeStanding(g, bounds.width, bounds.height);
+ else // asume NORTH
+ paintNorthBorderFreeStanding(g, bounds.width, bounds.height);
+ }
+ else
+ {
+ if (direction == WEST)
+ paintWestBorder(g, bounds.width, bounds.height);
+ else if (direction == EAST)
+ paintEastBorder(g, bounds.width, bounds.height);
+ else if (direction == SOUTH)
+ paintSouthBorder(g, bounds.width, bounds.height);
+ else // asume NORTH
+ paintNorthBorder(g, bounds.width, bounds.height);
+ }
+ }
+
+ private void paintArrow(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+
+ if (direction == SOUTH)
+ {
+ int x = w / 2;
+ int y = h / 2 + 2;
+ for (int i = 1; i < 5; i++)
+ g.drawLine(x - i, y - i, x + i - 1, y - i);
+ }
+ else if (direction == EAST)
+ {
+ int x = w / 2 + 2;
+ int y = h / 2;
+ for (int i = 1; i < 5; i++)
+ g.drawLine(x - i, y - i, x - i, y + i - 1);
+ }
+ else if (direction == WEST)
+ {
+ int x = w / 2 - 3;
+ int y = h / 2;
+ for (int i = 1; i < 5; i++)
+ g.drawLine(x + i, y - i, x + i, y + i - 1);
+ }
+ else // assume NORTH
+ {
+ int x = w / 2;
+ int y = h / 2 - 3;
+ for (int i = 1; i < 5; i++)
+ g.drawLine(x - i, y + i, x + i - 1, y + i);
+ }
+ }
+ /**
+ * Paints the border for a button with a {@link #NORTH} direction that
+ * belongs to a free standing scroll bar.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintNorthBorderFreeStanding(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, w - 2, 0);
+ g.drawLine(0, 0, 0, h - 1);
+ g.drawLine(2, h - 1, w - 2, h - 1);
+ g.drawLine(w - 2, 2, w - 2, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(1, 1, 1, h - 2);
+ g.drawLine(1, 1, w - 3, 1);
+ g.drawLine(w - 1, 1, w - 1, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(1, h - 1, 1, h - 1);
+ g.drawLine(w - 2, 1, w - 2, 1);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, w - 1, 0);
+ g.drawLine(w - 1, 0, w - 1, h - 1);
+ g.drawLine(0, 0, 0, h - 1);
+ }
+ }
+
+ /**
+ * Paints the border for a button with a {@link #SOUTH} direction that
+ * belongs to a free standing scroll bar.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintSouthBorderFreeStanding(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, w - 2, 0);
+ g.drawLine(0, 0, 0, h - 1);
+ g.drawLine(2, h - 1, w - 2, h - 1);
+ g.drawLine(w - 2, 2, w - 2, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(1, 1, 1, h - 1);
+ g.drawLine(1, 1, w - 1, 1);
+ g.drawLine(w - 1, 1, w - 1, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(1, h - 1, 1, h - 1);
+ g.drawLine(w - 1, 1, w - 1, 1);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, h - 1, w - 1, h - 1);
+ g.drawLine(w - 1, 0, w - 1, h - 1);
+ g.drawLine(0, 0, 0, h - 1);
+ }
+ }
+
+ /**
+ * Paints the border for a button with an {@link #EAST} direction that
+ * belongs to a free standing scroll bar.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintEastBorderFreeStanding(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, w - 2, 0);
+ g.drawLine(w - 2, 0, w - 2, h - 2);
+ g.drawLine(0, h - 2, w - 2, h - 2);
+
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(0, 1, w - 1, 1);
+ g.drawLine(w - 1, 1, w - 1, h - 1);
+ g.drawLine(0, h - 1, w - 1, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(w - 2, 1, w - 2, 1);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, w - 1, 0);
+ g.drawLine(w - 1, 0, w - 1, h - 1);
+ g.drawLine(0, h - 1, w - 1, h - 1);
+ }
+ }
+
+ /**
+ * Paints the border for a button with a {@link #WEST} direction that
+ * belongs to a free standing scroll bar.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintWestBorderFreeStanding(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, w - 1, 0);
+ g.drawLine(0, 0, 0, h - 2);
+ g.drawLine(0, h - 2, w - 1, h - 2);
+
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(1, 1, w - 1, 1);
+ g.drawLine(1, 1, 1, h - 1);
+ g.drawLine(1, h - 1, w - 1, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(1, h - 2, 1, h - 2);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, w - 1, 0);
+ g.drawLine(0, 0, 0, h - 1);
+ g.drawLine(0, h - 1, w - 1, h - 1);
+ }
+ }
+
+ /**
+ * Paints the border for a button with a {@link #NORTH} direction that
+ * belongs to a scroll bar that is not free standing.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintNorthBorder(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, 0, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(1, 0, 1, h - 1);
+ g.drawLine(1, 0, w - 1, 0);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, 0, h - 1);
+ }
+ }
+
+ /**
+ * Paints the border for a button with a {@link #SOUTH} direction that
+ * belongs to a scroll bar that is not free standing.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintSouthBorder(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, 0, h - 1);
+ g.drawLine(0, h - 1, w - 1, h - 1);
+
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(1, 0, 1, h - 1);
+ g.drawLine(1, 0, w - 1, 0);
+
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(1, h - 1, 1, h - 1);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, 0, h - 1);
+ }
+ }
+
+ /**
+ * Paints the border for a button with an {@link #EAST} direction that
+ * belongs to a scroll bar that is not free standing.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintEastBorder(Graphics g, int w, int h)
+ {
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, w - 1, 0);
+ g.drawLine(w - 1, 2, w - 1, h - 1);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(0, 1, w - 2, 1);
+ g.drawLine(0, 1, 0, h - 1);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, w - 1, 0);
+ }
+ }
+
+ /**
+ * Paints the border for a button with a {@link #WEST} direction that
+ * belongs to a scroll bar that is not free standing.
+ *
+ * @param g the graphics device.
+ * @param w the button width.
+ * @param h the button height.
+ */
+ private void paintWestBorder(Graphics g, int w, int h)
+ {
+ Rectangle bounds = SwingUtilities.getLocalBounds(this);
+ if (isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, 0, bounds.width - 1, 0);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(0, 1, bounds.width - 1, 1);
+ g.drawLine(0, 1, 0, bounds.height - 1);
+ }
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(0, 0, bounds.width - 1, 0);
+ }
+ }
+
+ /**
+ * Returns the preferred size for the button, which varies depending on
+ * the direction of the button and whether or not it is free standing.
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize()
+ {
+ int adj = 1;
+ if (!freeStanding)
+ adj = 2;
+
+ if (direction == EAST)
+ return new Dimension(buttonWidth - adj, buttonWidth);
+ else if (direction == WEST)
+ return new Dimension(buttonWidth - 2, buttonWidth);
+ else if (direction == SOUTH)
+ return new Dimension(buttonWidth, buttonWidth - adj);
+ else // assume NORTH
+ return new Dimension(buttonWidth, buttonWidth - 2);
+ }
+
+ /**
+ * Returns the minimum size for the button.
+ *
+ * @return The minimum size for the button.
+ */
+ public Dimension getMinimumSize()
+ {
+ return getPreferredSize();
+ }
+
+ /**
+ * Returns the maximum size for the button.
+ *
+ * @return <code>Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)</code>.
+ */
+ public Dimension getMaximumSize()
+ {
+ if (maximumSize == null)
+ maximumSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ return maximumSize;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalScrollPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,159 @@
+/* MetalScrollPaneUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JComponent;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicScrollPaneUI;
+
+/**
+ * A UI delegate for the {@link JScrollPane} component.
+ */
+public class MetalScrollPaneUI
+ extends BasicScrollPaneUI
+{
+ /**
+ * Constructs a new instance of <code>MetalScrollPaneUI</code>.
+ */
+ public MetalScrollPaneUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a shared instance of <code>MetalScrollPaneUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A shared instance of <code>MetalScrollPaneUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalScrollPaneUI();
+ }
+
+ /**
+ * Configures the specified component appropriate for the look and feel.
+ * This method is invoked when the ComponentUI instance is being installed
+ * as the UI delegate on the specified component. This method should
+ * completely configure the component for the look and feel,
+ * including the following:
+ * 1. Install any default property values for color, fonts, borders,
+ * icons, opacity, etc. on the component. Whenever possible, property
+ * values initialized by the client program should not be overridden.
+ * 2. Install a LayoutManager on the component if necessary.
+ * 3. Create/add any required sub-components to the component.
+ * 4. Create/install event listeners on the component.
+ * 5. Create/install a PropertyChangeListener on the component in order
+ * to detect and respond to component property changes appropriately.
+ * 6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
+ * 7. Initialize any appropriate instance data.
+ *
+ * @param c - the component to install the ui on
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ JScrollBar hsb = scrollpane.getHorizontalScrollBar();
+ hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, Boolean.FALSE);
+ }
+
+ /**
+ * Reverses configuration which was done on the specified component
+ * during installUI. This method is invoked when this UIComponent
+ * instance is being removed as the UI delegate for the specified
+ * component. This method should undo the configuration performed in
+ * installUI, being careful to leave the JComponent instance in a
+ * clean state (no extraneous listeners, look-and-feel-specific property
+ * objects, etc.). This should include the following:
+ * 1. Remove any UI-set borders from the component.
+ * 2. Remove any UI-set layout managers on the component.
+ * 3. Remove any UI-added sub-components from the component.
+ * 4. Remove any UI-added event/property listeners from the component.
+ * 5. Remove any UI-installed keyboard UI from the component.
+ * 6. Nullify any allocated instance data objects to allow for GC.
+ *
+ * @param c - the component to uninstall the ui on
+ */
+ public void uninstallUI(JComponent c)
+ {
+ JScrollBar hsb = scrollpane.getHorizontalScrollBar();
+ hsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, null);
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ vsb.putClientProperty(MetalScrollBarUI.FREE_STANDING_PROP, null);
+ super.uninstallUI(c);
+ }
+
+ /**
+ * Installs listeners on scrollPane
+ *
+ * @param scrollPane - the component to install the listeners on
+ */
+ public void installListeners(JScrollPane scrollPane)
+ {
+ super.installListeners(scrollPane);
+ }
+
+ /**
+ * Uninstalls listeners on scrollPane
+ *
+ * @param scrollPane - the component to uninstall the listeners on
+ */
+ public void uninstallListeners(JScrollPane scrollPane)
+ {
+ super.uninstallListeners(scrollPane);
+ }
+
+ /**
+ * TODO
+ *
+ * @return TODO
+ */
+ protected PropertyChangeListener createScrollBarSwapListener()
+ {
+ // FIXME: Anything else to do here?
+ return super.createPropertyChangeListener();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,131 @@
+/* MetalSeparatorUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.JComponent;
+import javax.swing.JSeparator;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicSeparatorUI;
+
+/**
+ * A UI delegate for the {@link JSeparator} component.
+ */
+public class MetalSeparatorUI
+ extends BasicSeparatorUI
+{
+
+ // FIXME: maybe replace by a Map of instances when this becomes stateful
+ /** The shared UI instance for MetalSeparatorUIs */
+ private static MetalSeparatorUI instance;
+
+ /**
+ * Constructs a new instance of <code>MetalSeparatorUI</code>.
+ */
+ public MetalSeparatorUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a shared instance of <code>MetalSeparatorUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A shared instance of <code>MetalSeparatorUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ if (instance == null)
+ instance = new MetalSeparatorUI();
+ return instance;
+ }
+
+ /**
+ * The separator is made of two lines. The top line will be
+ * the Metal theme color separatorForeground (or left line if it's vertical).
+ * The bottom or right line will be the Metal theme color
+ * separatorBackground.
+ * The two lines will
+ * be centered inside the bounds box. If the separator is horizontal,
+ * then it will be vertically centered, or if it's vertical, it will
+ * be horizontally centered.
+ *
+ * @param g The Graphics object to paint with
+ * @param c The JComponent to paint.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Rectangle r = new Rectangle();
+ SwingUtilities.calculateInnerArea(c, r);
+ Color saved = g.getColor();
+ Color c1 = UIManager.getColor("Separator.foreground");
+ Color c2 = UIManager.getColor("Separator.background");
+ JSeparator s;
+ if (c instanceof JSeparator)
+ s = (JSeparator) c;
+ else
+ return;
+
+ if (s.getOrientation() == JSeparator.HORIZONTAL)
+ {
+ int midAB = r.height / 2;
+ g.setColor(c1);
+ g.drawLine(r.x, r.y + midAB - 1, r.x + r.width, r.y + midAB - 1);
+
+ g.setColor(c2);
+ g.fillRect(r.x, r.y + midAB, r.x + r.width, r.y + midAB);
+ }
+ else
+ {
+ int midAD = r.height / 2 + r.y;
+ g.setColor(c1);
+ g.drawLine(r.x, r.y, r.x, r.y + r.height);
+
+ g.setColor(c2);
+ g.fillRect(r.x + midAD, r.y + r.height, r.x + midAD, r.y + r.height);
+ }
+ g.setColor(saved);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,472 @@
+/* MetalSliderUI.java
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.Icon;
+import javax.swing.JComponent;
+import javax.swing.JSlider;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicGraphicsUtils;
+import javax.swing.plaf.basic.BasicSliderUI;
+
+/**
+ * A UI delegate for the {@link JSlider} component.
+ */
+public class MetalSliderUI extends BasicSliderUI
+{
+ /**
+ * A property change handler that updates the rendered component in response
+ * to specific property change events. This custom handler is used to
+ * intercept the "JSlider.isFilled" property, which is only recognised by
+ * the {@link MetalLookAndFeel}.
+ */
+ protected class MetalPropertyListener
+ extends BasicSliderUI.PropertyChangeHandler
+ {
+ /**
+ * Creates a new listener.
+ */
+ protected MetalPropertyListener()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Handles property change events. Events with the name "JSlider.isFilled"
+ * are handled here, and other events are passed to the superclass.
+ *
+ * @param e the property change event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(SLIDER_FILL))
+ {
+ Boolean b = (Boolean) e.getNewValue();
+ if (b == null)
+ filledSlider = false;
+ else
+ filledSlider = b.booleanValue();
+ }
+ else
+ super.propertyChange(e);
+ }
+ }
+
+ /** The thumb color (unused, because an icon is used to draw the thumb). */
+ protected static Color thumbColor;
+
+ /**
+ * The highlight color used for drawing the track rect when the slider is
+ * enabled.
+ */
+ protected static Color highlightColor;
+
+ /**
+ * The shadow color used for drawing the track rect when the slider is
+ * enabled.
+ */
+ protected static Color darkShadowColor;
+
+ /** The track width. */
+ protected static int trackWidth = UIManager.getInt("Slider.trackWidth");
+
+ /** The length of the major tick marks. */
+ protected static int tickLength = UIManager.getInt("Slider.majorTickLength");
+
+ /** The icon used for the thumb control of horizontally oriented sliders. */
+ protected static Icon horizThumbIcon = UIManager.getIcon(
+ "Slider.horizontalThumbIcon");
+
+ /** The icon used for the thumb control of vertically oriented sliders. */
+ protected static Icon vertThumbIcon = UIManager.getIcon(
+ "Slider.verticalThumbIcon");
+
+ /** The gap between the track and the tick marks. */
+ protected final int TICK_BUFFER = 4;
+
+ /** A key to look up the filledSlider setting in the {@link UIManager}. */
+ protected final String SLIDER_FILL = "JSlider.isFilled";
+
+ /**
+ * A flag that controls whether or not the track is filled up to the value
+ * of the slider.
+ */
+ protected boolean filledSlider;
+
+ /**
+ * Constructs a new instance.
+ */
+ public MetalSliderUI()
+ {
+ super(null);
+ filledSlider = UIManager.getBoolean(SLIDER_FILL);
+ darkShadowColor = MetalLookAndFeel.getControlDarkShadow();
+ highlightColor = MetalLookAndFeel.getControlHighlight();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalSliderUI</code>.
+ *
+ * @param component the component (ignored).
+ *
+ * @return A new instance of <code>MetalSliderUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalSliderUI();
+ }
+
+ /**
+ * Installs the default for this UI delegate in the supplied component.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ Boolean b = (Boolean) c.getClientProperty(SLIDER_FILL);
+ if (b != null)
+ filledSlider = b.booleanValue();
+ }
+
+ /**
+ * Creates a property change listener for the slider.
+ *
+ * @param slider the slider.
+ *
+ * @return A new instance of {@link MetalPropertyListener}.
+ */
+ protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
+ {
+ return new MetalPropertyListener();
+ }
+
+ /**
+ * Paints the thumb icon for the slider.
+ *
+ * @param g the graphics device.
+ */
+ public void paintThumb(Graphics g)
+ {
+ Color save = g.getColor();
+ g.setColor(thumbColor);
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ horizThumbIcon.paintIcon(slider, g, thumbRect.x, thumbRect.y);
+ else
+ vertThumbIcon.paintIcon(slider, g, thumbRect.x, thumbRect.y);
+ g.setColor(save);
+ }
+
+ /**
+ * Paints the track along which the thumb control moves.
+ *
+ * @param g the graphics device.
+ */
+ public void paintTrack(Graphics g)
+ {
+ Color shadowColor = MetalLookAndFeel.getControlShadow();
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ {
+ int trackX = trackRect.x;
+ int trackY = trackRect.y + (trackRect.height - getTrackWidth()) / 2;
+ int trackW = trackRect.width;
+ int trackH = getTrackWidth();
+
+ // draw border
+ if (slider.isEnabled())
+ BasicGraphicsUtils.drawEtchedRect(g, trackX, trackY, trackW, trackH,
+ darkShadowColor, shadowColor, darkShadowColor, highlightColor);
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawRect(trackX, trackY, trackW - 2, trackH - 2);
+ }
+
+ // fill track (if required)
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
+ {
+ if (slider.isEnabled())
+ {
+ int xPos = xPositionForValue(slider.getValue());
+ int x = slider.getInverted() ? xPos : trackRect.x;
+ int w = slider.getInverted() ? trackX + trackW - xPos
+ : xPos - trackRect.x;
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1);
+ g.setColor(UIManager.getColor("Slider.altTrackColor"));
+ g.drawLine(x + 1, trackY + 2, x + w - 3, trackY + 2);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 1, trackY + 3, x + w - 3, trackY + 3);
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.drawLine(x + 1, trackY + 4, x + w - 3, trackY + 4);
+ }
+ }
+ else if (filledSlider)
+ {
+ int xPos = xPositionForValue(slider.getValue());
+ int x = slider.getInverted() ? xPos : trackRect.x;
+ int w = slider.getInverted() ? trackX + trackW - xPos
+ : xPos - trackRect.x;
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(x + 1, trackY + 1, w - 3, getTrackWidth() - 3);
+ if (slider.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1);
+ g.drawLine(x + 1, trackY + 1, x + 1,
+ trackY + getTrackWidth() - 3);
+ }
+ }
+ }
+ else
+ {
+ int trackX = trackRect.x + (trackRect.width - getTrackWidth()) / 2;
+ int trackY = trackRect.y;
+ int trackW = getTrackWidth();
+ int trackH = trackRect.height;
+ if (slider.isEnabled())
+ BasicGraphicsUtils.drawEtchedRect(g, trackX, trackY, trackW, trackH,
+ darkShadowColor, shadowColor, darkShadowColor, highlightColor);
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawRect(trackX, trackY, trackW - 2, trackH - 2);
+ }
+
+ // Fill track if necessary.
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
+ {
+ if (slider.isEnabled())
+ {
+ int yPos = yPositionForValue(slider.getValue());
+ int y = slider.getInverted() ? trackY : yPos;
+ int h = slider.getInverted() ? yPos - trackY
+ : trackY + trackH - yPos;
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3);
+ g.setColor(UIManager.getColor("Slider.altTrackColor"));
+ g.drawLine(trackX + 2, y + 1, trackX + 2, y + h - 3);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(trackX + 3, y + 1, trackX + 3, y + h - 3);
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.drawLine(trackX + 4, y + 1, trackX + 4, y + h - 3);
+ }
+ }
+ else if (filledSlider)
+ {
+ int yPos = yPositionForValue(slider.getValue());
+ int y = slider.getInverted() ? trackY : yPos;
+ int h = slider.getInverted() ? yPos - trackY
+ : trackY + trackH - yPos;
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(trackX + 1, y + 1, getTrackWidth() - 3, h - 3);
+ if (slider.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(trackX + 1, y + 1, trackX + trackW - 3, y + 1);
+ g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3);
+ }
+ }
+ }
+ }
+
+ /**
+ * Draws the focus rectangle for the slider. The Metal look and feel
+ * indicates that the {@link JSlider} has the focus by changing the color of
+ * the thumb control - this is handled elsewhere and so this method is empty
+ * (it overrides the method in the {@link BasicSliderUI} class to prevent
+ * a default focus highlight from being drawn).
+ *
+ * @param g the graphics device.
+ */
+ public void paintFocus(Graphics g)
+ {
+ thumbColor = getFocusColor();
+ paintThumb(g);
+ }
+
+ /**
+ * Returns the size of the thumb icon.
+ *
+ * @return The size of the thumb icon.
+ */
+ protected Dimension getThumbSize()
+ {
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ return new Dimension(horizThumbIcon.getIconWidth(),
+ horizThumbIcon.getIconHeight());
+ else
+ return new Dimension(vertThumbIcon.getIconWidth(),
+ vertThumbIcon.getIconHeight());
+ }
+
+ /**
+ * Returns the length of the major tick marks.
+ *
+ * @return The length of the major tick marks.
+ */
+ public int getTickLength()
+ {
+ return tickLength + TICK_BUFFER;
+ }
+
+ /**
+ * Returns the track width.
+ *
+ * @return The track width.
+ */
+ protected int getTrackWidth()
+ {
+ return trackWidth;
+ }
+
+ /**
+ * Returns the track length.
+ *
+ * @return The track length.
+ */
+ protected int getTrackLength()
+ {
+ return slider.getOrientation() == JSlider.HORIZONTAL
+ ? tickRect.width : tickRect.height;
+ }
+
+ /**
+ * Returns the thumb overhang.
+ *
+ * @return The thumb overhang.
+ */
+ protected int getThumbOverhang()
+ {
+ // FIXME: for what might this method be used?
+ return 0;
+ }
+
+ protected void scrollDueToClickInTrack(int dir)
+ {
+ // FIXME: for what might this method be overridden?
+ super.scrollDueToClickInTrack(dir);
+ }
+
+ /**
+ * Paints the minor ticks for a slider with a horizontal orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param x the x value for the tick.
+ */
+ protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds,
+ int x)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength / 2);
+ }
+
+ /**
+ * Paints the major ticks for a slider with a horizontal orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param x the x value for the tick.
+ */
+ protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds,
+ int x)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength);
+ }
+
+ /**
+ * Paints the minor ticks for a slider with a vertical orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param y the y value for the tick.
+ */
+ protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds,
+ int y)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength / 2, y);
+ }
+
+ /**
+ * Paints the major ticks for a slider with a vertical orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param y the y value for the tick.
+ */
+ protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds,
+ int y)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength, y);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,231 @@
+/* MetalSplitPaneDivider.java
+Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.LayoutManager;
+import java.awt.Point;
+
+import javax.swing.JSplitPane;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.plaf.basic.BasicArrowButton;
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
+
+/**
+ * The divider that is used by the {@link MetalSplitPaneUI}.
+ *
+ * @author Roman Kennke (roman at kennke.org)
+ */
+class MetalSplitPaneDivider extends BasicSplitPaneDivider
+{
+ /** The dark color in the pattern. */
+ Color dark;
+
+ /** The light color in the pattern. */
+ Color light;
+
+ /** The JSplitPane the divider is on. */
+ JSplitPane splitPane;
+
+ /** The split pane orientation. */
+ int orientation;
+
+ /**
+ * Creates a new instance of <code>MetalSplitPaneDivider</code>.
+ *
+ * @param ui the <code>MetalSplitPaneUI</code> that uses this divider
+ */
+ public MetalSplitPaneDivider(MetalSplitPaneUI ui, Color light, Color dark)
+ {
+ super(ui);
+ setLayout(new MetalDividerLayout());
+ this.splitPane = super.splitPane;
+ this.orientation = super.orientation;
+ this.light = light;
+ this.dark = dark;
+ }
+
+ /**
+ * Paints the divider.
+ *
+ * @param g the <code>Graphics</code> context to use for painting
+ */
+ public void paint(Graphics g)
+ {
+ Dimension s = getSize();
+
+ if (splitPane.hasFocus())
+ {
+ g.setColor(UIManager.getColor("SplitPane.dividerFocusColor"));
+ g.fillRect(0, 0, s.width, s.height);
+ }
+
+ // Paint border if one exists.
+ Border border = getBorder();
+ if (border != null)
+ border.paintBorder(this, g, 0, 0, s.width, s.height);
+
+ MetalUtils.fillMetalPattern(splitPane, g, 2, 2, s.width - 4, s.height - 4,
+ light, dark);
+ if (splitPane.isOneTouchExpandable())
+ {
+ ((BasicArrowButton) rightButton).paint(g);
+ ((BasicArrowButton) leftButton).paint(g);
+ }
+ }
+
+ /**
+ * This helper class acts as the Layout Manager for the divider.
+ */
+ public class MetalDividerLayout implements LayoutManager
+ {
+ /** The right button. */
+ BasicArrowButton rb;
+
+ /** The left button. */
+ BasicArrowButton lb;
+
+ /**
+ * Creates a new DividerLayout object.
+ */
+ public MetalDividerLayout()
+ {
+ // Nothing to do here
+ }
+
+ /**
+ * This method is called when a Component is added.
+ *
+ * @param string The constraints string.
+ * @param c The Component to add.
+ */
+ public void addLayoutComponent(String string, Component c)
+ {
+ // Nothing to do here, constraints are set depending on
+ // orientation in layoutContainer
+ }
+
+ /**
+ * This method is called to lay out the container.
+ *
+ * @param c The container to lay out.
+ */
+ public void layoutContainer(Container c)
+ {
+ // The only components we care about setting up are the
+ // one touch buttons.
+ if (splitPane.isOneTouchExpandable())
+ {
+ if (c.getComponentCount() == 2)
+ {
+ Component c1 = c.getComponent(0);
+ Component c2 = c.getComponent(1);
+ if ((c1 instanceof BasicArrowButton)
+ && (c2 instanceof BasicArrowButton))
+ {
+ lb = (BasicArrowButton) c1;
+ rb = (BasicArrowButton) c2;
+ }
+ }
+ if (rb != null && lb != null)
+ {
+ Point p = getLocation();
+ lb.setSize(lb.getPreferredSize());
+ rb.setSize(rb.getPreferredSize());
+ lb.setLocation(p.x, p.y);
+
+ if (orientation == JSplitPane.HORIZONTAL_SPLIT)
+ {
+ rb.setDirection(SwingConstants.EAST);
+ lb.setDirection(SwingConstants.WEST);
+ rb.setLocation(p.x, p.y + lb.getHeight());
+ }
+ else
+ {
+ rb.setDirection(SwingConstants.SOUTH);
+ lb.setDirection(SwingConstants.NORTH);
+ rb.setLocation(p.x + lb.getWidth(), p.y);
+ }
+ }
+ }
+ }
+
+ /**
+ * This method returns the minimum layout size.
+ *
+ * @param c The container to calculate for.
+ *
+ * @return The minimum layout size.
+ */
+ public Dimension minimumLayoutSize(Container c)
+ {
+ return preferredLayoutSize(c);
+ }
+
+ /**
+ * This method returns the preferred layout size.
+ *
+ * @param c The container to calculate for.
+ *
+ * @return The preferred layout size.
+ */
+ public Dimension preferredLayoutSize(Container c)
+ {
+ int dividerSize = getDividerSize();
+ return new Dimension(dividerSize, dividerSize);
+ }
+
+ /**
+ * This method is called when a component is removed.
+ *
+ * @param c The component to remove.
+ */
+ public void removeLayoutComponent(Component c)
+ {
+ // Nothing to do here. If buttons are removed
+ // they will not be layed out when layoutContainer is
+ // called.
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* MetalSplitPaneUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+
+import javax.swing.JComponent;
+import javax.swing.JSplitPane;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+
+/**
+ * A UI delegate for the {@link JSplitPane} component.
+ */
+public class MetalSplitPaneUI extends BasicSplitPaneUI
+{
+ /**
+ * Constructs a new instance of <code>MetalSplitPaneUI</code>.
+ */
+ public MetalSplitPaneUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalSplitPaneUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalSplitPaneUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalSplitPaneUI();
+ }
+
+ /**
+ * Returns the divider that is used by the <code>JSplitPane</code>.
+ *
+ * The divider returned by this method is a {@link BasicSplitPaneDivider}
+ * that is drawn using the Metal look.
+ *
+ * @return the default divider to use for <code>JSplitPane</code>s.
+ */
+ public BasicSplitPaneDivider createDefaultDivider()
+ {
+ Color light = UIManager.getColor("SplitPane.highlight");
+ Color dark = UIManager.getColor("SplitPane.darkShadow");
+ return new MetalSplitPaneDivider(this, light, dark);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1269 @@
+/* MetalTabbedPaneUI.java
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.LayoutManager;
+import java.awt.Rectangle;
+
+import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicTabbedPaneUI;
+
+/**
+ * A UI delegate for the {@link JTabbedPane} component.
+ */
+public class MetalTabbedPaneUI extends BasicTabbedPaneUI
+{
+
+ /**
+ * A {@link LayoutManager} responsible for placing all the tabs and the
+ * visible component inside the {@link JTabbedPane}. This class is only used
+ * for {@link JTabbedPane#WRAP_TAB_LAYOUT}.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class TabbedPaneLayout
+ extends BasicTabbedPaneUI.TabbedPaneLayout
+ {
+ /**
+ * Creates a new instance of the layout manager.
+ */
+ public TabbedPaneLayout()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Overridden to do nothing, because tab runs are not rotated in the
+ * {@link MetalLookAndFeel}.
+ *
+ * @param tabPlacement the tab placement (one of {@link #TOP},
+ * {@link #BOTTOM}, {@link #LEFT} or {@link #RIGHT}).
+ * @param selectedRun the index of the selected run.
+ */
+ protected void rotateTabRuns(int tabPlacement, int selectedRun)
+ {
+ // do nothing, because tab runs are not rotated in the MetalLookAndFeel
+ }
+
+ /**
+ * Overridden to do nothing, because the selected tab does not have extra
+ * padding in the {@link MetalLookAndFeel}.
+ *
+ * @param tabPlacement the tab placement (one of {@link #TOP},
+ * {@link #BOTTOM}, {@link #LEFT} or {@link #RIGHT}).
+ * @param selectedIndex the index of the selected tab.
+ */
+ protected void padSelectedTab(int tabPlacement, int selectedIndex)
+ {
+ // do nothing, because the selected tab does not have extra padding in
+ // the MetalLookAndFeel
+ }
+
+ /**
+ * Overridden because tab runs are only normalized for TOP and BOTTOM
+ * tab placement in the Metal L&F.
+ */
+ protected void normalizeTabRuns(int tabPlacement, int tabCount, int start,
+ int max)
+ {
+ if (tabPlacement == TOP || tabPlacement == BOTTOM)
+ super.normalizeTabRuns(tabPlacement, tabCount, start, max);
+ }
+ }
+
+ /**
+ * The minimum tab width.
+ */
+ protected int minTabWidth;
+
+ /**
+ * The color for the selected tab.
+ */
+ protected Color selectColor;
+
+ /**
+ * The color for a highlighted selected tab.
+ */
+ protected Color selectHighlight;
+
+ /**
+ * The background color used for the tab area.
+ */
+ protected Color tabAreaBackground;
+
+ /** The graphics to draw the highlight below the tab. */
+ private Graphics hg;
+
+ /**
+ * Indicates if the tabs are having their background filled.
+ */
+ private boolean tabsOpaque;
+
+ /**
+ * Constructs a new instance of MetalTabbedPaneUI.
+ */
+ public MetalTabbedPaneUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns an instance of MetalTabbedPaneUI.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return an instance of MetalTabbedPaneUI
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalTabbedPaneUI();
+ }
+
+ /**
+ * Creates and returns an instance of {@link TabbedPaneLayout}.
+ *
+ * @return A layout manager used by this UI delegate.
+ */
+ protected LayoutManager createLayoutManager()
+ {
+ return (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT)
+ ? new MetalTabbedPaneUI.TabbedPaneLayout()
+ : super.createLayoutManager();
+ }
+
+ /**
+ * Paints the border for a single tab.
+ *
+ * @param g the graphics device.
+ * @param tabPlacement the tab placement ({@link #TOP}, {@link #LEFT},
+ * {@link #BOTTOM} or {@link #RIGHT}).
+ * @param tabIndex the index of the tab to draw the border for.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param isSelected indicates whether or not the tab is selected.
+ */
+ protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
+ int x, int y, int w, int h, boolean isSelected)
+ {
+ int bottom = y + h - 1;
+ int right = x + w - 1;
+
+ switch (tabPlacement)
+ {
+ case LEFT:
+ paintLeftTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
+ break;
+ case BOTTOM:
+ paintBottomTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
+ break;
+ case RIGHT:
+ paintRightTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
+ break;
+ case TOP:
+ default:
+ paintTopTabBorder(tabIndex, g, x, y, w, h, bottom, right, isSelected);
+ }
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the top
+ * ({@link #TOP}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm the y coordinate of the bottom border
+ * @param rght the x coordinate of the right border
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintTopTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ int tabCount = tabPane.getTabCount();
+ int currentRun = getRunForTab(tabCount, tabIndex);
+ int right = w - 1;
+ int bottom = h - 1;
+
+ // Paint gap.
+ if (shouldFillGap(currentRun, tabIndex, x, y))
+ {
+ g.translate(x, y);
+ g.setColor(getColorForGap(currentRun, x, y + 1));
+ g.fillRect(1, 0, 5, 3);
+ g.fillRect(1, 3, 2, 2);
+ g.translate(-x, -y);
+ }
+
+ g.translate(x, y);
+
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ if (isOcean && isSelected)
+ g.setColor(oceanSelectedBorder);
+ else
+ g.setColor(darkShadow);
+
+ // Slant
+ g.drawLine(1, 5, 6, 0);
+ // Top.
+ g.drawLine(6, 0, right, 0);
+ // Right.
+ int lastIndex = lastTabInRun(tabCount, currentRun);
+ if (tabIndex == lastIndex)
+ g.drawLine(right, 1, right, bottom);
+ // Left.
+ int selectedIndex = tabPane.getSelectedIndex();
+ if (isOcean && tabIndex - 1 == selectedIndex
+ && currentRun == getRunForTab(tabCount, selectedIndex))
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ if (tabIndex != tabRuns[runCount - 1])
+ {
+ if (isOcean && isSelected)
+ {
+ g.drawLine(0, 6, 0, bottom);
+ g.setColor(darkShadow);
+ g.drawLine(0, 0, 0, 5);
+ }
+ else
+ {
+ g.drawLine(0, 0, 0, bottom);
+ }
+ }
+ else
+ {
+ g.drawLine(0, 6, 0, bottom);
+ }
+
+ // Paint the highlight.
+ g.setColor(isSelected ? selectHighlight : highlight);
+ // Slant.
+ g.drawLine(1, 6, 6, 1);
+ // Top.
+ g.drawLine(6, 1, right, 1);
+ // Left.
+ g.drawLine(1, 6, 1, bottom);
+ int firstIndex = tabRuns[currentRun];
+ if (tabIndex == firstIndex && tabIndex != tabRuns[runCount - 1])
+ {
+ if (tabPane.getSelectedIndex() == tabRuns[currentRun + 1])
+ g.setColor(selectHighlight);
+ else
+ g.setColor(highlight);
+ g.drawLine(1, 0, 1, 4);
+ }
+
+ g.translate(-x, -y);
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the left
+ * ({@link #LEFT}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintLeftTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ g.translate(x, y);
+ int bottom = h - 1;
+ int right = w - 1;
+
+ int tabCount = tabPane.getTabCount();
+ int currentRun = getRunForTab(tabCount, tabIndex);
+ int firstIndex = tabRuns[currentRun];
+
+ // Paint the part of the above tab.
+ if (tabIndex != firstIndex && tabIndex > 0 && tabsOpaque)
+ {
+ Color c;
+ if (tabPane.getSelectedIndex() == tabIndex - 1)
+ c = selectColor;
+ else
+ c = getUnselectedBackground(tabIndex - 1);
+ g.setColor(c);
+ g.fillRect(2, 0, 4, 3);
+ g.drawLine(2, 3, 2, 3);
+ }
+
+ // Paint the highlight.
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ if (isOcean)
+ {
+ g.setColor(isSelected ? selectHighlight : MetalLookAndFeel.getWhite());
+ }
+ else
+ {
+ g.setColor(isSelected ? selectHighlight : highlight);
+ }
+ // Slant.
+ g.drawLine(1, 6, 6, 1);
+ // Left.
+ g.drawLine(1, 6, 1, bottom);
+ // Top.
+ g.drawLine(6, 1, right, 1);
+ if (tabIndex != firstIndex)
+ {
+ if (isOcean)
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+ }
+ g.drawLine(1, 0, 1, 4);
+ }
+
+ // Paint border.
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ if (isOcean && isSelected)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ else
+ {
+ g.setColor(darkShadow);
+ }
+
+ // Slant.
+ g.drawLine(1, 5, 6, 0);
+ // Top.
+ g.drawLine(6, 0, right, 0);
+ // Bottom.
+ int lastIndex = lastTabInRun(tabCount, currentRun);
+ if (tabIndex == lastIndex)
+ {
+ g.drawLine(0, bottom, right, bottom);
+ }
+ // Left.
+ if (isOcean)
+ {
+ if (tabPane.getSelectedIndex() == tabIndex - 1)
+ {
+ 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 != firstIndex)
+ {
+ g.setColor(darkShadow);
+ g.drawLine(0, 0, 0, 5);
+ }
+ }
+ else if (tabIndex != firstIndex)
+ {
+ g.drawLine(0, 0, 0, bottom);
+ }
+ else
+ {
+ g.drawLine(0, 6, 0, bottom);
+ }
+ }
+ else
+ {
+ if (tabIndex != firstIndex)
+ {
+ g.drawLine(0, 0, 0, bottom);
+ }
+ else
+ {
+ g.drawLine(0, 6, 0, bottom);
+ }
+ }
+
+ g.translate(-x, -y);
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the right
+ * ({@link #RIGHT}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintRightTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ g.translate(x, y);
+ int bottom = h - 1;
+ int right = w - 1;
+
+ int tabCount = tabPane.getTabCount();
+ int currentRun = getRunForTab(tabCount, tabIndex);
+ int firstIndex = tabRuns[currentRun];
+
+ // Paint part of the above tab.
+ if (tabIndex != firstIndex && tabIndex > 0 && tabsOpaque)
+ {
+ Color c;
+ if (tabPane.getSelectedIndex() == tabIndex - 1)
+ c = selectColor;
+ else
+ c = getUnselectedBackground(tabIndex - 1);
+ g.setColor(c);
+ g.fillRect(right - 5, 0, 5, 3);
+ g.fillRect(right - 2, 3, 2, 2);
+ }
+
+ // Paint highlight.
+ g.setColor(isSelected ? selectHighlight : highlight);
+
+ // Slant.
+ g.drawLine(right - 6, 1, right - 1, 6);
+ // Top.
+ g.drawLine(0, 1, right - 6, 1);
+ // Left.
+ if (! isSelected)
+ {
+ g.drawLine(0, 1, 0, bottom);
+ }
+
+ // Paint border.
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ if (isOcean && isSelected)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ else
+ {
+ g.setColor(darkShadow);
+ }
+
+ // Bottom.
+ int lastIndex = lastTabInRun(tabCount, currentRun);
+ if (tabIndex == lastIndex)
+ {
+ g.drawLine(0, bottom, right, bottom);
+ }
+ // Slant.
+ if (isOcean && tabPane.getSelectedIndex() == tabIndex - 1)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ g.drawLine(right - 6, 0, right, 6);
+ // Top.
+ g.drawLine(0, 0, right - 6, 0);
+ // Right.
+ if (isOcean && isSelected)
+ {
+ g.drawLine(right, 6, right, bottom);
+ if (tabIndex != firstIndex)
+ {
+ g.setColor(darkShadow);
+ g.drawLine(right, 0, right, 5);
+ }
+ }
+ else if (isOcean && tabPane.getSelectedIndex() == tabIndex - 1)
+ {
+ if (tabIndex != firstIndex)
+ {
+ g.setColor(oceanSelectedBorder);
+ g.drawLine(right, 0, right, 6);
+ }
+ g.setColor(darkShadow);
+ g.drawLine(right, 7, right, bottom);
+ }
+ else if (tabIndex != firstIndex)
+ {
+ g.drawLine(right, 0, right, bottom);
+ }
+ else
+ {
+ g.drawLine(right, 6, right, bottom);
+ }
+ g.translate(-x, -y);
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the bottom
+ * ({@link #BOTTOM}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintBottomTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ int bottom = h - 1;
+ int right = w - 1;
+
+ int tabCount = tabPane.getTabCount();
+ int currentRun = getRunForTab(tabCount, tabIndex);
+ // Paint gap if necessary.
+ if (shouldFillGap(currentRun, tabIndex, x, y))
+ {
+ g.translate(x, y);
+ g.setColor(getColorForGap(currentRun, x, y));
+ g.fillRect(1, bottom - 4, 3, 5);
+ g.fillRect(4, bottom - 1, 2, 2);
+ g.translate(-x, -y);
+ }
+
+ g.translate(x, y);
+
+ // Paint border.
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ if (isOcean && isSelected)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ else
+ {
+ g.setColor(darkShadow);
+ }
+ // Slant.
+ g.drawLine(1, bottom - 5, 6, bottom);
+ // Bottom.
+ g.drawLine(6, bottom, right, bottom);
+ // Right.
+ int lastIndex = lastTabInRun(tabCount, currentRun);
+ if (tabIndex == lastIndex)
+ {
+ g.drawLine(right, 0, right, bottom);
+ }
+ // Left.
+ if (isOcean && isSelected)
+ {
+ g.drawLine(0, 0, 0, bottom - 5);
+
+ // 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);
+ }
+ }
+ else
+ {
+ if (isOcean && tabIndex == tabPane.getSelectedIndex() + 1)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ if (tabIndex != tabRuns[runCount - 1])
+ {
+ g.drawLine(0, 0, 0, bottom);
+ }
+ else
+ {
+ g.drawLine(0, 0, 0, bottom - 6);
+ }
+ }
+
+ // Paint highlight.
+ g.setColor(isSelected ? selectHighlight : highlight);
+ // Slant.
+ g.drawLine(1, bottom - 6, 6, bottom - 1);
+ // Left.
+ g.drawLine(1, 0, 1, bottom - 6);
+
+ int firstIndex = tabRuns[currentRun];
+ if (tabIndex == firstIndex && tabIndex != tabRuns[runCount - 1])
+ {
+ if (tabPane.getSelectedIndex() == tabRuns[currentRun + 1])
+ {
+ g.setColor(selectHighlight);
+ }
+ else
+ {
+ g.setColor(highlight);
+ }
+ g.drawLine(1, bottom - 4, 1, bottom);
+ }
+
+ g.translate(-x, -y);
+ }
+
+ /**
+ * Paints the background for a tab.
+ *
+ * @param g the graphics device.
+ * @param tabPlacement the tab placement ({@link #TOP}, {@link #LEFT},
+ * {@link #BOTTOM} or {@link #RIGHT}).
+ * @param tabIndex the index of the tab to draw the border for.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param isSelected indicates whether or not the tab is selected.
+ */
+ protected void paintTabBackground(Graphics g, int tabPlacement,
+ int tabIndex, int x, int y, int w, int h, boolean isSelected)
+ {
+ if (isSelected)
+ g.setColor(selectColor);
+ else
+ g.setColor(getUnselectedBackground(tabIndex));
+
+ switch (tabPlacement)
+ {
+ case LEFT:
+ g.fillRect(x + 5, y + 1, w - 5, h - 1);
+ g.fillRect(x + 2, y + 4, 3, h - 4);
+ break;
+ case BOTTOM:
+ g.fillRect(x + 2, y, w - 2, h - 3);
+ g.fillRect(x + 5, y + h - 4, w - 5, 3);
+ break;
+ case RIGHT:
+ g.fillRect(x, y + 1, w - 4, h - 1);
+ g.fillRect(x + w - 4, y + 5, 3, h - 5);
+ break;
+ case TOP:
+ default:
+ g.fillRect(x + 4, y + 2, w - 4, h - 2);
+ g.fillRect(x + 2, y + 5, 2, h - 5);
+ }
+ }
+
+ /**
+ * 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}.
+ *
+ * @param tabPlacement the tab placement for the {@link JTabbedPane} (one of
+ * {@link #TOP}, {@link #BOTTOM}, {@link #LEFT} and {@link #RIGHT}).
+ * @param run the run index.
+ *
+ * @return A boolean.
+ */
+ protected boolean shouldPadTabRun(int tabPlacement, int run)
+ {
+ // as far as I can tell, all runs should be padded except the last run
+ // (which is drawn at the very top for tabPlacement == TOP)
+ return run < this.runCount - 1;
+ }
+
+ /**
+ * Installs the defaults for this UI. This method calls super.installDefaults
+ * and then loads the Metal specific defaults for TabbedPane.
+ */
+ protected void installDefaults()
+ {
+ super.installDefaults();
+ selectColor = UIManager.getColor("TabbedPane.selected");
+ selectHighlight = UIManager.getColor("TabbedPane.selectHighlight");
+ tabAreaBackground = UIManager.getColor("TabbedPane.tabAreaBackground");
+ tabsOpaque = UIManager.getBoolean("TabbedPane.tabsOpaque");
+ minTabWidth = 0;
+ }
+
+ /**
+ * Returns the color for the gap.
+ *
+ * @param currentRun - The current run to return the color for
+ * @param x - The x position of the current run
+ * @param y - The y position of the current run
+ *
+ * @return the color for the gap in the current run.
+ */
+ protected Color getColorForGap(int currentRun, int x, int y)
+ {
+ int index = tabForCoordinate(tabPane, x, y);
+ int selected = tabPane.getSelectedIndex();
+ if (selected == index)
+ return selectColor;
+ return tabAreaBackground;
+ }
+
+ /**
+ * Returns true if the gap should be filled in.
+ *
+ * @param currentRun - The current run
+ * @param tabIndex - The current tab
+ * @param x - The x position of the tab
+ * @param y - The y position of the tab
+ *
+ * @return true if the gap at the current run should be filled
+ */
+ protected boolean shouldFillGap(int currentRun, int tabIndex, int x, int y)
+ {
+ // As far as I can tell, the gap is never filled in.
+ return false;
+ }
+
+ /**
+ * Paints the highlight below the tab, if there is one.
+ */
+ protected void paintHighlightBelowTab()
+ {
+ int selected = tabPane.getSelectedIndex();
+ int tabPlacement = tabPane.getTabPlacement();
+ Rectangle bounds = getTabBounds(tabPane, selected);
+
+ hg.setColor(selectColor);
+ int x = bounds.x;
+ int y = bounds.y;
+ int w = bounds.width;
+ int h = bounds.height;
+
+ if (tabPlacement == TOP)
+ hg.fillRect(x, y + h - 2, w, 30);
+ else if (tabPlacement == LEFT)
+ hg.fillRect(x + w - 1, y, 20, h);
+ else if (tabPlacement == BOTTOM)
+ hg.fillRect(x, y - h + 2, w, 30);
+ else if (tabPlacement == RIGHT)
+ hg.fillRect(x - 18, y, 20, h);
+ else
+ throw new AssertionError("Unrecognised 'tabPlacement' argument.");
+ hg = null;
+ }
+
+ /**
+ * Returns true if we should rotate the tab runs.
+ *
+ * @param tabPlacement - The current tab placement.
+ * @param selectedRun - The selected run.
+ *
+ * @return true if the tab runs should be rotated.
+ */
+ protected boolean shouldRotateTabRuns(int tabPlacement,
+ int selectedRun)
+ {
+ // false because tab runs are not rotated in the MetalLookAndFeel
+ return false;
+ }
+
+ protected int calculateMaxTabHeight(int tabPlacement)
+ {
+ // FIXME: Why is this overridden?
+ return super.calculateMaxTabHeight(tabPlacement);
+ }
+
+ /**
+ * Returns the amount of overlay among the tabs. In
+ * the Metal L&F the overlay for LEFT and RIGHT placement
+ * is half of the maxTabHeight. For TOP and BOTTOM placement
+ * the tabs do not overlay.
+ *
+ * @param tabPlacement the placement
+ *
+ * @return the amount of overlay among the tabs
+ */
+ protected int getTabRunOverlay(int tabPlacement)
+ {
+ int overlay = 0;
+ if (tabPlacement == LEFT || tabPlacement == RIGHT)
+ {
+ int maxHeight = calculateMaxTabHeight(tabPlacement);
+ overlay = maxTabHeight / 2;
+ }
+ return overlay;
+ }
+
+ /**
+ * Paints the upper edge of the content border.
+ *
+ * @param g the graphics to use for painting
+ * @param tabPlacement the tab placement
+ * @param selectedIndex the index of the selected tab
+ * @param x the upper left coordinate of the content area
+ * @param y the upper left coordinate of the content area
+ * @param w the width of the content area
+ * @param h the height of the content area
+ */
+ protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
+ int selectedIndex, int x, int y,
+ int w, int h)
+ {
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ if (isOcean)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ else
+ {
+ g.setColor(selectHighlight);
+ }
+
+ Rectangle rect = selectedIndex < 0 ? null :
+ getTabBounds(selectedIndex, calcRect);
+
+ // If tabs are not placed on TOP, or if the selected tab is not in the
+ // run directly above the content or the selected tab is not visible,
+ // then we draw an unbroken line.
+ if (tabPlacement != TOP || selectedIndex < 0
+ || rect.y + rect.height + 1 < y || rect.x < x || rect.x > x + w)
+ {
+ g.drawLine(x, y, x + w - 2, y);
+ if (isOcean && tabPlacement == TOP)
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x, y + 1, x + w - 2, y + 1);
+ }
+ }
+ else
+ {
+ boolean isLast = isLastTabInRun(selectedIndex);
+ if (isLast)
+ {
+ g.drawLine(x, y, rect.x + 1, y);
+ }
+ else
+ {
+ g.drawLine(x, y, rect.x, y);
+ }
+
+ int right = x + w - 1;
+ if (rect.x + rect.width < right - 1)
+ {
+ if (isLast)
+ {
+ g.drawLine(rect.x + rect.width - 1, y, right - 1, y);
+ }
+ else
+ {
+ g.drawLine(rect.x + rect.width, y, right - 1, y);
+ }
+ }
+ else
+ {
+ g.setColor(shadow);
+ g.drawLine(x + w - 2, y, x + w - 2, y);
+ }
+
+ // When in OceanTheme, draw another white line.
+ if (isOcean)
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+ if (isLast)
+ {
+ g.drawLine(x, y + 1, rect.x + 1, y + 1);
+ }
+ else
+ {
+ g.drawLine(x, y + 1, rect.x, y + 1);
+ }
+
+ if (rect.x + rect.width < right - 1)
+ {
+ if (isLast)
+ {
+ g.drawLine(rect.x + rect.width - 1, y + 1, right - 1,
+ y + 1);
+ }
+ else
+ {
+ g.drawLine(rect.x + rect.width, y + 1, right - 1, y + 1);
+ }
+ }
+ else
+ {
+ g.setColor(shadow);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
+ }
+ }
+ }
+ }
+
+ /**
+ * Paints the lower edge of the content border.
+ *
+ * @param g the graphics to use for painting
+ * @param tabPlacement the tab placement
+ * @param selectedIndex the index of the selected tab
+ * @param x the upper left coordinate of the content area
+ * @param y the upper left coordinate of the content area
+ * @param w the width of the content area
+ * @param h the height of the content area
+ */
+ protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
+ int selectedIndex, int x, int y,
+ int w, int h)
+ {
+ g.setColor(darkShadow);
+
+ // If tabs are not placed on BOTTOM, or if the selected tab is not in the
+ // run directly below the content or the selected tab is not visible,
+ // then we draw an unbroken line.
+ Rectangle rect = selectedIndex < 0 ? null :
+ getTabBounds(selectedIndex, calcRect);
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ if (tabPlacement != BOTTOM || selectedIndex < 0 || rect.y - 1 > h
+ || rect.x < x || rect.x > x + w)
+ {
+ if (isOcean && tabPlacement == BOTTOM)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ }
+ else
+ {
+ boolean isLast = isLastTabInRun(selectedIndex);
+ if (isOcean)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+
+ int bottom = y + h - 1;
+ int right = x + w - 1;
+ if (isLast)
+ {
+ g.drawLine(x, bottom, rect.x, bottom);
+ }
+ else
+ {
+ g.drawLine(x, bottom, rect.x - 1, bottom);
+ }
+
+ if (rect.x + rect.width < x + w - 2)
+ {
+ if (isLast)
+ {
+ g.drawLine(rect.x + rect.width - 1, bottom, right, bottom);
+ }
+ else
+ {
+ g.drawLine(rect.x + rect.width, bottom, right, bottom);
+ }
+ }
+ }
+ }
+
+ /**
+ * Paints the left edge of the content border.
+ *
+ * @param g the graphics to use for painting
+ * @param tabPlacement the tab placement
+ * @param selectedIndex the index of the selected tab
+ * @param x the upper left coordinate of the content area
+ * @param y the upper left coordinate of the content area
+ * @param w the width of the content area
+ * @param h the height of the content area
+ */
+ protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
+ int selectedIndex, int x, int y,
+ int w, int h)
+ {
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+ Rectangle rect = selectedIndex < 0 ? null :
+ getTabBounds(selectedIndex, calcRect);
+
+ if (isOcean)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ else
+ {
+ g.setColor(selectHighlight);
+ }
+
+ // If tabs are not placed on LEFT, or if the selected tab is not in the
+ // run directly left to the content or the selected tab is not visible,
+ // then we draw an unbroken line.
+ if (tabPlacement != LEFT || selectedIndex < 0
+ || rect.x + rect.width + 1 < x || rect.y < y || rect.y > y + h)
+ {
+ g.drawLine(x, y + 1, x, y + h - 2);
+ if (isOcean && tabPlacement == LEFT)
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x, y + 1, x, y + h - 2);
+ }
+ }
+ else
+ {
+ g.drawLine(x, y, x, rect.y + 1);
+ if (rect.y + rect.height < y + h - 2)
+ {
+ g.drawLine(x, rect.y + rect.height + 1, x, y + h + 2);
+ }
+ if (isOcean)
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 1, rect.y + 1);
+ if (rect.y + rect.height < y + h - 2)
+ {
+ g.drawLine(x + y, rect.y + rect.height + 1, x + 1, y + h + 2);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Paints the right edge of the content border.
+ *
+ * @param g the graphics to use for painting
+ * @param tabPlacement the tab placement
+ * @param selectedIndex the index of the selected tab
+ * @param x the upper left coordinate of the content area
+ * @param y the upper left coordinate of the content area
+ * @param w the width of the content area
+ * @param h the height of the content area
+ */
+ protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
+ int selectedIndex, int x, int y,
+ int w, int h)
+ {
+ g.setColor(darkShadow);
+ Rectangle rect = selectedIndex < 0 ? null :
+ getTabBounds(selectedIndex, calcRect);
+ boolean isOcean = MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme;
+ Color oceanSelectedBorder =
+ UIManager.getColor("TabbedPane.borderHightlightColor");
+
+ // If tabs are not placed on RIGHT, or if the selected tab is not in the
+ // run directly right to the content or the selected tab is not visible,
+ // then we draw an unbroken line.
+ if (tabPlacement != RIGHT || selectedIndex < 0 || rect.x - 1 > w
+ || rect.y < y || rect.y > y + h)
+ {
+ if (isOcean && tabPlacement == RIGHT)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+ }
+ else
+ {
+ if (isOcean)
+ {
+ g.setColor(oceanSelectedBorder);
+ }
+ g.drawLine(x + w - 1, y, x + w - 1, rect.y);
+
+ if (rect.y + rect.height < y + h - 2)
+ {
+ g.drawLine(x + w - 1, rect.y + rect.height, x + w - 1, y + h - 2);
+ }
+ }
+ }
+
+ /**
+ * Determines if the specified tab is the last tab in its tab run.
+ *
+ * @param tabIndex the index of the tab
+ *
+ * @return if the specified tab is the last tab in its tab run
+ */
+ private boolean isLastTabInRun(int tabIndex)
+ {
+ int count = tabPane.getTabCount();
+ int run = getRunForTab(count, tabIndex);
+ int lastIndex = lastTabInRun(count, run);
+ return tabIndex == lastIndex;
+ }
+
+ /**
+ * Returns the background for an unselected tab. This first asks the
+ * JTabbedPane for the background at the specified tab index, if this
+ * is an UIResource (that means, it is inherited from the JTabbedPane)
+ * and the TabbedPane.unselectedBackground UI property is not null,
+ * this returns the value of the TabbedPane.unselectedBackground property,
+ * otherwise the value returned by the JTabbedPane.
+ *
+ * @param tabIndex the index of the tab for which we query the background
+ *
+ * @return the background for an unselected tab
+ */
+ private Color getUnselectedBackground(int tabIndex)
+ {
+ Color bg = tabPane.getBackgroundAt(tabIndex);
+ Color unselectedBackground =
+ UIManager.getColor("TabbedPane.unselectedBackground");
+ if (bg instanceof UIResource && unselectedBackground != null)
+ 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;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTextFieldUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTextFieldUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTextFieldUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTextFieldUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* MetalTextFieldUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.beans.PropertyChangeEvent;
+
+import javax.swing.JComponent;
+import javax.swing.JTextField;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicTextFieldUI;
+
+/**
+ * A UI delegate for the {@link JTextField} component.
+ */
+public class MetalTextFieldUI extends BasicTextFieldUI
+{
+ /**
+ * Constructs a new instance of MetalTextFieldUI.
+ */
+ public MetalTextFieldUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalTextFieldUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalTextFieldUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalTextFieldUI();
+ }
+
+ /**
+ * This method gets called when a bound property is changed on the associated
+ * JTextComponent. This is a hook which UI implementations may change to
+ * reflect how the UI displays bound properties of JTextComponent subclasses.
+ */
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ super.propertyChange(evt);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTheme.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTheme.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTheme.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTheme.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,576 @@
+/* MetalTheme.java --
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.FontUIResource;
+
+/**
+ * The base class for themes used by the {@link MetalLookAndFeel}. A default
+ * theme ({@link DefaultMetalTheme}) is provided, or you can create and use
+ * your own.
+ *
+ * @see MetalLookAndFeel#setCurrentTheme(MetalTheme)
+ */
+public abstract class MetalTheme
+{
+ private ColorUIResource BLACK = new ColorUIResource(Color.BLACK);
+ private ColorUIResource WHITE = new ColorUIResource(Color.WHITE);
+
+ /**
+ * Default constructor.
+ */
+ public MetalTheme()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * Returns the name of the theme.
+ *
+ * @return The name of the theme.
+ */
+ public abstract String getName();
+
+ /**
+ * Adds custom entries to the UI defaults table. This method is empty.
+ *
+ * @param table the table.
+ */
+ public void addCustomEntriesToTable(UIDefaults table)
+ {
+ // Do nothing here.
+ // This method needs to be overridden to actually do something.
+ // It is called from MetalLookAndFeel.getDefaults().
+ }
+
+ /**
+ * Returns the accelerator foreground color. The default implementation
+ * returns the color from {@link #getPrimary1()}.
+ *
+ * @return The accelerator foreground color.
+ */
+ public ColorUIResource getAcceleratorForeground()
+ {
+ return getPrimary1();
+ }
+
+ /**
+ * Returns the accelerator selected foreground color. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The accelerator selected foreground color.
+ */
+ public ColorUIResource getAcceleratorSelectedForeground()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the control color. The default implementation returns the color
+ * from {@link #getSecondary3()}.
+ *
+ * @return The control color.
+ */
+ public ColorUIResource getControl()
+ {
+ return getSecondary3();
+ }
+
+ /**
+ * Returns the color used for dark shadows on controls. The default
+ * implementation returns the color from {@link #getSecondary1()}.
+ *
+ * @return The color used for dark shadows on controls.
+ */
+ public ColorUIResource getControlDarkShadow()
+ {
+ return getSecondary1();
+ }
+
+ /**
+ * Returns the color used for disabled controls. The default implementation
+ * returns the color from {@link #getSecondary1()}.
+ *
+ * @return The color used for disabled controls.
+ */
+ public ColorUIResource getControlDisabled()
+ {
+ return getSecondary2();
+ }
+
+ /**
+ * Returns the color used to draw highlights for controls. The default
+ * implementation returns the color from {@link #getWhite()}.
+ *
+ * @return The color used to draw highlights for controls.
+ */
+ public ColorUIResource getControlHighlight()
+ {
+ return getWhite();
+ }
+
+ /**
+ * Returns the color used to display control info. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The color used to display control info.
+ */
+ public ColorUIResource getControlInfo()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the color used to draw shadows for controls. The default
+ * implementation returns the color from {@link #getSecondary2()}.
+ *
+ * @return The color used to draw shadows for controls.
+ */
+ public ColorUIResource getControlShadow()
+ {
+ return getSecondary2();
+ }
+
+ /**
+ * Returns the color used for text on controls. The default implementation
+ * returns the color from {@link #getControlInfo()}.
+ *
+ * @return The color used for text on controls.
+ */
+ public ColorUIResource getControlTextColor()
+ {
+ return getControlInfo();
+ }
+
+ /**
+ * Returns the color used for the desktop background. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The color used for the desktop background.
+ */
+ public ColorUIResource getDesktopColor()
+ {
+ return getPrimary2();
+ }
+
+ /**
+ * Returns the color used to draw focus highlights. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The color used to draw focus highlights.
+ */
+ public ColorUIResource getFocusColor()
+ {
+ return getPrimary2();
+ }
+
+ /**
+ * Returns the color used to draw highlighted text. The default
+ * implementation returns the color from {@link #getHighlightedTextColor()}.
+ *
+ * @return The color used to draw highlighted text.
+ */
+ public ColorUIResource getHighlightedTextColor()
+ {
+ return getControlTextColor();
+ }
+
+ /**
+ * Returns the color used to draw text on inactive controls. The default
+ * implementation returns the color from {@link #getControlDisabled()}.
+ *
+ * @return The color used to draw text on inactive controls.
+ */
+ public ColorUIResource getInactiveControlTextColor()
+ {
+ return getControlDisabled();
+ }
+
+ /**
+ * Returns the color used to draw inactive system text. The default
+ * implementation returns the color from {@link #getSecondary2()}.
+ *
+ * @return The color used to draw inactive system text.
+ */
+ public ColorUIResource getInactiveSystemTextColor()
+ {
+ return getSecondary2();
+ }
+
+ /**
+ * Returns the background color for menu items. The default implementation
+ * returns the color from {@link #getSecondary3()}.
+ *
+ * @return The background color for menu items.
+ *
+ * @see #getMenuSelectedBackground()
+ */
+ public ColorUIResource getMenuBackground()
+ {
+ return getSecondary3();
+ }
+
+ /**
+ * Returns the foreground color for disabled menu items. The default
+ * implementation returns the color from {@link #getSecondary2()}.
+ *
+ * @return The foreground color for disabled menu items.
+ *
+ * @see #getMenuForeground()
+ */
+ public ColorUIResource getMenuDisabledForeground()
+ {
+ return getSecondary2();
+ }
+
+ /**
+ * Returns the foreground color for menu items. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The foreground color for menu items.
+ *
+ * @see #getMenuDisabledForeground()
+ * @see #getMenuSelectedForeground()
+ */
+ public ColorUIResource getMenuForeground()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the background color for selected menu items. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The background color for selected menu items.
+ *
+ * @see #getMenuBackground()
+ */
+ public ColorUIResource getMenuSelectedBackground()
+ {
+ return getPrimary2();
+ }
+
+ /**
+ * Returns the foreground color for selected menu items. The default
+ * implementation returns the value from {@link #getBlack()}.
+ *
+ * @return The foreground color for selected menu items.
+ *
+ * @see #getMenuForeground()
+ */
+ public ColorUIResource getMenuSelectedForeground()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the primary color for controls. The default implementation
+ * returns the color from {@link #getPrimary3()}.
+ *
+ * @return The primary color for controls.
+ */
+ public ColorUIResource getPrimaryControl()
+ {
+ return getPrimary3();
+ }
+
+ /**
+ * Returns the primary color for the dark shadow on controls. The default
+ * implementation returns the color from {@link #getPrimary1()}.
+ *
+ * @return The primary color for the dark shadow on controls.
+ */
+ public ColorUIResource getPrimaryControlDarkShadow()
+ {
+ return getPrimary1();
+ }
+
+ /**
+ * Returns the primary color for the highlight on controls. The default
+ * implementation returns the color from {@link #getWhite()}.
+ *
+ * @return The primary color for the highlight on controls.
+ */
+ public ColorUIResource getPrimaryControlHighlight()
+ {
+ return getWhite();
+ }
+
+ /**
+ * Returns the primary color for the information on controls. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The primary color for the information on controls.
+ */
+ public ColorUIResource getPrimaryControlInfo()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the primary color for the shadow on controls. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The primary color for the shadow on controls.
+ */
+ public ColorUIResource getPrimaryControlShadow()
+ {
+ return getPrimary2();
+ }
+
+ /**
+ * Returns the background color for separators. The default implementation
+ * returns the color from {@link #getWhite()}.
+ *
+ * @return The background color for separators.
+ */
+ public ColorUIResource getSeparatorBackground()
+ {
+ return getWhite();
+ }
+
+ /**
+ * Returns the foreground color for separators. The default implementation
+ * returns the value from {@link #getPrimary1()}.
+ *
+ * @return The foreground color for separators.
+ */
+ public ColorUIResource getSeparatorForeground()
+ {
+ return getPrimary1();
+ }
+
+ /**
+ * Returns the color used for system text. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The color used for system text.
+ */
+ public ColorUIResource getSystemTextColor()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the color used to highlight text. The default implementation
+ * returns the color from {@link #getPrimary3()}.
+ *
+ * @return The color used to highlight text.
+ */
+ public ColorUIResource getTextHighlightColor()
+ {
+ return getPrimary3();
+ }
+
+ /**
+ * Returns the color used to display user text. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The color used to display user text.
+ */
+ public ColorUIResource getUserTextColor()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the window background color. The default implementation returns
+ * the color from {@link #getWhite()}.
+ *
+ * @return The window background color.
+ */
+ public ColorUIResource getWindowBackground()
+ {
+ return getWhite();
+ }
+
+ /**
+ * Returns the window title background color. The default implementation
+ * returns the color from {@link #getPrimary3()}.
+ *
+ * @return The window title background color.
+ */
+ public ColorUIResource getWindowTitleBackground()
+ {
+ return getPrimary3();
+ }
+
+ /**
+ * Returns the window title foreground color. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The window title foreground color.
+ */
+ public ColorUIResource getWindowTitleForeground()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the background color for an inactive window title. The default
+ * implementation returns the color from {@link #getSecondary3()}.
+ *
+ * @return The background color for an inactive window title.
+ */
+ public ColorUIResource getWindowTitleInactiveBackground()
+ {
+ return getSecondary3();
+ }
+
+ /**
+ * Returns the foreground color for an inactive window title. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The foreground color for an inactive window title.
+ */
+ public ColorUIResource getWindowTitleInactiveForeground()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the color used for black.
+ *
+ * @return The color used for black.
+ */
+ protected ColorUIResource getBlack()
+ {
+ return BLACK;
+ }
+
+ /**
+ * Returns the color used for white.
+ *
+ * @return The color used for white.
+ */
+ protected ColorUIResource getWhite()
+ {
+ return WHITE;
+ }
+
+ /**
+ * Returns the first primary color for this theme.
+ *
+ * @return The first primary color.
+ */
+ protected abstract ColorUIResource getPrimary1();
+
+ /**
+ * Returns the second primary color for this theme.
+ *
+ * @return The second primary color.
+ */
+ protected abstract ColorUIResource getPrimary2();
+
+ /**
+ * Returns the third primary color for this theme.
+ *
+ * @return The third primary color.
+ */
+ protected abstract ColorUIResource getPrimary3();
+
+ /**
+ * Returns the first secondary color for this theme.
+ *
+ * @return The first secondary color.
+ */
+ protected abstract ColorUIResource getSecondary1();
+
+ /**
+ * Returns the second secondary color for this theme.
+ *
+ * @return The second secondary color.
+ */
+ protected abstract ColorUIResource getSecondary2();
+
+ /**
+ * Returns the third secondary color for this theme.
+ *
+ * @return The third secondary color.
+ */
+ protected abstract ColorUIResource getSecondary3();
+
+ /**
+ * Returns the font used for text on controls.
+ *
+ * @return The font used for text on controls.
+ */
+ public abstract FontUIResource getControlTextFont();
+
+ /**
+ * Returns the font used for text in menus.
+ *
+ * @return The font used for text in menus.
+ */
+ public abstract FontUIResource getMenuTextFont();
+
+ /**
+ * Returns the font used for sub text.
+ *
+ * @return The font used for sub text.
+ */
+ public abstract FontUIResource getSubTextFont();
+
+ /**
+ * Returns the font used for system text.
+ *
+ * @return The font used for system text.
+ */
+ public abstract FontUIResource getSystemTextFont();
+
+ /**
+ * Returns the font used for user text.
+ *
+ * @return The font used for user text.
+ */
+ public abstract FontUIResource getUserTextFont();
+
+ /**
+ * Returns the font used for window titles.
+ *
+ * @return The font used for window titles.
+ */
+ public abstract FontUIResource getWindowTitleFont();
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,230 @@
+/* MetalToggleButtonUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
+import javax.swing.JComponent;
+import javax.swing.JToggleButton;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicButtonUI;
+import javax.swing.plaf.basic.BasicToggleButtonUI;
+
+/**
+ * A UI delegate for the {@link JToggleButton} component.
+ */
+public class MetalToggleButtonUI
+ extends BasicToggleButtonUI
+{
+
+ /** The color for the focus border. */
+ protected Color focusColor;
+
+ /** The color that indicates a selected button. */
+ protected Color selectColor;
+
+ /** The color for disabled button labels. */
+ protected Color disabledTextColor;
+
+ /**
+ * Returns a new instance of <code>MetalToggleButtonUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalToggleButtonUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalToggleButtonUI();
+ }
+
+ /**
+ * Constructs a new instance of <code>MetalToggleButtonUI</code>.
+ */
+ public MetalToggleButtonUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns the color for the focus border.
+ *
+ * @return the color for the focus border
+ */
+ protected Color getFocusColor()
+ {
+ return focusColor;
+ }
+
+ /**
+ * Returns the color that indicates a selected button.
+ *
+ * @return the color that indicates a selected button
+ */
+ protected Color getSelectColor()
+ {
+ return selectColor;
+ }
+
+ /**
+ * Returns the color for the text label of disabled buttons. The value
+ * is initialised in the {@link #installDefaults(AbstractButton)} method
+ * by reading the <code>ToggleButton.disabledText</code> item from the UI
+ * defaults.
+ *
+ * @return The color for the text label of disabled buttons.
+ */
+ protected Color getDisabledTextColor()
+ {
+ return disabledTextColor;
+ }
+
+ /**
+ * Updates the button with the defaults for this look and feel.
+ *
+ * @param b the button.
+ */
+ public void installDefaults(AbstractButton b)
+ {
+ super.installDefaults(b);
+ focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+ selectColor = UIManager.getColor(getPropertyPrefix() + "select");
+ disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
+ }
+
+ /**
+ * Paints the button background when it is pressed/selected.
+ *
+ * @param g the graphics device.
+ * @param b the button.
+ */
+ protected void paintButtonPressed(Graphics g, AbstractButton b)
+ {
+ if (b.isContentAreaFilled() && b.isOpaque())
+ {
+ Color saved = g.getColor();
+ Rectangle bounds = SwingUtilities.getLocalBounds(b);
+ g.setColor(selectColor);
+ g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ g.setColor(saved);
+ }
+ }
+
+ /**
+ * Paints the text for the button.
+ *
+ * As of JDK 1.4 this method is obsolete.
+ * Use {@link BasicButtonUI#paintText(java.awt.Graphics,
+ * javax.swing.AbstractButton, java.awt.Rectangle, java.lang.String)}.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ * @param textRect the bounds for the text.
+ * @param text the text.
+ *
+ */
+ protected void paintText(Graphics g, JComponent c, Rectangle textRect,
+ String text)
+ {
+ Font savedFont = g.getFont();
+ Color savedColor = g.getColor();
+ g.setFont(c.getFont());
+ if (c.isEnabled())
+ g.setColor(c.getForeground());
+ else
+ g.setColor(disabledTextColor);
+ FontMetrics fm = g.getFontMetrics(c.getFont());
+ int ascent = fm.getAscent();
+ g.drawString(text, textRect.x, textRect.y + ascent);
+ g.setFont(savedFont);
+ g.setColor(savedColor);
+ }
+
+ /**
+ * Draws the focus highlight around the text and icon.
+ *
+ * @param g the graphics device.
+ * @param b the button.
+ */
+ protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
+ Rectangle textRect, Rectangle iconRect)
+ {
+ if (!b.hasFocus())
+ return;
+ Color saved = g.getColor();
+ g.setColor(focusColor);
+ Rectangle fr = iconRect.union(textRect);
+ g.drawRect(fr.x - 1, fr.y - 1, fr.width + 1, fr.height + 1);
+ g.setColor(saved);
+ }
+
+ /**
+ * If the property <code>ToggleButton.gradient</code> is set, then a gradient
+ * is painted as background, otherwise the normal superclass behaviour is
+ * called.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+ ButtonModel m = b.getModel();
+ if (b.getBackground() instanceof UIResource
+ && b.isContentAreaFilled()
+ && b.isEnabled() && ! m.isArmed() && ! m.isPressed()
+ && UIManager.get(getPropertyPrefix() + "gradient") != null)
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL,
+ getPropertyPrefix() + "gradient");
+ paint(g, c);
+ }
+ else
+ super.update(g, c);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,298 @@
+/* MetalToolBarUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.ContainerListener;
+import java.awt.event.MouseEvent;
+
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JComponent;
+import javax.swing.JToolBar;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicToolBarUI;
+
+/**
+ * A UI delegate for the {@link JToolBar} component.
+ */
+public class MetalToolBarUI extends BasicToolBarUI
+{
+
+ /**
+ * A listener (no longer used) that responds when components are added to or
+ * removed from the {@link JToolBar}. The required behaviour is now
+ * handled in the super class.
+ *
+ * @see MetalToolBarUI#createContainerListener()
+ */
+ protected class MetalContainerListener
+ extends BasicToolBarUI.ToolBarContListener
+ {
+ /**
+ * Creates a new instance.
+ */
+ protected MetalContainerListener()
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * A listener (no longer used) that responds to property change events in a
+ * {@link JToolBar} component. The required behaviour is now handled in the
+ * super class.
+ *
+ * @see MetalToolBarUI#createRolloverListener()
+ */
+ protected class MetalRolloverListener
+ extends BasicToolBarUI.PropertyListener
+ {
+ /**
+ * Creates a new instance.
+ */
+ protected MetalRolloverListener()
+ {
+ // Nothing to do here.
+ }
+ }
+
+ /**
+ * The container listener (an implementation specific field, according to the
+ * spec, and not used in GNU Classpath).
+ */
+ protected ContainerListener contListener;
+
+ /**
+ * The rollover listener (an implementation specific field, according to the
+ * spec, and not used in GNU Classpath).
+ */
+ protected PropertyChangeListener rolloverListener;
+
+ /**
+ * Creates a new instance of this UI delegate.
+ */
+ public MetalToolBarUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalToolBarUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalToolBarUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalToolBarUI();
+ }
+
+ /**
+ * Returns <code>null</code> as permitted by recent versions of the API
+ * specification. Originally it seems this method returned a new instance of
+ * {@link MetalRolloverListener}, but this is now redundant.
+ *
+ * @return <code>null</code>.
+ */
+ protected PropertyChangeListener createRolloverListener()
+ {
+ return null;
+ }
+
+ /**
+ * Returns <code>null</code> as permitted by recent versions of the API
+ * specification. Originally it seems this method returned a new instance of
+ * {@link MetalContainerListener}, but this is now redundant.
+ *
+ * @return <code>null</code>.
+ */
+ protected ContainerListener createContainerListener()
+ {
+ return null;
+ }
+
+ /**
+ * Returns a border with no rollover effect for buttons in the tool bar.
+ *
+ * @return A border.
+ *
+ * @see MetalBorders#getToolbarButtonBorder()
+ */
+ protected Border createNonRolloverBorder()
+ {
+ return MetalBorders.getToolbarButtonBorder();
+ }
+
+ /**
+ * Sets the offset for the window used for dragging the toolbar.
+ * It is set as long as the window is not null (it has been installed).
+ */
+ protected void setDragOffset(Point p)
+ {
+ if (dragWindow != null)
+ dragWindow.setOffset(p);
+ }
+
+ /**
+ * Creates and returns an instance of MetalDockingListener.
+ *
+ * @return an instance of MetalDockingListener.
+ */
+ protected MouseInputListener createDockingListener()
+ {
+ return new MetalDockingListener(toolBar);
+ }
+
+ /**
+ * This is the MouseHandler class that allows the user to drag the JToolBar
+ * in and out of the parent and dock it if it can.
+ */
+ protected class MetalDockingListener extends BasicToolBarUI.DockingListener
+ {
+ /**
+ * Creates a new DockingListener object.
+ *
+ * @param t The JToolBar this DockingListener is being used for.
+ */
+ public MetalDockingListener(JToolBar t)
+ {
+ super(t);
+ }
+
+ /**
+ * This method is called when the mouse is pressed in the JToolBar. If the
+ * press doesn't occur in a place where it causes the JToolBar to be
+ * dragged, it returns. Otherwise, it starts a drag session.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ super.mousePressed(e);
+ setDragOffset(new Point(e.getX(), e.getY()));
+ }
+
+ /**
+ * This method is called when the mouse is dragged. It delegates the drag
+ * painting to the dragTo method.
+ *
+ * @param e The MouseEvent.
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ // Does not do anything differently than dragging
+ // BasicToolBarUI.DockingListener
+ super.mouseDragged(e);
+ }
+ }
+
+ /**
+ * Installs the UI on the toolbar. This calls super and sets the rollover
+ * property according to the <code>UIManager</code> property
+ * "ToolBar.isRollover".
+ *
+ * @param c the component to install the UI on
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ if (c instanceof JToolBar)
+ {
+ JToolBar tb = (JToolBar) c;
+ tb.setRollover(UIManager.getBoolean("ToolBar.isRollover"));
+ }
+ }
+
+ /**
+ * Uninstalls the UI from the toolbar. This calls super and resets the
+ * rollover property.
+ *
+ * @param c the component to uninstall the UI from
+ */
+ public void uninstallUI(JComponent c)
+ {
+ if (c instanceof JToolBar)
+ {
+ JToolBar tb = (JToolBar) c;
+ tb.setRollover(false);
+ }
+ super.uninstallUI(c);
+ }
+
+ /**
+ * Paints the background of the component if necessary and then calls
+ * <code>paint(g, c)</code>.
+ *
+ * This is overridden to implement the OceanTheme gradient when an OceanTheme
+ * is installed.
+ *
+ * @param g the graphics to use
+ * @param c the component to paint.
+ *
+ * @since 1.5
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ // TODO: Sun's implementation uses the MenuBar.gradient here.
+ // I would consider this a bug, but implement it like this
+ // for compatibility.
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
+ && UIManager.get("MenuBar.gradient") != null)
+ {
+ if (c.isOpaque())
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL,
+ "MenuBar.gradient");
+ }
+ paint(g, c);
+ }
+ else
+ {
+ super.update(g, c);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,330 @@
+/* MetalToolTipUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.JToolTip;
+import javax.swing.KeyStroke;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicToolTipUI;
+
+/**
+ * A UI delegate for the {@link JToolTip} component.
+ */
+public class MetalToolTipUI
+ extends BasicToolTipUI
+{
+ /**
+ * The amount of space between the tool tip text and the accelerator
+ * description (if visible).
+ */
+ public static final int padSpaceBetweenStrings = 12;
+
+ /** The shared UI instance. */
+ private static MetalToolTipUI instance;
+
+ /** A flag controlling the visibility of the accelerator (if there is one). */
+ private boolean isAcceleratorHidden;
+
+ /** A string representing the accelerator key for the component. */
+ private String acceleratorString;
+
+ /**
+ * The delimiter for the accelerator string.
+ */
+ private String acceleratorDelimiter;
+
+ /** The font for the accelerator string. */
+ private Font acceleratorFont;
+
+ /** The color for the accelerator string. */
+ private Color acceleratorForeground;
+
+ /** The active border. */
+ private Border activeBorder;
+
+ /** The inactive border. */
+ private Border inactiveBorder;
+
+ /**
+ * Constructs a new instance of <code>MetalToolTipUI</code>.
+ */
+ public MetalToolTipUI()
+ {
+ super();
+ activeBorder = UIManager.getBorder("ToolTip.border");
+ inactiveBorder = UIManager.getBorder("ToolTip.borderInactive");
+ isAcceleratorHidden = UIManager.getBoolean("ToolTip.hideAccelerator");
+ acceleratorFont = UIManager.getFont("MenuItem.acceleratorFont");
+ acceleratorForeground = UIManager.getColor("MenuItem.acceleratorForeground");
+ acceleratorDelimiter = UIManager.getString("MenuItem.acceleratorDelimiter");
+ }
+
+ /**
+ * Returns a shared instance of the <code>MetalToolTipUI</code> class.
+ * Although this UI delegate does maintain state information, there is never
+ * more than one tool tip visible, so it is OK to use a shared instance.
+ *
+ * @param component the component (a {@link JToolTip}).
+ *
+ * @return A shared instance of the <code>MetalToolTipUI</code> class.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ if (instance == null)
+ instance = new MetalToolTipUI();
+ return instance;
+ }
+
+ /**
+ * Returns a string representing the accelerator key (if there is one) for
+ * the component that the tool tip belongs to.
+ *
+ * @return A string representing the accelerator key.
+ */
+ public String getAcceleratorString()
+ {
+ return acceleratorString;
+ }
+
+ /**
+ * Installs the UI for the specified component (a {@link JToolTip}).
+ *
+ * @param c the {@link JToolTip} component.
+ */
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ Border existingBorder = c.getBorder();
+ if (existingBorder == null || existingBorder instanceof UIResource)
+ {
+ if (c.isEnabled())
+ c.setBorder(activeBorder);
+ else
+ c.setBorder(inactiveBorder);
+ }
+ }
+
+ /**
+ * Clears the defaults set in {@link #installUI(JComponent)}.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ super.uninstallUI(c);
+ if (c.getBorder() instanceof UIResource)
+ c.setBorder(null);
+ }
+
+ /**
+ * Returns <code>true</code> if the accelerator string is hidden, and
+ * <code>false</code> otherwise. This setting is controlled by the
+ * <code>ToolTip.hideAccelerator</code> entry in the UI defaults table.
+ *
+ * @return A boolean.
+ */
+ protected boolean isAcceleratorHidden()
+ {
+ return isAcceleratorHidden;
+ }
+
+ /**
+ * Returns the preferred size for the {@link JToolTip} component.
+ *
+ * @param c the component (a {@link JToolTip}).
+ *
+ * @return The preferred size.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ if (isAcceleratorHidden())
+ return super.getPreferredSize(c);
+ else
+ {
+ Insets insets = c.getInsets();
+ JToolTip tt = (JToolTip) c;
+ String tipText = tt.getTipText();
+ if (tipText != null)
+ {
+ FontMetrics fm = c.getFontMetrics(c.getFont());
+ int prefH = fm.getHeight() + insets.top + insets.bottom;
+ int prefW = fm.stringWidth(tipText) + insets.left + insets.right;
+
+ // this seems to be the first opportunity we have to get the
+ // accelerator string from the component (if it has one)
+ acceleratorString = fetchAcceleratorString(c);
+ if (acceleratorString != null)
+ {
+ prefW += padSpaceBetweenStrings;
+ fm = c.getFontMetrics(acceleratorFont);
+ prefW += fm.stringWidth(acceleratorString);
+ }
+ return new Dimension(prefW, prefH);
+ }
+ else return new Dimension(0, 0);
+ }
+ }
+
+ /**
+ * Paints the tool tip.
+ *
+ * @param g the graphics context.
+ * @param c the {@link JToolTip} component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ JToolTip tip = (JToolTip) c;
+
+ String text = tip.getTipText();
+ Toolkit t = tip.getToolkit();
+ if (text == null)
+ return;
+
+ Rectangle vr = new Rectangle();
+ vr = SwingUtilities.calculateInnerArea(tip, vr);
+ Rectangle ir = new Rectangle();
+ Rectangle tr = new Rectangle();
+ FontMetrics fm = t.getFontMetrics(tip.getFont());
+ int ascent = fm.getAscent();
+ SwingUtilities.layoutCompoundLabel(tip, fm, text, null,
+ SwingConstants.CENTER, SwingConstants.LEFT,
+ SwingConstants.CENTER, SwingConstants.CENTER, vr, ir, tr, 0);
+ Color saved = g.getColor();
+ g.setColor(Color.BLACK);
+
+ g.drawString(text, vr.x, vr.y + ascent);
+
+ // paint accelerator
+ if (acceleratorString != null)
+ {
+ g.setFont(acceleratorFont);
+ g.setColor(acceleratorForeground);
+ fm = t.getFontMetrics(acceleratorFont);
+ int width = fm.stringWidth(acceleratorString);
+ g.drawString(acceleratorString, vr.x + vr.width - width
+ - padSpaceBetweenStrings / 2, vr.y + vr.height - fm.getDescent());
+ }
+
+ g.setColor(saved);
+ }
+
+ /**
+ * Returns a string representing the accelerator for the component, or
+ * <code>null</code> if the component has no accelerator.
+ *
+ * @param c the component.
+ *
+ * @return A string representing the accelerator (possibly
+ * <code>null</code>).
+ */
+ private String fetchAcceleratorString(JComponent c)
+ {
+ String result = null;
+ if (c instanceof JToolTip)
+ {
+ JToolTip toolTip = (JToolTip) c;
+ JComponent component = toolTip.getComponent();
+ KeyStroke ks = null;
+ int mne = 0;
+ if (component instanceof JMenuItem)
+ {
+ JMenuItem item = (JMenuItem) component;
+ ks = item.getAccelerator();
+ if (ks == null)
+ mne = item.getMnemonic();
+ }
+ else if (component instanceof AbstractButton)
+ {
+ AbstractButton button = (AbstractButton) component;
+ mne = button.getMnemonic();
+ }
+ if (mne > 0)
+ ks = KeyStroke.getKeyStroke(Character.toUpperCase((char) mne),
+ InputEvent.ALT_MASK, false);
+ if (ks != null)
+ result = acceleratorToString(ks);
+ }
+ return result;
+ }
+
+ /**
+ * Returns a string representing an accelerator.
+ *
+ * @param accelerator the accelerator (<code>null</code> not permitted).
+ *
+ * @return A string representing an accelerator.
+ */
+ private String acceleratorToString(KeyStroke accelerator)
+ {
+ // convert keystroke into string format
+ String modifiersText = "";
+ int modifiers = accelerator.getModifiers();
+ char keyChar = accelerator.getKeyChar();
+ int keyCode = accelerator.getKeyCode();
+
+ if (modifiers != 0)
+ modifiersText = KeyEvent.getKeyModifiersText(modifiers)
+ + acceleratorDelimiter;
+
+ if (keyCode == KeyEvent.VK_UNDEFINED)
+ return modifiersText + keyChar;
+ else
+ return modifiersText + KeyEvent.getKeyText(keyCode);
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,217 @@
+/* MetalTreeUI.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Rectangle;
+
+import javax.swing.JComponent;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicTreeUI;
+
+/**
+ * A UI delegate for the {@link JTree} component.
+ */
+public class MetalTreeUI extends BasicTreeUI
+{
+ /**
+ * Constructs a new instance of <code>MetalTreeUI</code>.
+ */
+ public MetalTreeUI()
+ {
+ super();
+ }
+
+ /**
+ * Returns a new instance of <code>MetalTreeUI</code>.
+ *
+ * @param component the component for which we return an UI instance
+ *
+ * @return A new instance of <code>MetalTreeUI</code>.
+ */
+ public static ComponentUI createUI(JComponent component)
+ {
+ return new MetalTreeUI();
+ }
+
+ /**
+ * The horizontal element of legs between nodes starts at the right of the
+ * left-hand side of the child node by default. This method makes the
+ * leg end before that.
+ */
+ protected int getHorizontalLegBuffer()
+ {
+ return super.getHorizontalLegBuffer();
+ }
+
+ /**
+ * Configures the specified component appropriate for the look and feel.
+ * This method is invoked when the ComponentUI instance is being installed
+ * as the UI delegate on the specified component. This method should completely
+ * configure the component for the look and feel, including the following:
+ * 1. Install any default property values for color, fonts, borders, icons,
+ * opacity, etc. on the component. Whenever possible, property values
+ * initialized by the client program should not be overridden.
+ * 2. Install a LayoutManager on the component if necessary.
+ * 3. Create/add any required sub-components to the component.
+ * 4. Create/install event listeners on the component.
+ * 5. Create/install a PropertyChangeListener on the component in order
+ * to detect and respond to component property changes appropriately.
+ * 6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
+ * 7. Initialize any appropriate instance data.
+ */
+ public void installUI(JComponent c)
+ {
+ // TODO: What to do here, if anything?
+ super.installUI(c);
+ }
+
+ /**
+ * Reverses configuration which was done on the specified component during
+ * installUI. This method is invoked when this UIComponent instance is being
+ * removed as the UI delegate for the specified component. This method should
+ * undo the configuration performed in installUI, being careful to leave the
+ * JComponent instance in a clean state (no extraneous listeners,
+ * look-and-feel-specific property objects, etc.). This should include
+ * the following:
+ * 1. Remove any UI-set borders from the component.
+ * 2. Remove any UI-set layout managers on the component.
+ * 3. Remove any UI-added sub-components from the component.
+ * 4. Remove any UI-added event/property listeners from the component.
+ * 5. Remove any UI-installed keyboard UI from the component.
+ * 6. Nullify any allocated instance data objects to allow for GC.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ // TODO: What to do here?
+ super.uninstallUI(c);
+ }
+
+ /**
+ * This function converts between the string passed into the client
+ * property and the internal representation (currently an int).
+ *
+ * @param lineStyleFlag - String representation
+ */
+ protected void decodeLineStyle(Object lineStyleFlag)
+ throws NotImplementedException
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Checks if the location is in expand control.
+ *
+ * @param row - current row
+ * @param rowLevel - current level
+ * @param mouseX - current x location of the mouse click
+ * @param mouseY - current y location of the mouse click
+ */
+ protected boolean isLocationInExpandControl(int row, int rowLevel,
+ int mouseX, int mouseY)
+ {
+ return super.isLocationInExpandControl(tree.getPathForRow(row),
+ mouseX, mouseY);
+ }
+
+ /**
+ * Paints the specified component appropriate for the look and feel.
+ * This method is invoked from the ComponentUI.update method when the
+ * specified component is being painted. Subclasses should override this
+ * method and use the specified Graphics object to render the content of
+ * the component.
+ *
+ * @param g - the current graphics configuration.
+ * @param c - the current component to draw
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ // Calls BasicTreeUI's paint since it takes care of painting all
+ // types of icons.
+ super.paint(g, c);
+ }
+
+ /**
+ * Paints the horizontal separators.
+ *
+ * @param g - the current graphics configuration.
+ * @param c - the current component to draw
+ */
+ protected void paintHorizontalSeparators(Graphics g, JComponent c)
+ throws NotImplementedException
+ {
+ // FIXME: not implemented
+ }
+
+
+ /**
+ * Paints the vertical part of the leg. The receiver should NOT modify
+ * clipBounds, insets.
+ *
+ * @param g - the current graphics configuration.
+ * @param clipBounds -
+ * @param insets -
+ * @param path - the current path
+ */
+ protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds,
+ Insets insets, TreePath path)
+ {
+ super.paintVerticalPartOfLeg(g, clipBounds, insets, path);
+ }
+
+ /**
+ * Paints the horizontal part of the leg. The receiver should NOT \
+ * modify clipBounds, or insets.
+ * NOTE: parentRow can be -1 if the root is not visible.
+ */
+ protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds,
+ Insets insets, Rectangle bounds,
+ TreePath path, int row,
+ boolean isExpanded, boolean hasBeenExpanded,
+ boolean isLeaf)
+ {
+ super.paintHorizontalPartOfLeg(g, clipBounds, insets, bounds, path, row,
+ isExpanded, hasBeenExpanded, isLeaf);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,597 @@
+/* MetalUtils.java
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.metal;
+
+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;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+
+/**
+ * Some utility and helper methods for the Metal Look & Feel.
+ *
+ * @author Roman Kennke (roman at kennke.org)
+ */
+class MetalUtils
+{
+
+ /**
+ * The typical metal pattern for use with Graphics2D.
+ */
+ static BufferedImage pattern2D;
+
+ /**
+ * The light color to draw the pattern.
+ */
+ static Color lightColor;
+
+ /**
+ * The dark color to draw to draw the pattern.
+ */
+ static Color darkColor;
+
+ /**
+ * Fills a rectangle with the typical Metal pattern.
+ *
+ * @param g the <code>Graphics</code> context to use
+ * @param x the X coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param y the Y coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param w the width of the rectangle to fill
+ * @param h the height of the rectangle to fill
+ * @param light the light color to use
+ * @param dark the dark color to use
+ */
+ static void fillMetalPattern(Component c, Graphics g, int x, int y, int w, int h,
+ Color light, Color dark)
+ {
+ if (g instanceof Graphics2D
+ && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") == null)
+ fillMetalPattern2D((Graphics2D) g, x, y, w, h, light, dark);
+ else
+ {
+ int xOff = 0;
+ for (int mY = y; mY < (y + h); mY++)
+ {
+ // set color alternating with every line
+ if (((mY - y) % 2) == 0)
+ g.setColor(light);
+ else
+ g.setColor(dark);
+
+ for (int mX = x + xOff; mX < (x + w); mX += 4)
+ {
+ g.fillRect(mX, mY, 1, 1);
+ }
+
+ // increase x offset
+ xOff++;
+ if (xOff > 3)
+ xOff = 0;
+ }
+ }
+ }
+
+ /**
+ * Fills a rectangle with the typical Metal pattern using Java2D.
+ *
+ * @param g2d the <code>Graphics2D</code> context to use
+ * @param x the X coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param y the Y coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param w the width of the rectangle to fill
+ * @param h the height of the rectangle to fill
+ */
+ static void fillMetalPattern2D(Graphics2D g2d, int x, int y, int w, int h,
+ Color light, Color dark)
+ {
+ if (pattern2D == null || !darkColor.equals(dark) || !lightColor.equals(light))
+ initializePattern(light, dark);
+
+ // Prepare the texture.
+ TexturePaint texture =
+ new TexturePaint(pattern2D, new Rectangle2D.Double(0., 0., 4., 4.));
+ g2d.setPaint(texture);
+ g2d.fillRect(x, y, w, h);
+ }
+
+ /**
+ * Initializes the pattern image.
+ */
+ static void initializePattern(Color light, Color dark)
+ {
+ pattern2D = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ lightColor = light;
+ darkColor = dark;
+ Graphics g = pattern2D.getGraphics();
+ g.setColor(light);
+ g.fillRect(0, 0, 1, 1);
+ g.fillRect(2, 2, 1, 1);
+ g.setColor(dark);
+ g.fillRect(1, 1, 1, 1);
+ g.fillRect(3, 3, 1, 1);
+ g.dispose();
+ }
+
+ /**
+ * Paints the typical Metal gradient. See {@link #paintGradient(Graphics,
+ * int, int, int, int, float, float, Color, Color, Color, int, int[][])}
+ * for more details.
+ *
+ * This variant paints a gradient without a mask.
+ *
+ * @param g the graphics context to use
+ * @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 dir the direction of the gradient, either
+ * @param uiProp the key of the UIManager property that has the parameters
+ */
+ static void paintGradient(Graphics g, int x, int y, int w, int h,
+ int dir, String uiProp)
+ {
+ paintGradient(g, x, y, w, h, dir, uiProp, null);
+ }
+
+ /**
+ * Paints the typical Metal gradient. See {@link #paintGradient(Graphics,
+ * int, int, int, int, float, float, Color, Color, Color, int, int[][])}
+ * for more details.
+ *
+ * The parameters are fetched from the UIManager using the key
+ * <code>uiProp</code>. The value is expected to be a {@link List} that
+ * contains 4 values: two {@link Double}s and 3 {@link Color} object that
+ * together make up the parameters passed to the painting method.
+ *
+ * @param g the graphics context to use
+ * @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 dir the direction of the gradient, either
+ * @param uiProp the key of the UIManager property that has the parameters
+ * @param mask the mask that should be used when painting the gradient as
+ * described above
+ */
+ static void paintGradient(Graphics g, int x, int y, int w, int h,
+ int dir, String uiProp, int[][] mask)
+ {
+ List params = (List) UIManager.get(uiProp);
+ float g1 = ((Float) params.get(0)).floatValue();
+ float g2 = ((Float) params.get(1)).floatValue();
+ Color c1 = (Color) params.get(2);
+ Color c2 = (Color) params.get(3);
+ Color c3 = (Color) params.get(4);
+ paintGradient(g, x, y, w, h, g1, g2, c1, c2, c3, dir, mask);
+ }
+
+ /**
+ * Paints the typical Metal gradient. The gradient is painted as follows:
+ * <pre>
+ *
+ * +-------+--------+--------+-----------------------------+
+ * | | | | |
+ * +-------+--------+--------+-----------------------------+
+ * c1 -> c2 -- c2 -> c1 --------> c3
+ * < -g1- > < -g2- > < -g1- >
+ * </pre>
+ *
+ * There are 4 distinct areas in this gradient:
+ * <ol>
+ * <li>A gradient from color 1 to color 2 with the relative width specified
+ * by <code>g1</code></li>
+ * <li>A solid area with the color 2 and the relative width specified by
+ * <code>g2</code></li>
+ * <li>A gradient from color 2 to color 1 with the relative width specified
+ * by <code>g1</code></li>
+ *
+ * The <code>mask</code> parameter is an array if int arrays, where the first
+ * index specifies the row (in the gradient direction), and the second index
+ * is the starting and end offset of that line. This way you can specify a
+ * mask that should be laid over the gradient for paintint non-rectangular
+ * gradients. The following example should demonstrate this for painting
+ * a circular shaped gradient (note that the first and last line should not
+ * be drawn at all, they are only here to show the circular shape more
+ * clearly). Everything <em>inside</code> the surrounded area is filled by
+ * the gradient:
+ *
+ * <pre>
+ * 012345678
+ * xxx
+ * 0 x x { {4, 7},
+ * 1 x x {3, 8},
+ * 2 x x {3, 8},
+ * 3 x x {3, 8},
+ * 4 x x {4, 7} }
+ * xxx
+ * </pre>
+ *
+ * The <code>mask</code> array is expected to have <code>w</code> or
+ * <code>h</code> array elements, depending on the direction.
+ *
+ * If the <code>mask</code> parameter is null, then the gradient is painted
+ * without a mask.
+ *
+ * @param g the graphics context to use
+ * @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 dir the direction of the gradient, either
+ * {@link SwingConstants#HORIZONTAL} or {@link SwingConstants#VERTICAL}
+ * @param mask the mask that should be used when painting the gradient as
+ * described above
+ */
+ static void paintGradient(Graphics g, int x, int y, int w, int h, float g1,
+ float g2, Color c1, Color c2, Color c3, int dir,
+ int[][] mask)
+ {
+ if (dir == SwingConstants.HORIZONTAL)
+ paintHorizontalGradient(g, x, y, w, h, g1, g2, c1, c2, c3, mask);
+ else
+ paintVerticalGradient(g, x, y, w, h, g1, g2, c1, c2, c3, mask);
+ }
+
+ /**
+ * Paints a horizontal gradient. See {@link #paintGradient(Graphics, int,
+ * int, int, int, float, float, Color, Color, Color, int, int[][])}
+ * for details.
+ *
+ * @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
+ */
+ static void paintHorizontalGradient(Graphics g, int x, int y, int w, int h,
+ 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;
+ // The size of the first gradient area (c1->2).
+ int w1 = (int) (w * g1);
+ // The size of the solid c2 area.
+ int w2 = (int) (w * g2);
+ int x0 = x;
+ int x1 = x0 + w1;
+ int x2 = x1 + w2;
+ int x3 = x2 + w1;
+ int x4 = x + w;
+
+ // Paint first gradient area (c1->c2).
+ int xc; // The current y coordinate.
+ for (xc = x0; xc < x1; xc++)
+ {
+ if (xc > x + w)
+ break;
+
+ // Perform color interpolation;
+ double factor = (xc - x0) / (double) w1;
+ int rInt = (int) ((c2.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c2.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c2.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ if (mask != null)
+ {
+ y0 = mask[xc - x0][0] + y;
+ y1 = mask[xc - x0][1] + y;
+ }
+ g.fillRect(xc, y0, 1, y1 - y0);
+ }
+ // Paint solid c2 area.
+ g.setColor(c2);
+ if (mask == null)
+ {
+ g.fillRect(x1, y, x2 - x1, h);
+ }
+ else
+ {
+ for (xc = x1; xc < x2; xc++)
+ {
+ y0 = mask[xc - x0][0] + y;
+ y1 = mask[xc - x0][1] + y;
+ g.fillRect(xc, y0, 1, y1 - y0);
+ }
+ }
+
+ // Paint second gradient area (c2->c1).
+ for (xc = x2; xc < x3; xc++)
+ {
+ if (xc > x + w)
+ break;
+
+ // Perform color interpolation;
+ double factor = (xc - x2) / (double) w1;
+ int rInt = (int) ((c1.getRed() - c2.getRed()) * factor + c2.getRed());
+ int gInt = (int) ((c1.getGreen() - c2.getGreen()) * factor
+ + c2.getGreen());
+ int bInt = (int) ((c1.getBlue() - c2.getBlue()) * factor
+ + c2.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ if (mask != null)
+ {
+ y0 = mask[xc - x0][0] + y;
+ y1 = mask[xc - x0][1] + y;
+ }
+ g.fillRect(xc, y0, 1, y1 - y0);
+ }
+
+ // Paint third gradient area (c1->c3).
+ for (xc = x3; xc < x4; xc++)
+ {
+ if (xc > x + w)
+ break;
+
+ // Perform color interpolation;
+ double factor = (xc - x3) / (double) (x4 - x3);
+ int rInt = (int) ((c3.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c3.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c3.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ if (mask != null)
+ {
+ y0 = mask[xc - x0][0] + y;
+ y1 = mask[xc - x0][1] + y;
+ }
+ g.drawLine(xc, y0, xc, y1);
+ }
+ }
+
+ /**
+ * Paints a vertical gradient. See {@link #paintGradient(Graphics, int, int,
+ * int, int, float, float, Color, Color, Color, int, int[][])} for details.
+ *
+ * @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
+ */
+ static void paintVerticalGradient(Graphics g, int x, int y, int w, int h,
+ 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;
+ // The size of the first gradient area (c1->2).
+ int w1 = (int) (h * g1);
+ // The size of the solid c2 area.
+ int w2 = (int) (h * g2);
+ int y0 = y;
+ int y1 = y0 + w1;
+ int y2 = y1 + w2;
+ int y3 = y2 + w1;
+ int y4 = y + h;
+
+ // Paint first gradient area (c1->c2).
+ int yc; // The current y coordinate.
+ for (yc = y0; yc < y1; yc++)
+ {
+ if (yc > y + h)
+ break;
+
+ // Perform color interpolation;
+ double factor = (yc - y0) / (double) w1;
+ int rInt = (int) ((c2.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c2.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c2.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ if (mask != null)
+ {
+ x0 = mask[yc - y0][0] + x;
+ x1 = mask[yc - y0][1] + x;
+ }
+ g.fillRect(x0, yc, x1 - x0, 1);
+ }
+ // Paint solid c2 area.
+ g.setColor(c2);
+ if (mask == null)
+ {
+ g.fillRect(x, y1, w, y2 - y1);
+ }
+ else
+ {
+ for (yc = y1; yc < y2; yc++)
+ {
+ x0 = mask[yc - y0][0] + x;
+ x1 = mask[yc - y0][1] + x;
+ g.fillRect(x0, yc, x1 - x0, 1);
+ }
+ }
+
+ // Paint second gradient area (c2->c1).
+ for (yc = y2; yc < y3; yc++)
+ {
+ if (yc > y + h)
+ break;
+
+ // Perform color interpolation;
+ double factor = (yc - y2) / (double) w1;
+ int rInt = (int) ((c1.getRed() - c2.getRed()) * factor + c2.getRed());
+ int gInt = (int) ((c1.getGreen() - c2.getGreen()) * factor
+ + c2.getGreen());
+ int bInt = (int) ((c1.getBlue() - c2.getBlue()) * factor
+ + c2.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ if (mask != null)
+ {
+ x0 = mask[yc - y0][0] + x;
+ x1 = mask[yc - y0][1] + x;
+ }
+ g.fillRect(x0, yc, x1 - x0, 1);
+ }
+
+ // Paint third gradient area (c1->c3).
+ for (yc = y3; yc < y4; yc++)
+ {
+ if (yc > y + h)
+ break;
+
+ // Perform color interpolation;
+ double factor = (yc - y3) / (double) (y4 - y3);
+ int rInt = (int) ((c3.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c3.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c3.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ if (mask != null)
+ {
+ x0 = mask[yc - y0][0] + x;
+ x1 = mask[yc - y0][1] + x;
+ }
+ 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))));
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,316 @@
+/* DefaultMetalTheme.java -- A modern theme for the Metal L&F
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Insets;
+import java.util.Arrays;
+
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
+
+/**
+ * A modern theme for the Metal Look & Feel.
+ * @since 1.5
+ *
+ * @author Roman Kennke (roman at kennke.org)
+ */
+public class OceanTheme extends DefaultMetalTheme
+{
+ /**
+ * The OceanTheme value for black.
+ */
+ static final ColorUIResource BLACK = new ColorUIResource(51, 51, 51);
+
+ /**
+ * The OceanTheme value for primary1.
+ */
+ static final ColorUIResource PRIMARY1 = new ColorUIResource(99, 130, 191);
+
+ /**
+ * The OceanTheme value for primary1.
+ */
+ static final ColorUIResource PRIMARY2 = new ColorUIResource(163, 184, 204);
+
+ /**
+ * The OceanTheme value for primary1.
+ */
+ static final ColorUIResource PRIMARY3 = new ColorUIResource(184, 207, 229);
+
+ /**
+ * The OceanTheme value for secondary1.
+ */
+ static final ColorUIResource SECONDARY1 = new ColorUIResource(122, 138, 153);
+
+ /**
+ * The OceanTheme value for secondary2.
+ */
+ static final ColorUIResource SECONDARY2 = new ColorUIResource(184, 207, 229);
+
+ /**
+ * The OceanTheme value for secondary3.
+ */
+ static final ColorUIResource SECONDARY3 = new ColorUIResource(238, 238, 238);
+
+ /**
+ * The OceanTheme value for inactive control text.
+ */
+ static final ColorUIResource INACTIVE_CONTROL_TEXT =
+ new ColorUIResource(153, 153, 153);
+
+ /**
+ * Returns the name of this theme, "Ocean"
+ */
+ public String getName()
+ {
+ return "Ocean";
+ }
+
+ /**
+ * Returns the color for control text, which is the
+ * value of the theme's black value.
+ */
+ public ColorUIResource getControlTextColor()
+ {
+ return getBlack();
+ }
+
+ /**
+ * Returns the desktop color, which is the theme's white color.
+ */
+ public ColorUIResource getDesktopColor()
+ {
+ return getWhite();
+ }
+
+ /**
+ * Returns the color for inactive control text, which is the
+ * RGB value (153, 153, 153).
+ */
+ public ColorUIResource getInactiveControlTextColor()
+ {
+ return INACTIVE_CONTROL_TEXT;
+ }
+
+ /**
+ * Returns the OceanTheme's color for disabled menu foreground,
+ *
+ */
+ public ColorUIResource getMenuDisabledForeground()
+ {
+ return INACTIVE_CONTROL_TEXT;
+ }
+
+
+ /**
+ * Returns the OceanTheme's color for black, the RGB value
+ * (51, 51, 51).
+ *
+ * @return Returns the OceanTheme's value for black
+ */
+ protected ColorUIResource getBlack()
+ {
+ return BLACK;
+ }
+
+ /**
+ * Return the OceanTheme's value for primary 1, the RGB value
+ * (99, 130, 191).
+ */
+ protected ColorUIResource getPrimary1()
+ {
+ return PRIMARY1;
+ }
+
+ /**
+ * Return the OceanTheme's value for primary 2, the RGB value
+ * (163, 184, 204).
+ */
+ protected ColorUIResource getPrimary2()
+ {
+ return PRIMARY2;
+ }
+
+ /**
+ * Return the OceanTheme's value for primary 1, the RGB value
+ * (184, 207, 229).
+ */
+ protected ColorUIResource getPrimary3()
+ {
+ return PRIMARY3;
+ }
+
+ /**
+ * Return the OceanTheme's value for secondary 1, the RGB value
+ * (122, 138, 153).
+ */
+ protected ColorUIResource getSecondary1()
+ {
+ return SECONDARY1;
+ }
+
+ /**
+ * Return the OceanTheme's value for secondary 2, the RGB value
+ * (184, 207, 229).
+ */
+ protected ColorUIResource getSecondary2()
+ {
+ return SECONDARY2;
+ }
+ /**
+ * Return the OceanTheme's value for secondary 3, the RGB value
+ * (238, 238, 238).
+ */
+ protected ColorUIResource getSecondary3()
+ {
+ return SECONDARY3;
+ }
+
+ /**
+ * Adds customized entries to the UIDefaults table.
+ *
+ * @param defaults the UI defaults table
+ */
+ public void addCustomEntriesToTable(UIDefaults defaults)
+ {
+ // Gradients.
+ defaults.put("Button.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("CheckBox.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("CheckBoxMenuItem.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("MenuBar.gradient", Arrays.asList(new Object[]
+ {new Float(1.0), new Float(0.0), new ColorUIResource(Color.WHITE),
+ new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
+ defaults.put("RadioButton.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("RadioButtonMenuItem.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("ScrollBar.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("Slider.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.2), new ColorUIResource(200, 221, 242),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("Slider.focusGradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.2), new ColorUIResource(200, 221, 242),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("ToggleButton.gradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("InternalFrame.activeTitleGradient", Arrays.asList(new Object[]
+ {new Float(0.3), new Float(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+
+ // Colors.
+ ColorUIResource c1 = new ColorUIResource(200, 221, 242);
+ ColorUIResource c2 = new ColorUIResource(153, 153, 153);
+ ColorUIResource c3 = new ColorUIResource(204, 204, 204);
+ ColorUIResource c4 = new ColorUIResource(210, 226, 239);
+ ColorUIResource c5 = new ColorUIResource(218, 218, 218);
+ defaults.put("Button.disabledToolBarBorderBackground", c3);
+ defaults.put("Button.toolBarBorderBackground", c2);
+ defaults.put("Label.disabledForeground", c2);
+ defaults.put("MenuBar.borderColor", c3);
+ defaults.put("Slider.altTrackColor", c4);
+ defaults.put("SplitPane.dividerFocusColor", c1);
+ defaults.put("TabbedPane.contentAreaColor", c1);
+ defaults.put("TabbedPane.borderHightlightColor", PRIMARY1);
+ defaults.put("TabbedPane.selected", c1);
+ defaults.put("TabbedPane.tabAreaBackground", c5);
+ defaults.put("TabbedPane.unselectedBackground", SECONDARY3);
+ defaults.put("Table.gridColor", SECONDARY1);
+ defaults.put("ToolBar.borderColor", c3);
+ defaults.put("Tree.selectionBorderColor", PRIMARY1);
+
+ // Borders.
+ defaults.put("Table.focusCellHighlightBorder",
+ new LineBorderUIResource(getPrimary1()));
+
+ // Insets.
+ defaults.put("TabbedPane.contentBorderInsets", new Insets(4, 2, 3, 3));
+ defaults.put("TabbedPane.tabAreaInsets", new Insets(2, 2, 0, 6));
+
+ // Flags.
+ defaults.put("SplitPane.oneTouchButtonsOpaque", Boolean.FALSE);
+ defaults.put("Menu.opaque", Boolean.FALSE);
+ defaults.put("ToolBar.isRollover", Boolean.TRUE);
+ defaults.put("RadioButton.rollover", Boolean.TRUE);
+ defaults.put("CheckBox.rollover", Boolean.TRUE);
+ defaults.put("Button.rollover", Boolean.TRUE);
+
+ // Icons.
+ // FIXME: Add OceanTheme icons.
+// defaults.put("Tree.leafIcon", XXX);
+// defaults.put("Tree.expandedIcon", XXX);
+// defaults.put("Tree.openIcon", XXX);
+// defaults.put("Tree.closedIcon", XXX);
+// defaults.put("Tree.collapsedIcon", XXX);
+// defaults.put("FileChooser.newFolderIcon", XXX);
+// defaults.put("FileChooser.homeFolderIcon", XXX);
+// defaults.put("FileChooser.upFolderIcon", XXX);
+// defaults.put("FileView.hardDriveIcon", XXX);
+// defaults.put("FileView.floppyDriveIcon", XXX);
+// defaults.put("FileView.fileIcon", XXX);
+// defaults.put("FileView.computerIcon", XXX);
+// defaults.put("FileView.directoryIcon", XXX);
+// defaults.put("OptionPane.questionIcon", XXX);
+// defaults.put("OptionPane.errorIcon", XXX);
+// defaults.put("OptionPane.warningIcon", XXX);
+// defaults.put("OptionPane.informationIcon", XXX);
+// defaults.put("InternalFrame.icon", XXX);
+// defaults.put("InternalFrame.closeIcon", XXX);
+// defaults.put("InternalFrame.iconifyIcon", XXX);
+// defaults.put("InternalFrame.minimizeIcon", XXX);
+// defaults.put("InternalFrame.maximizeIcon", XXX);
+// defaults.put("InternalFrame.paletteCloseIcon", XXX);
+
+ // UI classes.
+ defaults.put("MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI");
+
+ // Others.
+ defaults.put("Button.rolloverIconType", "ocean");
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/metal/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.plaf.metal package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.plaf.metal</title></head>
+
+<body>
+<p>Provides a cross-platform look and feel known as "Metal". To install this
+look and feel, add the following code (or something similar)
+near the start of your application:</p>
+<pre>try
+ {
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
+catch (UnsupportedLookAndFeelException e)
+ {
+ e.printStackTrace();
+ }</pre>
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiButtonUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ButtonUI} instances, one
+ * from the primary look and feel, and one or more from the auxiliary look and
+ * feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiButtonUI extends ButtonUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiButtonUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiButtonUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiButtonUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiButtonUI mui = new MultiButtonUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiButtonUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
\ No newline at end of file
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiColorChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ColorChooserUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ColorChooserUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiColorChooserUI extends ColorChooserUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiColorChooserUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiColorChooserUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiColorChooserUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiColorChooserUI mui = new MultiColorChooserUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiColorChooserUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,430 @@
+/* MultiComboBoxUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ComboBoxUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiComboBoxUI extends ComboBoxUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiComboBoxUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiComboBoxUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiComboBoxUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiComboBoxUI mui = new MultiComboBoxUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiComboBoxUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#setPopupVisible(JComboBox, boolean)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ * @param visible the visible state.
+ */
+ public void setPopupVisible(JComboBox c, boolean visible)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ ui.setPopupVisible(c, visible);
+ }
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#isPopupVisible(JComboBox)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The result for the UI delegate from the primary look and feel.
+ */
+ public boolean isPopupVisible(JComboBox c)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ result = ui.isPopupVisible(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ /* boolean ignored = */ ui.isPopupVisible(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#isFocusTraversable(JComboBox)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return <code>true</code> if the combo box is traversable according to the
+ * UI delegate in the primary look and feel, and <code>false</code>
+ * otherwise.
+ */
+ public boolean isFocusTraversable(JComboBox c)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ result = ui.isFocusTraversable(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ /* boolean ignored = */ ui.isFocusTraversable(c);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiDesktopIconUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopIconUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link DesktopIconUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiDesktopIconUI extends DesktopIconUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiDesktopIconUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiDesktopIconUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiDesktopIconUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiDesktopIconUI mui = new MultiDesktopIconUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiDesktopIconUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiDesktopIconUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link DesktopPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiDesktopPaneUI extends DesktopPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiDesktopPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiDesktopPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiDesktopPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiDesktopPaneUI mui = new MultiDesktopPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiDesktopPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,511 @@
+/* MultiFileChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileView;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.FileChooserUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link FileChooserUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiFileChooserUI extends FileChooserUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiFileChooserUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiFileChooserUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiFileChooserUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiFileChooserUI mui = new MultiFileChooserUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getAcceptAllFileFilter(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the filter for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The filter returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public FileFilter getAcceptAllFileFilter(JFileChooser chooser)
+ {
+ FileFilter result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getAcceptAllFileFilter(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* FileFilter ignored = */ ui.getAcceptAllFileFilter(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getFileView(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the view for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The view returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public FileView getFileView(JFileChooser chooser)
+ {
+ FileView result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getFileView(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* FileView ignored = */ ui.getFileView(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getApproveButtonText(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the text for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The text returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public String getApproveButtonText(JFileChooser chooser)
+ {
+ String result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getApproveButtonText(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* String ignored = */ ui.getApproveButtonText(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getDialogTitle(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the title for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The title returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public String getDialogTitle(JFileChooser chooser)
+ {
+ String result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getDialogTitle(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* String ignored = */ ui.getDialogTitle(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#rescanCurrentDirectory(JFileChooser)}
+ * method for all the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>.
+ *
+ * @param chooser the file chooser.
+ */
+ public void rescanCurrentDirectory(JFileChooser chooser)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ ui.rescanCurrentDirectory(chooser);
+ }
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#ensureFileIsVisible(JFileChooser, File)}
+ * method for all the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>.
+ *
+ * @param chooser the file chooser.
+ * @param file the file.
+ */
+ public void ensureFileIsVisible(JFileChooser chooser, File file)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ ui.ensureFileIsVisible(chooser, file);
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,353 @@
+/* MultiInternalFrameUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InternalFrameUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link InternalFrameUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiInternalFrameUI extends InternalFrameUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiInternalFrameUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiInternalFrameUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiInternalFrameUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiInternalFrameUI mui = new MultiInternalFrameUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiInternalFrameUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiLabelUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.LabelUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link LabelUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiLabelUI extends LabelUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiLabelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiLabelUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiLabelUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiLabelUI mui = new MultiLabelUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiLabelUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,449 @@
+/* MultiListUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ListUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ListUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiListUI extends ListUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiListUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiListUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiListUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiListUI mui = new MultiListUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiListUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#locationToIndex(JList, Point)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the index for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param location the location.
+ *
+ * @return The index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int locationToIndex(JList list, Point location)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.locationToIndex(list, location);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* int ignored = */ ui.locationToIndex(list, location);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#indexToLocation(JList, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param index the index.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Point indexToLocation(JList list, int index)
+ {
+ Point result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.indexToLocation(list, index);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* Point ignored = */ ui.indexToLocation(list, index);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#getCellBounds(JList, int, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param index1 the first index.
+ * @param index2 the second index.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getCellBounds(JList list, int index1, int index2)
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.getCellBounds(list, index1, index2);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* Rectangle ignored = */ ui.getCellBounds(list, index1, index2);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,243 @@
+/* MultiLookAndFeel.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.util.Vector;
+
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A look and feel that provides the ability to use auxiliary look and feels
+ * in addition to the primary look and feel.
+ */
+public class MultiLookAndFeel extends LookAndFeel
+{
+
+ /**
+ * Creates a new instance of the look and feel.
+ */
+ public MultiLookAndFeel()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns the name for the look and feel.
+ *
+ * @return "Multiplexing Look and Feel".
+ */
+ public String getName()
+ {
+ return "Multiplexing Look and Feel";
+ }
+
+ /**
+ * Returns an identifier for the look and feel.
+ *
+ * @return "Multiplex".
+ */
+ public String getID()
+ {
+ return "Multiplex";
+ }
+
+ /**
+ * Returns a description of the look and feel.
+ *
+ * @return A description of the look and feel.
+ */
+ public String getDescription()
+ {
+ return "Allows multiple UI instances per component instance";
+ }
+
+ /**
+ * Returns <code>false</code> to indicate that this look and feel is not
+ * native to any platform.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> always, since this look and feel is supported on
+ * all platforms.
+ *
+ * @return <code>true</code>.
+ */
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
+
+ /**
+ * Creates and returns the UI defaults for this look and feel.
+ *
+ * @return The UI defaults.
+ */
+ public UIDefaults getDefaults()
+ {
+ UIDefaults defaults = new UIDefaults();
+ defaults.put("ButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("CheckBoxUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("CheckBoxMenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("ColorChooserUI",
+ "javax.swing.plaf.multi.MultiColorChooserUI");
+ defaults.put("ComboBoxUI", "javax.swing.plaf.multi.MultiComboBoxUI");
+ defaults.put("DesktopPaneUI", "javax.swing.plaf.multi.MultiDesktopPaneUI");
+ defaults.put("DesktopIconUI", "javax.swing.plaf.multi.MultiDesktopIconUI");
+ defaults.put("EditorPaneUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("FileChooserUI", "javax.swing.plaf.multi.MultiFileChooserUI");
+ defaults.put("FormattedTextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("InternalFrameUI",
+ "javax.swing.plaf.multi.MultiInternalFrameUI");
+ defaults.put("LabelUI", "javax.swing.plaf.multi.MultiLabelUI");
+ defaults.put("ListUI", "javax.swing.plaf.multi.MultiListUI");
+ defaults.put("MenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("MenuUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("MenuBarUI", "javax.swing.plaf.multi.MultiMenuBarUI");
+ defaults.put("OptionPaneUI", "javax.swing.plaf.multi.MultiOptionPaneUI");
+ defaults.put("PanelUI", "javax.swing.plaf.multi.MultiPanelUI");
+ defaults.put("PasswordFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("PopupMenuUI", "javax.swing.plaf.multi.MultiPopupMenuUI");
+ defaults.put("PopupMenuSeparatorUI",
+ "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("ProgressBarUI", "javax.swing.plaf.multi.MultiProgressBarUI");
+ defaults.put("RadioButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("RadioButtonMenuItemUI",
+ "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("RootPaneUI", "javax.swing.plaf.multi.MultiRootPaneUI");
+ defaults.put("ScrollBarUI", "javax.swing.plaf.multi.MultiScrollBarUI");
+ defaults.put("ScrollPaneUI", "javax.swing.plaf.multi.MultiScrollPaneUI");
+ defaults.put("SeparatorUI", "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("SliderUI", "javax.swing.plaf.multi.MultiSliderUI");
+ defaults.put("SpinnerUI", "javax.swing.plaf.multi.MultiSpinnerUI");
+ defaults.put("SplitPaneUI", "javax.swing.plaf.multi.MultiSplitPaneUI");
+ defaults.put("TabbedPaneUI", "javax.swing.plaf.multi.MultiTabbedPaneUI");
+ defaults.put("TableHeaderUI", "javax.swing.plaf.multi.MultiTableHeaderUI");
+ defaults.put("TableUI", "javax.swing.plaf.multi.MultiTableUI");
+ defaults.put("TextAreaUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("TextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("TextPaneUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("ToggleButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("ToolBarSeparatorUI",
+ "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("ToolBarUI", "javax.swing.plaf.multi.MultiToolBarUI");
+ defaults.put("ToolTipUI", "javax.swing.plaf.multi.MultiToolTipUI");
+ defaults.put("ViewportUI", "javax.swing.plaf.multi.MultiViewportUI");
+ return defaults;
+ }
+
+ /**
+ * Creates the UI delegates for the <code>target</code> component and
+ * returns a multiplexing UI delegate (<code>mui</code>) if there are
+ * multiple delegates.
+ *
+ * @param mui a multiplexing UI delegate appropriate for the component.
+ * @param uis a vector into which the UI delegates will be added.
+ * @param target the target component.
+ *
+ * @return A UI delegate.
+ */
+ public static ComponentUI createUIs(ComponentUI mui, Vector uis,
+ JComponent target)
+ {
+ // get primary UI delegate for 'target', and add it to uis
+ ComponentUI ui = null;
+ LookAndFeel primary = UIManager.getLookAndFeel();
+ if (primary != null)
+ {
+ ui = UIManager.getUI(target);
+ uis.add(ui);
+ }
+ // for any auxiliary look and feels in use, get the UI delegate and add
+ // it to uis
+ LookAndFeel[] auxlafs = UIManager.getAuxiliaryLookAndFeels();
+ for (int i = 0; i < auxlafs.length; i++)
+ {
+ LookAndFeel auxlaf = auxlafs[i];
+ // FIXME: here I call getDefaults() to get the UI delegate from the
+ // auxiliary look and feel. But getDefaults() creates a new set of
+ // defaults every time it is called, which is wasteful. Unfortunately
+ // I cannot find another way to get the UI delegate, so I'm doing it
+ // anyway...
+ UIDefaults defaults = auxlaf.getDefaults();
+ ui = defaults.getUI(target);
+ if (ui != null)
+ uis.add(ui);
+ }
+ // if uis contains more than 1 delegate, return mui, otherwise return
+ // the primary delegate
+ if (uis.size() > 1)
+ return mui;
+ else
+ return ui;
+ }
+
+ /**
+ * Returns an array containing the same {@link ComponentUI} instances as
+ * <code>uis</code>. If <code>uis</code> is <code>null</code>, a zero-length
+ * array is returned.
+ *
+ * @param uis a list of {@link ComponentUI} references (<code>null</code>
+ * permitted).
+ *
+ * @return An array containing the same {@link ComponentUI} instances as
+ * <code>uis</code>, or <code>null</code> if <code>uis</code> is
+ * empty.
+ */
+ protected static ComponentUI[] uisToArray(Vector uis)
+ {
+ if (uis == null)
+ return new ComponentUI[0];
+ int size = uis.size();
+ if (size == 0)
+ return null;
+ ComponentUI[] result = new ComponentUI[size];
+ uis.copyInto(result);
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiMenuBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MenuBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiMenuBarUI extends MenuBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiMenuBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiMenuBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiMenuBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiMenuBarUI mui = new MultiMenuBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiMenuBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiMenuItemUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuItemUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MenuItemUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiMenuItemUI extends MenuItemUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiMenuItemUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiMenuItemUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiItemUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiMenuItemUI mui = new MultiMenuItemUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiMenuItemUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,398 @@
+/* MultiOptionPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.OptionPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link OptionPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiOptionPaneUI extends OptionPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiOptionPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiOptionPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiOptionPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiOptionPaneUI mui = new MultiOptionPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiOptionPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link OptionPaneUI#selectInitialValue(JOptionPane)} method for
+ * all the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param pane the option pane.
+ */
+ public void selectInitialValue(JOptionPane pane)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ ui.selectInitialValue(pane);
+ }
+ }
+
+ /**
+ * Calls the {@link OptionPaneUI#containsCustomComponents(JOptionPane)}
+ * method for all the UI delegates managed by this
+ * <code>MultiOptionPaneUI</code>, returning the result for the UI delegate
+ * from the primary look and feel.
+ *
+ * @param pane the option pane.
+ *
+ * @return The result for the UI delegate from the primary look and feel.
+ */
+ public boolean containsCustomComponents(JOptionPane pane)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ result = ui.containsCustomComponents(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ /* boolean ignored = */ ui.containsCustomComponents(pane);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiPanelUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PanelUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link PanelUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiPanelUI extends PanelUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiPanelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiPanelUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiPanelUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiPanelUI mui = new MultiPanelUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiPanelUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiPopupMenuUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PopupMenuUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link PopupMenuUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiPopupMenuUI extends PopupMenuUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiPopupMenuUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiPopupMenuUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiPopupMenuUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiPopupMenuUI mui = new MultiPopupMenuUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiPopupMenuUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiProgressBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ProgressBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ProgressBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiProgressBarUI extends ProgressBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiProgressBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiProgressBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiProgressBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiProgressBarUI mui = new MultiProgressBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiProgressBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiRootPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.RootPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link RootPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiRootPaneUI extends RootPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiRootPanelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiRootPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiRootPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiRootPaneUI mui = new MultiRootPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiRootPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiScrollBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ScrollBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ScrollBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiScrollBarUI extends ScrollBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiScrollBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiScrollBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiScrollBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiScrollBarUI mui = new MultiScrollBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiScrollBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiScrollPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ScrollPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ScrollPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiScrollPaneUI extends ScrollPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiScrollPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiScrollPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiScrollPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiScrollPaneUI mui = new MultiScrollPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiScrollPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiSeparatorUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SeparatorUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MultiSeparatorUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSeparatorUI extends SeparatorUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSeparatorUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSeparatorUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSeparatorUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSeparatorUI mui = new MultiSeparatorUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSeparatorUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiSliderUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SliderUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SliderUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSliderUI extends SliderUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSliderUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSliderUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSliderUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSliderUI mui = new MultiSliderUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSliderUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiSpinnerUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SpinnerUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SpinnerUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSpinnerUI extends SpinnerUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSpinnerUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSpinnerUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSpinnerUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSpinnerUI mui = new MultiSpinnerUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSpinnerUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,494 @@
+/* MultiSplitPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JSplitPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SplitPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SplitPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSplitPaneUI extends SplitPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSplitPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSplitPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSplitPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSplitPaneUI mui = new MultiSplitPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSplitPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#resetToPreferredSizes(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ */
+ public void resetToPreferredSizes(JSplitPane pane)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.resetToPreferredSizes(pane);
+ }
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#setDividerLocation(JSplitPane, int)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ * @param location the location.
+ */
+ public void setDividerLocation(JSplitPane pane, int location)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.setDividerLocation(pane, location);
+ }
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getDividerLocation(JSplitPane)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getDividerLocation(JSplitPane pane)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getMinimumDividerLocation(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getMinimumDividerLocation(JSplitPane pane)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getMinimumDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getMinimumDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getMaximumDividerLocation(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getMaximumDividerLocation(JSplitPane pane)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getMaximumDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getMaximumDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#finishedPaintingChildren(JSplitPane,
+ * Graphics)} method for all the UI delegates managed by this
+ * <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ * @param g the graphics device.
+ */
+ public void finishedPaintingChildren(JSplitPane pane, Graphics g)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.finishedPaintingChildren(pane, g);
+ }
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,447 @@
+/* MultiTabbedPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TabbedPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TabbedPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTabbedPaneUI extends TabbedPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTabbedPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTabbedPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTabbedPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTabbedPaneUI mui = new MultiTabbedPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#tabForCoordinate(JTabbedPane, int, int)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the tab index for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return The tab index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int tabForCoordinate(JTabbedPane pane, int x, int y)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.tabForCoordinate(pane, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.tabForCoordinate(pane, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#getTabBounds(JTabbedPane, int)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the bounds for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ * @param index the index.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getTabBounds(JTabbedPane pane, int index)
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.getTabBounds(pane, index);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.getTabRunCount(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#getTabRunCount(JTabbedPane)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the nt for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getTabRunCount(JTabbedPane pane)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.getTabRunCount(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.getTabRunCount(pane);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiTableHeaderUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TableHeaderUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TableHeaderUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTableHeaderUI extends TableHeaderUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTableHeaderUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTableHeaderUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTableHeaderUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTableHeaderUI mui = new MultiTableHeaderUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTableHeaderUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiTableUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TableUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TableUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTableUI extends TableUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTableUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTableUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTableUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTableUI mui = new MultiTableUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTableUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,617 @@
+/* MultiTextUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TextUI;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.EditorKit;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.Position;
+import javax.swing.text.View;
+import javax.swing.text.Position.Bias;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TextUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTextUI extends TextUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTextUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTextUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTextUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTextUI mui = new MultiTextUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTextUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#modelToView(JTextComponent, int)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle modelToView(JTextComponent tc, int pos)
+ throws BadLocationException
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.modelToView(tc, pos);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* Rectangle ignored = */ ui.modelToView(tc, pos);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#modelToView(JTextComponent, int, Position.Bias)}
+ * method for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle modelToView(JTextComponent tc, int pos, Bias bias)
+ throws BadLocationException
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.modelToView(tc, pos, bias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* Rectangle ignored = */ ui.modelToView(tc, pos, bias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#viewToModel(JTextComponent, Point)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param t the text component.
+ * @param pt the point.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int viewToModel(JTextComponent t, Point pt)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.viewToModel(t, pt);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.viewToModel(t, pt);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#viewToModel(JTextComponent, Point, Bias[])} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int viewToModel(JTextComponent tc, Point loc, Bias[] outBias)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.viewToModel(tc, loc, outBias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.viewToModel(tc, loc, outBias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#getNextVisualPositionFrom(JTextComponent, int,
+ * Position.Bias, int, Position.Bias[])} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getNextVisualPositionFrom(JTextComponent tc, int pos, Bias bias,
+ int direction, Bias[] outBias) throws BadLocationException
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getNextVisualPositionFrom(tc, pos, bias, direction,
+ outBias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.getNextVisualPositionFrom(tc, pos, bias,
+ direction, outBias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#damageRange(JTextComponent, int, int)} method for
+ * all the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param tc the component.
+ * @param start the start position.
+ * @param end the end position.
+ */
+ public void damageRange(JTextComponent tc, int start, int end)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ ui.damageRange(tc, start, end);
+ }
+ }
+
+ /**
+ * Calls the {@link TextUI#damageRange(JTextComponent, int, int,
+ * Position.Bias, Position.Bias)} method for all the UI delegates managed by
+ * this <code>MultiTextUI</code>.
+ *
+ * @param tc the component.
+ * @param start the start position.
+ * @param end the end position.
+ * @param startBias the start bias.
+ * @param endBias the end bias.
+ */
+ public void damageRange(JTextComponent tc, int start, int end,
+ Bias startBias, Bias endBias)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ ui.damageRange(tc, start, end, startBias, endBias);
+ }
+ }
+
+ /**
+ * Calls the {@link TextUI#getEditorKit(JTextComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the editor kit for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The editor kit returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public EditorKit getEditorKit(JTextComponent tc)
+ {
+ EditorKit result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getEditorKit(tc);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* EditorKit ignored = */ ui.getEditorKit(tc);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#getRootView(JTextComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the view for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The view returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public View getRootView(JTextComponent tc)
+ {
+ View result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getRootView(tc);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* View ignored = */ ui.getRootView(tc);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiToolBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ToolBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ToolBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiToolBarUI extends ToolBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiToolBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiToolBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiToolBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiToolBarUI mui = new MultiToolBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiToolBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiToolTipUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ToolTipUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ToolTipUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiToolTipUI extends ToolTipUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiToolTipUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiToolTipUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiToolTipUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiToolTipUI mui = new MultiToolTipUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiToolTipUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,628 @@
+/* MultiTreeUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JTree;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TreeUI;
+import javax.swing.tree.TreePath;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TreeUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTreeUI extends TreeUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTreeUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTreeUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTreeUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTreeUI mui = new MultiTreeUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTreeUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getPathBounds(JTree, TreePath)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getPathBounds(JTree tree, TreePath path)
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getPathBounds(tree, path);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* Rectangle ignored = */ ui.getPathBounds(tree, path);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getPathForRow(JTree, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getPathForRow(JTree tree, int row)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getPathForRow(tree, row);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getPathForRow(tree, row);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getRowForPath(JTree, TreePath)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the row index for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The row index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getRowForPath(JTree tree, TreePath path)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getRowForPath(tree, path);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* int ignored = */ ui.getRowForPath(tree, path);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getRowCount(JTree)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getRowCount(JTree tree)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getRowCount(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* int ignored = */ ui.getRowCount(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getClosestPathForLocation(JTree, int, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getClosestPathForLocation(JTree tree, int x, int y)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getClosestPathForLocation(tree, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getClosestPathForLocation(tree, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#isEditing(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The result returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public boolean isEditing(JTree tree)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.isEditing(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* boolean ignored = */ ui.isEditing(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#stopEditing(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The result returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public boolean stopEditing(JTree tree)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.stopEditing(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* boolean ignored = */ ui.stopEditing(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#cancelEditing(JTree)} method for
+ * all the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param tree the tree component.
+ */
+ public void cancelEditing(JTree tree)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ ui.cancelEditing(tree);
+ }
+ }
+
+ /**
+ * Calls the {@link TreeUI#startEditingAtPath(JTree, TreePath)} method for
+ * all the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param tree the tree component.
+ * @param path the path.
+ */
+ public void startEditingAtPath(JTree tree, TreePath path)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ ui.startEditingAtPath(tree, path);
+ }
+ }
+
+ /**
+ * Calls the {@link TreeUI#getEditingPath(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getEditingPath(JTree tree)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getEditingPath(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getEditingPath(tree);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,352 @@
+/* MultiViewPortUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ViewportUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ViewportUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiViewportUI extends ViewportUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiViewPortUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiViewportUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiViewportUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiViewportUI mui = new MultiViewportUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiViewportUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/multi/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.plaf.metal package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.plaf.multi</title></head>
+
+<body>
+<p>Provides a look and feel that can combine a primary look and feel with one or more auxiliary look and feels.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.plaf package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.plaf</title></head>
+
+<body>
+<p>A base package for the "pluggable look and feel" (plaf) mechanism used by
+the <code>javax.swing</code> classes.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/ColorType.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/ColorType.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/ColorType.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/ColorType.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,135 @@
+/* ColorType.java -- En enumeration of color types
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+/**
+ * A typesafe enumeration of color types.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public class ColorType
+{
+
+ /**
+ * A constant used to identify the foreground color of a component.
+ */
+ public static final ColorType FOREGROUND = new ColorType("Foreground");
+
+ /**
+ * A constant used to identify the background color of a component.
+ */
+ public static final ColorType BACKGROUND = new ColorType("Background");
+
+ /**
+ * A constant used to identify the foreground color of text of a component.
+ */
+ public static final ColorType TEXT_FOREGROUND
+ = new ColorType("TextForeground");
+
+ /**
+ * A constant used to identify the background color of text of a component.
+ */
+ public static final ColorType TEXT_BACKGROUND
+ = new ColorType("TextBackground");
+
+ /**
+ * A constant used to identify the focus color of a component.
+ */
+ public static final ColorType FOCUS = new ColorType("Focus");
+
+ /**
+ * The maximum number of color types.
+ */
+ public static final int MAX_COUNT;
+ static
+ {
+ // This is not a constant in the JDK.
+ MAX_COUNT = 5;
+ }
+
+ /**
+ * A counter used to assign an ID to the created color types.
+ */
+ private static int count = 0;
+
+ /**
+ * The ID of the color type.
+ */
+ private int id;
+
+ /**
+ * The description of the color type.
+ */
+ private String description;
+
+ /**
+ * Creates a new <code>Color</code> color type with the specified
+ * description.
+ *
+ * @param desc the textual description of the color type
+ */
+ protected ColorType(String desc)
+ {
+ description = desc;
+ id = count;
+ count++;
+ }
+
+ /**
+ * Returns the unique ID of the color type.
+ *
+ * @return the unique ID of the color type
+ */
+ public final int getID()
+ {
+ return id;
+ }
+
+ /**
+ * Returns the textual description of the color type.
+ *
+ * @return the textual description of the color type
+ */
+ public String toString()
+ {
+ return description;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/Region.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/Region.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/Region.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/Region.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,474 @@
+/* Region.java -- Describes a region within a component
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+/**
+ * Describes a region of a component or the complete component.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public class Region
+{
+
+ // FIXME: What should ui be for the non-component regions that have
+ // subregion==false?
+
+ /**
+ * Specifies an arrow button region.
+ */
+ public static final Region ARROW_BUTTON =
+ new Region("ArrowButton", null, false);
+
+ /**
+ * Specifies the region of a standard button.
+ */
+ public static final Region BUTTON =
+ new Region("Button", "ButtonUI", false);
+
+ /**
+ * Specifies the region of a check box.
+ */
+ public static final Region CHECK_BOX =
+ new Region("CheckBox", "CheckBoxUI", false);
+
+ /**
+ * Specifies the region of a check box menu item.
+ */
+ public static final Region CHECK_BOX_MENU_ITEM =
+ new Region("CheckBoxMenuItem", "CheckBoxMenuItemUI", false);
+
+ /**
+ * Specifies the region of a colorchooser.
+ */
+ public static final Region COLOR_CHOOSER =
+ new Region("ColorChooser", "ColorChooserUI", false);
+
+ /**
+ * Specifies the region of a combo box.
+ */
+ public static final Region COMBO_BOX =
+ new Region("ComboBox", "ComboBoxUI", false);
+
+ /**
+ * Specifies the region of a desktop pane.
+ */
+ public static final Region DESKTOP_PANE =
+ new Region("DesktopPane", "DesktopPaneUI", false);
+
+ /**
+ * Specifies the region of a desktop icon.
+ */
+ public static final Region DESKTOP_ICON =
+ new Region("DesktopIcon", "DesktopIconUI", false);
+
+ /**
+ * Specifies the region of an editor pane.
+ */
+ public static final Region EDITOR_PANE =
+ new Region("EditorPane", "EditorPaneUI", false);
+
+ /**
+ * Specifies the region of a file chooser.
+ */
+ public static final Region FILE_CHOOSER =
+ new Region("FileChooser", "FileChooserUI", false);
+
+ /**
+ * Specifies the region of a formatted text field.
+ */
+ public static final Region FORMATTED_TEXT_FIELD =
+ new Region("FormattedTextField", "FormattedTextFieldUI", false);
+
+ /**
+ * Specifies the region of an internal frame.
+ */
+ public static final Region INTERNAL_FRAME =
+ new Region("InternalFrame", "InternalFrameUI", false);
+
+ /**
+ * Specifies the region of the title pane of an internal frame.
+ */
+ public static final Region INTERNAL_FRAME_TITLE_PANE =
+ new Region("InternalFrameTitlePane", "InternalFrameTitlePaneUI", false);
+
+ /**
+ * Specifies the region of a label.
+ */
+ public static final Region LABEL =
+ new Region("Label", "LabelUI", false);
+
+ /**
+ * Specifies the region of a list.
+ */
+ public static final Region LIST =
+ new Region("List", "ListUI", false);
+
+ /**
+ * Specifies the region of a menu.
+ */
+ public static final Region MENU =
+ new Region("Menu", "MenuUI", false);
+
+ /**
+ * Specifies the region of a menu bar.
+ */
+ public static final Region MENU_BAR =
+ new Region("MenuBar", "MenuBarUI", false);
+
+ /**
+ * Specifies the region of a menu item.
+ */
+ public static final Region MENU_ITEM =
+ new Region("MenuItem", "MenuItemUI", false);
+
+ /**
+ * Specifies the region of a menu item accelerator. This is a subregion
+ * of menu item.
+ */
+ public static final Region MENU_ITEM_ACCELERATOR =
+ new Region("MenuItemAccelerator", null, true);
+
+ /**
+ * Specifies the region of an option pane.
+ */
+ public static final Region OPTION_PANE =
+ new Region("OptionPane", "OptionPaneUI", false);
+
+ /**
+ * Specifies the region of a panel.
+ */
+ public static final Region PANEL =
+ new Region("Panel", "PanelUI", false);
+
+ /**
+ * Specifies the region of a password field.
+ */
+ public static final Region PASSWORD_FIELD =
+ new Region("PasswordField", "PasswordFieldUI", false);
+
+ /**
+ * Specifies the region of a popup menu.
+ */
+ public static final Region POPUP_MENU =
+ new Region("PopupMenu", "PopupMenuUI", false);
+
+ /**
+ * Specifies the region of a popup menu separator.
+ */
+ public static final Region POPUP_MENU_SEPARATOR =
+ new Region("PopupMenuSeparator", null, false);
+
+ /**
+ * Specifies the region of a progress bar.
+ */
+ public static final Region PROGRESS_BAR =
+ new Region("ProgressBar", "ProgressBarUI", false);
+
+ /**
+ * Specifies the region of a radio button.
+ */
+ public static final Region RADIO_BUTTON =
+ new Region("RadioButton", "RadioButtonUI", false);
+
+ /**
+ * Specifies the region of a radio button menu item.
+ */
+ public static final Region RADIO_BUTTON_MENU_ITEM =
+ new Region("RadioButtonMenuItem", "RadioButtonMenuItemUI", false);
+
+ /**
+ * Specifies the region of a root pane.
+ */
+ public static final Region ROOT_PANE =
+ new Region("RootPane", "RootPaneUI", false);
+
+ /**
+ * Specifies the region of a scroll bar.
+ */
+ public static final Region SCROLL_BAR =
+ new Region("ScrollBar", "ScrollBarUI", false);
+
+ /**
+ * Specifies the region of a scroll bar track. This is a subregion of
+ * scroll bars.
+ */
+ public static final Region SCROLL_BAR_TRACK =
+ new Region("ScrollBarTrack", null, true);
+
+ /**
+ * Specifies the region of a scroll bar thumb. This is a subregion of
+ * scroll bars.
+ */
+ public static final Region SCROLL_BAR_THUMB =
+ new Region("ScrollBarThumb", null, true);
+
+ /**
+ * Specifies the region of a scroll pane.
+ */
+ public static final Region SCROLL_PANE =
+ new Region("ScrollPane", "ScrollPaneUI", false);
+
+ /**
+ * Specifies the region of a separator.
+ */
+ public static final Region SEPARATOR =
+ new Region("Separator", "SeparatorUI", false);
+
+ /**
+ * Specifies the region of a slider.
+ */
+ public static final Region SLIDER =
+ new Region("Slider", "SliderUI", false);
+
+ /**
+ * Specifies the region of a slider track. This is a subregion of a slider.
+ */
+ public static final Region SLIDER_TRACK =
+ new Region("SliderTrack", null, true);
+
+ /**
+ * Specifies the region of a slider thumb. This is a subregion of a slider.
+ */
+ public static final Region SLIDER_THUMB =
+ new Region("SliderThumb", null, true);
+
+ /**
+ * Specifies the region of a spinner.
+ */
+ public static final Region SPINNER =
+ new Region("Spinner", "SpinnerUI", false);
+
+ /**
+ * Specifies the region of a split pane.
+ */
+ public static final Region SPLIT_PANE =
+ new Region("SplitPane", "SplitPaneUI", false);
+
+ /**
+ * Specifies the region of a split pane divider. This is a subregion of
+ * a split pane.
+ */
+ public static final Region SPLIT_PANE_DIVIDER =
+ new Region("SplitPaneDivider", null, true);
+
+ /**
+ * Specifies the region of a tabbed pane.
+ */
+ public static final Region TABBED_PANE =
+ new Region("TabbedPane", "TabbedPaneUI", false);
+
+ /**
+ * This specifies the region of a tab of a tabbed pane. This is a subregion
+ * of a tabbed pane.
+ */
+ public static final Region TABBED_PANE_TAB =
+ new Region("TabbedPaneTab", null, true);
+
+ /**
+ * This specifies the region underneath the tabs of a tabbed pane. This is a
+ * subregion of a tabbed pane.
+ */
+ public static final Region TABBED_PANE_TAB_AREA =
+ new Region("TabbedPaneTabArea", null, true);
+
+ /**
+ * This specifies the region for the content of a tabbed pane. This is a
+ * subregion of a tabbed pane.
+ */
+ public static final Region TABBED_PANE_CONTENT =
+ new Region("TabbedPaneContent", null, true);
+
+ /**
+ * Specifies the region of a table.
+ */
+ public static final Region TABLE =
+ new Region("Table", "TableUI", false);
+
+ /**
+ * Specifies the region of a table header.
+ */
+ public static final Region TABLE_HEADER =
+ new Region("TableHeader", "TableHeaderUI", false);
+
+ /**
+ * Specifies the region of a text area.
+ */
+ public static final Region TEXT_AREA =
+ new Region("TextArea", "TextAreaUI", false);
+
+ /**
+ * Specifies the region of a text field.
+ */
+ public static final Region TEXT_FIELD =
+ new Region("TextField", "TextFieldUI", false);
+
+ /**
+ * Specifies the region of a text pane.
+ */
+ public static final Region TEXT_PANE =
+ new Region("TextPane", "TextPaneUI", false);
+
+ /**
+ * Specifies the region of a toggle button.
+ */
+ public static final Region TOGGLE_BUTTON =
+ new Region("ToggleButton", "ToggleButtonUI", false);
+
+ /**
+ * Specifies the region of a tool bar.
+ */
+ public static final Region TOOL_BAR =
+ new Region("ToolBar", "ToolBarUI", false);
+
+ /**
+ * Specifies the content region of a tool bar. This is a subregion of a tool
+ * bar.
+ */
+ public static final Region TOOL_BAR_CONTENT =
+ new Region("ToolBarContent", null, true);
+
+ /**
+ * Specifies the drag window region of a tool bar. This is a subregion of a
+ * tool bar.
+ */
+ public static final Region TOOL_BAR_DRAG_WINDOW =
+ new Region("ToolBarDragWindow", null, false);
+
+ /**
+ * Specifies the region of a tool tip.
+ */
+ public static final Region TOOL_TIP =
+ new Region("ToolTip", "ToolTipUI", false);
+
+ /**
+ * Specifies the region of a separator of a tool bar. This is a subregion of
+ * a tool bar.
+ */
+ public static final Region TOOL_BAR_SEPARATOR =
+ new Region("ToolBarSeparator", null, false);
+
+ /**
+ * Specifies the region of a tree.
+ */
+ public static final Region TREE =
+ new Region("Tree", "TreeUI", false);
+
+ /**
+ * Specifies the region of a tree cell. This is a subregion of a tree.
+ */
+ public static final Region TREE_CELL =
+ new Region("TreeCell", null, true);
+
+ /**
+ * Specifies the region of a viewport.
+ */
+ public static final Region VIEWPORT =
+ new Region("Viewport", "ViewportUI", false);
+
+
+ /**
+ * The UI class id for the region. This is package private because this will
+ * be used by other classes in that package.
+ */
+ String ui;
+
+ /**
+ * The name of the region.
+ */
+ private String name;
+
+ /**
+ * If this region is a subregion or not.
+ */
+ private boolean subregion;
+
+ /**
+ * Creates a new <code>Region</code> with the specified name and ui ID.
+ * The <code>ui</code> must be the same what
+ * {@link javax.swing.JComponent#getUIClassID()} returns for toplevel regions. For
+ * subregions this should be <code>null</code>.
+ *
+ * @param name the name of the region
+ * @param ui the UI class ID of the region or <code>null</code> for
+ * subregions
+ * @param subregion <code>true</code> if this region is a subregion,
+ * <code>false</code> otherwise
+ */
+ protected Region(String name, String ui, boolean subregion)
+ {
+ this.name = name;
+ this.ui = ui;
+ this.subregion = subregion;
+ }
+
+ /**
+ * Returns <code>true</code> if this region describes a subregion of a
+ * component, <code>false</code> if it describes a component region itself.
+ *
+ * @return <code>true</code> if this region describes a subregion of a
+ * component, <code>false</code> if it describes a component region
+ * itself
+ */
+ public boolean isSubregion()
+ {
+ return subregion;
+ }
+
+ /**
+ * Returns the name of the region.
+ *
+ * @return the name of the region
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the name of the region.
+ *
+ * @return the name of the region
+ */
+ public String toString()
+ {
+ return name;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthConstants.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthConstants.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthConstants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthConstants.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,85 @@
+/* SynthConstants.java -- A couple of constants used by Synth
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+/**
+ * A couple of constants used by the Synth Look and Feel.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public interface SynthConstants
+{
+ /**
+ * A primary state indicating that a component is enabled.
+ */
+ static final int ENABLED = 1;
+
+ /**
+ * A primary state indicating that a component is disabled.
+ */
+ static final int DISABLED = 8;
+
+ /**
+ * A primary state indicating that the mouse is over a region.
+ */
+ static final int MOUSE_OVER = 2;
+
+ /**
+ * A primary state indicating that the component is in a pressed state (which
+ * does not necessarily mean that the mouse is pressed over the component).
+ */
+ static final int PRESSED = 4;
+
+ /**
+ * Indicates that a region has focus.
+ */
+ static final int FOCUSED = 256;
+
+ /**
+ * Indicates that a region is selected.
+ */
+ static final int SELECTED = 512;
+
+ /**
+ * Indicates that a region is in its default state.
+ */
+ static final int DEFAULT = 1024;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,134 @@
+/* SynthContext.java -- Contextual information about a region
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+import javax.swing.JComponent;
+
+/**
+ * Contains some contextual information about a region. The information passed
+ * in objects of this class can only be considered valid during the method call
+ * that it was passed to.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public class SynthContext
+{
+
+ /**
+ * The component.
+ */
+ private JComponent component;
+
+ /**
+ * The region of the component.
+ */
+ private Region region;
+
+ /**
+ * The style of the component.
+ */
+ private SynthStyle style;
+
+ /**
+ * The state of the component.
+ */
+ private int state;
+
+ /**
+ * Creates a new <code>SynthContext</code> object.
+ *
+ * @param component the component for which this context is used
+ * @param region the region of the component
+ * @param style the style associated with the component
+ * @param state a or'ed bitmask of the constants from {@link SynthConstants}
+ */
+ public SynthContext(JComponent component, Region region, SynthStyle style,
+ int state)
+ {
+ this.component = component;
+ this.region = region;
+ this.style = style;
+ this.state = state;
+ }
+
+ /**
+ * Returns the component that contains the region.
+ *
+ * @return the component that contains the region
+ */
+ public JComponent getComponent()
+ {
+ return component;
+ }
+
+ /**
+ * Returns the region that identifies this state.
+ *
+ * @return the region that identifies this state
+ */
+ public Region getRegion()
+ {
+ return region;
+ }
+
+ /**
+ * Returns the style of the region.
+ *
+ * @return the style of the region
+ */
+ public SynthStyle getStyle()
+ {
+ return style;
+ }
+
+ /**
+ * Returns the state of the component. This is a or'ed bitmask of the
+ * constants defined in {@link SynthConstants}.
+ *
+ * @return the state of the component
+ *
+ * @see SynthConstants
+ */
+ public int getComponentState()
+ {
+ return state;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthGraphicsUtils.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthGraphicsUtils.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthGraphicsUtils.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthGraphicsUtils.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,289 @@
+/* SynthGraphicsUtils.java -- Wrapper for graphics primitives used in Synth
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.Icon;
+import javax.swing.SwingUtilities;
+
+/**
+ * Wrapper for graphics primitives used in Synth.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public class SynthGraphicsUtils
+
+{
+ /**
+ * Creates a new <code>SynthGraphicsUtils</code> object.
+ */
+ public SynthGraphicsUtils()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Draws a line from (x1,y1) to (x2,y2).
+ *
+ * @param ctx the synth context, identifies the region
+ * @param paintKey identifies the portion of the component to be painted, may
+ * be <code>null</code>
+ * @param g the graphics context to use for painting
+ * @param x1 the x coordinate of the start point
+ * @param y1 the y coordinate of the start point
+ * @param x2 the x coordinate of the end point
+ * @param y2 the y coordinate of the end point
+ */
+ public void drawLine(SynthContext ctx, Object paintKey, Graphics g, int x1,
+ int y1, int x2, int y2)
+ {
+ // TODO: Correct?
+ g.drawLine(x1, y1, x2, y2);
+ }
+
+ /**
+ * Lays out a label and (if non-null) an icon. The calculated coordinates are
+ * then stored in <code>viewR</code>, <code>iconR</code> and
+ * <code>textR</code>.
+ *
+ * The alignment and position parameters may be one of the alignment or
+ * position constants defined in {@link javax.swing.SwingConstants}.
+ *
+ * @param ctx the synth context, identifies the current region
+ * @param fm the font metrics to use to fetch the text measures
+ * @param text the text to lay out, may be <code>null</code>
+ * @param icon the icon to lay out, may be <code>null</code>
+ * @param hAlign the horizontal alignment of the label
+ * @param vAlign the vertical alignment of the label
+ * @param hTextPos the horizontal text position
+ * @param vTextPos the vertical text position
+ * @param viewR the view rectangle (return parameter)
+ * @param iconR the icon rectangle (return parameter)
+ * @param textR the text rectangle (return parameter)
+ * @param iconTextGap the gap between text and label
+ *
+ * @return the label text, may be shortened
+ */
+ public String layoutText(SynthContext ctx, FontMetrics fm, String text,
+ Icon icon, int hAlign, int vAlign, int hTextPos,
+ int vTextPos, Rectangle viewR, Rectangle iconR,
+ Rectangle textR, int iconTextGap)
+ {
+ return SwingUtilities.layoutCompoundLabel(fm, text, icon, vAlign, hAlign,
+ vTextPos, hTextPos, viewR, iconR,
+ textR, iconTextGap);
+ }
+
+ /**
+ * Returns the width of the string <code>text</code> for the specified font
+ * and font metrics.
+ *
+ * @param ctx identifies the current region
+ * @param font the font
+ * @param fm the font metrics to use
+ * @param text the text to be measured
+ *
+ * @return the width of the string <code>text</code> for the specified font
+ * and font metrics
+ */
+ public int computeStringWidth(SynthContext ctx, Font font, FontMetrics fm,
+ String text)
+ {
+ return fm.stringWidth(text);
+ }
+
+ /**
+ * Calculates the minimums size that is needed to render the label with
+ * <code>text</code> and <code>icon</code> correctly.
+ *
+ * @param ctx identifies the current region
+ * @param font the font to use
+ * @param text the label text
+ * @param icon the label icon
+ * @param hAlign the horizontal alignment
+ * @param vAlign the vertical alignment
+ * @param hTextPosition the horizontal text position
+ * @param vTextPosition the vertical text position
+ * @param iconTextGap the gap between icon and text
+ * @param mnemonicIndex index to the mnemonic character within
+ * <code>text</code>
+ *
+ * @return the minimums size that is needed to render the label with
+ * <code>text</code> and <code>icon</code> correctly
+ */
+ public Dimension getMinimumSize(SynthContext ctx, Font font, String text,
+ Icon icon, int hAlign, int vAlign,
+ int hTextPosition,int vTextPosition,
+ int iconTextGap,int mnemonicIndex)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return new Dimension(0, 0);
+ }
+
+ /**
+ * Calculates the preferred size that is needed to render the label with
+ * <code>text</code> and <code>icon</code> correctly.
+ *
+ * @param ctx identifies the current region
+ * @param font the font to use
+ * @param text the label text
+ * @param icon the label icon
+ * @param hAlign the horizontal alignment
+ * @param vAlign the vertical alignment
+ * @param hTextPosition the horizontal text position
+ * @param vTextPosition the vertical text position
+ * @param iconTextGap the gap between icon and text
+ * @param mnemonicIndex index to the mnemonic character within
+ * <code>text</code>
+ *
+ * @return the preferred size that is needed to render the label with
+ * <code>text</code> and <code>icon</code> correctly
+ */
+ public Dimension getPreferredSize(SynthContext ctx, Font font, String text,
+ Icon icon, int hAlign, int vAlign,
+ int hTextPosition,int vTextPosition,
+ int iconTextGap,int mnemonicIndex)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return new Dimension(0, 0);
+ }
+
+ /**
+ * Calculates the maximum size that is needed to render the label with
+ * <code>text</code> and <code>icon</code> correctly.
+ *
+ * @param ctx identifies the current region
+ * @param font the font to use
+ * @param text the label text
+ * @param icon the label icon
+ * @param hAlign the horizontal alignment
+ * @param vAlign the vertical alignment
+ * @param hTextPosition the horizontal text position
+ * @param vTextPosition the vertical text position
+ * @param iconTextGap the gap between icon and text
+ * @param mnemonicIndex index to the mnemonic character within
+ * <code>text</code>
+ *
+ * @return the maximum size that is needed to render the label with
+ * <code>text</code> and <code>icon</code> correctly
+ */
+ public Dimension getMaximumSize(SynthContext ctx, Font font, String text,
+ Icon icon, int hAlign, int vAlign,
+ int hTextPosition,int vTextPosition,
+ int iconTextGap,int mnemonicIndex)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return new Dimension(0, 0);
+ }
+
+ /**
+ * Returns the maximum character height of the font from the component of the
+ * passed in <code>context</code>.
+ *
+ * @param context identifies the current component and region
+ *
+ * @return the maximum character height of the font from the component of the
+ * passed in <code>context</code>
+ */
+ public int getMaximumCharHeight(SynthContext context)
+ {
+ Component comp = context.getComponent();
+ Font font = comp.getFont();
+ return comp.getFontMetrics(font).getHeight();
+ }
+
+ /**
+ * Renders the specified <code>text</code> within the <code>bounds</code>.
+ *
+ * @param ctx identifies the component and region
+ * @param g the graphics context for drawing the tetx
+ * @param text the text to be rendered
+ * @param bounds the bounds within which the text should be rendered
+ * @param mnemonicIndex the index of the mnemonic character within
+ * <code>text</code>
+ */
+ public void paintText(SynthContext ctx, Graphics g, String text,
+ Rectangle bounds, int mnemonicIndex)
+ {
+ // FIXME: This is very primitive and should be improved to paint the
+ // mnemonic char.
+ g.drawString(text, bounds.x, bounds.y);
+ }
+
+ /**
+ * Renders the specified <code>text</code> at the specified location.
+ *
+ * @param ctx identifies the component and region
+ * @param g the graphics context for drawing the tetx
+ * @param text the text to be rendered
+ * @param x the X location where the text should be rendered
+ * @param y the Y location where the text should be rendered
+ * @param mnemonicIndex the index of the mnemonic character within
+ * <code>text</code>
+ */
+ public void paintText(SynthContext ctx, Graphics g, String text,
+ int x, int y, int mnemonicIndex)
+ {
+ // FIXME: This is very primitive and should be improved to paint the
+ // mnemonic char.
+ g.drawString(text, x, y);
+ }
+
+ public void paintText(SynthContext ctx, Graphics g, String text, Icon icon,
+ int hAlign, int vAlign, int hTextPosition,
+ int vTextPosition, int iconTextGap, int mnemonicIndex,
+ int textOffset)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthLookAndFeel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthLookAndFeel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthLookAndFeel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthLookAndFeel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,281 @@
+/* SynthLookAndFeel.java -- A skinnable Swing look and feel
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.io.InputStream;
+import java.text.ParseException;
+
+import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+
+/**
+ * A look and feel that can be customized either by providing a file to
+ * {@link #load} or by setting a {@link SynthStyleFactory} using
+ * {@link #setStyleFactory}.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public class SynthLookAndFeel
+ extends BasicLookAndFeel
+{
+
+ /**
+ * The style factory that will be used by the UI classes to load their
+ * style sets from.
+ */
+ private static SynthStyleFactory styleFactory;
+
+ /**
+ * Creates a new instance of <code>SynthLookAndFeel</code>. In order to use
+ * the Synth look and feel you either need to call {@link #load} to load a
+ * set of styles from an XML file, or you need to call
+ * {@link #setStyleFactory} to provide your own style factory.
+ */
+ public SynthLookAndFeel()
+ {
+ // FIXME: What to do here, if anything?
+ }
+
+ /**
+ * Sets the style factory that the UI classes of Synth will use to load their
+ * sets of styles.
+ *
+ * @param sf the style factory to set
+ */
+ public static void setStyleFactory(SynthStyleFactory sf)
+ {
+ styleFactory = sf;
+ }
+
+ /**
+ * Returns the current style factory that the UI classes of Synth will use to
+ * load their sets of styles.
+ *
+ * @return the current style factory
+ */
+ public static SynthStyleFactory getStyleFactory()
+ {
+ return styleFactory;
+ }
+
+ /**
+ * Returns the style for the specified component and region.
+ *
+ * @param c the component for which to return the style
+ * @param r the region of the component for which to return the style
+ *
+ * @return the style for the specified component and region
+ */
+ public static SynthStyle getStyle(JComponent c, Region r)
+ {
+ return getStyleFactory().getStyle(c, r);
+ }
+
+ /**
+ * Updates all style information of the component and it's children.
+ *
+ * @param c the componenent for which to update the style
+ */
+ public static void updateStyles(Component c)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this properly.
+ }
+
+ /**
+ * Returns the region for a given Swing component.
+ *
+ * @param c the Swing component for which to fetch the region
+ *
+ * @return the region for a given Swing component
+ */
+ public static Region getRegion(JComponent c)
+ throws NotImplementedException
+ {
+ // FIXME: This can be implemented as soon as we have the component UI
+ // classes in place, since this region will be matched via the UI classes.
+ return null;
+ }
+
+ /**
+ * Creates the Synth look and feel component UI instance for the given
+ * component.
+ *
+ * @param c the component for which to create a UI instance
+ *
+ * @return the Synth look and feel component UI instance for the given
+ * component
+ */
+ public static ComponentUI createUI(JComponent c)
+ throws NotImplementedException
+ {
+ // FIXME: This can be implemented as soon as we have the component UI
+ // classes in place.
+ return null;
+ }
+
+ /**
+ * Initializes this look and feel.
+ */
+ public void initialize()
+ throws NotImplementedException
+ {
+ super.initialize();
+ // TODO: Implement at least the following here:
+ // if (styleFactory != null)
+ // styleFactory = new DefaultStyleFactory();
+ }
+
+ /**
+ * Uninitializes the look and feel.
+ */
+ public void uninitialize()
+ throws NotImplementedException
+ {
+ super.uninitialize();
+ // TODO: What to do here?
+ }
+
+ /**
+ * Returns the UI defaults of this look and feel.
+ *
+ * @return the UI defaults of this look and feel
+ */
+ public UIDefaults getDefaults()
+ throws NotImplementedException
+ {
+ // FIXME: This is certainly wrong. The defaults should be fetched/merged
+ // from the file from which the l&f is loaded.
+ return super.getDefaults();
+ }
+
+ /**
+ * FIXME: DOCUMENT ME!
+ *
+ * @return FIXME
+ */
+ public boolean shouldUpdateStyleOnAncestorChanged()
+ throws NotImplementedException
+ {
+ return false;
+ }
+
+ /**
+ * Loads a set of {@link SynthStyle}s that are used for the look and feel of
+ * the components. The <code>resourceBase</code> parameter is used to resolve
+ * references against, like icons and other files.
+ *
+ * @param in the input stream from where to load the styles
+ * @param resourceBase the base against which references are resolved.
+ *
+ * @throws ParseException if the input stream cannot be parsed
+ * @throws IllegalArgumentException if one of the parameters is
+ * <code>null</code>
+ */
+ // FIXME: The signature in the JDK has a Class<?> here. Should be fixed as
+ // soon as we switch to the generics branch.
+ public void load(InputStream in, Class resourceBase)
+ throws ParseException, IllegalArgumentException, NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ }
+
+ /**
+ * Returns a textual description of the Synth look and feel. This returns
+ * "Synth look and feel".
+ *
+ * @return a textual description of the Synth look and feel
+ */
+ public String getDescription()
+ {
+ return "Synth look and feel";
+ }
+
+ /**
+ * Returns the ID of the Synth look and feel. This returns "Synth".
+ *
+ * @return the ID of the Synth look and feel
+ */
+ public String getID()
+ {
+ return "Synth";
+ }
+
+ /**
+ * Returns the name of the Synth look and feel. This returns
+ * "Synth look and feel".
+ *
+ * @return the name of the Synth look and feel
+ */
+ public String getName()
+ {
+ return "Synth look and feel";
+ }
+
+ /**
+ * Returns <code>false</code> since the Synth look and feel is not a native
+ * look and feel.
+ *
+ * @return <code>false</code>
+ */
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> since the Synth look and feel is always a
+ * supported look and feel.
+ *
+ * @return <code>true</code>
+ */
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthPainter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthPainter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthPainter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthPainter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1999 @@
+/* SynthPainter.java -- An abstract painter for synth components
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+import java.awt.Graphics;
+
+/**
+ * The abstract definition of a delegate that takes the responsibility of
+ * painting for the components.
+ *
+ * This class is defined to be abstract and all methods are no-ops.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public abstract class SynthPainter
+{
+
+ /**
+ * Creates a new <code>SynthPainter</code> object.
+ */
+ public SynthPainter()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the foreground of an arrow button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param dir the orientation of the arrow
+ */
+ public void paintArrowButtonForeground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int dir)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the foreground of a progress bar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param dir the orientation of the progress bar
+ */
+ public void paintProgressBarForeground(SynthContext ctx, Graphics g,
+ int x, int y, int w, int h,
+ int dir)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the foreground of a separator.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param dir the orientation of the separator
+ */
+ public void paintSeparatorForeground(SynthContext ctx, Graphics g,
+ int x, int y, int w, int h,
+ int dir)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the foreground of a split pane's divider.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param dir the orientation of the divider
+ */
+ public void paintSplitPaneDividerForeground(SynthContext ctx, Graphics g,
+ int x, int y, int w, int h,
+ int dir)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints a split pane's divider, when it is being dragged.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param dir the orientation of the divider
+ */
+ public void paintSplitPaneDragDivider(SynthContext ctx, Graphics g,
+ int x, int y, int w, int h,
+ int dir)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the indicator for a tree cell which has the focus.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTreeCellFocus(SynthContext ctx, Graphics g,
+ int x, int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of an arrow button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintArrowButtonBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of an arrow button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintArrowButtonBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintButtonBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintButtonBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a check box.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintCheckBoxBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a check box.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintCheckBoxBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a check box menu item.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintCheckBoxMenuItemBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a check box menu item.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintCheckBoxMenuItemBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a color chooser.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintColorChooserBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a color chooser.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintColorChooserBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a combo box.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintComboBoxBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a combo box.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintComboBoxBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a desktop icon.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintDesktopIconBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a desktop icon.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintDesktopIconBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a desktop pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintDesktopPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a desktop pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintDesktopPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of an editor pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintEditorPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of an editor pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintEditorPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a file chooser.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintFileChooserBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a file chooser.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintFileChooserBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a formatted text field.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintFormattedTextFieldBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a formatted text field.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintFormattedTextFieldBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of an internal frame.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintInternalFrameBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of an internal frame.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintInternalFrameBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of an internal frame's title pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintInternalFrameTitlePaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of an internal frame's title pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintInternalFrameTitlePaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a label.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintLabelBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a label.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintLabelBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a list.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintListBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a list.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintListBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a menu.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintMenuBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a menu.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintMenuBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a menu bar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintMenuBarBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a menu bar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintMenuBarBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a menu item.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintMenuItemBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a menu item.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintMenuItemBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of an option pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintOptionPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of an option pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintOptionPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a panel.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintPanelBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a panel.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintPanelBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a password field.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintPasswordFieldBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a password field.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintPasswordFieldBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a popup menu.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintPopupMenuBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a popup menu.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintPopupMenuBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a progress bar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintProgressBarBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a progress bar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintProgressBarBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a radio button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintRadioButtonBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a radio button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintRadioButtonBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a radio button menu item.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintRadioButtonMenuItemBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a radio button menu item.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintRadioButtonMenuItemBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a root pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintRootPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a root pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintRootPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a scrollbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintScrollBarBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a scrollbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintScrollBarBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a scrollbar's thumb.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param orientation orientation of the scrollbar
+ */
+ public void paintScrollBarThumbBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int orientation)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a scrollbar's thumb.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param orientation orientation of the scrollbar
+ */
+ public void paintScrollBarThumbBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int orientation)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a scrollbar's track.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintScrollBarTrackBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a scrollbar's track.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintScrollBarTrackBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a scroll pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintScrollPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a scroll pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintScrollPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a separator.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSeparatorBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a separator.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSeparatorBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a slider.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSliderBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a slider.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSliderBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a slider's thumb.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param orientation orientation of the slider
+ */
+ public void paintSliderThumbBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int orientation)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a slider's thumb.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param orientation orientation of the slider
+ */
+ public void paintSliderThumbBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int orientation)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a slider's track.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSliderTrackBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a slider's track.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSliderTrackBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a spinner.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSpinnerBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a spinner.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSpinnerBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a split pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSplitPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a split pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSplitPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a split pane's divider.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintSplitPaneDividerBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTabbedPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTabbedPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of the contents of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTabbedPaneContentBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of the contents of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTabbedPaneContentBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of the tab area of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTabbedPaneTabAreaBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of the tab area of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTabbedPaneTabAreaBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a tab of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param index the index of the tab to paint
+ */
+ public void paintTabbedPaneTabBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int index)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a tab of a tabbed pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ * @param index the index of the tab to paint
+ */
+ public void paintTabbedPaneTabBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h, int index)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a table.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTableBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a table.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTableBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a table's header.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTableHeaderBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a table's header.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTableHeaderBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a text area.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTextAreaBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a text area.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTextAreaBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a text field.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTextFieldBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a text field.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTextFieldBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a text pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTextPaneBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a text pane.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTextPaneBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a toggle button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToggleButtonBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a toggle button.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToggleButtonBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a toolbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolBarBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a toolbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolBarBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of the contents of a toolbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolBarContentBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of the contents of a toolbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolBarContentBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of the window of a detached toolbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolBarDragWindowBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of the window of a detached toolbar.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolBarDragWindowBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a tool tip.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolTipBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a tool tip.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintToolTipBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a tree.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTreeBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a tree.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTreeBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a cell in a tree.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTreeCellBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a cell in a tree.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintTreeCellBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the background of a viewport.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintViewportBackground(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Paints the border of a viewport.
+ *
+ * @param ctx the synth context identifying the component and region for
+ * painting
+ * @param g the graphics context to use for painting
+ * @param x the X coordinate of the area to paint
+ * @param y the Y coordinate of the area to paint
+ * @param w the width of the area to paint
+ * @param h the height of the area to paint
+ */
+ public void paintViewportBorder(SynthContext ctx, Graphics g, int x,
+ int y, int w, int h)
+ {
+ // Nothing to do here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyle.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyle.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyle.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyle.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,203 @@
+/* SynthStyle.java -- A set of style properties
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Insets;
+
+import javax.swing.Icon;
+
+/**
+ * A set of style properties that can be installed on a component.
+ *
+ * @author Roman Kennke (kennke at aicas.com)
+ *
+ * @since 1.5
+ */
+public abstract class SynthStyle
+{
+
+ /**
+ * Creates a new <code>SynthStyle</code> object.
+ */
+ public SynthStyle()
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ }
+
+ public SynthGraphicsUtils getGraphicsUtils(SynthContext ctx)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return null;
+ }
+
+ public Color getColor(SynthContext ctx, ColorType type)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return null;
+ }
+
+ protected abstract Color getColorForState(SynthContext ctx, ColorType type);
+
+ public Font getFont(SynthContext ctx)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return null;
+ }
+
+ protected abstract Font getFontForState(SynthContext ctx);
+
+ public Insets getInsets(SynthContext ctx, Insets result)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return null;
+ }
+
+ public SynthPainter getPainter(SynthContext ctx)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return null;
+ }
+
+ public boolean isOpaque(SynthContext ctx)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return true;
+ }
+
+ public Object get(SynthContext ctx, Object key)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ return null;
+ }
+
+ public void installDefaults(SynthContext ctx)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ }
+
+ public void uninstallDefaults(SynthContext ctx)
+ throws NotImplementedException
+ {
+ // FIXME: Implement this correctly.
+ }
+
+ /**
+ * A convenience method to fetch an integer property.
+ * If the property's value is a {@link Number}, then the
+ * integer value is returned. Otherwise, the default value
+ * is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @param defaultValue the default value
+ * @return the integer value of the property, or the default value
+ */
+ public int getInt(SynthContext ctx, Object key, int defaultValue)
+ {
+ Object obj = get(ctx, key);
+ if (obj instanceof Number)
+ return ((Number) obj).intValue();
+ return defaultValue;
+ }
+
+ /**
+ * A convenience method to fetch an integer property.
+ * If the property's value is a {@link Boolean}, then the
+ * value is returned. Otherwise, the default value
+ * is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @param defaultValue the default value
+ * @return the boolean value of the property, or the default value
+ */
+ public boolean getBoolean(SynthContext ctx, Object key,
+ boolean defaultValue)
+ {
+ Object obj = get(ctx, key);
+ if (obj instanceof Boolean)
+ return ((Boolean) obj).booleanValue();
+ return defaultValue;
+ }
+
+ /**
+ * A convenience method to fetch an Icon-valued property.
+ * If the property's value is an {@link Icon}, then the
+ * value is returned. Otherwise, null is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @return the icon, or null
+ */
+ public Icon getIcon(SynthContext ctx, Object key)
+ {
+ Object obj = get(ctx, key);
+ if (key instanceof Icon)
+ return (Icon) obj;
+ return null;
+ }
+
+ /**
+ * A convenience method to fetch a String property.
+ * If the property's value is a {@link String}, then the
+ * value is returned. Otherwise, the default value
+ * is returned.
+ * @param ctx the context
+ * @param key the key to fetch
+ * @param defaultValue the default value
+ * @return the String value of the property, or the default value
+ */
+ public String getString(SynthContext ctx, Object key, String defaultValue)
+ {
+ Object obj = get(ctx, key);
+ if (obj instanceof String)
+ return (String) obj;
+ return defaultValue;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyleFactory.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyleFactory.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyleFactory.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/SynthStyleFactory.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* SynthStyleFactory.java -- A factory for SynthStyles
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.synth;
+
+import javax.swing.JComponent;
+
+public abstract class SynthStyleFactory
+{
+
+ /**
+ * Creates a new <code>SynthStyleFactory</code>.
+ */
+ public SynthStyleFactory()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns a {@link SynthStyle} for the specified region of the specified
+ * component.
+ *
+ * @param c the component for which to create a style
+ * @param id the region of the component
+ *
+ * @return a style for the specified region of the specified component
+ */
+ public abstract SynthStyle getStyle(JComponent c, Region id);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/plaf/synth/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.plaf.metal package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.plaf.synth</title></head>
+
+<body>
+<p>Provides a look and feel that can be customized by and XML file or by
+ providing a custom {@link SynthStyleFactory}.
+</p>
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/AbstractTableModel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/AbstractTableModel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/AbstractTableModel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/AbstractTableModel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,301 @@
+/* AbstractTableModel.java --
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.table;
+
+import java.io.Serializable;
+import java.util.EventListener;
+
+import javax.swing.event.EventListenerList;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+/**
+ * A base class that can be used to create implementations of the
+ * {@link TableModel} interface.
+ *
+ * @author Andrew Selkirk
+ */
+public abstract class AbstractTableModel implements TableModel, Serializable
+{
+ static final long serialVersionUID = -5798593159423650347L;
+
+ /**
+ * Storage for the listeners registered with this model.
+ */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * Creates a default instance.
+ */
+ public AbstractTableModel()
+ {
+ // no setup required here
+ }
+
+ /**
+ * Returns the name of the specified column. This method generates default
+ * names in a sequence (starting with column 0): A, B, C, ..., Z, AA, AB,
+ * AC, ..., AZ, BA, BB, BC, and so on. Subclasses may override this method
+ * to allow column names to be specified on some other basis.
+ *
+ * @param columnIndex the column index.
+ *
+ * @return The name of the column.
+ */
+ public String getColumnName(int columnIndex)
+ {
+ StringBuffer buffer = new StringBuffer();
+ while (columnIndex >= 0)
+ {
+ buffer.insert(0, (char) ('A' + columnIndex % 26));
+ columnIndex = columnIndex / 26 - 1;
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Return the index of the specified column, or <code>-1</code> if there is
+ * no column with the specified name.
+ *
+ * @param columnName the name of the column (<code>null</code> not permitted).
+ *
+ * @return The index of the column, -1 if not found.
+ *
+ * @see #getColumnName(int)
+ * @throws NullPointerException if <code>columnName</code> is
+ * <code>null</code>.
+ */
+ public int findColumn(String columnName)
+ {
+ int count = getColumnCount();
+
+ for (int index = 0; index < count; index++)
+ {
+ String name = getColumnName(index);
+
+ if (columnName.equals(name))
+ return index;
+ }
+
+ // Unable to locate.
+ return -1;
+ }
+
+ /**
+ * Returns the <code>Class</code> for all <code>Object</code> instances
+ * in the specified column.
+ *
+ * @param columnIndex the column index.
+ *
+ * @return The class.
+ */
+ public Class getColumnClass(int columnIndex)
+ {
+ return Object.class;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified cell is editable, and
+ * <code>false</code> if it is not. This implementation returns
+ * <code>false</code> for all arguments, subclasses should override the
+ * method if necessary.
+ *
+ * @param rowIndex the row index of the cell.
+ * @param columnIndex the column index of the cell.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isCellEditable(int rowIndex, int columnIndex)
+ {
+ return false;
+ }
+
+ /**
+ * Sets the value of the given cell. This implementation ignores all
+ * arguments and does nothing, subclasses should override the
+ * method if necessary.
+ *
+ * @param value the new value (<code>null</code> permitted).
+ * @param rowIndex the row index of the cell.
+ * @param columnIndex the column index of the cell.
+ */
+ public void setValueAt(Object value, int rowIndex, int columnIndex)
+ {
+ // Do nothing...
+ }
+
+ /**
+ * Adds a listener to the table model. The listener will receive notification
+ * of all changes to the table model.
+ *
+ * @param listener the listener.
+ */
+ public void addTableModelListener(TableModelListener listener)
+ {
+ listenerList.add(TableModelListener.class, listener);
+ }
+
+ /**
+ * Removes a listener from the table model so that it will no longer receive
+ * notification of changes to the table model.
+ *
+ * @param listener the listener to remove.
+ */
+ public void removeTableModelListener(TableModelListener listener)
+ {
+ listenerList.remove(TableModelListener.class, listener);
+ }
+
+ /**
+ * Returns an array containing the listeners that have been added to the
+ * table model.
+ *
+ * @return Array of {@link TableModelListener} objects.
+ *
+ * @since 1.4
+ */
+ public TableModelListener[] getTableModelListeners()
+ {
+ return (TableModelListener[])
+ listenerList.getListeners(TableModelListener.class);
+ }
+
+ /**
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that the table data has changed.
+ */
+ public void fireTableDataChanged()
+ {
+ fireTableChanged(new TableModelEvent(this, 0, Integer.MAX_VALUE));
+ }
+
+ /**
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that the table structure has changed.
+ */
+ public void fireTableStructureChanged()
+ {
+ fireTableChanged(new TableModelEvent(this, TableModelEvent.HEADER_ROW));
+ }
+
+ /**
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that some rows have been inserted into the model.
+ *
+ * @param firstRow the index of the first row.
+ * @param lastRow the index of the last row.
+ */
+ public void fireTableRowsInserted(int firstRow, int lastRow)
+ {
+ fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
+ TableModelEvent.ALL_COLUMNS,
+ TableModelEvent.INSERT));
+ }
+
+ /**
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that some rows have been updated.
+ *
+ * @param firstRow the index of the first row.
+ * @param lastRow the index of the last row.
+ */
+ public void fireTableRowsUpdated(int firstRow, int lastRow)
+ {
+ fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
+ TableModelEvent.ALL_COLUMNS,
+ TableModelEvent.UPDATE));
+ }
+
+ /**
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that some rows have been deleted from the model.
+ *
+ * @param firstRow the index of the first row.
+ * @param lastRow the index of the last row.
+ */
+ public void fireTableRowsDeleted(int firstRow, int lastRow)
+ {
+ fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
+ TableModelEvent.ALL_COLUMNS,
+ TableModelEvent.DELETE));
+ }
+
+ /**
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that a single cell has been updated.
+ *
+ * @param row the row index.
+ * @param column the column index.
+ */
+ public void fireTableCellUpdated(int row, int column)
+ {
+ fireTableChanged(new TableModelEvent(this, row, row, column));
+ }
+
+ /**
+ * Sends the specified event to all registered listeners.
+ *
+ * @param event the event to send.
+ */
+ public void fireTableChanged(TableModelEvent event)
+ {
+ int index;
+ TableModelListener listener;
+ Object[] list = listenerList.getListenerList();
+
+ for (index = 0; index < list.length; index += 2)
+ {
+ listener = (TableModelListener) list [index + 1];
+ listener.tableChanged(event);
+ }
+ }
+
+ /**
+ * Returns an array of listeners of the given type that are registered with
+ * this model.
+ *
+ * @param listenerType the listener class.
+ *
+ * @return An array of listeners (possibly empty).
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/DefaultTableCellRenderer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/DefaultTableCellRenderer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/DefaultTableCellRenderer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/javax/swing/table/DefaultTableCellRenderer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,277 @@
+/* DefaultTableCellRenderer.java --
+ Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.table;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Rectangle;
+import java.io.Serializable;
+
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+
+/**
+ * Class to display every cells.
+ */
+public class DefaultTableCellRenderer extends JLabel
+ implements TableCellRenderer, Serializable
+{
+ static final long serialVersionUID = 7878911414715528324L;
+
+ protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
+
+ public static class UIResource extends DefaultTableCellRenderer
+ implements javax.swing.plaf.UIResource
+ {
+ public UIResource()
+ {
+ super();
+ }
+ }
+
+ /**
+ * Stores the color set by setForeground().
+ */
+ Color foreground;
+
+ /**
+ * Stores the color set by setBackground().
+ */
+ Color background;
+
+ /**
+ * Creates a default table cell renderer with an empty border.
+ */
+ public DefaultTableCellRenderer()
+ {
+ super();
+ }
+
+ /**
+ * Assign the unselected-foreground.
+ *
+ * @param c the color to assign
+ */
+ public void setForeground(Color c)
+ {
+ super.setForeground(c);
+ foreground = c;
+ }
+
+ /**
+ * Assign the unselected-background.
+ *
+ * @param c the color to assign
+ */
+ public void setBackground(Color c)
+ {
+ super.setBackground(c);
+ background = c;
+ }
+
+ /**
+ * Look and feel has changed.
+ *
+ * <p>Replaces the current UI object with the latest version from
+ * the UIManager.</p>
+ */
+ public void updateUI()
+ {
+ super.updateUI();
+ background = null;
+ foreground = null;
+ }
+
+ /**
+ * Get the string value of the object and pass it to setText().
+ *
+ * @param table the JTable
+ * @param value the value of the object. For the text content,
+ * null is rendered as an empty cell.
+ * @param isSelected is the cell selected?
+ * @param hasFocus has the cell the focus?
+ * @param row the row to render
+ * @param column the cell to render
+ *
+ * @return this component (the default table cell renderer)
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row, int column)
+ {
+ setValue(value);
+ setOpaque(true);
+
+ if (table == null)
+ return this;
+
+ if (isSelected)
+ {
+ super.setBackground(table.getSelectionBackground());
+ super.setForeground(table.getSelectionForeground());
+ }
+ else
+ {
+ if (background != null)
+ super.setBackground(background);
+ else
+ super.setBackground(table.getBackground());
+ if (foreground != null)
+ super.setForeground(foreground);
+ else
+ super.setForeground(table.getForeground());
+ }
+
+ Border b = null;
+ if (hasFocus)
+ {
+ if (isSelected)
+ b = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
+ if (b == null)
+ b = UIManager.getBorder("Table.focusCellHighlightBorder");
+ }
+ else
+ b = noFocusBorder;
+ setBorder(b);
+
+ setFont(table.getFont());
+
+ // If the current background is equal to the table's background, then we
+ // can avoid filling the background by setting the renderer opaque.
+ Color back = getBackground();
+ setOpaque(back != null && back.equals(table.getBackground()));
+
+ return this;
+ }
+
+ /**
+ * Overriden for performance.
+ *
+ * <p>This method needs to be overridden in a subclass to actually
+ * do something.</p>
+ *
+ * @return always true
+ */
+ public boolean isOpaque()
+ {
+ return true;
+ }
+
+ /**
+ * Overriden for performance.
+ *
+ * <p>This method needs to be overridden in a subclass to actually
+ * do something.</p>
+ */
+ public void validate()
+ {
+ // Does nothing.
+ }
+
+ public void revalidate()
+ {
+ // Does nothing.
+ }
+
+ /**
+ * Overriden for performance.
+ *
+ * <p>This method needs to be overridden in a subclass to actually
+ * do something.</p>
+ */
+ public void repaint(long tm, int x, int y, int width, int height)
+ {
+ // Does nothing.
+ }
+
+ /**
+ * Overriden for performance.
+ *
+ * <p>This method needs to be overridden in a subclass to actually
+ * do something.</p>
+ */
+ public void repaint(Rectangle r)
+ {
+ // Does nothing.
+ }
+
+ /**
+ * Overriden for performance.
+ *
+ * <p>This method needs to be overridden in a subclass to actually
+ * do something.</p>
+ */
+ protected void firePropertyChange(String propertyName, Object oldValue,
+ Object newValue)
+ {
+ // Does nothing.
+ }
+
+ /**
+ * Overriden for performance.
+ *
+ * <p>This method needs to be overridden in a subclass to actually
+ * do something.</p>
+ */
+ public void firePropertyChange(String propertyName, boolean oldValue,
+ boolean newValue)
+ {
+ // Does nothing.
+ }
+
+ /**
+ * Sets the String for this cell.
+ *
+ * @param value the string value for this cell; if value is null it
+ * sets the text value to an empty string
+ */
+ protected void setValue(Object value)
+ {
+ if (value != null)
+ setText(value.toString());
+ else
+ // null is rendered as an empty cell.
+ setText("");
+ }
+}
More information about the llvm-commits
mailing list