Imported GNU Classpath 0.90
[official-gcc.git] / libjava / classpath / javax / swing / plaf / synth / SynthLookAndFeel.java
blob8d0596d416e00b66b4d5fa5f488f0572a2599a18
1 /* SynthLookAndFeel.java -- A skinnable Swing look and feel
2 Copyright (C) 2006 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. */
39 package javax.swing.plaf.synth;
41 import java.awt.Component;
42 import java.io.InputStream;
43 import java.text.ParseException;
45 import javax.swing.JComponent;
46 import javax.swing.UIDefaults;
47 import javax.swing.plaf.ComponentUI;
48 import javax.swing.plaf.basic.BasicLookAndFeel;
51 /**
52 * A look and feel that can be customized either by providing a file to
53 * {@link #load} or by setting a {@link SynthStyleFactory} using
54 * {@link #setStyleFactory}.
56 * @author Roman Kennke (kennke@aicas.com)
58 * @since 1.5
60 public class SynthLookAndFeel
61 extends BasicLookAndFeel
64 /**
65 * The style factory that will be used by the UI classes to load their
66 * style sets from.
68 private static SynthStyleFactory styleFactory;
70 /**
71 * Creates a new instance of <code>SynthLookAndFeel</code>. In order to use
72 * the Synth look and feel you either need to call {@link #load} to load a
73 * set of styles from an XML file, or you need to call
74 * {@link #setStyleFactory} to provide your own style factory.
76 public SynthLookAndFeel()
78 // FIXME: What to do here, if anything?
81 /**
82 * Sets the style factory that the UI classes of Synth will use to load their
83 * sets of styles.
85 * @param sf the style factory to set
87 public static void setStyleFactory(SynthStyleFactory sf)
89 styleFactory = sf;
92 /**
93 * Returns the current style factory that the UI classes of Synth will use to
94 * load their sets of styles.
96 * @return the current style factory
98 public static SynthStyleFactory getStyleFactory()
100 return styleFactory;
104 * Returns the style for the specified component and region.
106 * @param c the component for which to return the style
107 * @param r the region of the component for which to return the style
109 * @return the style for the specified component and region
111 public static SynthStyle getStyle(JComponent c, Region r)
113 return getStyleFactory().getStyle(c, r);
117 * Updates all style information of the component and it's children.
119 * @param c the componenent for which to update the style
121 public static void updateStyles(Component c)
123 // FIXME: Implement this properly.
127 * Returns the region for a given Swing component.
129 * @param c the Swing component for which to fetch the region
131 * @return the region for a given Swing component
133 public static Region getRegion(JComponent c)
135 // FIXME: This can be implemented as soon as we have the component UI
136 // classes in place, since this region will be matched via the UI classes.
137 return null;
141 * Creates the Synth look and feel component UI instance for the given
142 * component.
144 * @param c the component for which to create a UI instance
146 * @return the Synth look and feel component UI instance for the given
147 * component
149 public static ComponentUI createUI(JComponent c)
151 // FIXME: This can be implemented as soon as we have the component UI
152 // classes in place.
153 return null;
157 * Initializes this look and feel.
159 public void initialize()
161 super.initialize();
162 // TODO: Implement at least the following here:
163 // if (styleFactory != null)
164 // styleFactory = new DefaultStyleFactory();
168 * Uninitializes the look and feel.
170 public void uninitialize()
172 super.uninitialize();
173 // TODO: What to do here?
177 * Returns the UI defaults of this look and feel.
179 * @return the UI defaults of this look and feel
181 public UIDefaults getDefaults()
183 // FIXME: This is certainly wrong. The defaults should be fetched/merged
184 // from the file from which the l&f is loaded.
185 return super.getDefaults();
189 * FIXME: DOCUMENT ME!
191 * @return FIXME
193 public boolean shouldUpdateStyleOnAncestorChanged()
195 return false;
199 * Loads a set of {@link SynthStyle}s that are used for the look and feel of
200 * the components. The <code>resourceBase</code> parameter is used to resolve
201 * references against, like icons and other files.
203 * @param in the input stream from where to load the styles
204 * @param resourceBase the base against which references are resolved.
206 * @throws ParseException if the input stream cannot be parsed
207 * @throws IllegalArgumentException if one of the parameters is
208 * <code>null</code>
210 // FIXME: The signature in the JDK has a Class<?> here. Should be fixed as
211 // soon as we switch to the generics branch.
212 public void load(InputStream in, Class resourceBase)
213 throws ParseException, IllegalArgumentException
215 // FIXME: Implement this correctly.
219 * Returns a textual description of the Synth look and feel. This returns
220 * &quot;Synt look and feel&quot;.
222 * @return a textual description of the Synth look and feel
224 public String getDescription()
226 return "Synth look and feel";
230 * Returns the ID of the Synth look and feel. This returns &quot;Synth&quot;.
232 * @return the ID of the Synth look and feel
234 public String getID()
236 return "Synth";
240 * Returns the name of the Synth look and feel. This returns
241 * &quot;Synt look and feel&quot;.
243 * @return the name of the Synth look and feel
245 public String getName()
247 return "Synth look and feel";
251 * Returns <code>false</code> since the Synth look and feel is not a native
252 * look and feel.
254 * @return <code>false</code>
256 public boolean isNativeLookAndFeel()
258 return false;
262 * Returns <code>true</code> since the Synth look and feel is always a
263 * supported look and feel.
265 * @return <code>true</code>
267 public boolean isSupportedLookAndFeel()
269 return true;