jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
author alexsch
Wed, 25 Sep 2013 17:08:31 +0400
changeset 20168 137788883a22
parent 5506 202f599c92aa
permissions -rw-r--r--
8025070: [javadoc] fix some javadoc errors in javax/swing/plaf/synth Reviewed-by: serb, alexsch Contributed-by: Alexander Stepanov <alexander.v.stepanov@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3749
diff changeset
     2
 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
     4
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3749
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3749
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    10
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    15
 * accompanied this code).
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    16
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3749
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3749
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3749
diff changeset
    23
 * questions.
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    24
 */
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    25
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    26
package javax.swing.plaf.synth;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    27
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    28
import sun.swing.StringUIClientPropertyKey;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    29
import sun.swing.MenuItemLayoutHelper;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    30
import sun.swing.plaf.synth.SynthIcon;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    31
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    32
import javax.swing.*;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    33
import javax.swing.text.View;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    34
import java.awt.*;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    35
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    36
/**
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    37
 * Calculates preferred size and layouts synth menu items.
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    38
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    39
 * All JMenuItems (and JMenus) include enough space for the insets
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    40
 * plus one or more elements.  When we say "label" below, we mean
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    41
 * "icon and/or text."
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    42
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    43
 * Cases to consider for SynthMenuItemUI (visualized here in a
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    44
 * LTR orientation; the RTL case would be reversed):
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    45
 *                   label
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    46
 *      check icon + label
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    47
 *      check icon + label + accelerator
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    48
 *                   label + accelerator
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    49
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    50
 * Cases to consider for SynthMenuUI (again visualized here in a
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    51
 * LTR orientation):
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    52
 *                   label + arrow
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    53
 *
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    54
 * Note that in the above scenarios, accelerator and arrow icon are
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    55
 * mutually exclusive.  This means that if a popup menu contains a mix
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    56
 * of JMenus and JMenuItems, we only need to allow enough space for
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    57
 * max(maxAccelerator, maxArrow), and both accelerators and arrow icons
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    58
 * can occupy the same "column" of space in the menu.
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    59
 */
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    60
class SynthMenuItemLayoutHelper extends MenuItemLayoutHelper {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    61
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    62
    public static final StringUIClientPropertyKey MAX_ACC_OR_ARROW_WIDTH =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    63
            new StringUIClientPropertyKey("maxAccOrArrowWidth");
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    64
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    65
    public static final ColumnAlignment LTR_ALIGNMENT_1 =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    66
            new ColumnAlignment(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    67
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    68
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    69
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    70
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    71
                    SwingConstants.RIGHT
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    72
            );
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    73
    public static final ColumnAlignment LTR_ALIGNMENT_2 =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    74
            new ColumnAlignment(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    75
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    76
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    77
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    78
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    79
                    SwingConstants.RIGHT
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    80
            );
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    81
    public static final ColumnAlignment RTL_ALIGNMENT_1 =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    82
            new ColumnAlignment(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    83
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    84
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    85
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    86
                    SwingConstants.LEFT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    87
                    SwingConstants.LEFT
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    88
            );
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    89
    public static final ColumnAlignment RTL_ALIGNMENT_2 =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    90
            new ColumnAlignment(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    91
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    92
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    93
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    94
                    SwingConstants.RIGHT,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    95
                    SwingConstants.LEFT
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    96
            );
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    97
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    98
    private SynthContext context;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
    99
    private SynthContext accContext;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   100
    private SynthStyle style;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   101
    private SynthStyle accStyle;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   102
    private SynthGraphicsUtils gu;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   103
    private SynthGraphicsUtils accGu;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   104
    private boolean alignAcceleratorText;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   105
    private int maxAccOrArrowWidth;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   106
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   107
    public SynthMenuItemLayoutHelper(SynthContext context, SynthContext accContext,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   108
                                     JMenuItem mi, Icon checkIcon, Icon arrowIcon,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   109
                                     Rectangle viewRect, int gap, String accDelimiter,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   110
                                     boolean isLeftToRight, boolean useCheckAndArrow,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   111
                                     String propertyPrefix) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   112
        this.context = context;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   113
        this.accContext = accContext;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   114
        this.style = context.getStyle();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   115
        this.accStyle = accContext.getStyle();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   116
        this.gu = style.getGraphicsUtils(context);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   117
        this.accGu = accStyle.getGraphicsUtils(accContext);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   118
        this.alignAcceleratorText = getAlignAcceleratorText(propertyPrefix);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   119
        reset(mi, checkIcon, arrowIcon, viewRect, gap, accDelimiter,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   120
              isLeftToRight, style.getFont(context), accStyle.getFont(accContext),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   121
              useCheckAndArrow, propertyPrefix);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   122
        setLeadingGap(0);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   123
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   124
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   125
    private boolean getAlignAcceleratorText(String propertyPrefix) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   126
        return style.getBoolean(context,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   127
                propertyPrefix + ".alignAcceleratorText", true);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   128
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   129
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   130
    protected void calcWidthsAndHeights() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   131
        // iconRect
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   132
        if (getIcon() != null) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   133
            getIconSize().setWidth(SynthIcon.getIconWidth(getIcon(), context));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   134
            getIconSize().setHeight(SynthIcon.getIconHeight(getIcon(), context));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   135
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   136
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   137
        // accRect
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   138
        if (!getAccText().equals("")) {
1300
e7bbe37ce03a 6736649: test/closed/javax/swing/JMenuItem/6458123/ManualBug6458123.java fails on Linux
mlapshin
parents: 1295
diff changeset
   139
             getAccSize().setWidth(accGu.computeStringWidth(getAccContext(),
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   140
                    getAccFontMetrics().getFont(), getAccFontMetrics(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   141
                    getAccText()));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   142
            getAccSize().setHeight(getAccFontMetrics().getHeight());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   143
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   144
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   145
        // textRect
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   146
        if (getText() == null) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   147
            setText("");
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   148
        } else if (!getText().equals("")) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   149
            if (getHtmlView() != null) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   150
                // Text is HTML
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   151
                getTextSize().setWidth(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   152
                        (int) getHtmlView().getPreferredSpan(View.X_AXIS));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   153
                getTextSize().setHeight(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   154
                        (int) getHtmlView().getPreferredSpan(View.Y_AXIS));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   155
            } else {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   156
                // Text isn't HTML
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   157
                getTextSize().setWidth(gu.computeStringWidth(context,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   158
                        getFontMetrics().getFont(), getFontMetrics(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   159
                        getText()));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   160
                getTextSize().setHeight(getFontMetrics().getHeight());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   161
            }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   162
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   163
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   164
        if (useCheckAndArrow()) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   165
            // checkIcon
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   166
            if (getCheckIcon() != null) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   167
                getCheckSize().setWidth(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   168
                        SynthIcon.getIconWidth(getCheckIcon(), context));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   169
                getCheckSize().setHeight(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   170
                        SynthIcon.getIconHeight(getCheckIcon(), context));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   171
            }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   172
            // arrowRect
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   173
            if (getArrowIcon() != null) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   174
                getArrowSize().setWidth(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   175
                        SynthIcon.getIconWidth(getArrowIcon(), context));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   176
                getArrowSize().setHeight(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   177
                        SynthIcon.getIconHeight(getArrowIcon(), context));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   178
            }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   179
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   180
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   181
        // labelRect
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   182
        if (isColumnLayout()) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   183
            getLabelSize().setWidth(getIconSize().getWidth()
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   184
                    + getTextSize().getWidth() + getGap());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   185
            getLabelSize().setHeight(MenuItemLayoutHelper.max(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   186
                    getCheckSize().getHeight(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   187
                    getIconSize().getHeight(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   188
                    getTextSize().getHeight(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   189
                    getAccSize().getHeight(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   190
                    getArrowSize().getHeight()));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   191
        } else {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   192
            Rectangle textRect = new Rectangle();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   193
            Rectangle iconRect = new Rectangle();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   194
            gu.layoutText(context, getFontMetrics(), getText(), getIcon(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   195
                    getHorizontalAlignment(), getVerticalAlignment(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   196
                    getHorizontalTextPosition(), getVerticalTextPosition(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   197
                    getViewRect(), iconRect, textRect, getGap());
3749
d0ecbd7075b1 6797139: JButton title is truncating for some strings irrespective of preferred size.
alexp
parents: 1300
diff changeset
   198
            textRect.width += getLeftTextExtraWidth();
1295
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   199
            Rectangle labelRect = iconRect.union(textRect);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   200
            getLabelSize().setHeight(labelRect.height);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   201
            getLabelSize().setWidth(labelRect.width);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   202
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   203
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   204
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   205
    protected void calcMaxWidths() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   206
        calcMaxWidth(getCheckSize(), MAX_CHECK_WIDTH);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   207
        maxAccOrArrowWidth =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   208
                calcMaxValue(MAX_ACC_OR_ARROW_WIDTH, getArrowSize().getWidth());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   209
        maxAccOrArrowWidth =
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   210
                calcMaxValue(MAX_ACC_OR_ARROW_WIDTH, getAccSize().getWidth());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   211
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   212
        if (isColumnLayout()) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   213
            calcMaxWidth(getIconSize(), MAX_ICON_WIDTH);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   214
            calcMaxWidth(getTextSize(), MAX_TEXT_WIDTH);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   215
            int curGap = getGap();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   216
            if ((getIconSize().getMaxWidth() == 0)
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   217
                    || (getTextSize().getMaxWidth() == 0)) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   218
                curGap = 0;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   219
            }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   220
            getLabelSize().setMaxWidth(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   221
                    calcMaxValue(MAX_LABEL_WIDTH, getIconSize().getMaxWidth()
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   222
                            + getTextSize().getMaxWidth() + curGap));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   223
        } else {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   224
            // We shouldn't use current icon and text widths
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   225
            // in maximal widths calculation for complex layout.
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   226
            getIconSize().setMaxWidth(getParentIntProperty(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   227
                    MAX_ICON_WIDTH));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   228
            calcMaxWidth(getLabelSize(), MAX_LABEL_WIDTH);
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   229
            // If maxLabelWidth is wider
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   230
            // than the widest icon + the widest text + gap,
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   231
            // we should update the maximal text witdh
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   232
            int candidateTextWidth = getLabelSize().getMaxWidth() -
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   233
                    getIconSize().getMaxWidth();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   234
            if (getIconSize().getMaxWidth() > 0) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   235
                candidateTextWidth -= getGap();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   236
            }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   237
            getTextSize().setMaxWidth(calcMaxValue(
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   238
                    MAX_TEXT_WIDTH, candidateTextWidth));
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   239
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   240
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   241
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   242
    public SynthContext getContext() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   243
        return context;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   244
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   245
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   246
    public SynthContext getAccContext() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   247
        return accContext;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   248
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   249
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   250
    public SynthStyle getStyle() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   251
        return style;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   252
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   253
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   254
    public SynthStyle getAccStyle() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   255
        return accStyle;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   256
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   257
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   258
    public SynthGraphicsUtils getGraphicsUtils() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   259
        return gu;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   260
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   261
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   262
    public SynthGraphicsUtils getAccGraphicsUtils() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   263
        return accGu;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   264
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   265
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   266
    public boolean alignAcceleratorText() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   267
        return alignAcceleratorText;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   268
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   269
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   270
    public int getMaxAccOrArrowWidth() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   271
        return maxAccOrArrowWidth;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   272
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   273
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   274
    protected void prepareForLayout(LayoutResult lr) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   275
        lr.getCheckRect().width = getCheckSize().getMaxWidth();
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   276
        // An item can have an arrow or a check icon at once
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   277
        if (useCheckAndArrow() && (!"".equals(getAccText()))) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   278
            lr.getAccRect().width = maxAccOrArrowWidth;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   279
        } else {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   280
            lr.getArrowRect().width = maxAccOrArrowWidth;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   281
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   282
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   283
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   284
    public ColumnAlignment getLTRColumnAlignment() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   285
        if (alignAcceleratorText()) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   286
            return LTR_ALIGNMENT_2;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   287
        } else {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   288
            return LTR_ALIGNMENT_1;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   289
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   290
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   291
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   292
    public ColumnAlignment getRTLColumnAlignment() {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   293
        if (alignAcceleratorText()) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   294
            return RTL_ALIGNMENT_2;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   295
        } else {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   296
            return RTL_ALIGNMENT_1;
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   297
        }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   298
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   299
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   300
    protected void layoutIconAndTextInLabelRect(LayoutResult lr) {
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   301
        lr.setTextRect(new Rectangle());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   302
        lr.setIconRect(new Rectangle());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   303
        gu.layoutText(context, getFontMetrics(), getText(), getIcon(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   304
                getHorizontalAlignment(), getVerticalAlignment(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   305
                getHorizontalTextPosition(), getVerticalTextPosition(),
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   306
                lr.getLabelRect(), lr.getIconRect(), lr.getTextRect(), getGap());
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   307
    }
3cf2264a5743 6584657: GTK Look and Feel: Bugs in menu item layout
mlapshin
parents:
diff changeset
   308
}