1. /*
  2. * @(#)Region.java 1.26 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.gtk;
  8. import javax.swing.*;
  9. import java.util.*;
  10. /**
  11. * A typesafe enumeration of the distinct rendering portions of
  12. * Swing's Components. Some Components support more than one region.
  13. *
  14. * @version 1.26, 01/23/03
  15. * @author Scott Violet
  16. */
  17. class Region {
  18. private static final Map uiToRegionMap = new HashMap();
  19. public static final Region ARROW_BUTTON = new Region("ArrowButton",
  20. "ArrowButtonUI");
  21. public static final Region BUTTON = new Region("Button",
  22. "ButtonUI");
  23. public static final Region CHECK_BOX = new Region("CheckBox",
  24. "CheckBoxUI");
  25. public static final Region CHECK_BOX_MENU_ITEM = new Region(
  26. "CheckBoxMenuItem", "CheckBoxMenuItemUI");
  27. public static final Region COLOR_CHOOSER = new Region(
  28. "ColorChooser", "ColorChooserUI");
  29. public static final Region COMBO_BOX = new Region(
  30. "ComboBox", "ComboBoxUI");
  31. public static final Region DESKTOP_PANE = new Region("DesktopPane",
  32. "DesktopPaneUI");
  33. public static final Region DESKTOP_ICON = new Region("DesktopIcon",
  34. "DesktopIconUI");
  35. public static final Region EDITOR_PANE = new Region("EditorPane",
  36. "EditorPaneUI");
  37. public static final Region FILE_CHOOSER = new Region("FileChooser",
  38. "FileChooserUI");
  39. public static final Region FORMATTED_TEXT_FIELD = new Region(
  40. "FormattedTextField", "FormattedTextFieldUI");
  41. public static final Region INTERNAL_FRAME = new Region("InternalFrame",
  42. "InternalFrameUI");
  43. public static final Region INTERNAL_FRAME_TITLE_PANE =
  44. new Region("InternalFrameTitlePane",
  45. "InternalFrameTitlePaneUI");
  46. public static final Region LABEL = new Region("Label", "LabelUI");
  47. public static final Region LIST = new Region("List", "ListUI");
  48. public static final Region MENU = new Region("Menu", "MenuUI");
  49. public static final Region MENU_BAR = new Region("MenuBar", "MenuBarUI");
  50. public static final Region MENU_ITEM = new Region("MenuItem","MenuItemUI");
  51. public static final Region MENU_ITEM_ACCELERATOR = new Region(
  52. "MenuItemAccelerator");
  53. public static final Region OPTION_PANE = new Region("OptionPane",
  54. "OptionPaneUI");
  55. public static final Region PANEL = new Region("Panel", "PanelUI");
  56. public static final Region PASSWORD_FIELD = new Region("PasswordField",
  57. "PasswordFieldUI");
  58. public static final Region POPUP_MENU = new Region("PopupMenu",
  59. "PopupMenuUI");
  60. public static final Region POPUP_MENU_SEPARATOR = new Region(
  61. "PopupMenuSeparator", "PopupMenuSeparatorUI");
  62. public static final Region PROGRESS_BAR = new Region("ProgressBar",
  63. "ProgressBarUI");
  64. public static final Region RADIO_BUTTON = new Region(
  65. "RadioButton", "RadioButtonUI");
  66. public static final Region RADIO_BUTTON_MENU_ITEM = new Region(
  67. "RadioButtonMenuItem", "RadioButtonMenuItemUI");
  68. public static final Region ROOT_PANE = new Region("RootPane",
  69. "RootPaneUI");
  70. public static final Region SCROLL_BAR = new Region("ScrollBar",
  71. "ScrollBarUI");
  72. public static final Region SCROLL_BAR_TRACK = new Region("ScrollBarTrack");
  73. public static final Region SCROLL_BAR_THUMB = new Region("ScrollBarThumb");
  74. public static final Region SCROLL_PANE = new Region("ScrollPane",
  75. "ScrollPaneUI");
  76. public static final Region SEPARATOR = new Region("Separator",
  77. "SeparatorUI");
  78. public static final Region SLIDER = new Region("Slider", "SliderUI");
  79. public static final Region SLIDER_TRACK = new Region("SliderTrack");
  80. public static final Region SLIDER_THUMB = new Region("SliderThumb");
  81. public static final Region SPINNER = new Region("Spinner", "SpinnerUI");
  82. public static final Region SPLIT_PANE = new Region("SplitPane",
  83. "SplitPaneUI");
  84. public static final Region SPLIT_PANE_DIVIDER = new Region(
  85. "SplitPaneDivider", "SplitPaneDividerUI");
  86. public static final Region TABBED_PANE = new Region("TabbedPane",
  87. "TabbedPaneUI");
  88. public static final Region TABBED_PANE_TAB = new Region("TabbedPaneTab");
  89. public static final Region TABBED_PANE_TAB_AREA =
  90. new Region("TabbedPaneTabArea");
  91. public static final Region TABBED_PANE_CONTENT =
  92. new Region("TabbedPaneContent");
  93. public static final Region TABLE = new Region("Table", "TableUI");
  94. public static final Region TABLE_HEADER = new Region("TableHeader",
  95. "TableHeaderUI");
  96. public static final Region TEXT_AREA = new Region("TextArea",
  97. "TextAreaUI");
  98. public static final Region TEXT_FIELD = new Region("TextField",
  99. "TextFieldUI");
  100. public static final Region TEXT_PANE = new Region("TextPane",
  101. "TextPaneUI");
  102. public static final Region TOGGLE_BUTTON = new Region("ToggleButton",
  103. "ToggleButtonUI");
  104. public static final Region TOOL_BAR = new Region("ToolBar", "ToolBarUI");
  105. public static final Region TOOL_BAR_CONTENT = new Region("ToolBarContent");
  106. public static final Region TOOL_BAR_DRAG_WINDOW = new Region(
  107. "ToolBarDragWindow", null, false);
  108. public static final Region TOOL_TIP = new Region("ToolTip", "ToolTipUI");
  109. public static final Region TOOL_BAR_SEPARATOR = new Region(
  110. "ToolBarSeparator", "ToolBarSeparatorUI");
  111. public static final Region TREE = new Region("Tree", "TreeUI");
  112. public static final Region TREE_CELL = new Region("TreeCell");
  113. public static final Region VIEWPORT = new Region("Viewport", "ViewportUI");
  114. private String name;
  115. private boolean subregion;
  116. static Region getRegion(JComponent c) {
  117. return (Region)uiToRegionMap.get(c.getUIClassID());
  118. }
  119. static void registerUIs(UIDefaults table) {
  120. Iterator uis = uiToRegionMap.keySet().iterator();
  121. while (uis.hasNext()) {
  122. Object key = uis.next();
  123. table.put(key, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
  124. }
  125. }
  126. Region(String name) {
  127. this(name, null, true);
  128. }
  129. Region(String name, String ui) {
  130. this(name, ui, false);
  131. }
  132. Region(String name, String ui, boolean subregion) {
  133. this.name = name;
  134. if (ui != null) {
  135. uiToRegionMap.put(ui, this);
  136. }
  137. this.subregion = subregion;
  138. }
  139. /**
  140. * Returns true if the Region is a subregion of a Component.
  141. *
  142. * @return true if the Region is a subregion of a Component.
  143. */
  144. public boolean isSubregion() {
  145. return subregion;
  146. }
  147. /**
  148. * Returns the name of the region.
  149. *
  150. * @return name of the subregion.
  151. */
  152. public String getName() {
  153. return name;
  154. }
  155. public String toString() {
  156. return name;
  157. }
  158. }