< prev index next >

src/share/classes/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2006, 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


  30 import java.awt.Graphics;
  31 import java.awt.Rectangle;
  32 
  33 /**
  34  * @author Joshua Outwater
  35  */
  36 class GTKGraphicsUtils extends SynthGraphicsUtils {
  37     public void paintText(SynthContext context, Graphics g, String text,
  38                           int x, int y, int mnemonicIndex) {
  39         if (text == null || text.length() <= 0) {
  40             // We don't need to paint empty strings
  41             return;
  42         }
  43 
  44         if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) {
  45             // Metacity handles painting of text on internal frame title,
  46             // ignore this.
  47             return;
  48         }
  49         int componentState = context.getComponentState();
  50         if ((componentState & SynthConstants.DISABLED) ==
  51                               SynthConstants.DISABLED){
  52             Color orgColor = g.getColor();
  53             g.setColor(context.getStyle().getColor(context,
  54                                                    GTKColorType.WHITE));
  55             x += 1;
  56             y += 1;
  57             super.paintText(context, g, text, x, y, mnemonicIndex);
  58 
  59             g.setColor(orgColor);
  60             x -= 1;
  61             y -= 1;
  62             super.paintText(context, g, text, x, y, mnemonicIndex);
  63         }
  64         else {
  65             String themeName = GTKLookAndFeel.getGtkThemeName();
  66             if (themeName != null && themeName.startsWith("blueprint") &&
  67                 shouldShadowText(context.getRegion(), componentState)) {
  68 
  69                 g.setColor(Color.BLACK);
  70                 super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
  71                 g.setColor(Color.WHITE);
  72             }
  73 
  74             super.paintText(context, g, text, x, y, mnemonicIndex);
  75         }
  76     }
  77 
  78     /**
  79      * Paints text at the specified location. This will not attempt to
  80      * render the text as html nor will it offset by the insets of the
  81      * component.
  82      *
  83      * @param ss SynthContext
  84      * @param g Graphics used to render string in.
  85      * @param text Text to render
  86      * @param bounds Bounds of the text to be drawn.
  87      * @param mnemonicIndex Index to draw string at.
  88      */
  89     public void paintText(SynthContext context, Graphics g, String text,
  90                           Rectangle bounds, int mnemonicIndex) {
  91         if (text == null || text.length() <= 0) {
  92             // We don't need to paint empty strings
  93             return;
  94         }
  95 


   1 /*
   2  * Copyright (c) 2002, 2018, 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


  30 import java.awt.Graphics;
  31 import java.awt.Rectangle;
  32 
  33 /**
  34  * @author Joshua Outwater
  35  */
  36 class GTKGraphicsUtils extends SynthGraphicsUtils {
  37     public void paintText(SynthContext context, Graphics g, String text,
  38                           int x, int y, int mnemonicIndex) {
  39         if (text == null || text.length() <= 0) {
  40             // We don't need to paint empty strings
  41             return;
  42         }
  43 
  44         if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) {
  45             // Metacity handles painting of text on internal frame title,
  46             // ignore this.
  47             return;
  48         }
  49         int componentState = context.getComponentState();















  50         String themeName = GTKLookAndFeel.getGtkThemeName();
  51         if (themeName != null && themeName.startsWith("blueprint") &&
  52             shouldShadowText(context.getRegion(), componentState)) {
  53 
  54             g.setColor(Color.BLACK);
  55             super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
  56             g.setColor(Color.WHITE);
  57         }

  58         super.paintText(context, g, text, x, y, mnemonicIndex);

  59     }
  60 
  61     /**
  62      * Paints text at the specified location. This will not attempt to
  63      * render the text as html nor will it offset by the insets of the
  64      * component.
  65      *
  66      * @param ss SynthContext
  67      * @param g Graphics used to render string in.
  68      * @param text Text to render
  69      * @param bounds Bounds of the text to be drawn.
  70      * @param mnemonicIndex Index to draw string at.
  71      */
  72     public void paintText(SynthContext context, Graphics g, String text,
  73                           Rectangle bounds, int mnemonicIndex) {
  74         if (text == null || text.length() <= 0) {
  75             // We don't need to paint empty strings
  76             return;
  77         }
  78 


< prev index next >