From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../javax/swing/plaf/multi/MultiButtonUI.java | 352 ++++++++++++ .../swing/plaf/multi/MultiColorChooserUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiComboBoxUI.java | 430 ++++++++++++++ .../javax/swing/plaf/multi/MultiDesktopIconUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiDesktopPaneUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiFileChooserUI.java | 511 +++++++++++++++++ .../swing/plaf/multi/MultiInternalFrameUI.java | 353 ++++++++++++ .../javax/swing/plaf/multi/MultiLabelUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiListUI.java | 449 +++++++++++++++ .../javax/swing/plaf/multi/MultiLookAndFeel.java | 243 ++++++++ .../javax/swing/plaf/multi/MultiMenuBarUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiMenuItemUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiOptionPaneUI.java | 398 +++++++++++++ .../javax/swing/plaf/multi/MultiPanelUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiPopupMenuUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiProgressBarUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiRootPaneUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiScrollBarUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiScrollPaneUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiSeparatorUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiSliderUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiSpinnerUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiSplitPaneUI.java | 494 ++++++++++++++++ .../javax/swing/plaf/multi/MultiTabbedPaneUI.java | 447 +++++++++++++++ .../javax/swing/plaf/multi/MultiTableHeaderUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiTableUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiTextUI.java | 617 ++++++++++++++++++++ .../javax/swing/plaf/multi/MultiToolBarUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiToolTipUI.java | 352 ++++++++++++ .../javax/swing/plaf/multi/MultiTreeUI.java | 628 +++++++++++++++++++++ .../javax/swing/plaf/multi/MultiViewportUI.java | 352 ++++++++++++ .../classpath/javax/swing/plaf/multi/package.html | 46 ++ 32 files changed, 12008 insertions(+) create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiListUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java create mode 100644 libjava/classpath/javax/swing/plaf/multi/package.html (limited to 'libjava/classpath/javax/swing/plaf/multi') diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java new file mode 100644 index 000000000..044f65141 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiButtonUI.java @@ -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 MultiButtonUI 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 MultiButtonUI 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 MultiButtonUI. + * + * @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 MultiButtonUI. + * + * @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 + * MultiButtonUI. 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 MultiButtonUI, + * 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 true 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 false 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 MultiButtonUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiButtonUI. + * + * @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 MultiButtonUI, + * 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 MultiButtonUI, + * 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 MultiButtonUI, + * 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 MultiButtonUI, + * 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 MultiButtonUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java new file mode 100644 index 000000000..1a9684928 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiColorChooserUI.java @@ -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 MultiColorChooserUI 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 MultiColorChooserUI + * 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 MultiColorChooserUI. + * + * @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 MultiColorChooserUI. + * + * @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 + * MultiColorChooserUI. 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 MultiColorChooserUI, + * 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 true 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 false 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 MultiColorChooserUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiColorChooserUI. + * + * @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 MultiColorChooserUI, + * 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 MultiColorChooserUI, + * 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 MultiColorChooserUI, + * 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 MultiColorChooserUI, + * 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 MultiColorChooserUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java new file mode 100644 index 000000000..f16987399 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java @@ -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 MultiComboBoxUI 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 MultiComboBoxUI + * 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 MultiComboBoxUI. + * + * @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 MultiComboBoxUI. + * + * @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 + * MultiComboBoxUI. 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 MultiComboBoxUI, + * 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 true 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 false 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 MultiComboBoxUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiComboBoxUI. + * + * @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 MultiComboBoxUI, + * 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 MultiComboBoxUI, + * 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 MultiComboBoxUI, + * 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 MultiComboBoxUI, + * 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 MultiComboBoxUI, + * 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 MultiComboBoxUI. + * + * @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 MultiComboBoxUI, + * 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 MultiComboBoxUI, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return true if the combo box is traversable according to the + * UI delegate in the primary look and feel, and false + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java new file mode 100644 index 000000000..091566ecf --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiDesktopIconUI.java @@ -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 MultiDesktopIconUI 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 MultiDesktopIconUI 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 MultiDesktopIconUI. + * + * @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 MultiDesktopIconUI. + * + * @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 + * MultiDesktopIconUI. 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 MultiDesktopIconUI, + * 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 true 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 false 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 MultiDesktopIconUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiDesktopIconUI. + * + * @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 MultiDesktopIconUI, + * 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 MultiDesktopIconUI, + * 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 MultiDesktopIconUI, + * 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 MultiDesktopIconUI, + * 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 MultiDesktopIconUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java new file mode 100644 index 000000000..fb62257b8 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiDesktopPaneUI.java @@ -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 MultiDesktopPaneUI 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 MultiDesktopPaneUI 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 MultiDesktopPaneUI. + * + * @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 MultiDesktopPaneUI. + * + * @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 + * MultiDesktopPaneUI. 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 MultiDesktopPaneUI, + * 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 true 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 false 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 MultiDesktopPaneUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiDesktopPaneUI. + * + * @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 MultiDesktopPaneUI, + * 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 MultiDesktopPaneUI, + * 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 MultiDesktopPaneUI, + * 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 MultiDesktopPaneUI, + * 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 MultiDesktopPaneUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java new file mode 100644 index 000000000..2ab8841f9 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java @@ -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 MultiFileChooserUI 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 MultiFileChooserUI 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 MultiFileChooserUI. + * + * @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 MultiFileChooserUI. + * + * @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 + * MultiFileChooserUI. 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 MultiFileChooserUI, + * 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 true 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 false 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 MultiFileChooserUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiFileChooserUI. + * + * @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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 MultiFileChooserUI, + * 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 + * MultiFileChooserUI. + * + * @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 + * MultiFileChooserUI. + * + * @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); + } + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java new file mode 100644 index 000000000..37b2ee3af --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiInternalFrameUI.java @@ -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 MultiInternalFrameUI 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 MultiInternalFrameUI + * 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 MultiInternalFrameUI. + * + * @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 MultiInternalFrameUI. + * + * @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 + * MultiInternalFrameUI. 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 MultiInternalFrameUI, + * 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 true 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 false 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 MultiInternalFrameUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiInternalFrameUI. + * + * @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 MultiInternalFrameUI, + * 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 MultiInternalFrameUI, + * 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 MultiInternalFrameUI, + * 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 MultiInternalFrameUI, + * 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 MultiInternalFrameUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java new file mode 100644 index 000000000..2f0e7d06e --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiLabelUI.java @@ -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 MultiLabelUI 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 MultiLabelUI 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 MultiLabelUI. + * + * @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 MultiLabelUI. + * + * @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 + * MultiLabelUI. 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 MultiLabelUI, + * 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 true 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 false 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 MultiLabelUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiLabelUI. + * + * @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 MultiLabelUI, + * 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 MultiLabelUI, + * 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 MultiLabelUI, + * 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 MultiLabelUI, + * 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 MultiLabelUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java new file mode 100644 index 000000000..d6b77f5b4 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java @@ -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 MultiListUI 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 MultiListUI 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 MultiListUI. + * + * @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 MultiListUI. + * + * @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 + * MultiListUI. 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 MultiListUI, + * 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 true 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 false 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 MultiListUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiListUI. + * + * @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 MultiListUI, + * 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 MultiListUI, + * 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 MultiListUI, + * 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 MultiListUI, + * 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 MultiListUI, + * 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 MultiListUI, + * 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 MultiListUI, + * 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 MultiListUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java b/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java new file mode 100644 index 000000000..4e81fd054 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java @@ -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 false to indicate that this look and feel is not + * native to any platform. + * + * @return false. + */ + public boolean isNativeLookAndFeel() + { + return false; + } + + /** + * Returns true always, since this look and feel is supported on + * all platforms. + * + * @return true. + */ + 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 target component and + * returns a multiplexing UI delegate (mui) 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 + * uis. If uis is null, a zero-length + * array is returned. + * + * @param uis a list of {@link ComponentUI} references (null + * permitted). + * + * @return An array containing the same {@link ComponentUI} instances as + * uis, or null if uis 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java new file mode 100644 index 000000000..5b43f6bd8 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiMenuBarUI.java @@ -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 MultiMenuBarUI 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 MultiMenuBarUI 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 MultiMenuBarUI. + * + * @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 MultiMenuBarUI. + * + * @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 + * MultiMenuBarUI. 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 MultiMenuBarUI, + * 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 true 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 false 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 MultiMenuBarUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiMenuBarUI. + * + * @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 MultiMenuBarUI, + * 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 MultiMenuBarUI, + * 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 MultiMenuBarUI, + * 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 MultiMenuBarUI, + * 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 MultiMenuBarUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java new file mode 100644 index 000000000..6d361b086 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiMenuItemUI.java @@ -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 MultiMenuItemUI 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 MultiItemUI 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 MultiMenuItemUI. + * + * @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 MultiMenuItemUI. + * + * @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 + * MultiMenuItemUI. 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 MultiMenuItemUI, + * 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 true 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 false 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 MultiMenuItemUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiMenuItemUI. + * + * @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 MultiMenuItemUI, + * 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 MultiMenuItemUI, + * 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 MultiMenuItemUI, + * 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 MultiMenuItemUI, + * 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 MultiMenuItemUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java new file mode 100644 index 000000000..eaa4a4257 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java @@ -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 MultiOptionPaneUI 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 MultiOptionPaneUI 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 MultiOptionPaneUI. + * + * @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 MultiOptionPaneUI. + * + * @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 + * MultiOptionPaneUI. 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 MultiOptionPaneUI, + * 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 true 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 false 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 MultiOptionPaneUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiOptionPaneUI. + * + * @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 MultiOptionPaneUI, + * 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 MultiOptionPaneUI, + * 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 MultiOptionPaneUI, + * 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 MultiOptionPaneUI, + * 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 MultiOptionPaneUI, + * 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 MultiOptionPaneUI. + * + * @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 + * MultiOptionPaneUI, 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java new file mode 100644 index 000000000..7b84599d0 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiPanelUI.java @@ -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 MultiPanelUI 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 MultiPanelUI 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 MultiPanelUI. + * + * @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 MultiPanelUI. + * + * @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 + * MultiPanelUI. 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 MultiPanelUI, + * 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 true 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 false 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 MultiPanelUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiPanelUI. + * + * @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 MultiPanelUI, + * 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 MultiPanelUI, + * 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 MultiPanelUI, + * 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 MultiPanelUI, + * 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 MultiPanelUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java new file mode 100644 index 000000000..0afaaf74e --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiPopupMenuUI.java @@ -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 MultiPopupMenuUI 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 MultiPopupMenuUI 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 MultiPopupMenuUI. + * + * @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 MultiPopupMenuUI. + * + * @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 + * MultiPopupMenuUI. 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 MultiPopupMenuUI, + * 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 true 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 false 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 MultiPopupMenuUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiPopupMenuUI. + * + * @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 MultiPopupMenuUI, + * 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 MultiPopupMenuUI, + * 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 MultiPopupMenuUI, + * 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 MultiPopupMenuUI, + * 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 MultiPopupMenuUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java new file mode 100644 index 000000000..0395bdd2d --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiProgressBarUI.java @@ -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 MultiProgressBarUI 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 MultiProgressBarUI 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 MultiProgressBarUI. + * + * @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 MultiProgressBarUI. + * + * @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 + * MultiProgressBarUI. 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 MultiProgressBarUI, + * 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 true 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 false 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 MultiProgressBarUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiProgressBarUI. + * + * @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 MultiProgressBarUI, + * 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 MultiProgressBarUI, + * 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 MultiProgressBarUI, + * 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 MultiProgressBarUI, + * 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 MultiProgressBarUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java new file mode 100644 index 000000000..69c7ffe1b --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiRootPaneUI.java @@ -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 MultiRootPanelUI 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 MultiRootPaneUI 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 MultiRootPaneUI. + * + * @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 MultiRootPaneUI. + * + * @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 + * MultiRootPaneUI. 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 MultiRootPaneUI, + * 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 true 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 false 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 MultiRootPaneUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiRootPaneUI. + * + * @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 MultiRootPaneUI, + * 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 MultiRootPaneUI, + * 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 MultiRootPaneUI, + * 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 MultiRootPaneUI, + * 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 MultiRootPaneUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java new file mode 100644 index 000000000..4ec8b3fca --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiScrollBarUI.java @@ -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 MultiScrollBarUI 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 MultiScrollBarUI 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 MultiScrollBarUI. + * + * @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 MultiScrollBarUI. + * + * @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 + * MultiScrollBarUI. 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 MultiScrollBarUI, + * 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 true 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 false 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 MultiScrollBarUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiScrollBarUI. + * + * @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 MultiScrollBarUI, + * 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 MultiScrollBarUI, + * 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 MultiScrollBarUI, + * 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 MultiScrollBarUI, + * 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 MultiScrollBarUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java new file mode 100644 index 000000000..5a0bc1ebf --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiScrollPaneUI.java @@ -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 MultiScrollPaneUI 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 MultiScrollPaneUI 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 MultiScrollPaneUI. + * + * @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 MultiScrollPaneUI. + * + * @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 + * MultiScrollPaneUI. 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 MultiScrollPaneUI, + * 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 true 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 false 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 MultiScrollPaneUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiScrollPaneUI. + * + * @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 MultiScrollPaneUI, + * 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 MultiScrollPaneUI, + * 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 MultiScrollPaneUI, + * 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 MultiScrollPaneUI, + * 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 MultiScrollPaneUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java new file mode 100644 index 000000000..fbd9712fe --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiSeparatorUI.java @@ -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 MultiSeparatorUI 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 MultiSeparatorUI 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 MultiSeparatorUI. + * + * @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 MultiSeparatorUI. + * + * @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 + * MultiSeparatorUI. 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 MultiSeparatorUI, + * 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 true 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 false 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 MultiSeparatorUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiSeparatorUI. + * + * @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 MultiSeparatorUI, + * 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 MultiSeparatorUI, + * 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 MultiSeparatorUI, + * 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 MultiSeparatorUI, + * 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 MultiSeparatorUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java new file mode 100644 index 000000000..cb896c547 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiSliderUI.java @@ -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 MultiSliderUI 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 MultiSliderUI 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 MultiSliderUI. + * + * @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 MultiSliderUI. + * + * @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 + * MultiSliderUI. 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 MultiSliderUI, + * 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 true 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 false 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 MultiSliderUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiSliderUI. + * + * @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 MultiSliderUI, + * 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 MultiSliderUI, + * 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 MultiSliderUI, + * 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 MultiSliderUI, + * 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 MultiSliderUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java new file mode 100644 index 000000000..fd805f9cb --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiSpinnerUI.java @@ -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 MultiSpinnerUI 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 MultiSpinnerUI 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 MultiSpinnerUI. + * + * @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 MultiSpinnerUI. + * + * @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 + * MultiSpinnerUI. 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 MultiSpinnerUI, + * 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 true 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 false 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 MultiSpinnerUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiSpinnerUI. + * + * @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 MultiSpinnerUI, + * 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 MultiSpinnerUI, + * 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 MultiSpinnerUI, + * 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 MultiSpinnerUI, + * 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 MultiSpinnerUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java new file mode 100644 index 000000000..1eb2e41f5 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java @@ -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 MultiSplitPaneUI 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 MultiSplitPaneUI 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 MultiSplitPaneUI. + * + * @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 MultiSplitPaneUI. + * + * @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 + * MultiSplitPaneUI. 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 MultiSplitPaneUI, + * 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 true 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 false 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 MultiSplitPaneUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiSplitPaneUI. + * + * @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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI. + * + * @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 MultiSplitPaneUI. + * + * @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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI, + * 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 MultiSplitPaneUI, + * 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 + * MultiSplitPaneUI. + * + * @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); + } + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java new file mode 100644 index 000000000..3f9d22af4 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java @@ -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 MultiTabbedPaneUI 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 MultiTabbedPaneUI 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 MultiTabbedPaneUI. + * + * @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 MultiTabbedPaneUI. + * + * @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 + * MultiTabbedPaneUI. 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 MultiTabbedPaneUI, + * 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 true 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 false 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 MultiTabbedPaneUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiTabbedPaneUI. + * + * @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 MultiTabbedPaneUI, + * 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 MultiTabbedPaneUI, + * 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 MultiTabbedPaneUI, + * 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 MultiTabbedPaneUI, + * 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 MultiTabbedPaneUI, + * 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 + * MultiTabbedPaneUI, 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 + * MultiTabbedPaneUI, 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 + * MultiTabbedPaneUI, 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java new file mode 100644 index 000000000..972303bec --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiTableHeaderUI.java @@ -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 MultiTableHeaderUI 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 MultiTableHeaderUI 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 MultiTableHeaderUI. + * + * @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 MultiTableHeaderUI. + * + * @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 + * MultiTableHeaderUI. 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 MultiTableHeaderUI, + * 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 true 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 false 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 MultiTableHeaderUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiTableHeaderUI. + * + * @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 MultiTableHeaderUI, + * 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 MultiTableHeaderUI, + * 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 MultiTableHeaderUI, + * 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 MultiTableHeaderUI, + * 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 MultiTableHeaderUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java new file mode 100644 index 000000000..1cd1a4c88 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiTableUI.java @@ -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 MultiTableUI 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 MultiTableUI 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 MultiTableUI. + * + * @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 MultiTableUI. + * + * @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 + * MultiTableUI. 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 MultiTableUI, + * 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 true 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 false 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 MultiTableUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiTableUI. + * + * @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 MultiTableUI, + * 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 MultiTableUI, + * 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 MultiTableUI, + * 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 MultiTableUI, + * 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 MultiTableUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java new file mode 100644 index 000000000..392fd9811 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiTextUI.java @@ -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 MultiTextUI 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 MultiTextUI 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 MultiTextUI. + * + * @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 MultiTextUI. + * + * @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 + * MultiTextUI. 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 MultiTextUI, + * 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 true 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 false 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 MultiTextUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiTextUI. + * + * @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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI, + * 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 MultiTextUI. + * + * @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 MultiTextUI. + * + * @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 MultiTextUI, + * 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 MultiTextUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java new file mode 100644 index 000000000..5f308d991 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiToolBarUI.java @@ -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 MultiToolBarUI 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 MultiToolBarUI 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 MultiToolBarUI. + * + * @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 MultiToolBarUI. + * + * @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 + * MultiToolBarUI. 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 MultiToolBarUI, + * 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 true 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 false 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 MultiToolBarUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiToolBarUI. + * + * @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 MultiToolBarUI, + * 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 MultiToolBarUI, + * 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 MultiToolBarUI, + * 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 MultiToolBarUI, + * 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 MultiToolBarUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java new file mode 100644 index 000000000..9db9efb69 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiToolTipUI.java @@ -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 MultiToolTipUI 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 MultiToolTipUI 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 MultiToolTipUI. + * + * @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 MultiToolTipUI. + * + * @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 + * MultiToolTipUI. 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 MultiToolTipUI, + * 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 true 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 false 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 MultiToolTipUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiToolTipUI. + * + * @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 MultiToolTipUI, + * 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 MultiToolTipUI, + * 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 MultiToolTipUI, + * 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 MultiToolTipUI, + * 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 MultiToolTipUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java new file mode 100644 index 000000000..f70decc69 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiTreeUI.java @@ -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 MultiTreeUI 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 MultiTreeUI 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 MultiTreeUI. + * + * @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 MultiTreeUI. + * + * @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 + * MultiTreeUI. 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 MultiTreeUI, + * 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 true 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 false 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 MultiTreeUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiTreeUI. + * + * @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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI, + * 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 MultiTreeUI. + * + * @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 MultiTreeUI. + * + * @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 MultiTreeUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java new file mode 100644 index 000000000..55f9cba70 --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/MultiViewportUI.java @@ -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 MultiViewPortUI 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 MultiViewportUI 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 MultiViewportUI. + * + * @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 MultiViewportUI. + * + * @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 + * MultiViewportUI. 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 MultiViewportUI, + * 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 true 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 false 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 MultiViewportUI. + * + * @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 paint(Graphics, JComponent) method for all the UI + * delegates managed by this MultiViewportUI. + * + * @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 MultiViewportUI, + * 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 MultiViewportUI, + * 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 MultiViewportUI, + * 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 MultiViewportUI, + * 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 MultiViewportUI, + * 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; + } + +} diff --git a/libjava/classpath/javax/swing/plaf/multi/package.html b/libjava/classpath/javax/swing/plaf/multi/package.html new file mode 100644 index 000000000..568a7d0bf --- /dev/null +++ b/libjava/classpath/javax/swing/plaf/multi/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.swing.plaf.multi + + +

Provides a look and feel that can combine a primary look and feel with one or more auxiliary look and feels.

+ + + -- cgit v1.2.3