Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / javax / swing / plaf / multi / MultiPanelUI.java
blob67629b2febab495807d746a0b64fa808e3ae8390
1 /* MultiPanelUI.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax.swing.plaf.multi;
40 import java.awt.Dimension;
41 import java.awt.Graphics;
42 import java.util.Iterator;
43 import java.util.Vector;
45 import javax.accessibility.Accessible;
46 import javax.swing.JComponent;
47 import javax.swing.LookAndFeel;
48 import javax.swing.UIManager;
49 import javax.swing.plaf.ComponentUI;
50 import javax.swing.plaf.PanelUI;
52 /**
53 * A UI delegate that that coordinates multiple {@link PanelUI}
54 * instances, one from the primary look and feel, and one or more from the
55 * auxiliary look and feel(s).
57 * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
59 public class MultiPanelUI extends PanelUI
62 /** A list of references to the actual component UIs. */
63 protected Vector uis;
65 /**
66 * Creates a new <code>MultiPanelUI</code> instance.
68 * @see #createUI(JComponent)
70 public MultiPanelUI()
72 uis = new Vector();
75 /**
76 * Creates a delegate object for the specified component. If any auxiliary
77 * look and feels support this component, a <code>MultiPanelUI</code> is
78 * returned, otherwise the UI from the default look and feel is returned.
80 * @param target the component.
82 * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
84 public static ComponentUI createUI(JComponent target)
86 MultiPanelUI mui = new MultiPanelUI();
87 return MultiLookAndFeel.createUIs(mui, mui.uis, target);
90 /**
91 * Calls the {@link ComponentUI#installUI(JComponent)} method for all
92 * the UI delegates managed by this <code>MultiPanelUI</code>.
94 * @param c the component.
96 public void installUI(JComponent c)
98 Iterator iterator = uis.iterator();
99 while (iterator.hasNext())
101 ComponentUI ui = (ComponentUI) iterator.next();
102 ui.installUI(c);
107 * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
108 * the UI delegates managed by this <code>MultiPanelUI</code>.
110 * @param c the component.
112 public void uninstallUI(JComponent c)
114 Iterator iterator = uis.iterator();
115 while (iterator.hasNext())
117 ComponentUI ui = (ComponentUI) iterator.next();
118 ui.uninstallUI(c);
123 * Returns an array containing the UI delegates managed by this
124 * <code>MultiPanelUI</code>. The first item in the array is always
125 * the UI delegate from the installed default look and feel.
127 * @return An array of UI delegates.
129 public ComponentUI[] getUIs()
131 return MultiLookAndFeel.uisToArray(uis);
135 * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
136 * the UI delegates managed by this <code>MultiPanelUI</code>,
137 * returning the result for the UI delegate from the primary look and
138 * feel.
140 * @param c the component.
141 * @param x the x-coordinate.
142 * @param y the y-coordinate.
144 * @return <code>true</code> if the specified (x, y) coordinate falls within
145 * the bounds of the component as rendered by the UI delegate in the
146 * primary look and feel, and <code>false</code> otherwise.
148 public boolean contains(JComponent c, int x, int y)
150 boolean result = false;
151 Iterator iterator = uis.iterator();
152 // first UI delegate provides the return value
153 if (iterator.hasNext())
155 ComponentUI ui = (ComponentUI) iterator.next();
156 result = ui.contains(c, x, y);
158 // return values from auxiliary UI delegates are ignored
159 while (iterator.hasNext())
161 ComponentUI ui = (ComponentUI) iterator.next();
162 /* boolean ignored = */ ui.contains(c, x, y);
164 return result;
168 * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
169 * the UI delegates managed by this <code>MultiPanelUI</code>.
171 * @param g the graphics device.
172 * @param c the component.
174 public void update(Graphics g, JComponent c)
176 Iterator iterator = uis.iterator();
177 while (iterator.hasNext())
179 ComponentUI ui = (ComponentUI) iterator.next();
180 ui.update(g, c);
185 * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
186 * delegates managed by this <code>MultiPanelUI</code>.
188 * @param g the graphics device.
189 * @param c the component.
191 public void paint(Graphics g, JComponent c)
193 Iterator iterator = uis.iterator();
194 while (iterator.hasNext())
196 ComponentUI ui = (ComponentUI) iterator.next();
197 ui.paint(g, c);
202 * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
203 * the UI delegates managed by this <code>MultiPanelUI</code>,
204 * returning the preferred size for the UI delegate from the primary look and
205 * feel.
207 * @param c the component.
209 * @return The preferred size returned by the UI delegate from the primary
210 * look and feel.
212 public Dimension getPreferredSize(JComponent c)
214 Dimension result = null;
215 Iterator iterator = uis.iterator();
216 // first UI delegate provides the return value
217 if (iterator.hasNext())
219 ComponentUI ui = (ComponentUI) iterator.next();
220 result = ui.getPreferredSize(c);
222 // return values from auxiliary UI delegates are ignored
223 while (iterator.hasNext())
225 ComponentUI ui = (ComponentUI) iterator.next();
226 /* Dimension ignored = */ ui.getPreferredSize(c);
228 return result;
232 * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
233 * the UI delegates managed by this <code>MultiPanelUI</code>,
234 * returning the minimum size for the UI delegate from the primary look and
235 * feel.
237 * @param c the component.
239 * @return The minimum size returned by the UI delegate from the primary
240 * look and feel.
242 public Dimension getMinimumSize(JComponent c)
244 Dimension result = null;
245 Iterator iterator = uis.iterator();
246 // first UI delegate provides the return value
247 if (iterator.hasNext())
249 ComponentUI ui = (ComponentUI) iterator.next();
250 result = ui.getMinimumSize(c);
252 // return values from auxiliary UI delegates are ignored
253 while (iterator.hasNext())
255 ComponentUI ui = (ComponentUI) iterator.next();
256 /* Dimension ignored = */ ui.getMinimumSize(c);
258 return result;
262 * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
263 * the UI delegates managed by this <code>MultiPanelUI</code>,
264 * returning the maximum size for the UI delegate from the primary look and
265 * feel.
267 * @param c the component.
269 * @return The maximum size returned by the UI delegate from the primary
270 * look and feel.
272 public Dimension getMaximumSize(JComponent c)
274 Dimension result = null;
275 Iterator iterator = uis.iterator();
276 // first UI delegate provides the return value
277 if (iterator.hasNext())
279 ComponentUI ui = (ComponentUI) iterator.next();
280 result = ui.getMaximumSize(c);
282 // return values from auxiliary UI delegates are ignored
283 while (iterator.hasNext())
285 ComponentUI ui = (ComponentUI) iterator.next();
286 /* Dimension ignored = */ ui.getMaximumSize(c);
288 return result;
292 * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
293 * for all the UI delegates managed by this <code>MultiPanelUI</code>,
294 * returning the count for the UI delegate from the primary look and
295 * feel.
297 * @param c the component.
299 * @return The count returned by the UI delegate from the primary
300 * look and feel.
302 public int getAccessibleChildrenCount(JComponent c)
304 int result = 0;
305 Iterator iterator = uis.iterator();
306 // first UI delegate provides the return value
307 if (iterator.hasNext())
309 ComponentUI ui = (ComponentUI) iterator.next();
310 result = ui.getAccessibleChildrenCount(c);
312 // return values from auxiliary UI delegates are ignored
313 while (iterator.hasNext())
315 ComponentUI ui = (ComponentUI) iterator.next();
316 /* int ignored = */ ui.getAccessibleChildrenCount(c);
318 return result;
322 * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
323 * for all the UI delegates managed by this <code>MultiPanelUI</code>,
324 * returning the child for the UI delegate from the primary look and
325 * feel.
327 * @param c the component
328 * @param i the child index.
330 * @return The child returned by the UI delegate from the primary
331 * look and feel.
333 public Accessible getAccessibleChild(JComponent c, int i)
335 Accessible result = null;
336 Iterator iterator = uis.iterator();
337 // first UI delegate provides the return value
338 if (iterator.hasNext())
340 ComponentUI ui = (ComponentUI) iterator.next();
341 result = ui.getAccessibleChild(c, i);
343 // return values from auxiliary UI delegates are ignored
344 while (iterator.hasNext())
346 ComponentUI ui = (ComponentUI) iterator.next();
347 /* Accessible ignored = */ ui.getAccessibleChild(c, i);
349 return result;