< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java

Print this page


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


 117         this.alignAcceleratorText = getAlignAcceleratorText(propertyPrefix);
 118         reset(mi, checkIcon, arrowIcon, viewRect, gap, accDelimiter,
 119               isLeftToRight, style.getFont(context), accStyle.getFont(accContext),
 120               useCheckAndArrow, propertyPrefix);
 121         setLeadingGap(0);
 122     }
 123 
 124     private boolean getAlignAcceleratorText(String propertyPrefix) {
 125         return style.getBoolean(context,
 126                 propertyPrefix + ".alignAcceleratorText", true);
 127     }
 128 
 129     protected void calcWidthsAndHeights() {
 130         // iconRect
 131         if (getIcon() != null) {
 132             getIconSize().setWidth(SynthGraphicsUtils.getIconWidth(getIcon(), context));
 133             getIconSize().setHeight(SynthGraphicsUtils.getIconHeight(getIcon(), context));
 134         }
 135 
 136         // accRect
 137         if (!getAccText().equals("")) {
 138              getAccSize().setWidth(accGu.computeStringWidth(getAccContext(),
 139                     getAccFontMetrics().getFont(), getAccFontMetrics(),
 140                     getAccText()));
 141             getAccSize().setHeight(getAccFontMetrics().getHeight());
 142         }
 143 
 144         // textRect
 145         if (getText() == null) {
 146             setText("");
 147         } else if (!getText().equals("")) {
 148             if (getHtmlView() != null) {
 149                 // Text is HTML
 150                 getTextSize().setWidth(
 151                         (int) getHtmlView().getPreferredSpan(View.X_AXIS));
 152                 getTextSize().setHeight(
 153                         (int) getHtmlView().getPreferredSpan(View.Y_AXIS));
 154             } else {
 155                 // Text isn't HTML
 156                 getTextSize().setWidth(gu.computeStringWidth(context,
 157                         getFontMetrics().getFont(), getFontMetrics(),
 158                         getText()));
 159                 getTextSize().setHeight(getFontMetrics().getHeight());
 160             }
 161         }
 162 
 163         if (useCheckAndArrow()) {
 164             // checkIcon
 165             if (getCheckIcon() != null) {
 166                 getCheckSize().setWidth(
 167                         SynthGraphicsUtils.getIconWidth(getCheckIcon(), context));


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


 117         this.alignAcceleratorText = getAlignAcceleratorText(propertyPrefix);
 118         reset(mi, checkIcon, arrowIcon, viewRect, gap, accDelimiter,
 119               isLeftToRight, style.getFont(context), accStyle.getFont(accContext),
 120               useCheckAndArrow, propertyPrefix);
 121         setLeadingGap(0);
 122     }
 123 
 124     private boolean getAlignAcceleratorText(String propertyPrefix) {
 125         return style.getBoolean(context,
 126                 propertyPrefix + ".alignAcceleratorText", true);
 127     }
 128 
 129     protected void calcWidthsAndHeights() {
 130         // iconRect
 131         if (getIcon() != null) {
 132             getIconSize().setWidth(SynthGraphicsUtils.getIconWidth(getIcon(), context));
 133             getIconSize().setHeight(SynthGraphicsUtils.getIconHeight(getIcon(), context));
 134         }
 135 
 136         // accRect
 137         if (!getAccText().isEmpty()) {
 138              getAccSize().setWidth(accGu.computeStringWidth(getAccContext(),
 139                     getAccFontMetrics().getFont(), getAccFontMetrics(),
 140                     getAccText()));
 141             getAccSize().setHeight(getAccFontMetrics().getHeight());
 142         }
 143 
 144         // textRect
 145         if (getText() == null) {
 146             setText("");
 147         } else if (!getText().isEmpty()) {
 148             if (getHtmlView() != null) {
 149                 // Text is HTML
 150                 getTextSize().setWidth(
 151                         (int) getHtmlView().getPreferredSpan(View.X_AXIS));
 152                 getTextSize().setHeight(
 153                         (int) getHtmlView().getPreferredSpan(View.Y_AXIS));
 154             } else {
 155                 // Text isn't HTML
 156                 getTextSize().setWidth(gu.computeStringWidth(context,
 157                         getFontMetrics().getFont(), getFontMetrics(),
 158                         getText()));
 159                 getTextSize().setHeight(getFontMetrics().getHeight());
 160             }
 161         }
 162 
 163         if (useCheckAndArrow()) {
 164             // checkIcon
 165             if (getCheckIcon() != null) {
 166                 getCheckSize().setWidth(
 167                         SynthGraphicsUtils.getIconWidth(getCheckIcon(), context));


< prev index next >