2362N/A * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. 619N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 619N/A * This code is free software; you can redistribute it and/or modify it 619N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 619N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 619N/A * This code is distributed in the hope that it will be useful, but WITHOUT 619N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 619N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 619N/A * version 2 for more details (a copy is included in the LICENSE file that 619N/A * accompanied this code). 619N/A * You should have received a copy of the GNU General Public License version 619N/A * 2 along with this work; if not, write to the Free Software Foundation, 619N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 619N/A * Calculates preferred size and layouts menu items. 619N/A /* Client Property keys for calculation of maximal widths */ 619N/A * The empty protected constructor is necessary for derived classes. 619N/A // In case of column layout, .checkIconFactory is defined for this UI, 619N/A // the icon is compatible with it and useCheckAndArrow() is true, 619N/A // then the icon is handled by the checkIcon. 619N/A +
".checkIconFactory");
619N/A return gap;
// There is no any check icon 619N/A // We shouldn't use current icon and text widths 619N/A // in maximal widths calculation for complex layout. 619N/A // If maxLabelWidth is wider 619N/A // than the widest icon + the widest text + gap, 619N/A // we should update the maximal text witdh 619N/A * Calculates and returns maximal value through specified parent component 619N/A * @param propertyName name of the property, which stores the maximal value. 619N/A * @param value a value which pretends to be maximal 619N/A * @return maximal value among the parent property and the value. 619N/A // Get maximal value from parent client property 619N/A // Store new maximal width in parent client property 619N/A * Returns parent client property as int. 619N/A * @param propertyName name of the parent property. 619N/A * @return value of the property as int. 619N/A * Answers should we do column layout for a menu item or not. 619N/A * We do it when a user doesn't set any alignments 619N/A * and text positions manually, except the vertical alignment. 619N/A * Calculates maximal text offset. 619N/A * It is required for some L&Fs (ex: Vista L&F). 619N/A * The offset is meaningful only for L2R column layout. 619N/A * @param viewRect the rectangle, the maximal text offset 619N/A * will be calculated for. 619N/A // Calculate the current text offset 619N/A // maximal text offset shouldn't be less than minimal text offset; 619N/A // Calculate and store the maximal text offset 619N/A * Layout icon, text, check icon, accelerator text and arrow icon 619N/A * in the viewRect and return their positions. 619N/A * If horizontalAlignment, verticalTextPosition and horizontalTextPosition 619N/A * are default (user doesn't set any manually) the layouting algorithm is: 619N/A * Elements are layouted in the five columns: 619N/A * check icon + icon + text + accelerator text + arrow icon 619N/A * In the other case elements are layouted in the four columns: 619N/A * check icon + label + accelerator text + arrow icon 619N/A * Label is union of icon and text. 619N/A * The order of columns can be reversed. 619N/A * It depends on the menu item orientation. 619N/A * Aligns the accelertor text and the check and arrow icons vertically 619N/A * with the center of the label rect. 619N/A * Fixes vertical alignment of all menu item elements if rect.y 619N/A * or (rect.y + rect.height) is out of viewRect bounds 619N/A // Set maximal width for all the five basic rects 619N/A // (three other ones are already maximal) 619N/A // All rects will be aligned at the left side 619N/A // Tune afterCheckIconGap 619N/A // Take into account minimal text offset 619N/A // Set Y coordinate for text and icon. 619N/A // Y coordinates for other rects 619N/A // will be calculated later in layoutMenuItem. 619N/A // Calculate valid X and Y coordinates for labelRect 619N/A // Tune afterCheckIconGap 619N/A // Take into account minimal text offset 619N/A // Center labelRect vertically 619N/A // Set maximal width for all the five basic rects 619N/A // (three other ones are already maximal) 619N/A // Tune the gap after check icon 619N/A // Take into account minimal text offset 619N/A // Set Y coordinates for text and icon. 619N/A // Y coordinates for other rects 619N/A // will be calculated later in layoutMenuItem. 619N/A // Calculate valid X and Y coordinate for labelRect 619N/A // Tune the gap after check icon 619N/A // Take into account minimal text offset 619N/A // Center labelRect vertically 619N/A * Sets Y coordinates of text and icon 619N/A * taking into account the vertical alignment 619N/A * Sets labelRect Y coordinate 619N/A * taking into account the vertical alignment 619N/A * Returns parent of this component if it is not a top-level menu 619N/A * Otherwise returns null. 619N/A * @param menuItem the menu item whose parent will be returned. 619N/A * @return parent of this component if it is not a top-level menu 619N/A * Otherwise returns null. 619N/A * Finds and returns maximal integer value in the given array. 619N/A * @param values array where the search will be performed. 619N/A * @return maximal vaule. 619N/A * Returns false if the component is a JMenu and it is a top 619N/A * level menu (on the menubar).