/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Calculates preferred size and layouts synth menu items.
*
* All JMenuItems (and JMenus) include enough space for the insets
* plus one or more elements. When we say "label" below, we mean
*
* Cases to consider for SynthMenuItemUI (visualized here in a
* LTR orientation; the RTL case would be reversed):
* label
* check icon + label
* check icon + label + accelerator
* label + accelerator
*
* Cases to consider for SynthMenuUI (again visualized here in a
* LTR orientation):
* label + arrow
*
* Note that in the above scenarios, accelerator and arrow icon are
* mutually exclusive. This means that if a popup menu contains a mix
* of JMenus and JMenuItems, we only need to allow enough space for
* max(maxAccelerator, maxArrow), and both accelerators and arrow icons
* can occupy the same "column" of space in the menu.
*/
new StringUIClientPropertyKey("maxAccOrArrowWidth");
new ColumnAlignment(
);
new ColumnAlignment(
);
new ColumnAlignment(
);
new ColumnAlignment(
);
private boolean alignAcceleratorText;
private int maxAccOrArrowWidth;
boolean isLeftToRight, boolean useCheckAndArrow,
this.accContext = accContext;
setLeadingGap(0);
}
propertyPrefix + ".alignAcceleratorText", true);
}
protected void calcWidthsAndHeights() {
// iconRect
}
// accRect
getAccText()));
}
// textRect
setText("");
if (getHtmlView() != null) {
// Text is HTML
} else {
// Text isn't HTML
getText()));
}
}
if (useCheckAndArrow()) {
// checkIcon
if (getCheckIcon() != null) {
}
// arrowRect
if (getArrowIcon() != null) {
}
}
// labelRect
if (isColumnLayout()) {
getCheckSize().getHeight(),
getIconSize().getHeight(),
getTextSize().getHeight(),
getAccSize().getHeight(),
getArrowSize().getHeight()));
} else {
}
}
protected void calcMaxWidths() {
if (isColumnLayout()) {
curGap = 0;
}
} else {
// We shouldn't use current icon and text widths
// in maximal widths calculation for complex layout.
// If maxLabelWidth is wider
// than the widest icon + the widest text + gap,
// we should update the maximal text witdh
getIconSize().getMaxWidth();
candidateTextWidth -= getGap();
}
}
}
return context;
}
return accContext;
}
return style;
}
return accStyle;
}
return gu;
}
return accGu;
}
public boolean alignAcceleratorText() {
return alignAcceleratorText;
}
public int getMaxAccOrArrowWidth() {
return maxAccOrArrowWidth;
}
// An item can have an arrow or a check icon at once
} else {
}
}
if (alignAcceleratorText()) {
return LTR_ALIGNMENT_2;
} else {
return LTR_ALIGNMENT_1;
}
}
if (alignAcceleratorText()) {
return RTL_ALIGNMENT_2;
} else {
return RTL_ALIGNMENT_1;
}
}
}
}