1. /*
  2. * @(#)GTKStyle.java 1.96 04/01/13
  3. *
  4. * Copyright 2004 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 java.awt.*;
  9. import java.awt.event.*;
  10. import java.awt.image.*;
  11. import java.io.*;
  12. import java.lang.reflect.*;
  13. import javax.swing.*;
  14. import javax.swing.colorchooser.*;
  15. import javax.swing.plaf.*;
  16. import javax.swing.text.DefaultEditorKit;
  17. import java.util.*;
  18. import sun.awt.*;
  19. import java.security.*;
  20. import java.awt.RenderingHints;
  21. /**
  22. * @version 1.96, 01/13/04
  23. * @author Scott Violet
  24. */
  25. class GTKStyle extends DefaultSynthStyle implements GTKConstants {
  26. private static final Object PENDING = new StringBuffer("Pending");
  27. static final Color BLACK_COLOR = new ColorUIResource(Color.BLACK);
  28. static final Color WHITE_COLOR = new ColorUIResource(Color.WHITE);
  29. private static final Color[][] DEFAULT_COLORS;
  30. /**
  31. * State the color array at an particular index in DEFAULT_COLORS
  32. * represents.
  33. */
  34. private static final int[] DEFAULT_COLOR_MAP;
  35. // NOTE: This will only be used if you weren't using GTKLookAndFeel
  36. // to create a GTKStyle, otherwise the default comes from GTKLookAndFeel.
  37. private static final Font DEFAULT_FONT = new FontUIResource(
  38. "sansserif", Font.PLAIN, 10);
  39. /**
  40. * Backing style properties that are used if the style does not
  41. * defined the property.
  42. */
  43. // PENDING: This needs to be massaged so that it does not need to
  44. // be AppContext specific. In particular some of the Map values are
  45. // exposed and mutable and could effect other applets.
  46. private static final HashMap DATA = new HashMap();
  47. /**
  48. * Maps from a key that is passed to Style.get to the equivalent class
  49. * specific key.
  50. */
  51. private static final HashMap CLASS_SPECIFIC_MAP;
  52. private static final GTKGraphics GTK_GRAPHICS = new GTKGraphics();
  53. private static final Object ICON_SIZE_KEY = new StringBuffer("IconSize");
  54. /**
  55. * Default size for icons on dialogs (optionpane).
  56. */
  57. private static final Dimension DIALOG_ICON_SIZE = new Dimension(48, 48);
  58. /**
  59. * Default size for icons on buttons.
  60. */
  61. private static final Dimension BUTTON_ICON_SIZE = new Dimension(20, 20);
  62. // These have been included for completeness, but currently are not used
  63. private static final Dimension MENU_ICON_SIZE = new Dimension(16, 16);
  64. private static final Dimension SMALL_TOOLBAR_ICON_SIZE = new Dimension(18, 18);
  65. private static final Dimension LARGE_TOOLBAR_ICON_SIZE = new Dimension(24, 24);
  66. private static final Dimension DND_ICON_SIZE = new Dimension(32, 32);
  67. /**
  68. * Indicates the thickness has not been set.
  69. */
  70. static final int UNDEFINED_THICKNESS = -1;
  71. // NOTE: If you add a new field to this class you will need to update
  72. // addto, and possibly the clone and GTKStyle(GTKStyle) constructors.
  73. private int xThickness = 2;
  74. private int yThickness = 2;
  75. /**
  76. * Represents the values that are specific to a particular class.
  77. * This is a CircularIdentityList of CircularIdentityLists, where the
  78. * first level entries are gtk class names, and the second
  79. * CircularIdentityLists contains the actual key/value pairs.
  80. */
  81. private CircularIdentityList classSpecificValues;
  82. /**
  83. * GTK components have a single font which is used in all states.
  84. */
  85. private Font font;
  86. /**
  87. * Icons.
  88. */
  89. private GTKStockIconInfo[] icons;
  90. /**
  91. * Sets the size of a particular icon type.
  92. */
  93. static void setIconSize(String key, int w, int h) {
  94. getIconSizeMap().put(key, new Dimension(w, h));
  95. }
  96. /**
  97. * Returns the size of a particular icon type. This should NOT
  98. * modify the return value.
  99. */
  100. static Dimension getIconSize(String key) {
  101. return (Dimension)getIconSizeMap().get(key);
  102. }
  103. private static Map getIconSizeMap() {
  104. AppContext appContext = AppContext.getAppContext();
  105. Map iconSizes = (Map)appContext.get(ICON_SIZE_KEY);
  106. if (iconSizes == null) {
  107. iconSizes = new HashMap();
  108. iconSizes.put("gtk-dialog", DIALOG_ICON_SIZE);
  109. iconSizes.put("gtk-button", BUTTON_ICON_SIZE);
  110. iconSizes.put("gtk-menu", MENU_ICON_SIZE);
  111. iconSizes.put("gtk-small-toolbar", SMALL_TOOLBAR_ICON_SIZE);
  112. iconSizes.put("gtk-large-toolbar", LARGE_TOOLBAR_ICON_SIZE);
  113. iconSizes.put("gtk-dnd", DND_ICON_SIZE);
  114. appContext.put(ICON_SIZE_KEY, iconSizes);
  115. }
  116. return iconSizes;
  117. }
  118. /**
  119. * Calculates the LIGHT color from the background color.
  120. */
  121. static Color calculateLightColor(Color bg) {
  122. return GTKColorType.adjustColor(bg, 1.0f, 1.3f, 1.3f);
  123. }
  124. /**
  125. * Calculates the DARK color from the background color.
  126. */
  127. static Color calculateDarkColor(Color bg) {
  128. return GTKColorType.adjustColor(bg, 1.0f, .7f, .7f);
  129. }
  130. /**
  131. * Calculates the MID color from the light and dark colors.
  132. */
  133. static Color calculateMidColor(Color lightColor, Color darkColor) {
  134. int light = lightColor.getRGB();
  135. int dark = darkColor.getRGB();
  136. int rLight = (light & 0xFF0000) >> 16;
  137. int rDark = (dark & 0xFF0000) >> 16;
  138. int gLight = (light & 0x00FF00) >> 8;
  139. int gDark = (dark & 0x00FF00) >> 8;
  140. int bLight = (light & 0xFF);
  141. int bDark = (dark & 0xFF);
  142. return new ColorUIResource((((rLight + rDark) / 2) << 16) |
  143. (((gLight + gDark) / 2) << 8) |
  144. ((bLight + bDark) / 2));
  145. }
  146. /**
  147. * Calculates the MID color from the background color.
  148. */
  149. static Color calculateMidColor(Color bg) {
  150. return calculateMidColor(calculateLightColor(bg),
  151. calculateDarkColor(bg));
  152. }
  153. /**
  154. * Creates an array of colors populated based on the passed in
  155. * the background color. Specifically this sets the
  156. * BACKGROUND, LIGHT, DARK, MID, BLACK, WHITE and FOCUS colors
  157. * from that of color, which is assumed to be the background.
  158. */
  159. static Color[] getColorsFrom(Color bg, Color fg) {
  160. Color lightColor = calculateLightColor(bg);
  161. Color darkColor = calculateDarkColor(bg);
  162. Color midColor = calculateMidColor(lightColor, darkColor);
  163. Color[] colors = new Color[GTKColorType.MAX_COUNT];
  164. colors[GTKColorType.BACKGROUND.getID()] = bg;
  165. colors[GTKColorType.LIGHT.getID()] = lightColor;
  166. colors[GTKColorType.DARK.getID()] = darkColor;
  167. colors[GTKColorType.MID.getID()] = midColor;
  168. colors[GTKColorType.BLACK.getID()] = BLACK_COLOR;
  169. colors[GTKColorType.WHITE.getID()] = WHITE_COLOR;
  170. colors[GTKColorType.FOCUS.getID()] = BLACK_COLOR;
  171. colors[GTKColorType.FOREGROUND.getID()] = fg;
  172. colors[GTKColorType.TEXT_FOREGROUND.getID()] = fg;
  173. colors[GTKColorType.TEXT_BACKGROUND.getID()] = WHITE_COLOR;
  174. return colors;
  175. }
  176. public GTKStyle(DefaultSynthStyle style) {
  177. super(style);
  178. if (style instanceof GTKStyle) {
  179. GTKStyle gStyle = (GTKStyle)style;
  180. font = gStyle.font;
  181. xThickness = gStyle.xThickness;
  182. yThickness = gStyle.yThickness;
  183. icons = gStyle.icons;
  184. classSpecificValues = cloneClassSpecificValues(
  185. gStyle.classSpecificValues);
  186. }
  187. }
  188. public GTKStyle() {
  189. super(new Insets(-1, -1, -1, -1), true, null, null);
  190. }
  191. public GTKStyle(Font font) {
  192. this();
  193. this.font = font;
  194. }
  195. public GTKStyle(StateInfo[] states,
  196. CircularIdentityList classSpecificValues,
  197. Font font,
  198. int xThickness, int yThickness,
  199. GTKStockIconInfo[] icons) {
  200. super(new Insets(-1, -1, -1, -1), true, states, null);
  201. this.font = font;
  202. this.xThickness = xThickness;
  203. this.yThickness = yThickness;
  204. this.icons = icons;
  205. this.classSpecificValues = classSpecificValues;
  206. }
  207. public SynthGraphics getSynthGraphics(SynthContext context) {
  208. return GTK_GRAPHICS;
  209. }
  210. public GTKEngine getEngine(SynthContext context) {
  211. GTKEngine engine = (GTKEngine)get(context, "engine");
  212. if (engine == null) {
  213. return GTKEngine.INSTANCE;
  214. }
  215. return engine;
  216. }
  217. public SynthPainter getBorderPainter(SynthContext state) {
  218. SynthPainter painter = super.getBorderPainter(state);
  219. if (painter == null) {
  220. return GTKPainter.INSTANCE;
  221. }
  222. return painter;
  223. }
  224. public SynthPainter getBackgroundPainter(SynthContext state) {
  225. SynthPainter painter = super.getBackgroundPainter(state);
  226. if (painter == null) {
  227. return GTKPainter.INSTANCE;
  228. }
  229. return painter;
  230. }
  231. public Insets getInsets(SynthContext state, Insets insets) {
  232. insets = super.getInsets(state, insets);
  233. if (insets.top == -1) {
  234. insets.left = insets.right = insets.top = insets.bottom = 0;
  235. insets = GTKPainter.INSTANCE.getInsets(state, insets);
  236. }
  237. return insets;
  238. }
  239. /**
  240. * Returns the value for a class specific property. A class specific value
  241. * is a value that will be picked up based on class hierarchy.
  242. * For example, a value specified for JComponent would be inherited on
  243. * JButtons and JTrees, but not Button.
  244. *
  245. * Note, the key used here should only contain the letters A-Z, a-z, the
  246. * digits 0-9, and the '-' character. If you need to request a value for
  247. * a key having characters outside this list, replace any other characters
  248. * with '-'. (ie. "default_border" should be "default-border").
  249. */
  250. public Object getClassSpecificValue(SynthContext context, String key) {
  251. if (classSpecificValues != null) {
  252. String gtkClass = GTKStyleFactory.gtkClassFor(context.getRegion());
  253. while (gtkClass != null) {
  254. CircularIdentityList classValues = (CircularIdentityList)
  255. classSpecificValues.get(gtkClass);
  256. if (classValues != null) {
  257. Object value = classValues.get(key);
  258. if (value != null) {
  259. return value;
  260. }
  261. }
  262. gtkClass = GTKStyleFactory.gtkSuperclass(gtkClass);
  263. }
  264. }
  265. return null;
  266. }
  267. /**
  268. * Returns a class specific property.
  269. */
  270. public int getClassSpecificIntValue(SynthContext context, String key,
  271. int defaultValue) {
  272. Object value = getClassSpecificValue(context, key);
  273. if (value instanceof Number) {
  274. return ((Number)value).intValue();
  275. }
  276. return defaultValue;
  277. }
  278. /**
  279. * Returns a class specific property.
  280. */
  281. public Insets getClassSpecificInsetsValue(SynthContext context, String key,
  282. Insets defaultValue) {
  283. Object value = getClassSpecificValue(context, key);
  284. if (value instanceof Insets) {
  285. return (Insets)value;
  286. }
  287. return defaultValue;
  288. }
  289. /**
  290. * Returns a class specific property.
  291. */
  292. public boolean getClassSpecificBoolValue(SynthContext context, String key,
  293. boolean defaultValue) {
  294. Object value = getClassSpecificValue(context, key);
  295. if (value instanceof Boolean) {
  296. return ((Boolean)value).booleanValue();
  297. }
  298. return defaultValue;
  299. }
  300. public Object get(SynthContext context, Object key) {
  301. Object value = super.get(context, key);
  302. if (value == null) {
  303. // See if this is a class specific value.
  304. Object classKey = CLASS_SPECIFIC_MAP.get(key);
  305. if (classKey != null) {
  306. value = getClassSpecificValue(context, (String)classKey);
  307. if (value != null) {
  308. return value;
  309. }
  310. }
  311. if (key == "foreground" || key == "focus" ||
  312. key == "SplitPane.dragPainter" ||
  313. key == "ScrollPane.viewportBorderPainter") {
  314. return GTKPainter.INSTANCE;
  315. }
  316. else if (key == "ScrollPane.viewportBorderInsets") {
  317. return GTKPainter.INSTANCE.getScrollPaneInsets(context,
  318. new Insets(0,0,0,0));
  319. }
  320. synchronized (DATA) {
  321. value = DATA.get(key);
  322. try {
  323. while (value == PENDING) {
  324. DATA.wait();
  325. value = DATA.get(key);
  326. }
  327. } catch (InterruptedException ie) {
  328. }
  329. if (value instanceof UIDefaults.LazyValue) {
  330. DATA.put(key, PENDING);
  331. }
  332. }
  333. if (value instanceof StyleSpecificValue) {
  334. put(key, ((StyleSpecificValue)value).getValue(context));
  335. }
  336. else if (value instanceof UIDefaults.ActiveValue) {
  337. value = ((UIDefaults.ActiveValue)value).
  338. createValue(null);
  339. }
  340. else if (value instanceof UIDefaults.LazyValue) {
  341. value = ((UIDefaults.LazyValue)value).
  342. createValue(null);
  343. synchronized(DATA) {
  344. DATA.put(key, value);
  345. DATA.notifyAll();
  346. }
  347. }
  348. }
  349. return value;
  350. }
  351. protected Font _getFont(JComponent c, Region id, int state) {
  352. if (font != null) {
  353. return font;
  354. }
  355. state = GTKLookAndFeel.synthStateToGTKState(id, state);
  356. Font f = super._getFont(c, id, state);
  357. if (f == null) {
  358. return DEFAULT_FONT;
  359. }
  360. return f;
  361. }
  362. /**
  363. * This method is to be used inside the GTK package when we want a
  364. * color for an explicit state, it will not attempt to remap the state
  365. * as getColor will.
  366. */
  367. Color getGTKColor(JComponent c, Region id,
  368. int state, ColorType type) {
  369. Color color = super._getColor(c, id, state, type);
  370. if (color != null) {
  371. return color;
  372. }
  373. return getDefaultColor(c, id, state, type);
  374. }
  375. /**
  376. * getColor is overriden to map the state from a Synth state to the
  377. * GTK state, this should be not used when you have already mapped the
  378. * state. Additionally this will map TEXT_FOREGROUND to the
  379. * <code>c.getForeground()</code> if it is non-null and not a UIResource.
  380. */
  381. public Color getColor(JComponent c, Region id, int state,
  382. ColorType type) {
  383. if (id == Region.LABEL && type == ColorType.TEXT_FOREGROUND) {
  384. type = ColorType.FOREGROUND;
  385. }
  386. state = GTKLookAndFeel.synthStateToGTKState(id, state);
  387. if (!id.isSubregion() &&
  388. (state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
  389. if (type == ColorType.BACKGROUND) {
  390. return c.getBackground();
  391. }
  392. else if (type == ColorType.FOREGROUND) {
  393. return c.getForeground();
  394. }
  395. else if (type == ColorType.TEXT_FOREGROUND) {
  396. Color fg = c.getForeground();
  397. if (fg != null && !(fg instanceof UIResource)) {
  398. // Only use the fg for text if specified.
  399. return fg;
  400. }
  401. }
  402. }
  403. return _getColor(c, id, state, type);
  404. }
  405. protected Color _getColor(JComponent c, Region id, int state,
  406. ColorType type) {
  407. Color color = super._getColor(c, id, state, type);
  408. if (color != null) {
  409. return color;
  410. }
  411. if (type == ColorType.FOCUS) {
  412. return BLACK_COLOR;
  413. }
  414. else if (type == GTKColorType.BLACK) {
  415. return BLACK_COLOR;
  416. }
  417. else if (type == GTKColorType.WHITE) {
  418. return WHITE_COLOR;
  419. }
  420. if (type == ColorType.TEXT_FOREGROUND && (GTKStyleFactory.
  421. isLabelBearing(id) || id == Region.MENU_ITEM_ACCELERATOR ||
  422. id == Region.TABBED_PANE_TAB)) {
  423. type = ColorType.FOREGROUND;
  424. }
  425. else if (id == Region.TABLE || id == Region.LIST ||
  426. id == Region.TREE || id == Region.TREE_CELL){
  427. if (type == ColorType.FOREGROUND) {
  428. type = ColorType.TEXT_FOREGROUND;
  429. if (state == SynthConstants.PRESSED) {
  430. state = SynthConstants.SELECTED;
  431. }
  432. }
  433. else if (type == ColorType.BACKGROUND) {
  434. type = ColorType.TEXT_BACKGROUND;
  435. if (state == SynthConstants.PRESSED) {
  436. state = SynthConstants.SELECTED;
  437. }
  438. }
  439. }
  440. return getDefaultColor(c, id, state, type);
  441. }
  442. Color getDefaultColor(JComponent c, Region id, int state,
  443. ColorType type) {
  444. if (type == ColorType.FOCUS) {
  445. return BLACK_COLOR;
  446. }
  447. else if (type == GTKColorType.BLACK) {
  448. return BLACK_COLOR;
  449. }
  450. else if (type == GTKColorType.WHITE) {
  451. return WHITE_COLOR;
  452. }
  453. for (int counter = DEFAULT_COLOR_MAP.length - 1;
  454. counter >= 0; counter--) {
  455. if ((DEFAULT_COLOR_MAP[counter] & state) != 0) {
  456. if (type.getID() < DEFAULT_COLORS[counter].length) {
  457. return DEFAULT_COLORS[counter][type.getID()];
  458. }
  459. }
  460. }
  461. if (type.getID() < DEFAULT_COLORS[2].length) {
  462. return DEFAULT_COLORS[2][type.getID()];
  463. }
  464. return null;
  465. }
  466. public boolean isOpaque(SynthContext context) {
  467. Region region = context.getRegion();
  468. if (region == Region.COMBO_BOX ||
  469. region == Region.DESKTOP_PANE ||
  470. region == Region.DESKTOP_ICON ||
  471. region == Region.EDITOR_PANE ||
  472. region == Region.FORMATTED_TEXT_FIELD ||
  473. region == Region.INTERNAL_FRAME ||
  474. region == Region.LIST ||
  475. region == Region.MENU_BAR ||
  476. region == Region.PASSWORD_FIELD ||
  477. region == Region.POPUP_MENU ||
  478. region == Region.PROGRESS_BAR ||
  479. region == Region.ROOT_PANE ||
  480. region == Region.SCROLL_PANE ||
  481. region == Region.SPINNER ||
  482. region == Region.TABLE ||
  483. region == Region.TEXT_AREA ||
  484. region == Region.TEXT_FIELD ||
  485. region == Region.TEXT_PANE ||
  486. region == Region.TOOL_BAR_DRAG_WINDOW ||
  487. region == Region.TOOL_TIP ||
  488. region == Region.TREE ||
  489. region == Region.VIEWPORT) {
  490. return true;
  491. }
  492. return false;
  493. }
  494. public int getXThickness() {
  495. return xThickness;
  496. }
  497. public int getYThickness() {
  498. return yThickness;
  499. }
  500. private Icon getStockIcon(SynthContext context, String key, String size) {
  501. Icon icon = null;
  502. GTKStockIconInfo iconInfo = null;
  503. GTKIconSource bestSource = null;
  504. int direction = LTR;
  505. if (context != null) {
  506. ComponentOrientation co = context.getComponent().
  507. getComponentOrientation();
  508. if (co == null || co.isLeftToRight()) {
  509. direction = LTR;
  510. }
  511. else {
  512. direction = RTL;
  513. }
  514. }
  515. // See if the style defines an icon
  516. if (icons != null) {
  517. for (int i = 0; i < icons.length; i++) {
  518. // find the first one that matches our key
  519. if (icons[i].getKey() == key) {
  520. iconInfo = icons[i];
  521. break;
  522. }
  523. }
  524. if (iconInfo != null) {
  525. // PENDING(shannonh) - pass in actual state
  526. bestSource = iconInfo.getBestIconSource(direction,
  527. SynthConstants.ENABLED,
  528. size);
  529. }
  530. if (bestSource != null) {
  531. icon = bestSource.toIcon();
  532. }
  533. }
  534. if (icon == null) {
  535. // Use a default icon
  536. icon = (Icon)((UIDefaults.LazyValue)LookAndFeel.makeIcon(
  537. GTKStyle.class, "resources/" + key + "-" + size +
  538. ".png")).createValue(null);
  539. }
  540. // If we used a default, or if the stock icon we found had a wildcard size,
  541. // we force the size to match that requested
  542. if (icon != null && (bestSource == null || bestSource.getSize() == null)) {
  543. Dimension iconSize = getIconSize(size);
  544. if (iconSize != null && (icon.getIconWidth() != iconSize.width ||
  545. icon.getIconHeight() != iconSize.height)) {
  546. Image image = new BufferedImage(iconSize.width, iconSize.height,
  547. BufferedImage.TYPE_INT_ARGB);
  548. Graphics2D g2d = (Graphics2D)image.getGraphics();
  549. // for nicer scaling
  550. g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
  551. RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  552. Image oldImage = null;
  553. if (icon instanceof ImageIcon) {
  554. oldImage = ((ImageIcon)icon).getImage();
  555. } else {
  556. oldImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
  557. BufferedImage.TYPE_INT_ARGB);
  558. Graphics g = oldImage.getGraphics();
  559. icon.paintIcon(null, g, 0, 0);
  560. g.dispose();
  561. }
  562. g2d.drawImage(oldImage, 0, 0, iconSize.width, iconSize.height, null);
  563. g2d.dispose();
  564. icon = new ImageIcon(image);
  565. }
  566. }
  567. return icon;
  568. }
  569. /**
  570. * Adds the specific label based properties from <code>style</code> to
  571. * this style.
  572. */
  573. void addLabelProperties(GTKStyle style) {
  574. // Take the font
  575. this.font = style.font;
  576. // And TEXT_FOREGROUND
  577. if (states == null) {
  578. if (style.states == null) {
  579. return;
  580. }
  581. states = new StateInfo[style.states.length];
  582. for (int counter = 0; counter < style.states.length; counter++) {
  583. Color color = style.states[counter].getColor(
  584. GTKColorType.FOREGROUND);
  585. states[counter] = createStateInfo(style.states[counter].
  586. getComponentState(), GTKColorType.TEXT_FOREGROUND, color);
  587. }
  588. }
  589. else {
  590. // Reset the text foreground of all our states, this will ensure
  591. // the correct color is picked up if style doesn't specify a
  592. // text color.
  593. for (int counter = states.length - 1; counter >= 0; counter--) {
  594. ((GTKStateInfo)states[counter]).setColor(
  595. GTKColorType.TEXT_FOREGROUND, null);
  596. }
  597. if (style.states != null) {
  598. for (int oCounter = style.states.length - 1; oCounter >= 0;
  599. oCounter--) {
  600. boolean matched = false;
  601. StateInfo oState = style.states[oCounter];
  602. int componentState = oState.getComponentState();
  603. Color color = oState.getColor(GTKColorType.FOREGROUND);
  604. for (int tCounter = states.length - 1; tCounter >= 0;
  605. tCounter--) {
  606. if (componentState == states[tCounter].
  607. getComponentState()) {
  608. ((GTKStateInfo)states[tCounter]).setColor(
  609. GTKColorType.TEXT_FOREGROUND, color);
  610. matched = true;
  611. break;
  612. }
  613. }
  614. if (!matched) {
  615. StateInfo[] newStates = new StateInfo[states.length+1];
  616. System.arraycopy(states, 0, newStates, 0,
  617. states.length);
  618. newStates[states.length] = createStateInfo(
  619. componentState, GTKColorType.TEXT_FOREGROUND,
  620. color);
  621. states = newStates;
  622. }
  623. }
  624. }
  625. }
  626. }
  627. /**
  628. * Creates a StateInfo with the specified component state, ColorType
  629. * and color. Subclasses that create a custom GTKStateInfo will need
  630. * to subclass and override this.
  631. */
  632. GTKStateInfo createStateInfo(int state, ColorType type, Color color) {
  633. Color[] colors = new Color[GTKColorType.MAX_COUNT];
  634. colors[type.getID()] = color;
  635. return new GTKStateInfo(state, null, null, null, colors, null);
  636. }
  637. /**
  638. * Adds a value specific to the style.
  639. */
  640. void put(Object key, Object value) {
  641. if (data == null) {
  642. data = new HashMap();
  643. }
  644. data.put(key, value);
  645. }
  646. /**
  647. * Returns true if the style should fill in the background of the
  648. * specified context for the specified state.
  649. */
  650. boolean fillBackground(SynthContext context, int state) {
  651. GTKStateInfo info = (GTKStateInfo)getStateInfo(state);
  652. if (info != null) {
  653. Object backgroundImage = info.getBackgroundImage();
  654. if (backgroundImage == "<none>" || backgroundImage == null) {
  655. return true;
  656. }
  657. return false;
  658. }
  659. return true;
  660. }
  661. /**
  662. * Returns the Icon to fill the background in with for the specified
  663. * context and state.
  664. */
  665. Image getBackgroundImage(SynthContext context, int state) {
  666. GTKStateInfo info = (GTKStateInfo)getStateInfo(state);
  667. if (info != null) {
  668. Object backgroundImage = info.getBackgroundImage();
  669. if (backgroundImage instanceof Image) {
  670. return (Image)backgroundImage;
  671. }
  672. }
  673. return null;
  674. }
  675. /**
  676. * Creates a clone of the receiver.
  677. */
  678. public Object clone() {
  679. GTKStyle style = (GTKStyle)super.clone();
  680. style.classSpecificValues = cloneClassSpecificValues(
  681. style.classSpecificValues);
  682. return style;
  683. }
  684. public DefaultSynthStyle addTo(DefaultSynthStyle style) {
  685. if (!(style instanceof GTKStyle)) {
  686. style = new GTKStyle(style);
  687. }
  688. GTKStyle gtkStyle = (GTKStyle)super.addTo(style);
  689. if (xThickness != UNDEFINED_THICKNESS) {
  690. gtkStyle.xThickness = xThickness;
  691. }
  692. if (yThickness != UNDEFINED_THICKNESS) {
  693. gtkStyle.yThickness = yThickness;
  694. }
  695. if (font != null) {
  696. gtkStyle.font = font;
  697. }
  698. if (gtkStyle.icons == null) {
  699. gtkStyle.icons = icons;
  700. }
  701. else if (icons != null) {
  702. GTKStockIconInfo[] mergedIcons =
  703. new GTKStockIconInfo[gtkStyle.icons.length + icons.length];
  704. System.arraycopy(icons, 0, mergedIcons, 0, icons.length);
  705. System.arraycopy(gtkStyle.icons, 0, mergedIcons, icons.length, gtkStyle.icons.length);
  706. gtkStyle.icons = mergedIcons;
  707. }
  708. if (gtkStyle.classSpecificValues == null) {
  709. gtkStyle.classSpecificValues =
  710. cloneClassSpecificValues(classSpecificValues);
  711. } else {
  712. addClassSpecificValues(classSpecificValues, gtkStyle.classSpecificValues);
  713. }
  714. return gtkStyle;
  715. }
  716. /**
  717. * Adds the data from one set of class specific values into another.
  718. *
  719. * @param from the list to grab data from (may be null)
  720. * @param to the list to add data to (may not be null)
  721. */
  722. static void addClassSpecificValues(CircularIdentityList from,
  723. CircularIdentityList to) {
  724. if (to == null) {
  725. throw new IllegalArgumentException("to may not be null");
  726. }
  727. if (from == null) {
  728. return;
  729. }
  730. synchronized(from) {
  731. Object firstKey = from.next();
  732. if (firstKey != null) {
  733. Object key = firstKey;
  734. do {
  735. CircularIdentityList cList = ((CircularIdentityList)
  736. from.get());
  737. CircularIdentityList oSublist = (CircularIdentityList)
  738. to.get(key);
  739. if (oSublist == null) {
  740. to.set(key, cList.clone());
  741. }
  742. else {
  743. Object cFirstKey = cList.next();
  744. if (cFirstKey != null) {
  745. Object cKey = cFirstKey;
  746. do {
  747. oSublist.set(cKey, cList.get());
  748. cKey = cList.next();
  749. } while (cKey != cFirstKey);
  750. }
  751. }
  752. key = from.next();
  753. } while (key != firstKey);
  754. }
  755. }
  756. }
  757. /**
  758. * Clones the class specific values.
  759. */
  760. static CircularIdentityList cloneClassSpecificValues(
  761. CircularIdentityList list) {
  762. if (list == null) {
  763. return null;
  764. }
  765. CircularIdentityList clone;
  766. synchronized(list) {
  767. Object firstKey = list.next();
  768. if (firstKey == null) {
  769. // Empty list
  770. return null;
  771. }
  772. clone = new CircularIdentityList();
  773. Object key = firstKey;
  774. do {
  775. clone.set(key, ((CircularIdentityList)list.get()).clone());
  776. key = list.next();
  777. } while (key != firstKey);
  778. }
  779. return clone;
  780. }
  781. /**
  782. * GTKStockIconInfo mirrors the information from a stock declaration
  783. * in the rc file: stock icon id, and a set of icon source
  784. * specifications.
  785. */
  786. static class GTKStockIconInfo {
  787. private String key;
  788. private GTKIconSource[] sources;
  789. GTKStockIconInfo(String key, GTKIconSource[] sources) {
  790. this.key = key.intern();
  791. this.sources = sources;
  792. Arrays.sort(this.sources);
  793. }
  794. public String getKey() {
  795. return key;
  796. }
  797. public GTKIconSource getBestIconSource(int direction, int state, String size) {
  798. for (int i = 0; i < sources.length; i++) {
  799. GTKIconSource src = sources[i];
  800. if ((src.direction == UNDEFINED || src.direction == direction)
  801. && (src.state == UNDEFINED || src.state == state)
  802. && (src.size == null || sizesMatch(src.size, size))) {
  803. return src;
  804. }
  805. }
  806. return null;
  807. }
  808. private static boolean sizesMatch(String sizeOne, String sizeTwo) {
  809. //Dimension one = getIconSize(sizeOne);
  810. //Dimension two = getIconSize(sizeTwo);
  811. //return one.width == two.width && one.height == two.height;
  812. // An earlier version of GTK compared the actual pixel sizes for
  813. // equality. Now it just compares the logical sizes.
  814. return sizeOne == sizeTwo;
  815. }
  816. public String toString() {
  817. StringBuffer buf = new StringBuffer("STOCK ICON " + key + ":\n");
  818. for (int i = 0; i < sources.length; i++) {
  819. buf.append(" ").append(sources[i].toString()).append('\n');
  820. }
  821. // remove last newline
  822. buf.deleteCharAt(buf.length() - 1);
  823. return buf.toString();
  824. }
  825. }
  826. /**
  827. * GTKIconSource represents a single icon source specification,
  828. * as declared inside a stock definition in an rc file:
  829. * path to image, size, direction, and state.
  830. */
  831. static class GTKIconSource implements Comparable {
  832. private Object image;
  833. private int direction;
  834. private int state;
  835. private String size;
  836. GTKIconSource(String image, int direction, int state, String size) {
  837. this.image = image;
  838. this.direction = direction;
  839. this.state = state;
  840. if (size != null) {
  841. this.size = size.intern();
  842. }
  843. }
  844. public int getDirection() {
  845. return direction;
  846. }
  847. public int getState() {
  848. return state;
  849. }
  850. public String getSize() {
  851. return size;
  852. }
  853. public int compareTo(Object o) {
  854. GTKIconSource other = (GTKIconSource)o;
  855. if (direction != UNDEFINED && other.direction == UNDEFINED) {
  856. return -1;
  857. } else if (direction == UNDEFINED && other.direction != UNDEFINED) {
  858. return 1;
  859. } else if (state != UNDEFINED && other.state == UNDEFINED) {
  860. return -1;
  861. } else if (state == UNDEFINED && other.state != UNDEFINED) {
  862. return 1;
  863. } else if (size != null && other.size == null) {
  864. return -1;
  865. } else if (size == null && other.size != null) {
  866. return 1;
  867. } else {
  868. return 0;
  869. }
  870. }
  871. public String toString() {
  872. return "image=" + image + ", dir=" + getDirectionName(direction)
  873. + ", state=" + getStateName(state, "*")
  874. + ", size=" + (size == null ? "*" : size);
  875. }
  876. // used above by toString()
  877. private static String getDirectionName(int dir) {
  878. switch(dir) {
  879. case LTR: return "LTR";
  880. case RTL: return "RTL";
  881. case UNDEFINED: return "*";
  882. }
  883. return "UNKNOWN";
  884. }
  885. public Icon toIcon() {
  886. if (image == null || image instanceof Icon) {
  887. return (Icon)image;
  888. }
  889. ImageIcon ii = (ImageIcon)AccessController.doPrivileged(new PrivilegedAction() {
  890. public Object run() {
  891. return new ImageIcon((String)image);
  892. }
  893. });
  894. if (ii.getIconWidth() > 0 && ii.getIconHeight() > 0) {
  895. image = ii;
  896. } else {
  897. // if we decide to mimic GTK and show a broken image,
  898. // it would be assigned to 'image' here
  899. image = null;
  900. }
  901. return (Icon)image;
  902. }
  903. }
  904. public String toString() {
  905. StringBuffer buf = new StringBuffer();
  906. buf.append("class=");
  907. buf.append(getClass().getName()).append('\n');
  908. if (font != null) {
  909. buf.append("font=").append(font.toString()).append('\n');
  910. }
  911. if (xThickness != UNDEFINED_THICKNESS) {
  912. buf.append("xt=").append(String.valueOf(xThickness)).append('\n');
  913. }
  914. if (yThickness != UNDEFINED_THICKNESS) {
  915. buf.append("yt=").append(String.valueOf(yThickness)).append('\n');
  916. }
  917. if (states != null) {
  918. buf.append("*** Colors and Pixmaps ***\n");
  919. for (int i = 0; i < states.length; i++) {
  920. buf.append(states[i].toString()).append('\n');
  921. }
  922. }
  923. if (classSpecificValues != null) {
  924. buf.append("*** Properties ***\n");
  925. buf.append(classSpecValsToString(classSpecificValues)).append('\n');
  926. }
  927. if (icons != null) {
  928. buf.append("*** Stock Icons ***\n");
  929. for (int i = 0; i < icons.length; i++) {
  930. buf.append(icons[i].toString()).append('\n');
  931. }
  932. }
  933. // remove last newline
  934. buf.deleteCharAt(buf.length() - 1);
  935. return buf.toString();
  936. }
  937. // used by toString()
  938. private static String classSpecValsToString(CircularIdentityList parent) {
  939. StringBuffer buf = new StringBuffer();
  940. Object parentFirst = parent.next();
  941. if (parentFirst == null) {
  942. return "";
  943. }
  944. Object parentKey = parentFirst;
  945. do {
  946. buf.append(parentKey).append('\n');
  947. CircularIdentityList child = (CircularIdentityList)parent.get();
  948. Object childFirst = child.next();
  949. if (childFirst == null) {
  950. break;
  951. }
  952. Object childKey = childFirst;
  953. do {
  954. buf.append(" ").append(childKey).append('=').append(child.get()).append('\n');
  955. childKey = child.next();
  956. } while (childKey != childFirst);
  957. parentKey = parent.next();
  958. } while (parentKey != parentFirst);
  959. // remove last newline
  960. buf.deleteCharAt(buf.length() - 1);
  961. return buf.toString();
  962. }
  963. /**
  964. * A subclass of StateInfo adding additional GTK state information.
  965. */
  966. public static class GTKStateInfo extends StateInfo {
  967. // <none>: fill in with background color
  968. // <parent>: do nothing, parent will have handled it
  969. // image: paint it.
  970. private Object backgroundImage;
  971. public GTKStateInfo(int state, SynthPainter bPainter,
  972. SynthPainter bgPainter, Font font, Color[] colors,
  973. Object backgroundImage) {
  974. super(state, bPainter, bgPainter, font, colors);
  975. this.backgroundImage = backgroundImage;
  976. }
  977. public GTKStateInfo(StateInfo info) {
  978. super(info);
  979. if (info instanceof GTKStateInfo) {
  980. backgroundImage = ((GTKStateInfo)info).backgroundImage;
  981. }
  982. }
  983. void setColor(ColorType type, Color color) {
  984. if (colors == null) {
  985. if (color == null) {
  986. return;
  987. }
  988. colors = new Color[GTKColorType.MAX_COUNT];
  989. }
  990. colors[type.getID()] = color;
  991. }
  992. public Color getColor(ColorType type) {
  993. Color color = super.getColor(type);
  994. if (color == null) {
  995. Color[] colors = getColors();
  996. Color bg;
  997. if (colors != null && (bg = super.getColor(
  998. GTKColorType.BACKGROUND)) != null) {
  999. if (type == GTKColorType.LIGHT) {
  1000. color = colors[GTKColorType.LIGHT.getID()] =
  1001. calculateLightColor(bg);
  1002. }
  1003. else if (type == GTKColorType.MID) {
  1004. color = colors[GTKColorType.MID.getID()] =
  1005. calculateMidColor(bg);
  1006. }
  1007. else if (type == GTKColorType.DARK) {
  1008. color = colors[GTKColorType.DARK.getID()] =
  1009. calculateDarkColor(bg);
  1010. }
  1011. }
  1012. }
  1013. return color;
  1014. }
  1015. /**
  1016. * This returns the background image, and will be one of:
  1017. * the String "<none>", the String "<parent>" or an Image.
  1018. *
  1019. * @return the background.
  1020. */
  1021. Object getBackgroundImage() {
  1022. if (backgroundImage == null ||
  1023. (backgroundImage instanceof Image) ||
  1024. backgroundImage == "<none>" ||
  1025. backgroundImage == "<parent>") {
  1026. return backgroundImage;
  1027. }
  1028. ImageIcon ii = (ImageIcon)AccessController.doPrivileged(new PrivilegedAction() {
  1029. public Object run() {
  1030. return new ImageIcon((String)backgroundImage);
  1031. }
  1032. });
  1033. if (ii.getIconWidth() > 0 && ii.getIconHeight() > 0) {
  1034. backgroundImage = ii.getImage();
  1035. } else {
  1036. backgroundImage = null;
  1037. }
  1038. return backgroundImage;
  1039. }
  1040. public Object clone() {
  1041. return new GTKStateInfo(this);
  1042. }
  1043. public StateInfo addTo(StateInfo info) {
  1044. if (!(info instanceof GTKStateInfo)) {
  1045. info = new GTKStateInfo(info);
  1046. }
  1047. else {
  1048. super.addTo(info);
  1049. }
  1050. GTKStateInfo gInfo = (GTKStateInfo)info;
  1051. if (backgroundImage != null) {
  1052. gInfo.backgroundImage = backgroundImage;
  1053. }
  1054. return gInfo;
  1055. }
  1056. public String toString() {
  1057. StringBuffer buf = new StringBuffer();
  1058. buf.append(getStateName(getComponentState(), "UNDEFINED")).append(":\n");
  1059. if (getColor(GTKColorType.FOREGROUND) != null) {
  1060. buf.append(" fg=").append(getColor(GTKColorType.FOREGROUND)).append('\n');
  1061. }
  1062. if (getColor(GTKColorType.BACKGROUND) != null) {
  1063. buf.append(" bg=").append(getColor(GTKColorType.BACKGROUND)).append('\n');
  1064. }
  1065. if (getColor(GTKColorType.TEXT_FOREGROUND) != null) {
  1066. buf.append(" text=").append(getColor(GTKColorType.TEXT_FOREGROUND)).append('\n');
  1067. }
  1068. if (getColor(GTKColorType.TEXT_BACKGROUND) != null) {
  1069. buf.append(" base=").append(getColor(GTKColorType.TEXT_BACKGROUND)).append('\n');
  1070. }
  1071. if (backgroundImage != null) {
  1072. buf.append(" pmn=").append(backgroundImage).append('\n');
  1073. }
  1074. // remove last newline
  1075. buf.deleteCharAt(buf.length() - 1);
  1076. return buf.toString();
  1077. }
  1078. }
  1079. // used by toString() in some of our inner classes
  1080. static String getStateName(int state, String undef) {
  1081. switch(state) {
  1082. case SynthConstants.ENABLED: return "NORMAL";
  1083. case SynthConstants.PRESSED: return "ACTIVE";
  1084. case SynthConstants.SELECTED: return "SELECTED";
  1085. case SynthConstants.MOUSE_OVER: return "PRELIGHT";
  1086. case SynthConstants.DISABLED: return "INSENSITIVE";
  1087. case UNDEFINED: return undef;
  1088. }
  1089. return "UNKNOWN";
  1090. }
  1091. /**
  1092. * A tagging interface indicating that a value coming from
  1093. * DATA should be added to the Style's data after invoking getValue.
  1094. * This is useful for lazy type properties that need to key off information
  1095. * kept in the style.
  1096. */
  1097. interface StyleSpecificValue {
  1098. public Object getValue(SynthContext context);
  1099. }
  1100. /**
  1101. * An Icon that is fetched using getStockIcon.
  1102. */
  1103. private static class GTKStockIcon extends SynthIcon implements Cloneable,
  1104. StyleSpecificValue {
  1105. private String key;
  1106. private String size;
  1107. private boolean loadedLTR;
  1108. private boolean loadedRTL;
  1109. private Icon ltrIcon;
  1110. private Icon rtlIcon;
  1111. private SynthStyle style;
  1112. GTKStockIcon(String key, String size) {
  1113. this.key = key;
  1114. this.size = size;
  1115. }
  1116. public void paintIcon(SynthContext context, Graphics g, int x,
  1117. int y, int w, int h) {
  1118. Icon icon = getIcon(context);
  1119. if (icon != null) {
  1120. if (context == null) {
  1121. icon.paintIcon(null, g, x, y);
  1122. }
  1123. else {
  1124. icon.paintIcon(context.getComponent(), g, x, y);
  1125. }
  1126. }
  1127. }
  1128. public int getIconWidth(SynthContext context) {
  1129. Icon icon = getIcon(context);
  1130. if (icon != null) {
  1131. return icon.getIconWidth();
  1132. }
  1133. return 0;
  1134. }
  1135. public int getIconHeight(SynthContext context) {
  1136. Icon icon = getIcon(context);
  1137. if (icon != null) {
  1138. return icon.getIconHeight();
  1139. }
  1140. return 0;
  1141. }
  1142. private Icon getIcon(SynthContext context) {
  1143. if (context != null) {
  1144. ComponentOrientation co = context.getComponent().
  1145. getComponentOrientation();
  1146. SynthStyle style = context.getStyle();
  1147. if (style != this.style) {
  1148. this.style = style;
  1149. loadedLTR = loadedRTL = false;
  1150. }
  1151. if (co == null || co.isLeftToRight()) {
  1152. if (!loadedLTR) {
  1153. loadedLTR = true;
  1154. ltrIcon = ((GTKStyle)context.getStyle()).
  1155. getStockIcon(context, key, size);
  1156. }
  1157. return ltrIcon;
  1158. }
  1159. else if (!loadedRTL) {
  1160. loadedRTL = true;
  1161. rtlIcon = ((GTKStyle)context.getStyle()).
  1162. getStockIcon(context, key,size);
  1163. }
  1164. return rtlIcon;
  1165. }
  1166. return ltrIcon;
  1167. }
  1168. public Object getValue(SynthContext context) {
  1169. try {
  1170. return clone();
  1171. } catch (CloneNotSupportedException cnse) {
  1172. }
  1173. return null;
  1174. }
  1175. }
  1176. /**
  1177. * MetalLazyValue is a slimmed down version of <code>ProxyLaxyValue</code>.
  1178. * The code is duplicate so that it can get at the package private
  1179. * classes in gtk.
  1180. */
  1181. static class GTKLazyValue implements UIDefaults.LazyValue {
  1182. /**
  1183. * Name of the class to create.
  1184. */
  1185. private String className;
  1186. private String methodName;
  1187. GTKLazyValue(String name) {
  1188. this(name, null);
  1189. }
  1190. GTKLazyValue(String name, String methodName) {
  1191. this.className = name;
  1192. this.methodName = methodName;
  1193. }
  1194. public Object createValue(UIDefaults table) {
  1195. try {
  1196. Class c = Class.forName(className, true,Thread.currentThread().
  1197. getContextClassLoader());
  1198. if (methodName == null) {
  1199. return c.newInstance();
  1200. }
  1201. Method m = c.getMethod(methodName, null);
  1202. return m.invoke(c, null);
  1203. } catch (ClassNotFoundException cnfe) {
  1204. } catch (IllegalAccessException iae) {
  1205. } catch (InvocationTargetException ite) {
  1206. } catch (NoSuchMethodException nsme) {
  1207. } catch (InstantiationException ie) {
  1208. }
  1209. return null;
  1210. }
  1211. }
  1212. static {
  1213. DEFAULT_COLOR_MAP = new int[] {
  1214. SynthConstants.PRESSED, SynthConstants.SELECTED,
  1215. SynthConstants.ENABLED, SynthConstants.MOUSE_OVER,
  1216. SynthConstants.DISABLED
  1217. };
  1218. DEFAULT_COLORS = new Color[5][];
  1219. // 2.0 colors
  1220. //
  1221. if (!GTKLookAndFeel.is2_2()) {
  1222. DEFAULT_COLORS[0] = getColorsFrom(
  1223. new ColorUIResource(195, 195, 195), BLACK_COLOR);
  1224. DEFAULT_COLORS[1] = getColorsFrom(
  1225. new ColorUIResource(0, 0, 156), WHITE_COLOR);
  1226. DEFAULT_COLORS[2] = getColorsFrom(
  1227. new ColorUIResource(214, 214, 214), BLACK_COLOR);
  1228. DEFAULT_COLORS[3] = getColorsFrom(
  1229. new ColorUIResource(233, 233, 233), BLACK_COLOR);
  1230. DEFAULT_COLORS[4] = getColorsFrom(
  1231. new ColorUIResource(214, 214, 214),
  1232. new ColorUIResource(117, 117, 117));
  1233. DEFAULT_COLORS[0][GTKColorType.TEXT_BACKGROUND.getID()] = new
  1234. ColorUIResource(188, 210, 238);
  1235. DEFAULT_COLORS[1][GTKColorType.TEXT_BACKGROUND.getID()] = new
  1236. ColorUIResource(164, 223, 255);
  1237. DEFAULT_COLORS[1][GTKColorType.TEXT_FOREGROUND.getID()] =
  1238. BLACK_COLOR;
  1239. DEFAULT_COLORS[2][GTKColorType.TEXT_FOREGROUND.getID()] =
  1240. BLACK_COLOR;
  1241. DEFAULT_COLORS[4][GTKColorType.TEXT_FOREGROUND.getID()] =
  1242. DEFAULT_COLORS[2][GTKColorType.TEXT_FOREGROUND.getID()];
  1243. }
  1244. else {
  1245. // 2.2 colors
  1246. DEFAULT_COLORS[0] = getColorsFrom(
  1247. new ColorUIResource(186, 181, 171), BLACK_COLOR);
  1248. DEFAULT_COLORS[1] = getColorsFrom(
  1249. new ColorUIResource(75, 105, 131), WHITE_COLOR);
  1250. DEFAULT_COLORS[2] = getColorsFrom(
  1251. new ColorUIResource(220, 218, 213), BLACK_COLOR);
  1252. DEFAULT_COLORS[3] = getColorsFrom(
  1253. new ColorUIResource(238, 235, 231), BLACK_COLOR);
  1254. DEFAULT_COLORS[4] = getColorsFrom(
  1255. new ColorUIResource(220, 218, 213),
  1256. new ColorUIResource(117, 117, 117));
  1257. DEFAULT_COLORS[0][GTKColorType.TEXT_BACKGROUND.getID()] = new
  1258. ColorUIResource(128, 125, 116);
  1259. DEFAULT_COLORS[1][GTKColorType.TEXT_BACKGROUND.getID()] = new
  1260. ColorUIResource(75, 105, 131);
  1261. DEFAULT_COLORS[2][GTKColorType.TEXT_BACKGROUND.getID()] =
  1262. WHITE_COLOR;
  1263. DEFAULT_COLORS[3][GTKColorType.TEXT_BACKGROUND.getID()] =
  1264. WHITE_COLOR;
  1265. DEFAULT_COLORS[4][GTKColorType.TEXT_BACKGROUND.getID()] = new
  1266. ColorUIResource(238, 235, 231);
  1267. DEFAULT_COLORS[0][GTKColorType.TEXT_FOREGROUND.getID()] =
  1268. WHITE_COLOR;
  1269. DEFAULT_COLORS[1][GTKColorType.TEXT_FOREGROUND.getID()] =
  1270. WHITE_COLOR;
  1271. DEFAULT_COLORS[2][GTKColorType.TEXT_FOREGROUND.getID()] =
  1272. BLACK_COLOR;
  1273. DEFAULT_COLORS[3][GTKColorType.TEXT_FOREGROUND.getID()] =
  1274. BLACK_COLOR;
  1275. DEFAULT_COLORS[4][GTKColorType.TEXT_FOREGROUND.getID()] = new
  1276. ColorUIResource(117, 117, 117);
  1277. }
  1278. CLASS_SPECIFIC_MAP = new HashMap();
  1279. CLASS_SPECIFIC_MAP.put("CheckBox.iconTextGap", "indicator-spacing");
  1280. CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width");
  1281. CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
  1282. CLASS_SPECIFIC_MAP.put("SplitPaneDivider.size", "handle-size");
  1283. CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");
  1284. CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width");
  1285. Integer caretBlinkRate = new Integer(500);
  1286. Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
  1287. Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
  1288. "ctrl C", DefaultEditorKit.copyAction,
  1289. "ctrl V", DefaultEditorKit.pasteAction,
  1290. "ctrl X", DefaultEditorKit.cutAction,
  1291. "COPY", DefaultEditorKit.copyAction,
  1292. "PASTE", DefaultEditorKit.pasteAction,
  1293. "CUT", DefaultEditorKit.cutAction,
  1294. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  1295. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  1296. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  1297. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  1298. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  1299. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  1300. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  1301. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  1302. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1303. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1304. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  1305. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  1306. "ctrl A", DefaultEditorKit.selectAllAction,
  1307. "HOME", DefaultEditorKit.beginLineAction,
  1308. "END", DefaultEditorKit.endLineAction,
  1309. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  1310. "shift END", DefaultEditorKit.selectionEndLineAction,
  1311. "typed \010", DefaultEditorKit.deletePrevCharAction,
  1312. "DELETE", DefaultEditorKit.deleteNextCharAction,
  1313. "RIGHT", DefaultEditorKit.forwardAction,
  1314. "LEFT", DefaultEditorKit.backwardAction,
  1315. "KP_RIGHT", DefaultEditorKit.forwardAction,
  1316. "KP_LEFT", DefaultEditorKit.backwardAction,
  1317. "ENTER", JTextField.notifyAction,
  1318. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  1319. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  1320. });
  1321. Object editorMargin = new InsetsUIResource(3,3,3,3);
  1322. Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
  1323. "ctrl C", DefaultEditorKit.copyAction,
  1324. "ctrl V", DefaultEditorKit.pasteAction,
  1325. "ctrl X", DefaultEditorKit.cutAction,
  1326. "COPY", DefaultEditorKit.copyAction,
  1327. "PASTE", DefaultEditorKit.pasteAction,
  1328. "CUT", DefaultEditorKit.cutAction,
  1329. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  1330. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  1331. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  1332. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  1333. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  1334. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  1335. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  1336. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  1337. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1338. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1339. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  1340. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  1341. "ctrl A", DefaultEditorKit.selectAllAction,
  1342. "HOME", DefaultEditorKit.beginLineAction,
  1343. "END", DefaultEditorKit.endLineAction,
  1344. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  1345. "shift END", DefaultEditorKit.selectionEndLineAction,
  1346. "UP", DefaultEditorKit.upAction,
  1347. "KP_UP", DefaultEditorKit.upAction,
  1348. "DOWN", DefaultEditorKit.downAction,
  1349. "KP_DOWN", DefaultEditorKit.downAction,
  1350. "PAGE_UP", DefaultEditorKit.pageUpAction,
  1351. "PAGE_DOWN", DefaultEditorKit.pageDownAction,
  1352. "shift PAGE_UP", "selection-page-up",
  1353. "shift PAGE_DOWN", "selection-page-down",
  1354. "ctrl shift PAGE_UP", "selection-page-left",
  1355. "ctrl shift PAGE_DOWN", "selection-page-right",
  1356. "shift UP", DefaultEditorKit.selectionUpAction,
  1357. "shift KP_UP", DefaultEditorKit.selectionUpAction,
  1358. "shift DOWN", DefaultEditorKit.selectionDownAction,
  1359. "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
  1360. "ENTER", DefaultEditorKit.insertBreakAction,
  1361. "typed \010", DefaultEditorKit.deletePrevCharAction,
  1362. "DELETE", DefaultEditorKit.deleteNextCharAction,
  1363. "RIGHT", DefaultEditorKit.forwardAction,
  1364. "LEFT", DefaultEditorKit.backwardAction,
  1365. "KP_RIGHT", DefaultEditorKit.forwardAction,
  1366. "KP_LEFT", DefaultEditorKit.backwardAction,
  1367. "TAB", DefaultEditorKit.insertTabAction,
  1368. "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
  1369. "ctrl HOME", DefaultEditorKit.beginAction,
  1370. "ctrl END", DefaultEditorKit.endAction,
  1371. "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
  1372. "ctrl shift END", DefaultEditorKit.selectionEndAction,
  1373. "ctrl T", "next-link-action",
  1374. "ctrl shift T", "previous-link-action",
  1375. "ctrl SPACE", "activate-link-action",
  1376. "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
  1377. });
  1378. Object[] defaults = {
  1379. "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
  1380. "SPACE", "pressed",
  1381. "released SPACE", "released",
  1382. "ENTER", "pressed",
  1383. "released ENTER", "released"
  1384. }),
  1385. "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object[]{
  1386. "SPACE", "pressed",
  1387. "released SPACE", "released",
  1388. }),
  1389. "CheckBox.icon", new GTKLazyValue(
  1390. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1391. "getCheckBoxIcon"),
  1392. "CheckBoxMenuItem.arrowIcon", new GTKLazyValue(
  1393. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1394. "getCheckBoxMenuItemArrowIcon"),
  1395. "CheckBoxMenuItem.checkIcon", new GTKLazyValue(
  1396. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1397. "getCheckBoxMenuItemCheckIcon"),
  1398. "ColorChooser.panels", new UIDefaults.ActiveValue() {
  1399. public Object createValue(UIDefaults table) {
  1400. return new AbstractColorChooserPanel[] {
  1401. new GTKColorChooserPanel() };
  1402. }
  1403. },
  1404. "ComboBox.ancestorInputMap",
  1405. new UIDefaults.LazyInputMap(new Object[] {
  1406. "ESCAPE", "hidePopup",
  1407. "PAGE_UP", "pageUpPassThrough",
  1408. "PAGE_DOWN", "pageDownPassThrough",
  1409. "HOME", "homePassThrough",
  1410. "END", "endPassThrough",
  1411. "DOWN", "selectNext",
  1412. "KP_DOWN", "selectNext",
  1413. "alt DOWN", "togglePopup",
  1414. "alt KP_DOWN", "togglePopup",
  1415. "alt UP", "togglePopup",
  1416. "alt KP_UP", "togglePopup",
  1417. "SPACE", "spacePopup",
  1418. "ENTER", "enterPressed",
  1419. "UP", "selectPrevious",
  1420. "KP_UP", "selectPrevious"
  1421. }),
  1422. "EditorPane.caretBlinkRate", caretBlinkRate,
  1423. "EditorPane.margin", editorMargin,
  1424. "EditorPane.focusInputMap", multilineInputMap,
  1425. "EditorPane.caretForeground", BLACK_COLOR,
  1426. "EditorPane.caretBlinkRate", caretBlinkRate,
  1427. "EditorPane.margin", editorMargin,
  1428. "EditorPane.focusInputMap", multilineInputMap,
  1429. "FileChooser.ancestorInputMap",
  1430. new UIDefaults.LazyInputMap(new Object[] {
  1431. "ESCAPE", "cancelSelection"
  1432. }),
  1433. "FileChooser.cancelIcon", new GTKStockIcon("gtk-cancel", "gtk-button"),
  1434. "FileChooser.okIcon", new GTKStockIcon("gtk-ok", "gtk-button"),
  1435. "FormattedTextField.focusInputMap",
  1436. new UIDefaults.LazyInputMap(new Object[] {
  1437. "ctrl C", DefaultEditorKit.copyAction,
  1438. "ctrl V", DefaultEditorKit.pasteAction,
  1439. "ctrl X", DefaultEditorKit.cutAction,
  1440. "COPY", DefaultEditorKit.copyAction,
  1441. "PASTE", DefaultEditorKit.pasteAction,
  1442. "CUT", DefaultEditorKit.cutAction,
  1443. "shift LEFT", DefaultEditorKit.selectionBackwardAction,
  1444. "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
  1445. "shift RIGHT", DefaultEditorKit.selectionForwardAction,
  1446. "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
  1447. "ctrl LEFT", DefaultEditorKit.previousWordAction,
  1448. "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
  1449. "ctrl RIGHT", DefaultEditorKit.nextWordAction,
  1450. "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
  1451. "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1452. "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
  1453. "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
  1454. "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
  1455. "ctrl A", DefaultEditorKit.selectAllAction,
  1456. "HOME", DefaultEditorKit.beginLineAction,
  1457. "END", DefaultEditorKit.endLineAction,
  1458. "shift HOME", DefaultEditorKit.selectionBeginLineAction,
  1459. "shift END", DefaultEditorKit.selectionEndLineAction,
  1460. "typed \010", DefaultEditorKit.deletePrevCharAction,
  1461. "DELETE", DefaultEditorKit.deleteNextCharAction,
  1462. "RIGHT", DefaultEditorKit.forwardAction,
  1463. "LEFT", DefaultEditorKit.backwardAction,
  1464. "KP_RIGHT", DefaultEditorKit.forwardAction,
  1465. "KP_LEFT", DefaultEditorKit.backwardAction,
  1466. "ENTER", JTextField.notifyAction,
  1467. "ctrl BACK_SLASH", "unselect",
  1468. "control shift O", "toggle-componentOrientation",
  1469. "ESCAPE", "reset-field-edit",
  1470. "UP", "increment",
  1471. "KP_UP", "increment",
  1472. "DOWN", "decrement",
  1473. "KP_DOWN", "decrement",
  1474. }),
  1475. "InternalFrameTitlePane.titlePaneLayout",
  1476. new GTKLazyValue("com.sun.java.swing.plaf.gtk.Metacity",
  1477. "getTitlePaneLayout"),
  1478. "InternalFrame.windowBindings", new Object[] {
  1479. "shift ESCAPE", "showSystemMenu",
  1480. "ctrl SPACE", "showSystemMenu",
  1481. "ESCAPE", "hideSystemMenu" },
  1482. "List.focusInputMap",
  1483. new UIDefaults.LazyInputMap(new Object[] {
  1484. "ctrl C", "copy",
  1485. "ctrl V", "paste",
  1486. "ctrl X", "cut",
  1487. "COPY", "copy",
  1488. "PASTE", "paste",
  1489. "CUT", "cut",
  1490. "UP", "selectPreviousRow",
  1491. "KP_UP", "selectPreviousRow",
  1492. "shift UP", "selectPreviousRowExtendSelection",
  1493. "shift KP_UP", "selectPreviousRowExtendSelection",
  1494. "DOWN", "selectNextRow",
  1495. "KP_DOWN", "selectNextRow",
  1496. "shift DOWN", "selectNextRowExtendSelection",
  1497. "shift KP_DOWN", "selectNextRowExtendSelection",
  1498. "LEFT", "selectPreviousColumn",
  1499. "KP_LEFT", "selectPreviousColumn",
  1500. "shift LEFT", "selectPreviousColumnExtendSelection",
  1501. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  1502. "RIGHT", "selectNextColumn",
  1503. "KP_RIGHT", "selectNextColumn",
  1504. "shift RIGHT", "selectNextColumnExtendSelection",
  1505. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  1506. "ctrl SPACE", "selectNextRowExtendSelection",
  1507. "HOME", "selectFirstRow",
  1508. "shift HOME", "selectFirstRowExtendSelection",
  1509. "END", "selectLastRow",
  1510. "shift END", "selectLastRowExtendSelection",
  1511. "PAGE_UP", "scrollUp",
  1512. "shift PAGE_UP", "scrollUpExtendSelection",
  1513. "PAGE_DOWN", "scrollDown",
  1514. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1515. "ctrl A", "selectAll",
  1516. "ctrl SLASH", "selectAll",
  1517. "ctrl BACK_SLASH", "clearSelection"
  1518. }),
  1519. "List.focusInputMap.RightToLeft",
  1520. new UIDefaults.LazyInputMap(new Object[] {
  1521. "LEFT", "selectNextColumn",
  1522. "KP_LEFT", "selectNextColumn",
  1523. "shift LEFT", "selectNextColumnExtendSelection",
  1524. "shift KP_LEFT", "selectNextColumnExtendSelection",
  1525. "RIGHT", "selectPreviousColumn",
  1526. "KP_RIGHT", "selectPreviousColumn",
  1527. "shift RIGHT", "selectPreviousColumnExtendSelection",
  1528. "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  1529. }),
  1530. "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK},
  1531. "Menu.arrowIcon", new GTKLazyValue(
  1532. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1533. "getMenuArrowIcon"),
  1534. "MenuBar.windowBindings", new Object[] {
  1535. "F10", "takeFocus" },
  1536. "MenuItem.arrowIcon", new GTKLazyValue(
  1537. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1538. "getMenuItemArrowIcon"),
  1539. "OptionPane.minimumSize", new DimensionUIResource(262, 90),
  1540. "OptionPane.windowBindings", new Object[] {
  1541. "ESCAPE", "close" },
  1542. "OptionPane.buttonClickThreshhold", new Integer(500),
  1543. "OptionPane.errorIcon", new GTKStockIcon("gtk-dialog-error",
  1544. "gtk-dialog"),
  1545. "OptionPane.informationIcon", new GTKStockIcon("gtk-dialog-info",
  1546. "gtk-dialog"),
  1547. "OptionPane.warningIcon", new GTKStockIcon("gtk-dialog-warning",
  1548. "gtk-dialog"),
  1549. "OptionPane.questionIcon", new GTKStockIcon("gtk-dialog-question",
  1550. "gtk-dialog"),
  1551. "OptionPane.yesIcon", new GTKStockIcon("gtk-yes", "gtk-button"),
  1552. "OptionPane.noIcon", new GTKStockIcon("gtk-no", "gtk-button"),
  1553. "OptionPane.cancelIcon", new GTKStockIcon("gtk-cancel",
  1554. "gtk-button"),
  1555. "OptionPane.okIcon", new GTKStockIcon("gtk-ok", "gtk-button"),
  1556. "PasswordField.caretForeground", BLACK_COLOR,
  1557. "PasswordField.caretBlinkRate", caretBlinkRate,
  1558. "PasswordField.margin", zeroInsets,
  1559. "PasswordField.focusInputMap", fieldInputMap,
  1560. "PopupMenu.selectedWindowInputMapBindings", new Object[] {
  1561. "ESCAPE", "cancel",
  1562. "DOWN", "selectNext",
  1563. "KP_DOWN", "selectNext",
  1564. "UP", "selectPrevious",
  1565. "KP_UP", "selectPrevious",
  1566. "LEFT", "selectParent",
  1567. "KP_LEFT", "selectParent",
  1568. "RIGHT", "selectChild",
  1569. "KP_RIGHT", "selectChild",
  1570. "ENTER", "return",
  1571. "SPACE", "return"
  1572. },
  1573. "PopupMenu.selectedWindowInputMapBindings.RightToLeft",
  1574. new Object[] {
  1575. "LEFT", "selectChild",
  1576. "KP_LEFT", "selectChild",
  1577. "RIGHT", "selectParent",
  1578. "KP_RIGHT", "selectParent",
  1579. },
  1580. "RadioButton.focusInputMap",
  1581. new UIDefaults.LazyInputMap(new Object[] {
  1582. "SPACE", "pressed",
  1583. "released SPACE", "released",
  1584. "RETURN", "pressed"
  1585. }),
  1586. "RadioButton.icon", new GTKLazyValue(
  1587. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1588. "getRadioButtonIcon"),
  1589. "RadioButtonMenuItem.arrowIcon", new GTKLazyValue(
  1590. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1591. "getRadioButtonMenuItemArrowIcon"),
  1592. "RadioButtonMenuItem.checkIcon", new GTKLazyValue(
  1593. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1594. "getRadioButtonMenuItemCheckIcon"),
  1595. // These bindings are only enabled when there is a default
  1596. // button set on the rootpane.
  1597. "RootPane.defaultButtonWindowKeyBindings", new Object[] {
  1598. "ENTER", "press",
  1599. "released ENTER", "release",
  1600. "ctrl ENTER", "press",
  1601. "ctrl released ENTER", "release"
  1602. },
  1603. "ScrollBar.thumbHeight", new Integer(14),
  1604. "ScrollBar.width", new Integer(16),
  1605. "ScrollBar.minimumThumbSize", new Dimension(8, 8),
  1606. "ScrollBar.maximumThumbSize", new Dimension(4096, 4096),
  1607. "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
  1608. "ScrollBar.focusInputMap",
  1609. new UIDefaults.LazyInputMap(new Object[] {
  1610. "RIGHT", "positiveUnitIncrement",
  1611. "KP_RIGHT", "positiveUnitIncrement",
  1612. "DOWN", "positiveUnitIncrement",
  1613. "KP_DOWN", "positiveUnitIncrement",
  1614. "PAGE_DOWN", "positiveBlockIncrement",
  1615. "LEFT", "negativeUnitIncrement",
  1616. "KP_LEFT", "negativeUnitIncrement",
  1617. "UP", "negativeUnitIncrement",
  1618. "KP_UP", "negativeUnitIncrement",
  1619. "PAGE_UP", "negativeBlockIncrement",
  1620. "HOME", "minScroll",
  1621. "END", "maxScroll"
  1622. }),
  1623. "ScrollBar.focusInputMap.RightToLeft",
  1624. new UIDefaults.LazyInputMap(new Object[] {
  1625. "RIGHT", "negativeUnitIncrement",
  1626. "KP_RIGHT", "negativeUnitIncrement",
  1627. "LEFT", "positiveUnitIncrement",
  1628. "KP_LEFT", "positiveUnitIncrement",
  1629. }),
  1630. "ScrollPane.ancestorInputMap",
  1631. new UIDefaults.LazyInputMap(new Object[] {
  1632. "RIGHT", "unitScrollRight",
  1633. "KP_RIGHT", "unitScrollRight",
  1634. "DOWN", "unitScrollDown",
  1635. "KP_DOWN", "unitScrollDown",
  1636. "LEFT", "unitScrollLeft",
  1637. "KP_LEFT", "unitScrollLeft",
  1638. "UP", "unitScrollUp",
  1639. "KP_UP", "unitScrollUp",
  1640. "PAGE_UP", "scrollUp",
  1641. "PAGE_DOWN", "scrollDown",
  1642. "ctrl PAGE_UP", "scrollLeft",
  1643. "ctrl PAGE_DOWN", "scrollRight",
  1644. "ctrl HOME", "scrollHome",
  1645. "ctrl END", "scrollEnd"
  1646. }),
  1647. "ScrollPane.ancestorInputMap.RightToLeft",
  1648. new UIDefaults.LazyInputMap(new Object[] {
  1649. "ctrl PAGE_UP", "scrollRight",
  1650. "ctrl PAGE_DOWN", "scrollLeft",
  1651. }),
  1652. "Separator.insets", zeroInsets,
  1653. "Separator.thickness", new Integer(2),
  1654. "Slider.paintValue", Boolean.TRUE,
  1655. "Slider.thumbWidth", new Integer(30),
  1656. "Slider.thumbHeight", new Integer(14),
  1657. "Slider.focusInputMap",
  1658. new UIDefaults.LazyInputMap(new Object[] {
  1659. "RIGHT", "positiveUnitIncrement",
  1660. "KP_RIGHT", "positiveUnitIncrement",
  1661. "DOWN", "negativeUnitIncrement",
  1662. "KP_DOWN", "negativeUnitIncrement",
  1663. "PAGE_DOWN", "negativeBlockIncrement",
  1664. "LEFT", "negativeUnitIncrement",
  1665. "KP_LEFT", "negativeUnitIncrement",
  1666. "UP", "positiveUnitIncrement",
  1667. "KP_UP", "positiveUnitIncrement",
  1668. "PAGE_UP", "positiveBlockIncrement",
  1669. "HOME", "minScroll",
  1670. "END", "maxScroll"
  1671. }),
  1672. "Slider.focusInputMap.RightToLeft",
  1673. new UIDefaults.LazyInputMap(new Object[] {
  1674. "RIGHT", "negativeUnitIncrement",
  1675. "KP_RIGHT", "negativeUnitIncrement",
  1676. "LEFT", "positiveUnitIncrement",
  1677. "KP_LEFT", "positiveUnitIncrement",
  1678. }),
  1679. "Spinner.ancestorInputMap",
  1680. new UIDefaults.LazyInputMap(new Object[] {
  1681. "UP", "increment",
  1682. "KP_UP", "increment",
  1683. "DOWN", "decrement",
  1684. "KP_DOWN", "decrement",
  1685. }),
  1686. "SplitPane.ancestorInputMap",
  1687. new UIDefaults.LazyInputMap(new Object[] {
  1688. "UP", "negativeIncrement",
  1689. "DOWN", "positiveIncrement",
  1690. "LEFT", "negativeIncrement",
  1691. "RIGHT", "positiveIncrement",
  1692. "KP_UP", "negativeIncrement",
  1693. "KP_DOWN", "positiveIncrement",
  1694. "KP_LEFT", "negativeIncrement",
  1695. "KP_RIGHT", "positiveIncrement",
  1696. "HOME", "selectMin",
  1697. "END", "selectMax",
  1698. "F8", "startResize",
  1699. "F6", "toggleFocus",
  1700. "ctrl TAB", "focusOutForward",
  1701. "ctrl shift TAB", "focusOutBackward"
  1702. }),
  1703. "SplitPaneDivider.size", new Integer(7),
  1704. "SplitPaneDivider.oneTouchOffset", new Integer(2),
  1705. "SplitPaneDivider.oneTouchButtonSize", new Integer(5),
  1706. "TabbedPane.focusInputMap",
  1707. new UIDefaults.LazyInputMap(new Object[] {
  1708. "RIGHT", "navigateRight",
  1709. "KP_RIGHT", "navigateRight",
  1710. "LEFT", "navigateLeft",
  1711. "KP_LEFT", "navigateLeft",
  1712. "UP", "navigateUp",
  1713. "KP_UP", "navigateUp",
  1714. "DOWN", "navigateDown",
  1715. "KP_DOWN", "navigateDown",
  1716. "ctrl DOWN", "requestFocusForVisibleComponent",
  1717. "ctrl KP_DOWN", "requestFocusForVisibleComponent",
  1718. "SPACE", "selectTabWithFocus"
  1719. }),
  1720. "TabbedPane.ancestorInputMap",
  1721. new UIDefaults.LazyInputMap(new Object[] {
  1722. "ctrl TAB", "navigateNext",
  1723. "ctrl shift TAB", "navigatePrevious",
  1724. "ctrl PAGE_DOWN", "navigatePageDown",
  1725. "ctrl PAGE_UP", "navigatePageUp",
  1726. "ctrl UP", "requestFocus",
  1727. "ctrl KP_UP", "requestFocus",
  1728. }),
  1729. "TabbedPane.selectionFollowsFocus", Boolean.FALSE,
  1730. "Table.ancestorInputMap",
  1731. new UIDefaults.LazyInputMap(new Object[] {
  1732. "ctrl C", "copy",
  1733. "ctrl V", "paste",
  1734. "ctrl X", "cut",
  1735. "COPY", "copy",
  1736. "PASTE", "paste",
  1737. "CUT", "cut",
  1738. "RIGHT", "selectNextColumn",
  1739. "KP_RIGHT", "selectNextColumn",
  1740. "LEFT", "selectPreviousColumn",
  1741. "KP_LEFT", "selectPreviousColumn",
  1742. "DOWN", "selectNextRow",
  1743. "KP_DOWN", "selectNextRow",
  1744. "UP", "selectPreviousRow",
  1745. "KP_UP", "selectPreviousRow",
  1746. "shift RIGHT", "selectNextColumnExtendSelection",
  1747. "shift KP_RIGHT", "selectNextColumnExtendSelection",
  1748. "shift LEFT", "selectPreviousColumnExtendSelection",
  1749. "shift KP_LEFT", "selectPreviousColumnExtendSelection",
  1750. "shift DOWN", "selectNextRowExtendSelection",
  1751. "shift KP_DOWN", "selectNextRowExtendSelection",
  1752. "shift UP", "selectPreviousRowExtendSelection",
  1753. "shift KP_UP", "selectPreviousRowExtendSelection",
  1754. "PAGE_UP", "scrollUpChangeSelection",
  1755. "PAGE_DOWN", "scrollDownChangeSelection",
  1756. "HOME", "selectFirstColumn",
  1757. "END", "selectLastColumn",
  1758. "shift PAGE_UP", "scrollUpExtendSelection",
  1759. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1760. "shift HOME", "selectFirstColumnExtendSelection",
  1761. "shift END", "selectLastColumnExtendSelection",
  1762. "ctrl PAGE_UP", "scrollLeftChangeSelection",
  1763. "ctrl PAGE_DOWN", "scrollRightChangeSelection",
  1764. "ctrl HOME", "selectFirstRow",
  1765. "ctrl END", "selectLastRow",
  1766. "ctrl shift PAGE_UP", "scrollRightExtendSelection",
  1767. "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
  1768. "ctrl shift HOME", "selectFirstRowExtendSelection",
  1769. "ctrl shift END", "selectLastRowExtendSelection",
  1770. "TAB", "selectNextColumnCell",
  1771. "shift TAB", "selectPreviousColumnCell",
  1772. "ENTER", "selectNextRowCell",
  1773. "shift ENTER", "selectPreviousRowCell",
  1774. "ctrl A", "selectAll",
  1775. "ESCAPE", "cancel",
  1776. "F2", "startEditing"
  1777. }),
  1778. "Table.ancestorInputMap.RightToLeft",
  1779. new UIDefaults.LazyInputMap(new Object[] {
  1780. "RIGHT", "selectPreviousColumn",
  1781. "KP_RIGHT", "selectPreviousColumn",
  1782. "LEFT", "selectNextColumn",
  1783. "KP_LEFT", "selectNextColumn",
  1784. "shift RIGHT", "selectPreviousColumnExtendSelection",
  1785. "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
  1786. "shift LEFT", "selectNextColumnExtendSelection",
  1787. "shift KP_LEFT", "selectNextColumnExtendSelection",
  1788. "ctrl PAGE_UP", "scrollRightChangeSelection",
  1789. "ctrl PAGE_DOWN", "scrollLeftChangeSelection",
  1790. "ctrl shift PAGE_UP", "scrollRightExtendSelection",
  1791. "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
  1792. }),
  1793. "TextArea.caretForeground", BLACK_COLOR,
  1794. "TextArea.caretBlinkRate", caretBlinkRate,
  1795. "TextArea.margin", zeroInsets,
  1796. "TextArea.focusInputMap", multilineInputMap,
  1797. "TextField.caretForeground", BLACK_COLOR,
  1798. "TextField.caretBlinkRate", caretBlinkRate,
  1799. "TextField.margin", zeroInsets,
  1800. "TextField.focusInputMap", fieldInputMap,
  1801. "TextPane.caretForeground", BLACK_COLOR,
  1802. "TextPane.caretBlinkRate", caretBlinkRate,
  1803. "TextPane.margin", editorMargin,
  1804. "TextPane.focusInputMap", multilineInputMap,
  1805. "ToggleButton.focusInputMap",
  1806. new UIDefaults.LazyInputMap(new Object[] {
  1807. "SPACE", "pressed",
  1808. "released SPACE", "released"
  1809. }),
  1810. "ToolBar.separatorSize", new DimensionUIResource(10, 10),
  1811. "ToolBar.handleIcon", new UIDefaults.ActiveValue() {
  1812. public Object createValue(UIDefaults table) {
  1813. return GTKIconFactory.getToolBarHandleIcon();
  1814. }
  1815. },
  1816. "ToolBar.ancestorInputMap",
  1817. new UIDefaults.LazyInputMap(new Object[] {
  1818. "UP", "navigateUp",
  1819. "KP_UP", "navigateUp",
  1820. "DOWN", "navigateDown",
  1821. "KP_DOWN", "navigateDown",
  1822. "LEFT", "navigateLeft",
  1823. "KP_LEFT", "navigateLeft",
  1824. "RIGHT", "navigateRight",
  1825. "KP_RIGHT", "navigateRight"
  1826. }),
  1827. "Tree.drawHorizontalLegs", Boolean.FALSE,
  1828. "Tree.drawVerticalLegs", Boolean.FALSE,
  1829. "Tree.rowHeight", new Integer(-1),
  1830. "Tree.scrollsOnExpand", Boolean.FALSE,
  1831. "Tree.expanderSize", new Integer(10),
  1832. "Tree.expandedIcon", new GTKLazyValue(
  1833. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1834. "getTreeExpandedIcon"),
  1835. "Tree.collapsedIcon", new GTKLazyValue(
  1836. "com.sun.java.swing.plaf.gtk.GTKIconFactory",
  1837. "getTreeCollapsedIcon"),
  1838. "Tree.trailingControlOffset", new Integer(12),
  1839. "Tree.controlSize", new Integer(18),
  1840. "Tree.indent", new Integer(14),
  1841. "Tree.scrollsHorizontallyAndVertically", Boolean.FALSE,
  1842. "Tree.drawsFocusBorder", Boolean.TRUE,
  1843. "Tree.focusInputMap",
  1844. new UIDefaults.LazyInputMap(new Object[] {
  1845. "ctrl C", "copy",
  1846. "ctrl V", "paste",
  1847. "ctrl X", "cut",
  1848. "COPY", "copy",
  1849. "PASTE", "paste",
  1850. "CUT", "cut",
  1851. "UP", "selectPrevious",
  1852. "KP_UP", "selectPrevious",
  1853. "shift UP", "selectPreviousExtendSelection",
  1854. "shift KP_UP", "selectPreviousExtendSelection",
  1855. "DOWN", "selectNext",
  1856. "KP_DOWN", "selectNext",
  1857. "shift DOWN", "selectNextExtendSelection",
  1858. "shift KP_DOWN", "selectNextExtendSelection",
  1859. "RIGHT", "selectChild",
  1860. "KP_RIGHT", "selectChild",
  1861. "LEFT", "selectParent",
  1862. "KP_LEFT", "selectParent",
  1863. "typed +", "expand",
  1864. "typed -", "collapse",
  1865. "BACK_SPACE", "moveSelectionToParent",
  1866. "PAGE_UP", "scrollUpChangeSelection",
  1867. "shift PAGE_UP", "scrollUpExtendSelection",
  1868. "PAGE_DOWN", "scrollDownChangeSelection",
  1869. "shift PAGE_DOWN", "scrollDownExtendSelection",
  1870. "HOME", "selectFirst",
  1871. "shift HOME", "selectFirstExtendSelection",
  1872. "END", "selectLast",
  1873. "shift END", "selectLastExtendSelection",
  1874. "F2", "startEditing",
  1875. "ctrl A", "selectAll",
  1876. "ctrl SLASH", "selectAll",
  1877. "ctrl BACK_SLASH", "clearSelection",
  1878. "ctrl SPACE", "toggleSelectionPreserveAnchor",
  1879. "shift SPACE", "extendSelection",
  1880. "ctrl HOME", "selectFirstChangeLead",
  1881. "ctrl END", "selectLastChangeLead",
  1882. "ctrl UP", "selectPreviousChangeLead",
  1883. "ctrl KP_UP", "selectPreviousChangeLead",
  1884. "ctrl DOWN", "selectNextChangeLead",
  1885. "ctrl KP_DOWN", "selectNextChangeLead",
  1886. "ctrl PAGE_DOWN", "scrollDownChangeLead",
  1887. "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
  1888. "ctrl PAGE_UP", "scrollUpChangeLead",
  1889. "ctrl shift PAGE_UP", "scrollUpExtendSelection",
  1890. "ctrl LEFT", "scrollLeft",
  1891. "ctrl KP_LEFT", "scrollLeft",
  1892. "ctrl RIGHT", "scrollRight",
  1893. "ctrl KP_RIGHT", "scrollRight",
  1894. "SPACE", "toggleSelectionPreserveAnchor",
  1895. }),
  1896. "Tree.focusInputMap.RightToLeft",
  1897. new UIDefaults.LazyInputMap(new Object[] {
  1898. "RIGHT", "selectParent",
  1899. "KP_RIGHT", "selectParent",
  1900. "LEFT", "selectChild",
  1901. "KP_LEFT", "selectChild",
  1902. }),
  1903. "Tree.ancestorInputMap",
  1904. new UIDefaults.LazyInputMap(new Object[] {
  1905. "ESCAPE", "cancel"
  1906. }),
  1907. };
  1908. for (int counter = 0, max = defaults.length; counter < max;
  1909. counter++) {
  1910. DATA.put(defaults[counter], defaults[++counter]);
  1911. }
  1912. }
  1913. }