diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/javax/swing/plaf/multi | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/multi')
32 files changed, 12008 insertions, 0 deletions
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 <code>MultiButtonUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiButtonUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiButtonUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiButtonUI mui = new MultiButtonUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiButtonUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiButtonUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiButtonUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiButtonUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiButtonUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiColorChooserUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiColorChooserUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiColorChooserUI</code> + * is returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiColorChooserUI mui = new MultiColorChooserUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiColorChooserUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiColorChooserUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiColorChooserUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiColorChooserUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiColorChooserUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiComboBoxUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiComboBoxUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiComboBoxUI</code> + * is returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiComboBoxUI mui = new MultiComboBoxUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiComboBoxUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiComboBoxUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link ComboBoxUI#setPopupVisible(JComboBox, boolean)} method + * for all the UI delegates managed by this <code>MultiComboBoxUI</code>. + * + * @param c the component. + * @param visible the visible state. + */ + public void setPopupVisible(JComboBox c, boolean visible) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComboBoxUI ui = (ComboBoxUI) iterator.next(); + ui.setPopupVisible(c, visible); + } + } + + /** + * Calls the {@link ComboBoxUI#isPopupVisible(JComboBox)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The result for the UI delegate from the primary look and feel. + */ + public boolean isPopupVisible(JComboBox c) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComboBoxUI ui = (ComboBoxUI) iterator.next(); + result = ui.isPopupVisible(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComboBoxUI ui = (ComboBoxUI) iterator.next(); + /* boolean ignored = */ ui.isPopupVisible(c); + } + return result; + } + + /** + * Calls the {@link ComboBoxUI#isFocusTraversable(JComboBox)} method for all + * the UI delegates managed by this <code>MultiComboBoxUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return <code>true</code> if the combo box is traversable according to the + * UI delegate in the primary look and feel, and <code>false</code> + * otherwise. + */ + public boolean isFocusTraversable(JComboBox c) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComboBoxUI ui = (ComboBoxUI) iterator.next(); + result = ui.isFocusTraversable(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComboBoxUI ui = (ComboBoxUI) iterator.next(); + /* boolean ignored = */ ui.isFocusTraversable(c); + } + return result; + } + +} 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 <code>MultiDesktopIconUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiDesktopIconUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiDesktopIconUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiDesktopIconUI mui = new MultiDesktopIconUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiDesktopIconUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiDesktopIconUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopIconUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiDesktopPaneUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiDesktopPaneUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiDesktopPaneUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiDesktopPaneUI mui = new MultiDesktopPaneUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiDesktopPaneUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiDesktopPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiDesktopPaneUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiFileChooserUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiFileChooserUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiFileChooserUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiFileChooserUI mui = new MultiFileChooserUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiFileChooserUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiFileChooserUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link FileChooserUI#getAcceptAllFileFilter(JFileChooser)} method + * for all the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the filter for the UI delegate from the primary look and + * feel. + * + * @param chooser the file chooser. + * + * @return The filter returned by the UI delegate from the primary + * look and feel. + */ + public FileFilter getAcceptAllFileFilter(JFileChooser chooser) + { + FileFilter result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + result = ui.getAcceptAllFileFilter(chooser); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + /* FileFilter ignored = */ ui.getAcceptAllFileFilter(chooser); + } + return result; + } + + /** + * Calls the {@link FileChooserUI#getFileView(JFileChooser)} method + * for all the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the view for the UI delegate from the primary look and + * feel. + * + * @param chooser the file chooser. + * + * @return The view returned by the UI delegate from the primary + * look and feel. + */ + public FileView getFileView(JFileChooser chooser) + { + FileView result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + result = ui.getFileView(chooser); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + /* FileView ignored = */ ui.getFileView(chooser); + } + return result; + } + + /** + * Calls the {@link FileChooserUI#getApproveButtonText(JFileChooser)} method + * for all the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the text for the UI delegate from the primary look and + * feel. + * + * @param chooser the file chooser. + * + * @return The text returned by the UI delegate from the primary + * look and feel. + */ + public String getApproveButtonText(JFileChooser chooser) + { + String result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + result = ui.getApproveButtonText(chooser); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + /* String ignored = */ ui.getApproveButtonText(chooser); + } + return result; + } + + /** + * Calls the {@link FileChooserUI#getDialogTitle(JFileChooser)} method + * for all the UI delegates managed by this <code>MultiFileChooserUI</code>, + * returning the title for the UI delegate from the primary look and + * feel. + * + * @param chooser the file chooser. + * + * @return The title returned by the UI delegate from the primary + * look and feel. + */ + public String getDialogTitle(JFileChooser chooser) + { + String result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + result = ui.getDialogTitle(chooser); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + /* String ignored = */ ui.getDialogTitle(chooser); + } + return result; + } + + /** + * Calls the {@link FileChooserUI#rescanCurrentDirectory(JFileChooser)} + * method for all the UI delegates managed by this + * <code>MultiFileChooserUI</code>. + * + * @param chooser the file chooser. + */ + public void rescanCurrentDirectory(JFileChooser chooser) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + ui.rescanCurrentDirectory(chooser); + } + } + + /** + * Calls the {@link FileChooserUI#ensureFileIsVisible(JFileChooser, File)} + * method for all the UI delegates managed by this + * <code>MultiFileChooserUI</code>. + * + * @param chooser the file chooser. + * @param file the file. + */ + public void ensureFileIsVisible(JFileChooser chooser, File file) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + FileChooserUI ui = (FileChooserUI) iterator.next(); + ui.ensureFileIsVisible(chooser, file); + } + } + +} 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 <code>MultiInternalFrameUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiInternalFrameUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiInternalFrameUI</code> + * is returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiInternalFrameUI mui = new MultiInternalFrameUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiInternalFrameUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiInternalFrameUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiInternalFrameUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiLabelUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiLabelUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiLabelUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiLabelUI mui = new MultiLabelUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiLabelUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiLabelUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiLabelUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiLabelUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiLabelUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiListUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiListUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiListUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiListUI mui = new MultiListUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiListUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiListUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiListUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiListUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiListUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiListUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiListUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link ListUI#locationToIndex(JList, Point)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the index for the UI delegate from the primary look and + * feel. + * + * @param list the list. + * @param location the location. + * + * @return The index returned by the UI delegate from the primary + * look and feel. + */ + public int locationToIndex(JList list, Point location) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ListUI ui = (ListUI) iterator.next(); + result = ui.locationToIndex(list, location); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ListUI ui = (ListUI) iterator.next(); + /* int ignored = */ ui.locationToIndex(list, location); + } + return result; + } + + /** + * Calls the {@link ListUI#indexToLocation(JList, int)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the location for the UI delegate from the primary look and + * feel. + * + * @param list the list. + * @param index the index. + * + * @return The location returned by the UI delegate from the primary + * look and feel. + */ + public Point indexToLocation(JList list, int index) + { + Point result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ListUI ui = (ListUI) iterator.next(); + result = ui.indexToLocation(list, index); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ListUI ui = (ListUI) iterator.next(); + /* Point ignored = */ ui.indexToLocation(list, index); + } + return result; + } + + /** + * Calls the {@link ListUI#getCellBounds(JList, int, int)} method for all + * the UI delegates managed by this <code>MultiListUI</code>, + * returning the bounds for the UI delegate from the primary look and + * feel. + * + * @param list the list. + * @param index1 the first index. + * @param index2 the second index. + * + * @return The bounds returned by the UI delegate from the primary + * look and feel. + */ + public Rectangle getCellBounds(JList list, int index1, int index2) + { + Rectangle result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ListUI ui = (ListUI) iterator.next(); + result = ui.getCellBounds(list, index1, index2); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ListUI ui = (ListUI) iterator.next(); + /* Rectangle ignored = */ ui.getCellBounds(list, index1, index2); + } + return result; + } + +} 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 <code>false</code> to indicate that this look and feel is not + * native to any platform. + * + * @return <code>false</code>. + */ + public boolean isNativeLookAndFeel() + { + return false; + } + + /** + * Returns <code>true</code> always, since this look and feel is supported on + * all platforms. + * + * @return <code>true</code>. + */ + public boolean isSupportedLookAndFeel() + { + return true; + } + + /** + * Creates and returns the UI defaults for this look and feel. + * + * @return The UI defaults. + */ + public UIDefaults getDefaults() + { + UIDefaults defaults = new UIDefaults(); + defaults.put("ButtonUI", "javax.swing.plaf.multi.MultiButtonUI"); + defaults.put("CheckBoxUI", "javax.swing.plaf.multi.MultiButtonUI"); + defaults.put("CheckBoxMenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI"); + defaults.put("ColorChooserUI", + "javax.swing.plaf.multi.MultiColorChooserUI"); + defaults.put("ComboBoxUI", "javax.swing.plaf.multi.MultiComboBoxUI"); + defaults.put("DesktopPaneUI", "javax.swing.plaf.multi.MultiDesktopPaneUI"); + defaults.put("DesktopIconUI", "javax.swing.plaf.multi.MultiDesktopIconUI"); + defaults.put("EditorPaneUI", "javax.swing.plaf.multi.MultiTextUI"); + defaults.put("FileChooserUI", "javax.swing.plaf.multi.MultiFileChooserUI"); + defaults.put("FormattedTextFieldUI", "javax.swing.plaf.multi.MultiTextUI"); + defaults.put("InternalFrameUI", + "javax.swing.plaf.multi.MultiInternalFrameUI"); + defaults.put("LabelUI", "javax.swing.plaf.multi.MultiLabelUI"); + defaults.put("ListUI", "javax.swing.plaf.multi.MultiListUI"); + defaults.put("MenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI"); + defaults.put("MenuUI", "javax.swing.plaf.multi.MultiMenuItemUI"); + defaults.put("MenuBarUI", "javax.swing.plaf.multi.MultiMenuBarUI"); + defaults.put("OptionPaneUI", "javax.swing.plaf.multi.MultiOptionPaneUI"); + defaults.put("PanelUI", "javax.swing.plaf.multi.MultiPanelUI"); + defaults.put("PasswordFieldUI", "javax.swing.plaf.multi.MultiTextUI"); + defaults.put("PopupMenuUI", "javax.swing.plaf.multi.MultiPopupMenuUI"); + defaults.put("PopupMenuSeparatorUI", + "javax.swing.plaf.multi.MultiSeparatorUI"); + defaults.put("ProgressBarUI", "javax.swing.plaf.multi.MultiProgressBarUI"); + defaults.put("RadioButtonUI", "javax.swing.plaf.multi.MultiButtonUI"); + defaults.put("RadioButtonMenuItemUI", + "javax.swing.plaf.multi.MultiMenuItemUI"); + defaults.put("RootPaneUI", "javax.swing.plaf.multi.MultiRootPaneUI"); + defaults.put("ScrollBarUI", "javax.swing.plaf.multi.MultiScrollBarUI"); + defaults.put("ScrollPaneUI", "javax.swing.plaf.multi.MultiScrollPaneUI"); + defaults.put("SeparatorUI", "javax.swing.plaf.multi.MultiSeparatorUI"); + defaults.put("SliderUI", "javax.swing.plaf.multi.MultiSliderUI"); + defaults.put("SpinnerUI", "javax.swing.plaf.multi.MultiSpinnerUI"); + defaults.put("SplitPaneUI", "javax.swing.plaf.multi.MultiSplitPaneUI"); + defaults.put("TabbedPaneUI", "javax.swing.plaf.multi.MultiTabbedPaneUI"); + defaults.put("TableHeaderUI", "javax.swing.plaf.multi.MultiTableHeaderUI"); + defaults.put("TableUI", "javax.swing.plaf.multi.MultiTableUI"); + defaults.put("TextAreaUI", "javax.swing.plaf.multi.MultiTextUI"); + defaults.put("TextFieldUI", "javax.swing.plaf.multi.MultiTextUI"); + defaults.put("TextPaneUI", "javax.swing.plaf.multi.MultiTextUI"); + defaults.put("ToggleButtonUI", "javax.swing.plaf.multi.MultiButtonUI"); + defaults.put("ToolBarSeparatorUI", + "javax.swing.plaf.multi.MultiSeparatorUI"); + defaults.put("ToolBarUI", "javax.swing.plaf.multi.MultiToolBarUI"); + defaults.put("ToolTipUI", "javax.swing.plaf.multi.MultiToolTipUI"); + defaults.put("ViewportUI", "javax.swing.plaf.multi.MultiViewportUI"); + return defaults; + } + + /** + * Creates the UI delegates for the <code>target</code> component and + * returns a multiplexing UI delegate (<code>mui</code>) if there are + * multiple delegates. + * + * @param mui a multiplexing UI delegate appropriate for the component. + * @param uis a vector into which the UI delegates will be added. + * @param target the target component. + * + * @return A UI delegate. + */ + public static ComponentUI createUIs(ComponentUI mui, Vector uis, + JComponent target) + { + // get primary UI delegate for 'target', and add it to uis + ComponentUI ui = null; + LookAndFeel primary = UIManager.getLookAndFeel(); + if (primary != null) + { + ui = UIManager.getUI(target); + uis.add(ui); + } + // for any auxiliary look and feels in use, get the UI delegate and add + // it to uis + LookAndFeel[] auxlafs = UIManager.getAuxiliaryLookAndFeels(); + for (int i = 0; i < auxlafs.length; i++) + { + LookAndFeel auxlaf = auxlafs[i]; + // FIXME: here I call getDefaults() to get the UI delegate from the + // auxiliary look and feel. But getDefaults() creates a new set of + // defaults every time it is called, which is wasteful. Unfortunately + // I cannot find another way to get the UI delegate, so I'm doing it + // anyway... + UIDefaults defaults = auxlaf.getDefaults(); + ui = defaults.getUI(target); + if (ui != null) + uis.add(ui); + } + // if uis contains more than 1 delegate, return mui, otherwise return + // the primary delegate + if (uis.size() > 1) + return mui; + else + return ui; + } + + /** + * Returns an array containing the same {@link ComponentUI} instances as + * <code>uis</code>. If <code>uis</code> is <code>null</code>, a zero-length + * array is returned. + * + * @param uis a list of {@link ComponentUI} references (<code>null</code> + * permitted). + * + * @return An array containing the same {@link ComponentUI} instances as + * <code>uis</code>, or <code>null</code> if <code>uis</code> is + * empty. + */ + protected static ComponentUI[] uisToArray(Vector uis) + { + if (uis == null) + return new ComponentUI[0]; + int size = uis.size(); + if (size == 0) + return null; + ComponentUI[] result = new ComponentUI[size]; + uis.copyInto(result); + return result; + } + +} 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 <code>MultiMenuBarUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiMenuBarUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiMenuBarUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiMenuBarUI mui = new MultiMenuBarUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiMenuBarUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiMenuBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuBarUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiMenuBarUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiMenuBarUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiMenuItemUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiMenuItemUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiItemUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiMenuItemUI mui = new MultiMenuItemUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiMenuItemUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiMenuItemUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiMenuItemUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiMenuItemUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiMenuItemUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiOptionPaneUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiOptionPaneUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiOptionPaneUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiOptionPaneUI mui = new MultiOptionPaneUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiOptionPaneUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiOptionPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiOptionPaneUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link OptionPaneUI#selectInitialValue(JOptionPane)} method for + * all the UI delegates managed by this <code>MultiOptionPaneUI</code>. + * + * @param pane the option pane. + */ + public void selectInitialValue(JOptionPane pane) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + OptionPaneUI ui = (OptionPaneUI) iterator.next(); + ui.selectInitialValue(pane); + } + } + + /** + * Calls the {@link OptionPaneUI#containsCustomComponents(JOptionPane)} + * method for all the UI delegates managed by this + * <code>MultiOptionPaneUI</code>, returning the result for the UI delegate + * from the primary look and feel. + * + * @param pane the option pane. + * + * @return The result for the UI delegate from the primary look and feel. + */ + public boolean containsCustomComponents(JOptionPane pane) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + OptionPaneUI ui = (OptionPaneUI) iterator.next(); + result = ui.containsCustomComponents(pane); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + OptionPaneUI ui = (OptionPaneUI) iterator.next(); + /* boolean ignored = */ ui.containsCustomComponents(pane); + } + return result; + } + +} 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 <code>MultiPanelUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiPanelUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiPanelUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiPanelUI mui = new MultiPanelUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiPanelUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiPanelUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiPanelUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiPanelUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiPanelUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiPopupMenuUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiPopupMenuUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiPopupMenuUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiPopupMenuUI mui = new MultiPopupMenuUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiPopupMenuUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiPopupMenuUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiPopupMenuUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiProgressBarUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiProgressBarUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiProgressBarUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiProgressBarUI mui = new MultiProgressBarUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiProgressBarUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiProgressBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiProgressBarUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiProgressBarUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiProgressBarUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiRootPanelUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiRootPaneUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiRootPaneUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiRootPaneUI mui = new MultiRootPaneUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiRootPaneUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiRootPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiRootPaneUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiRootPaneUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiRootPaneUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiScrollBarUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiScrollBarUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiScrollBarUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiScrollBarUI mui = new MultiScrollBarUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiScrollBarUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiScrollBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollBarUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiScrollBarUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiScrollBarUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiScrollPaneUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiScrollPaneUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiScrollPaneUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiScrollPaneUI mui = new MultiScrollPaneUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiScrollPaneUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiScrollPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiScrollPaneUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiSeparatorUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiSeparatorUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiSeparatorUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiSeparatorUI mui = new MultiSeparatorUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiSeparatorUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiSeparatorUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSeparatorUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiSeparatorUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiSeparatorUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiSliderUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiSliderUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiSliderUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiSliderUI mui = new MultiSliderUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiSliderUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiSliderUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSliderUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiSliderUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiSliderUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiSpinnerUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiSpinnerUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiSpinnerUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiSpinnerUI mui = new MultiSpinnerUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiSpinnerUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiSpinnerUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSpinnerUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiSpinnerUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiSpinnerUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiSplitPaneUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiSplitPaneUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiSplitPaneUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiSplitPaneUI mui = new MultiSplitPaneUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiSplitPaneUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiSplitPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link SplitPaneUI#resetToPreferredSizes(JSplitPane)} method + * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>. + * + * @param pane the component. + */ + public void resetToPreferredSizes(JSplitPane pane) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + ui.resetToPreferredSizes(pane); + } + } + + /** + * Calls the {@link SplitPaneUI#setDividerLocation(JSplitPane, int)} method + * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>. + * + * @param pane the component. + * @param location the location. + */ + public void setDividerLocation(JSplitPane pane, int location) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + ui.setDividerLocation(pane, location); + } + } + + /** + * Calls the {@link SplitPaneUI#getDividerLocation(JSplitPane)} method for all + * the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the location for the UI delegate from the primary look and + * feel. + * + * @param pane the component. + * + * @return The location returned by the UI delegate from the primary + * look and feel. + */ + public int getDividerLocation(JSplitPane pane) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + result = ui.getDividerLocation(pane); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + /* int ignored = */ ui.getDividerLocation(pane); + } + return result; + } + + /** + * Calls the {@link SplitPaneUI#getMinimumDividerLocation(JSplitPane)} method + * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the location for the UI delegate from the primary look and + * feel. + * + * @param pane the component. + * + * @return The location returned by the UI delegate from the primary + * look and feel. + */ + public int getMinimumDividerLocation(JSplitPane pane) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + result = ui.getMinimumDividerLocation(pane); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + /* int ignored = */ ui.getMinimumDividerLocation(pane); + } + return result; + } + + /** + * Calls the {@link SplitPaneUI#getMaximumDividerLocation(JSplitPane)} method + * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>, + * returning the location for the UI delegate from the primary look and + * feel. + * + * @param pane the component. + * + * @return The location returned by the UI delegate from the primary + * look and feel. + */ + public int getMaximumDividerLocation(JSplitPane pane) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + result = ui.getMaximumDividerLocation(pane); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + /* int ignored = */ ui.getMaximumDividerLocation(pane); + } + return result; + } + + /** + * Calls the {@link SplitPaneUI#finishedPaintingChildren(JSplitPane, + * Graphics)} method for all the UI delegates managed by this + * <code>MultiSplitPaneUI</code>. + * + * @param pane the component. + * @param g the graphics device. + */ + public void finishedPaintingChildren(JSplitPane pane, Graphics g) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + SplitPaneUI ui = (SplitPaneUI) iterator.next(); + ui.finishedPaintingChildren(pane, g); + } + } + +} 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 <code>MultiTabbedPaneUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiTabbedPaneUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiTabbedPaneUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiTabbedPaneUI mui = new MultiTabbedPaneUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiTabbedPaneUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiTabbedPaneUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTabbedPaneUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link TabbedPaneUI#tabForCoordinate(JTabbedPane, int, int)} + * method for all the UI delegates managed by this + * <code>MultiTabbedPaneUI</code>, returning the tab index for the UI + * delegate from the primary look and feel. + * + * @param pane the tabbed pane. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return The tab index returned by the UI delegate from the primary + * look and feel. + */ + public int tabForCoordinate(JTabbedPane pane, int x, int y) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TabbedPaneUI ui = (TabbedPaneUI) iterator.next(); + result = ui.tabForCoordinate(pane, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TabbedPaneUI ui = (TabbedPaneUI) iterator.next(); + /* int ignored = */ ui.tabForCoordinate(pane, x, y); + } + return result; + } + + /** + * Calls the {@link TabbedPaneUI#getTabBounds(JTabbedPane, int)} + * method for all the UI delegates managed by this + * <code>MultiTabbedPaneUI</code>, returning the bounds for the UI + * delegate from the primary look and feel. + * + * @param pane the tabbed pane. + * @param index the index. + * + * @return The bounds returned by the UI delegate from the primary + * look and feel. + */ + public Rectangle getTabBounds(JTabbedPane pane, int index) + { + Rectangle result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TabbedPaneUI ui = (TabbedPaneUI) iterator.next(); + result = ui.getTabBounds(pane, index); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TabbedPaneUI ui = (TabbedPaneUI) iterator.next(); + /* int ignored = */ ui.getTabRunCount(pane); + } + return result; + } + + /** + * Calls the {@link TabbedPaneUI#getTabRunCount(JTabbedPane)} + * method for all the UI delegates managed by this + * <code>MultiTabbedPaneUI</code>, returning the nt for the UI + * delegate from the primary look and feel. + * + * @param pane the tabbed pane. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getTabRunCount(JTabbedPane pane) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TabbedPaneUI ui = (TabbedPaneUI) iterator.next(); + result = ui.getTabRunCount(pane); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TabbedPaneUI ui = (TabbedPaneUI) iterator.next(); + /* int ignored = */ ui.getTabRunCount(pane); + } + return result; + } + +} 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 <code>MultiTableHeaderUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiTableHeaderUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiTableHeaderUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiTableHeaderUI mui = new MultiTableHeaderUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiTableHeaderUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiTableHeaderUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableHeaderUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiTableUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiTableUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiTableUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiTableUI mui = new MultiTableUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiTableUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiTableUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTableUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiTableUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiTableUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiTextUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiTextUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiTextUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiTextUI mui = new MultiTextUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiTextUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiTextUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiTextUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiTextUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link TextUI#modelToView(JTextComponent, int)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the bounds for the UI delegate from the primary look and + * feel. + * + * @param tc the text component. + * + * @return The bounds returned by the UI delegate from the primary + * look and feel. + */ + public Rectangle modelToView(JTextComponent tc, int pos) + throws BadLocationException + { + Rectangle result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.modelToView(tc, pos); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* Rectangle ignored = */ ui.modelToView(tc, pos); + } + return result; + } + + /** + * Calls the {@link TextUI#modelToView(JTextComponent, int, Position.Bias)} + * method for all the UI delegates managed by this <code>MultiTextUI</code>, + * returning the bounds for the UI delegate from the primary look and + * feel. + * + * @param tc the text component. + * + * @return The bounds returned by the UI delegate from the primary + * look and feel. + */ + public Rectangle modelToView(JTextComponent tc, int pos, Bias bias) + throws BadLocationException + { + Rectangle result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.modelToView(tc, pos, bias); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* Rectangle ignored = */ ui.modelToView(tc, pos, bias); + } + return result; + } + + /** + * Calls the {@link TextUI#viewToModel(JTextComponent, Point)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the position for the UI delegate from the primary look and + * feel. + * + * @param t the text component. + * @param pt the point. + * + * @return The position returned by the UI delegate from the primary + * look and feel. + */ + public int viewToModel(JTextComponent t, Point pt) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.viewToModel(t, pt); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* int ignored = */ ui.viewToModel(t, pt); + } + return result; + } + + /** + * Calls the {@link TextUI#viewToModel(JTextComponent, Point, Bias[])} method + * for all the UI delegates managed by this <code>MultiTextUI</code>, + * returning the position for the UI delegate from the primary look and + * feel. + * + * @param tc the text component. + * + * @return The position returned by the UI delegate from the primary + * look and feel. + */ + public int viewToModel(JTextComponent tc, Point loc, Bias[] outBias) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.viewToModel(tc, loc, outBias); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* int ignored = */ ui.viewToModel(tc, loc, outBias); + } + return result; + } + + /** + * Calls the {@link TextUI#getNextVisualPositionFrom(JTextComponent, int, + * Position.Bias, int, Position.Bias[])} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the position for the UI delegate from the primary look and + * feel. + * + * @param tc the text component. + * + * @return The position returned by the UI delegate from the primary + * look and feel. + */ + public int getNextVisualPositionFrom(JTextComponent tc, int pos, Bias bias, + int direction, Bias[] outBias) throws BadLocationException + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.getNextVisualPositionFrom(tc, pos, bias, direction, + outBias); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* int ignored = */ ui.getNextVisualPositionFrom(tc, pos, bias, + direction, outBias); + } + return result; + } + + /** + * Calls the {@link TextUI#damageRange(JTextComponent, int, int)} method for + * all the UI delegates managed by this <code>MultiTextUI</code>. + * + * @param tc the component. + * @param start the start position. + * @param end the end position. + */ + public void damageRange(JTextComponent tc, int start, int end) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + ui.damageRange(tc, start, end); + } + } + + /** + * Calls the {@link TextUI#damageRange(JTextComponent, int, int, + * Position.Bias, Position.Bias)} method for all the UI delegates managed by + * this <code>MultiTextUI</code>. + * + * @param tc the component. + * @param start the start position. + * @param end the end position. + * @param startBias the start bias. + * @param endBias the end bias. + */ + public void damageRange(JTextComponent tc, int start, int end, + Bias startBias, Bias endBias) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + ui.damageRange(tc, start, end, startBias, endBias); + } + } + + /** + * Calls the {@link TextUI#getEditorKit(JTextComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the editor kit for the UI delegate from the primary look and + * feel. + * + * @param tc the text component. + * + * @return The editor kit returned by the UI delegate from the primary + * look and feel. + */ + public EditorKit getEditorKit(JTextComponent tc) + { + EditorKit result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.getEditorKit(tc); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* EditorKit ignored = */ ui.getEditorKit(tc); + } + return result; + } + + /** + * Calls the {@link TextUI#getRootView(JTextComponent)} method for all + * the UI delegates managed by this <code>MultiTextUI</code>, + * returning the view for the UI delegate from the primary look and + * feel. + * + * @param tc the text component. + * + * @return The view returned by the UI delegate from the primary + * look and feel. + */ + public View getRootView(JTextComponent tc) + { + View result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + result = ui.getRootView(tc); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TextUI ui = (TextUI) iterator.next(); + /* View ignored = */ ui.getRootView(tc); + } + return result; + } + +} 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 <code>MultiToolBarUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiToolBarUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiToolBarUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiToolBarUI mui = new MultiToolBarUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiToolBarUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiToolBarUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolBarUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiToolBarUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiToolBarUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiToolTipUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiToolTipUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiToolTipUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiToolTipUI mui = new MultiToolTipUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiToolTipUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiToolTipUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiToolTipUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiToolTipUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiToolTipUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 <code>MultiTreeUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiTreeUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiTreeUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiTreeUI mui = new MultiTreeUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiTreeUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiTreeUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + + /** + * Calls the {@link TreeUI#getPathBounds(JTree, TreePath)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the bounds for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The bounds returned by the UI delegate from the primary + * look and feel. + */ + public Rectangle getPathBounds(JTree tree, TreePath path) + { + Rectangle result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.getPathBounds(tree, path); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* Rectangle ignored = */ ui.getPathBounds(tree, path); + } + return result; + } + + /** + * Calls the {@link TreeUI#getPathForRow(JTree, int)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the path for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The path returned by the UI delegate from the primary + * look and feel. + */ + public TreePath getPathForRow(JTree tree, int row) + { + TreePath result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.getPathForRow(tree, row); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* TreePath ignored = */ ui.getPathForRow(tree, row); + } + return result; + } + + /** + * Calls the {@link TreeUI#getRowForPath(JTree, TreePath)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the row index for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The row index returned by the UI delegate from the primary + * look and feel. + */ + public int getRowForPath(JTree tree, TreePath path) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.getRowForPath(tree, path); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* int ignored = */ ui.getRowForPath(tree, path); + } + return result; + } + + /** + * Calls the {@link TreeUI#getRowCount(JTree)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getRowCount(JTree tree) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.getRowCount(tree); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* int ignored = */ ui.getRowCount(tree); + } + return result; + } + + /** + * Calls the {@link TreeUI#getClosestPathForLocation(JTree, int, int)} method + * for all the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the path for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The path returned by the UI delegate from the primary + * look and feel. + */ + public TreePath getClosestPathForLocation(JTree tree, int x, int y) + { + TreePath result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.getClosestPathForLocation(tree, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* TreePath ignored = */ ui.getClosestPathForLocation(tree, x, y); + } + return result; + } + + /** + * Calls the {@link TreeUI#isEditing(JTree)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The result returned by the UI delegate from the primary + * look and feel. + */ + public boolean isEditing(JTree tree) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.isEditing(tree); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* boolean ignored = */ ui.isEditing(tree); + } + return result; + } + + /** + * Calls the {@link TreeUI#stopEditing(JTree)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The result returned by the UI delegate from the primary + * look and feel. + */ + public boolean stopEditing(JTree tree) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.stopEditing(tree); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* boolean ignored = */ ui.stopEditing(tree); + } + return result; + } + + /** + * Calls the {@link TreeUI#cancelEditing(JTree)} method for + * all the UI delegates managed by this <code>MultiTreeUI</code>. + * + * @param tree the tree component. + */ + public void cancelEditing(JTree tree) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + ui.cancelEditing(tree); + } + } + + /** + * Calls the {@link TreeUI#startEditingAtPath(JTree, TreePath)} method for + * all the UI delegates managed by this <code>MultiTreeUI</code>. + * + * @param tree the tree component. + * @param path the path. + */ + public void startEditingAtPath(JTree tree, TreePath path) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + ui.startEditingAtPath(tree, path); + } + } + + /** + * Calls the {@link TreeUI#getEditingPath(JTree)} method for all + * the UI delegates managed by this <code>MultiTreeUI</code>, + * returning the path for the UI delegate from the primary look and + * feel. + * + * @param tree the tree component. + * + * @return The path returned by the UI delegate from the primary + * look and feel. + */ + public TreePath getEditingPath(JTree tree) + { + TreePath result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + result = ui.getEditingPath(tree); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + TreeUI ui = (TreeUI) iterator.next(); + /* TreePath ignored = */ ui.getEditingPath(tree); + } + return result; + } + +} 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 <code>MultiViewPortUI</code> instance. + * + * @see #createUI(JComponent) + */ + public MultiViewportUI() + { + uis = new Vector(); + } + + /** + * Creates a delegate object for the specified component. If any auxiliary + * look and feels support this component, a <code>MultiViewportUI</code> is + * returned, otherwise the UI from the default look and feel is returned. + * + * @param target the component. + * + * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent) + */ + public static ComponentUI createUI(JComponent target) + { + MultiViewportUI mui = new MultiViewportUI(); + return MultiLookAndFeel.createUIs(mui, mui.uis, target); + } + + /** + * Calls the {@link ComponentUI#installUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>. + * + * @param c the component. + */ + public void installUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.installUI(c); + } + } + + /** + * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>. + * + * @param c the component. + */ + public void uninstallUI(JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.uninstallUI(c); + } + } + + /** + * Returns an array containing the UI delegates managed by this + * <code>MultiViewportUI</code>. The first item in the array is always + * the UI delegate from the installed default look and feel. + * + * @return An array of UI delegates. + */ + public ComponentUI[] getUIs() + { + return MultiLookAndFeel.uisToArray(uis); + } + + /** + * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>, + * returning the result for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return <code>true</code> if the specified (x, y) coordinate falls within + * the bounds of the component as rendered by the UI delegate in the + * primary look and feel, and <code>false</code> otherwise. + */ + public boolean contains(JComponent c, int x, int y) + { + boolean result = false; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.contains(c, x, y); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* boolean ignored = */ ui.contains(c, x, y); + } + return result; + } + + /** + * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void update(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.update(g, c); + } + } + + /** + * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI + * delegates managed by this <code>MultiViewportUI</code>. + * + * @param g the graphics device. + * @param c the component. + */ + public void paint(Graphics g, JComponent c) + { + Iterator iterator = uis.iterator(); + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + ui.paint(g, c); + } + } + + /** + * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>, + * returning the preferred size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The preferred size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getPreferredSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getPreferredSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getPreferredSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>, + * returning the minimum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The minimum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMinimumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMinimumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMinimumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all + * the UI delegates managed by this <code>MultiViewportUI</code>, + * returning the maximum size for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The maximum size returned by the UI delegate from the primary + * look and feel. + */ + public Dimension getMaximumSize(JComponent c) + { + Dimension result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getMaximumSize(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Dimension ignored = */ ui.getMaximumSize(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method + * for all the UI delegates managed by this <code>MultiViewportUI</code>, + * returning the count for the UI delegate from the primary look and + * feel. + * + * @param c the component. + * + * @return The count returned by the UI delegate from the primary + * look and feel. + */ + public int getAccessibleChildrenCount(JComponent c) + { + int result = 0; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChildrenCount(c); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* int ignored = */ ui.getAccessibleChildrenCount(c); + } + return result; + } + + /** + * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method + * for all the UI delegates managed by this <code>MultiViewportUI</code>, + * returning the child for the UI delegate from the primary look and + * feel. + * + * @param c the component + * @param i the child index. + * + * @return The child returned by the UI delegate from the primary + * look and feel. + */ + public Accessible getAccessibleChild(JComponent c, int i) + { + Accessible result = null; + Iterator iterator = uis.iterator(); + // first UI delegate provides the return value + if (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + result = ui.getAccessibleChild(c, i); + } + // return values from auxiliary UI delegates are ignored + while (iterator.hasNext()) + { + ComponentUI ui = (ComponentUI) iterator.next(); + /* Accessible ignored = */ ui.getAccessibleChild(c, i); + } + return result; + } + +} 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 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<!-- package.html - describes classes in javax.swing.plaf.metal package. + Copyright (C) 2002, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. --> + +<html> +<head><title>GNU Classpath - javax.swing.plaf.multi</title></head> + +<body> +<p>Provides a look and feel that can combine a primary look and feel with one or more auxiliary look and feels.</p> + +</body> +</html> |