1 /* Region.java -- Describes a region within a component
2    Copyright (C) 2006 Free Software Foundation, Inc.
3 
4 This file is part of GNU Classpath.
5 
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.
10 
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.
15 
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.
20 
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.
25 
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. */
37 
38 
39 package javax.swing.plaf.synth;
40 
41 /**
42  * Describes a region of a component or the complete component.
43  *
44  * @author Roman Kennke (kennke@aicas.com)
45  *
46  * @since 1.5
47  */
48 public class Region
49 {
50 
51   // FIXME: What should ui be for the non-component regions that have
52   // subregion==false?
53 
54   /**
55    * Specifies an arrow button region.
56    */
57   public static final Region ARROW_BUTTON =
58     new Region("ArrowButton", null, false);
59 
60   /**
61    * Specifies the region of a standard button.
62    */
63   public static final Region BUTTON =
64     new Region("Button", "ButtonUI", false);
65 
66   /**
67    * Specifies the region of a check box.
68    */
69   public static final Region CHECK_BOX =
70     new Region("CheckBox", "CheckBoxUI", false);
71 
72   /**
73    * Specifies the region of a check box menu item.
74    */
75   public static final Region CHECK_BOX_MENU_ITEM =
76     new Region("CheckBoxMenuItem", "CheckBoxMenuItemUI", false);
77 
78   /**
79    * Specifies the region of a colorchooser.
80    */
81   public static final Region COLOR_CHOOSER =
82     new Region("ColorChooser", "ColorChooserUI", false);
83 
84   /**
85    * Specifies the region of a combo box.
86    */
87   public static final Region COMBO_BOX =
88     new Region("ComboBox", "ComboBoxUI", false);
89 
90   /**
91    * Specifies the region of a desktop pane.
92    */
93   public static final Region DESKTOP_PANE =
94     new Region("DesktopPane", "DesktopPaneUI", false);
95 
96   /**
97    * Specifies the region of a desktop icon.
98    */
99   public static final Region DESKTOP_ICON =
100     new Region("DesktopIcon", "DesktopIconUI", false);
101 
102   /**
103    * Specifies the region of an editor pane.
104    */
105   public static final Region EDITOR_PANE =
106     new Region("EditorPane", "EditorPaneUI", false);
107 
108   /**
109    * Specifies the region of a file chooser.
110    */
111   public static final Region FILE_CHOOSER =
112     new Region("FileChooser", "FileChooserUI", false);
113 
114   /**
115    * Specifies the region of a formatted text field.
116    */
117   public static final Region FORMATTED_TEXT_FIELD =
118     new Region("FormattedTextField", "FormattedTextFieldUI", false);
119 
120   /**
121    * Specifies the region of an internal frame.
122    */
123   public static final Region INTERNAL_FRAME =
124     new Region("InternalFrame", "InternalFrameUI", false);
125 
126   /**
127    * Specifies the region of the title pane of an internal frame.
128    */
129   public static final Region INTERNAL_FRAME_TITLE_PANE =
130     new Region("InternalFrameTitlePane", "InternalFrameTitlePaneUI", false);
131 
132   /**
133    * Specifies the region of a label.
134    */
135   public static final Region LABEL =
136     new Region("Label", "LabelUI", false);
137 
138   /**
139    * Specifies the region of a list.
140    */
141   public static final Region LIST =
142     new Region("List", "ListUI", false);
143 
144   /**
145    * Specifies the region of a menu.
146    */
147   public static final Region MENU =
148     new Region("Menu", "MenuUI", false);
149 
150   /**
151    * Specifies the region of a menu bar.
152    */
153   public static final Region MENU_BAR =
154     new Region("MenuBar", "MenuBarUI", false);
155 
156   /**
157    * Specifies the region of a menu item.
158    */
159   public static final Region MENU_ITEM =
160     new Region("MenuItem", "MenuItemUI", false);
161 
162   /**
163    * Specifies the region of a menu item accelerator. This is a subregion
164    * of menu item.
165    */
166   public static final Region MENU_ITEM_ACCELERATOR =
167     new Region("MenuItemAccelerator", null, true);
168 
169   /**
170    * Specifies the region of an option pane.
171    */
172   public static final Region OPTION_PANE =
173     new Region("OptionPane", "OptionPaneUI", false);
174 
175   /**
176    * Specifies the region of a panel.
177    */
178   public static final Region PANEL =
179     new Region("Panel", "PanelUI", false);
180 
181   /**
182    * Specifies the region of a password field.
183    */
184   public static final Region PASSWORD_FIELD =
185     new Region("PasswordField", "PasswordFieldUI", false);
186 
187   /**
188    * Specifies the region of a popup menu.
189    */
190   public static final Region POPUP_MENU =
191     new Region("PopupMenu", "PopupMenuUI", false);
192 
193   /**
194    * Specifies the region of a popup menu separator.
195    */
196   public static final Region POPUP_MENU_SEPARATOR =
197     new Region("PopupMenuSeparator", null, false);
198 
199   /**
200    * Specifies the region of a progress bar.
201    */
202   public static final Region PROGRESS_BAR =
203     new Region("ProgressBar", "ProgressBarUI", false);
204 
205   /**
206    * Specifies the region of a radio button.
207    */
208   public static final Region RADIO_BUTTON =
209     new Region("RadioButton", "RadioButtonUI", false);
210 
211   /**
212    * Specifies the region of a radio button menu item.
213    */
214   public static final Region RADIO_BUTTON_MENU_ITEM =
215     new Region("RadioButtonMenuItem", "RadioButtonMenuItemUI", false);
216 
217   /**
218    * Specifies the region of a root pane.
219    */
220   public static final Region ROOT_PANE =
221     new Region("RootPane", "RootPaneUI", false);
222 
223   /**
224    * Specifies the region of a scroll bar.
225    */
226   public static final Region SCROLL_BAR =
227     new Region("ScrollBar", "ScrollBarUI", false);
228 
229   /**
230    * Specifies the region of a scroll bar track. This is a subregion of
231    * scroll bars.
232    */
233   public static final Region SCROLL_BAR_TRACK =
234     new Region("ScrollBarTrack", null, true);
235 
236   /**
237    * Specifies the region of a scroll bar thumb. This is a subregion of
238    * scroll bars.
239    */
240   public static final Region SCROLL_BAR_THUMB =
241     new Region("ScrollBarThumb", null, true);
242 
243   /**
244    * Specifies the region of a scroll pane.
245    */
246   public static final Region SCROLL_PANE =
247     new Region("ScrollPane", "ScrollPaneUI", false);
248 
249   /**
250    * Specifies the region of a separator.
251    */
252   public static final Region SEPARATOR =
253     new Region("Separator", "SeparatorUI", false);
254 
255   /**
256    * Specifies the region of a slider.
257    */
258   public static final Region SLIDER =
259     new Region("Slider", "SliderUI", false);
260 
261   /**
262    * Specifies the region of a slider track. This is a subregion of a slider.
263    */
264   public static final Region SLIDER_TRACK =
265     new Region("SliderTrack", null, true);
266 
267   /**
268    * Specifies the region of a slider thumb. This is a subregion of a slider.
269    */
270   public static final Region SLIDER_THUMB =
271     new Region("SliderThumb", null, true);
272 
273   /**
274    * Specifies the region of a spinner.
275    */
276   public static final Region SPINNER =
277     new Region("Spinner", "SpinnerUI", false);
278 
279   /**
280    * Specifies the region of a split pane.
281    */
282   public static final Region SPLIT_PANE =
283     new Region("SplitPane", "SplitPaneUI", false);
284 
285   /**
286    * Specifies the region of a split pane divider. This is a subregion of
287    * a split pane.
288    */
289   public static final Region SPLIT_PANE_DIVIDER =
290     new Region("SplitPaneDivider", null, true);
291 
292   /**
293    * Specifies the region of a tabbed pane.
294    */
295   public static final Region TABBED_PANE =
296     new Region("TabbedPane", "TabbedPaneUI", false);
297 
298   /**
299    * This specifies the region of a tab of a tabbed pane. This is a subregion
300    * of a tabbed pane.
301    */
302   public static final Region TABBED_PANE_TAB =
303     new Region("TabbedPaneTab", null, true);
304 
305   /**
306    * This specifies the region underneath the tabs of a tabbed pane. This is a
307    * subregion of a tabbed pane.
308    */
309   public static final Region TABBED_PANE_TAB_AREA =
310     new Region("TabbedPaneTabArea", null, true);
311 
312   /**
313    * This specifies the region for the content of a tabbed pane. This is a
314    * subregion of a tabbed pane.
315    */
316   public static final Region TABBED_PANE_CONTENT =
317     new Region("TabbedPaneContent", null, true);
318 
319   /**
320    * Specifies the region of a table.
321    */
322   public static final Region TABLE =
323     new Region("Table", "TableUI", false);
324 
325   /**
326    * Specifies the region of a table header.
327    */
328   public static final Region TABLE_HEADER =
329     new Region("TableHeader", "TableHeaderUI", false);
330 
331   /**
332    * Specifies the region of a text area.
333    */
334   public static final Region TEXT_AREA =
335     new Region("TextArea", "TextAreaUI", false);
336 
337   /**
338    * Specifies the region of a text field.
339    */
340   public static final Region TEXT_FIELD =
341     new Region("TextField", "TextFieldUI", false);
342 
343   /**
344    * Specifies the region of a text pane.
345    */
346   public static final Region TEXT_PANE =
347     new Region("TextPane", "TextPaneUI", false);
348 
349   /**
350    * Specifies the region of a toggle button.
351    */
352   public static final Region TOGGLE_BUTTON =
353     new Region("ToggleButton", "ToggleButtonUI", false);
354 
355   /**
356    * Specifies the region of a tool bar.
357    */
358   public static final Region TOOL_BAR =
359     new Region("ToolBar", "ToolBarUI", false);
360 
361   /**
362    * Specifies the content region of a tool bar. This is a subregion of a tool
363    * bar.
364    */
365   public static final Region TOOL_BAR_CONTENT =
366     new Region("ToolBarContent", null, true);
367 
368   /**
369    * Specifies the drag window region of a tool bar. This is a subregion of a
370    * tool bar.
371    */
372   public static final Region TOOL_BAR_DRAG_WINDOW =
373     new Region("ToolBarDragWindow", null, false);
374 
375   /**
376    * Specifies the region of a tool tip.
377    */
378   public static final Region TOOL_TIP =
379     new Region("ToolTip", "ToolTipUI", false);
380 
381   /**
382    * Specifies the region of a separator of a tool bar. This is a subregion of
383    * a tool bar.
384    */
385   public static final Region TOOL_BAR_SEPARATOR =
386     new Region("ToolBarSeparator", null, false);
387 
388   /**
389    * Specifies the region of a tree.
390    */
391   public static final Region TREE =
392     new Region("Tree", "TreeUI", false);
393 
394   /**
395    * Specifies the region of a tree cell. This is a subregion of a tree.
396    */
397   public static final Region TREE_CELL =
398     new Region("TreeCell", null, true);
399 
400   /**
401    * Specifies the region of a viewport.
402    */
403   public static final Region VIEWPORT =
404     new Region("Viewport", "ViewportUI", false);
405 
406 
407   /**
408    * The UI class id for the region. This is package private because this will
409    * be used by other classes in that package.
410    */
411   String ui;
412 
413   /**
414    * The name of the region.
415    */
416   private String name;
417 
418   /**
419    * If this region is a subregion or not.
420    */
421   private boolean subregion;
422 
423   /**
424    * Creates a new <code>Region</code> with the specified name and ui ID.
425    * The <code>ui</code> must be the same what
426    * {@link javax.swing.JComponent#getUIClassID()} returns for toplevel regions. For
427    * subregions this should be <code>null</code>.
428    *
429    * @param name the name of the region
430    * @param ui the UI class ID of the region or <code>null</code> for
431    *        subregions
432    * @param subregion <code>true</code> if this region is a subregion,
433    *        <code>false</code> otherwise
434    */
Region(String name, String ui, boolean subregion)435   protected Region(String name, String ui, boolean subregion)
436   {
437     this.name = name;
438     this.ui = ui;
439     this.subregion = subregion;
440   }
441 
442   /**
443    * Returns <code>true</code> if this region describes a subregion of a
444    * component, <code>false</code> if it describes a component region itself.
445    *
446    * @return <code>true</code> if this region describes a subregion of a
447    *         component, <code>false</code> if it describes a component region
448    *         itself
449    */
isSubregion()450   public boolean isSubregion()
451   {
452     return subregion;
453   }
454 
455   /**
456    * Returns the name of the region.
457    *
458    * @return the name of the region
459    */
getName()460   public String getName()
461   {
462     return name;
463   }
464 
465   /**
466    * Returns the name of the region.
467    *
468    * @return  the name of the region
469    */
toString()470   public String toString()
471   {
472     return name;
473   }
474 }
475