1. /*
  2. * @(#)GTKGraphicsUtils.java 1.13 03/12/19
  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 javax.swing.*;
  9. import javax.swing.plaf.synth.*;
  10. import java.awt.Color;
  11. import java.awt.Graphics;
  12. import java.awt.Rectangle;
  13. /**
  14. * @version 1.13, 12/19/03
  15. * @author Joshua Outwater
  16. */
  17. class GTKGraphicsUtils extends SynthGraphicsUtils {
  18. public void paintText(SynthContext context, Graphics g, String text,
  19. int x, int y, int mnemonicIndex) {
  20. int componentState = context.getComponentState();
  21. if ((componentState & SynthConstants.DISABLED) ==
  22. SynthConstants.DISABLED){
  23. Color orgColor = g.getColor();
  24. g.setColor(context.getStyle().getColor(context,
  25. GTKColorType.WHITE));
  26. x += 1;
  27. y += 1;
  28. super.paintText(context, g, text, x, y, mnemonicIndex);
  29. g.setColor(orgColor);
  30. x -= 1;
  31. y -= 1;
  32. super.paintText(context, g, text, x, y, mnemonicIndex);
  33. }
  34. else {
  35. super.paintText(context, g, text, x, y, mnemonicIndex);
  36. }
  37. }
  38. /**
  39. * Paints text at the specified location. This will not attempt to
  40. * render the text as html nor will it offset by the insets of the
  41. * component.
  42. *
  43. * @param ss SynthContext
  44. * @param g Graphics used to render string in.
  45. * @param text Text to render
  46. * @param bounds Bounds of the text to be drawn.
  47. * @param mnemonicIndex Index to draw string at.
  48. */
  49. public void paintText(SynthContext context, Graphics g, String text,
  50. Rectangle bounds, int mnemonicIndex) {
  51. Color color = g.getColor();
  52. Region region = context.getRegion();
  53. if ((region == Region.RADIO_BUTTON || region == Region.CHECK_BOX ||
  54. region == Region.TABBED_PANE_TAB) &&
  55. (context.getComponentState() & SynthConstants.FOCUSED) != 0) {
  56. JComponent source = context.getComponent();
  57. if (!(source instanceof AbstractButton) ||
  58. ((AbstractButton)source).isFocusPainted()) {
  59. ((GTKStyle)(context.getStyle())).getEngine(context).paintFocus(
  60. context, g, SynthConstants.ENABLED,
  61. "checkbutton", bounds.x - 2, bounds.y - 2,
  62. bounds.width + 4, bounds.height + 4);
  63. g.setColor(color);
  64. }
  65. }
  66. super.paintText(context, g, text, bounds, mnemonicIndex);
  67. }
  68. }