< prev index next >

src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsGraphicsUtils.java

Print this page




  30 import java.awt.*;
  31 
  32 import javax.swing.*;
  33 import javax.swing.plaf.UIResource;
  34 
  35 import static com.sun.java.swing.plaf.windows.TMSchema.*;
  36 
  37 /**
  38  * A collection of static utility methods used for rendering the Windows look
  39  * and feel.
  40  *
  41  * @author Mark Davidson
  42  * @since 1.4
  43  */
  44 public class WindowsGraphicsUtils {
  45 
  46     /**
  47      * Renders a text String in Windows without the mnemonic.
  48      * This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
  49      * the overriden paintText methods of the ButtonUI delegates will call this static method.
  50      * <p>
  51      * @param g Graphics context
  52      * @param b Current button to render
  53      * @param textRect Bounding rectangle to render the text.
  54      * @param text String to render
  55      */
  56     public static void paintText(Graphics g, AbstractButton b,
  57                                         Rectangle textRect, String text,
  58                                         int textShiftOffset) {
  59         FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
  60 
  61         int mnemIndex = b.getDisplayedMnemonicIndex();
  62         // W2K Feature: Check to see if the Underscore should be rendered.
  63         if (WindowsLookAndFeel.isMnemonicHidden() == true) {
  64             mnemIndex = -1;
  65         }
  66 
  67         XPStyle xp = XPStyle.getXP();
  68         if (xp != null && !(b instanceof JMenuItem)) {
  69             paintXPText(b, g, textRect.x + textShiftOffset,
  70                         textRect.y + fm.getAscent() + textShiftOffset,




  30 import java.awt.*;
  31 
  32 import javax.swing.*;
  33 import javax.swing.plaf.UIResource;
  34 
  35 import static com.sun.java.swing.plaf.windows.TMSchema.*;
  36 
  37 /**
  38  * A collection of static utility methods used for rendering the Windows look
  39  * and feel.
  40  *
  41  * @author Mark Davidson
  42  * @since 1.4
  43  */
  44 public class WindowsGraphicsUtils {
  45 
  46     /**
  47      * Renders a text String in Windows without the mnemonic.
  48      * This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
  49      * the overriden paintText methods of the ButtonUI delegates will call this static method.
  50      *
  51      * @param g Graphics context
  52      * @param b Current button to render
  53      * @param textRect Bounding rectangle to render the text.
  54      * @param text String to render
  55      */
  56     public static void paintText(Graphics g, AbstractButton b,
  57                                         Rectangle textRect, String text,
  58                                         int textShiftOffset) {
  59         FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
  60 
  61         int mnemIndex = b.getDisplayedMnemonicIndex();
  62         // W2K Feature: Check to see if the Underscore should be rendered.
  63         if (WindowsLookAndFeel.isMnemonicHidden() == true) {
  64             mnemIndex = -1;
  65         }
  66 
  67         XPStyle xp = XPStyle.getXP();
  68         if (xp != null && !(b instanceof JMenuItem)) {
  69             paintXPText(b, g, textRect.x + textShiftOffset,
  70                         textRect.y + fm.getAscent() + textShiftOffset,


< prev index next >