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