KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > gtk > GTKGraphicsUtils


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
9 import javax.swing.*;
10 import javax.swing.plaf.synth.*;
11 import java.awt.Color JavaDoc;
12 import java.awt.Graphics JavaDoc;
13 import java.awt.Rectangle JavaDoc;
14
15 /**
16  * @version 1.13, 12/19/03
17  * @author Joshua Outwater
18  */

19 class GTKGraphicsUtils extends SynthGraphicsUtils {
20     public void paintText(SynthContext context, Graphics JavaDoc g, String JavaDoc text,
21                           int x, int y, int mnemonicIndex) {
22         int componentState = context.getComponentState();
23         if ((componentState & SynthConstants.DISABLED) ==
24                               SynthConstants.DISABLED){
25             Color JavaDoc orgColor = g.getColor();
26             g.setColor(context.getStyle().getColor(context,
27                                                    GTKColorType.WHITE));
28             x += 1;
29             y += 1;
30             super.paintText(context, g, text, x, y, mnemonicIndex);
31
32             g.setColor(orgColor);
33             x -= 1;
34             y -= 1;
35             super.paintText(context, g, text, x, y, mnemonicIndex);
36         }
37         else {
38             super.paintText(context, g, text, x, y, mnemonicIndex);
39         }
40     }
41
42     /**
43      * Paints text at the specified location. This will not attempt to
44      * render the text as html nor will it offset by the insets of the
45      * component.
46      *
47      * @param ss SynthContext
48      * @param g Graphics used to render string in.
49      * @param text Text to render
50      * @param bounds Bounds of the text to be drawn.
51      * @param mnemonicIndex Index to draw string at.
52      */

53     public void paintText(SynthContext context, Graphics JavaDoc g, String JavaDoc text,
54                           Rectangle JavaDoc bounds, int mnemonicIndex) {
55         Color JavaDoc color = g.getColor();
56
57         Region region = context.getRegion();
58         if ((region == Region.RADIO_BUTTON || region == Region.CHECK_BOX ||
59              region == Region.TABBED_PANE_TAB) &&
60              (context.getComponentState() & SynthConstants.FOCUSED) != 0) {
61             JComponent source = context.getComponent();
62             if (!(source instanceof AbstractButton) ||
63                 ((AbstractButton)source).isFocusPainted()) {
64                 ((GTKStyle)(context.getStyle())).getEngine(context).paintFocus(
65                     context, g, SynthConstants.ENABLED,
66                         "checkbutton", bounds.x - 2, bounds.y - 2,
67                         bounds.width + 4, bounds.height + 4);
68                 g.setColor(color);
69             }
70         }
71         super.paintText(context, g, text, bounds, mnemonicIndex);
72     }
73 }
74
Popular Tags