< prev index next >

src/java.desktop/share/classes/sun/swing/MenuItemLayoutHelper.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


 239     }
 240 
 241     private int getCheckOffset(String propertyPrefix) {
 242         int checkIconOffset = gap;
 243         Object checkIconOffsetObject =
 244                 UIManager.get(propertyPrefix + ".checkIconOffset");
 245         if (checkIconOffsetObject instanceof Integer) {
 246             checkIconOffset = (Integer) checkIconOffsetObject;
 247         }
 248         return checkIconOffset;
 249     }
 250 
 251     protected void calcWidthsAndHeights() {
 252         // iconRect
 253         if (icon != null) {
 254             iconSize.width = icon.getIconWidth();
 255             iconSize.height = icon.getIconHeight();
 256         }
 257 
 258         // accRect
 259         if (!accText.equals("")) {
 260             accSize.width = SwingUtilities2.stringWidth(mi, accFm, accText);
 261             accSize.height = accFm.getHeight();
 262         }
 263 
 264         // textRect
 265         if (text == null) {
 266             text = "";
 267         } else if (!text.equals("")) {
 268             if (htmlView != null) {
 269                 // Text is HTML
 270                 textSize.width =
 271                         (int) htmlView.getPreferredSpan(View.X_AXIS);
 272                 textSize.height =
 273                         (int) htmlView.getPreferredSpan(View.Y_AXIS);
 274             } else {
 275                 // Text isn't HTML
 276                 textSize.width = SwingUtilities2.stringWidth(mi, fm, text);
 277                 textSize.height = fm.getHeight();
 278             }
 279         }
 280 
 281         if (useCheckAndArrow) {
 282             // checkIcon
 283             if (checkIcon != null) {
 284                 checkSize.width = checkIcon.getIconWidth();
 285                 checkSize.height = checkIcon.getIconHeight();
 286             }
 287             // arrowRect


   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


 239     }
 240 
 241     private int getCheckOffset(String propertyPrefix) {
 242         int checkIconOffset = gap;
 243         Object checkIconOffsetObject =
 244                 UIManager.get(propertyPrefix + ".checkIconOffset");
 245         if (checkIconOffsetObject instanceof Integer) {
 246             checkIconOffset = (Integer) checkIconOffsetObject;
 247         }
 248         return checkIconOffset;
 249     }
 250 
 251     protected void calcWidthsAndHeights() {
 252         // iconRect
 253         if (icon != null) {
 254             iconSize.width = icon.getIconWidth();
 255             iconSize.height = icon.getIconHeight();
 256         }
 257 
 258         // accRect
 259         if (!accText.isEmpty()) {
 260             accSize.width = SwingUtilities2.stringWidth(mi, accFm, accText);
 261             accSize.height = accFm.getHeight();
 262         }
 263 
 264         // textRect
 265         if (text == null) {
 266             text = "";
 267         } else if (!text.isEmpty()) {
 268             if (htmlView != null) {
 269                 // Text is HTML
 270                 textSize.width =
 271                         (int) htmlView.getPreferredSpan(View.X_AXIS);
 272                 textSize.height =
 273                         (int) htmlView.getPreferredSpan(View.Y_AXIS);
 274             } else {
 275                 // Text isn't HTML
 276                 textSize.width = SwingUtilities2.stringWidth(mi, fm, text);
 277                 textSize.height = fm.getHeight();
 278             }
 279         }
 280 
 281         if (useCheckAndArrow) {
 282             // checkIcon
 283             if (checkIcon != null) {
 284                 checkSize.width = checkIcon.getIconWidth();
 285                 checkSize.height = checkIcon.getIconHeight();
 286             }
 287             // arrowRect


< prev index next >