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

Print this page


   1 /*
   2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 108                                                           x + 1, y + 1);
 109             }
 110             if (color == null) {
 111                 color = b.getBackground().brighter();
 112             }
 113             g.setColor(color);
 114             SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
 115         }
 116     }
 117 
 118     static void paintXPText(AbstractButton b, Graphics g, int x, int y,
 119                             String text, int mnemIndex) {
 120         Part part = WindowsButtonUI.getXPButtonType(b);
 121         State state = WindowsButtonUI.getXPButtonState(b);
 122         paintXPText(b, part, state, g, x, y, text, mnemIndex);
 123     }
 124 
 125     static void paintXPText(AbstractButton b, Part part, State state,
 126             Graphics g, int x, int y, String text, int mnemIndex) {
 127         XPStyle xp = XPStyle.getXP();



 128         Color textColor = b.getForeground();
 129 
 130         if (textColor instanceof UIResource) {
 131             textColor = xp.getColor(b, part, state, Prop.TEXTCOLOR, b.getForeground());
 132             // to work around an apparent bug in Windows, use the pushbutton
 133             // color for disabled toolbar buttons if the disabled color is the
 134             // same as the enabled color
 135             if (part == Part.TP_BUTTON && state == State.DISABLED) {
 136                 Color enabledColor = xp.getColor(b, part, State.NORMAL,
 137                                      Prop.TEXTCOLOR, b.getForeground());
 138                 if(textColor.equals(enabledColor)) {
 139                     textColor = xp.getColor(b, Part.BP_PUSHBUTTON, state,
 140                                 Prop.TEXTCOLOR, textColor);
 141                 }
 142             }
 143             // only draw shadow if developer hasn't changed the foreground color
 144             // and if the current style has text shadows.
 145             TypeEnum shadowType = xp.getTypeEnum(b, part,
 146                                                  state, Prop.TEXTSHADOWTYPE);
 147             if (shadowType == TypeEnum.TST_SINGLE ||


   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 108                                                           x + 1, y + 1);
 109             }
 110             if (color == null) {
 111                 color = b.getBackground().brighter();
 112             }
 113             g.setColor(color);
 114             SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
 115         }
 116     }
 117 
 118     static void paintXPText(AbstractButton b, Graphics g, int x, int y,
 119                             String text, int mnemIndex) {
 120         Part part = WindowsButtonUI.getXPButtonType(b);
 121         State state = WindowsButtonUI.getXPButtonState(b);
 122         paintXPText(b, part, state, g, x, y, text, mnemIndex);
 123     }
 124 
 125     static void paintXPText(AbstractButton b, Part part, State state,
 126             Graphics g, int x, int y, String text, int mnemIndex) {
 127         XPStyle xp = XPStyle.getXP();
 128         if (xp == null) {
 129             return;
 130         }
 131         Color textColor = b.getForeground();
 132 
 133         if (textColor instanceof UIResource) {
 134             textColor = xp.getColor(b, part, state, Prop.TEXTCOLOR, b.getForeground());
 135             // to work around an apparent bug in Windows, use the pushbutton
 136             // color for disabled toolbar buttons if the disabled color is the
 137             // same as the enabled color
 138             if (part == Part.TP_BUTTON && state == State.DISABLED) {
 139                 Color enabledColor = xp.getColor(b, part, State.NORMAL,
 140                                      Prop.TEXTCOLOR, b.getForeground());
 141                 if(textColor.equals(enabledColor)) {
 142                     textColor = xp.getColor(b, Part.BP_PUSHBUTTON, state,
 143                                 Prop.TEXTCOLOR, textColor);
 144                 }
 145             }
 146             // only draw shadow if developer hasn't changed the foreground color
 147             // and if the current style has text shadows.
 148             TypeEnum shadowType = xp.getTypeEnum(b, part,
 149                                                  state, Prop.TEXTSHADOWTYPE);
 150             if (shadowType == TypeEnum.TST_SINGLE ||