blob: 30a425af88dcb287066bfaf5a35a38eace129010 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package javax.swing.plaf.multi;
26
27import java.util.Vector;
28import javax.swing.plaf.PopupMenuUI;
29import java.awt.event.MouseEvent;
30import javax.swing.Popup;
31import javax.swing.JPopupMenu;
32import javax.swing.plaf.ComponentUI;
33import javax.swing.JComponent;
34import java.awt.Graphics;
35import java.awt.Dimension;
36import javax.accessibility.Accessible;
37
38/**
39 * A multiplexing UI used to combine <code>PopupMenuUI</code>s.
40 *
41 * <p>This file was automatically generated by AutoMulti.
42 *
43 * @author Otto Multey
44 */
45public class MultiPopupMenuUI extends PopupMenuUI {
46
47 /**
48 * The vector containing the real UIs. This is populated
49 * in the call to <code>createUI</code>, and can be obtained by calling
50 * the <code>getUIs</code> method. The first element is guaranteed to be the real UI
51 * obtained from the default look and feel.
52 */
53 protected Vector uis = new Vector();
54
55////////////////////
56// Common UI methods
57////////////////////
58
59 /**
60 * Returns the list of UIs associated with this multiplexing UI. This
61 * allows processing of the UIs by an application aware of multiplexing
62 * UIs on components.
63 */
64 public ComponentUI[] getUIs() {
65 return MultiLookAndFeel.uisToArray(uis);
66 }
67
68////////////////////
69// PopupMenuUI methods
70////////////////////
71
72 /**
73 * Invokes the <code>isPopupTrigger</code> method on each UI handled by this object.
74 *
75 * @return the value obtained from the first UI, which is
76 * the UI obtained from the default <code>LookAndFeel</code>
77 * @since 1.3
78 */
79 public boolean isPopupTrigger(MouseEvent a) {
80 boolean returnValue =
81 ((PopupMenuUI) (uis.elementAt(0))).isPopupTrigger(a);
82 for (int i = 1; i < uis.size(); i++) {
83 ((PopupMenuUI) (uis.elementAt(i))).isPopupTrigger(a);
84 }
85 return returnValue;
86 }
87
88 /**
89 * Invokes the <code>getPopup</code> method on each UI handled by this object.
90 *
91 * @return the value obtained from the first UI, which is
92 * the UI obtained from the default <code>LookAndFeel</code>
93 * @since 1.4
94 */
95 public Popup getPopup(JPopupMenu a, int b, int c) {
96 Popup returnValue =
97 ((PopupMenuUI) (uis.elementAt(0))).getPopup(a,b,c);
98 for (int i = 1; i < uis.size(); i++) {
99 ((PopupMenuUI) (uis.elementAt(i))).getPopup(a,b,c);
100 }
101 return returnValue;
102 }
103
104////////////////////
105// ComponentUI methods
106////////////////////
107
108 /**
109 * Invokes the <code>contains</code> method on each UI handled by this object.
110 *
111 * @return the value obtained from the first UI, which is
112 * the UI obtained from the default <code>LookAndFeel</code>
113 */
114 public boolean contains(JComponent a, int b, int c) {
115 boolean returnValue =
116 ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
117 for (int i = 1; i < uis.size(); i++) {
118 ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
119 }
120 return returnValue;
121 }
122
123 /**
124 * Invokes the <code>update</code> method on each UI handled by this object.
125 */
126 public void update(Graphics a, JComponent b) {
127 for (int i = 0; i < uis.size(); i++) {
128 ((ComponentUI) (uis.elementAt(i))).update(a,b);
129 }
130 }
131
132 /**
133 * Returns a multiplexing UI instance if any of the auxiliary
134 * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the
135 * UI object obtained from the default <code>LookAndFeel</code>.
136 */
137 public static ComponentUI createUI(JComponent a) {
138 ComponentUI mui = new MultiPopupMenuUI();
139 return MultiLookAndFeel.createUIs(mui,
140 ((MultiPopupMenuUI) mui).uis,
141 a);
142 }
143
144 /**
145 * Invokes the <code>installUI</code> method on each UI handled by this object.
146 */
147 public void installUI(JComponent a) {
148 for (int i = 0; i < uis.size(); i++) {
149 ((ComponentUI) (uis.elementAt(i))).installUI(a);
150 }
151 }
152
153 /**
154 * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
155 */
156 public void uninstallUI(JComponent a) {
157 for (int i = 0; i < uis.size(); i++) {
158 ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
159 }
160 }
161
162 /**
163 * Invokes the <code>paint</code> method on each UI handled by this object.
164 */
165 public void paint(Graphics a, JComponent b) {
166 for (int i = 0; i < uis.size(); i++) {
167 ((ComponentUI) (uis.elementAt(i))).paint(a,b);
168 }
169 }
170
171 /**
172 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
173 *
174 * @return the value obtained from the first UI, which is
175 * the UI obtained from the default <code>LookAndFeel</code>
176 */
177 public Dimension getPreferredSize(JComponent a) {
178 Dimension returnValue =
179 ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
180 for (int i = 1; i < uis.size(); i++) {
181 ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
182 }
183 return returnValue;
184 }
185
186 /**
187 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
188 *
189 * @return the value obtained from the first UI, which is
190 * the UI obtained from the default <code>LookAndFeel</code>
191 */
192 public Dimension getMinimumSize(JComponent a) {
193 Dimension returnValue =
194 ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
195 for (int i = 1; i < uis.size(); i++) {
196 ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
197 }
198 return returnValue;
199 }
200
201 /**
202 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
203 *
204 * @return the value obtained from the first UI, which is
205 * the UI obtained from the default <code>LookAndFeel</code>
206 */
207 public Dimension getMaximumSize(JComponent a) {
208 Dimension returnValue =
209 ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
210 for (int i = 1; i < uis.size(); i++) {
211 ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
212 }
213 return returnValue;
214 }
215
216 /**
217 * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object.
218 *
219 * @return the value obtained from the first UI, which is
220 * the UI obtained from the default <code>LookAndFeel</code>
221 */
222 public int getAccessibleChildrenCount(JComponent a) {
223 int returnValue =
224 ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
225 for (int i = 1; i < uis.size(); i++) {
226 ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
227 }
228 return returnValue;
229 }
230
231 /**
232 * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
233 *
234 * @return the value obtained from the first UI, which is
235 * the UI obtained from the default <code>LookAndFeel</code>
236 */
237 public Accessible getAccessibleChild(JComponent a, int b) {
238 Accessible returnValue =
239 ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
240 for (int i = 1; i < uis.size(); i++) {
241 ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
242 }
243 return returnValue;
244 }
245}