0N/A/*
3412N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/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
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
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
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.apple.laf;
0N/A
0N/Aimport java.awt.*;
0N/A
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.border.Border;
0N/Aimport javax.swing.plaf.UIResource;
0N/A
0N/Apublic class AquaMenuBorder implements Border, UIResource {
0N/A public AquaMenuBorder() { }
0N/A
0N/A /**
0N/A * Paints the border for the specified component with the specified
0N/A * position and size.
0N/A * @param c the component for which this border is being painted
0N/A * @param g the paint graphics
0N/A * @param x the x position of the painted border
0N/A * @param y the y position of the painted border
0N/A * @param width the width of the painted border
0N/A * @param height the height of the painted border
0N/A */
0N/A public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) {
0N/A // for now we don't paint a border. We let the button paint it since there
0N/A // needs to be a strict ordering for aqua components.
0N/A //paintButton(c, g, x, y, width, height);
0N/A //if (c instanceof JPopupMenu) {
0N/A //g.setColor(Color.red);
0N/A //g.drawRect(x,y, width-1, height-1);
0N/A //}
0N/A }
0N/A
0N/A /**
3412N/A * Returns whether or not the border is opaque. If the border
4235N/A * is opaque, it is responsible for filling in it's own
4235N/A * background when painting.
0N/A */
0N/A public boolean isBorderOpaque() {
0N/A return false;
0N/A }
178N/A
0N/A protected static Insets getItemInsets() {
0N/A return new Insets(1, 5, 1, 5);
0N/A }
0N/A
0N/A protected static Insets getEmptyInsets() {
0N/A return new Insets(0, 0, 0, 0);
0N/A }
0N/A
0N/A protected static Insets getPopupInsets() {
0N/A return new Insets(4, 0, 4, 0);
0N/A }
0N/A
0N/A /**
0N/A * Returns the insets of the border.
0N/A * @param c the component for which this border insets value applies
0N/A */
0N/A public Insets getBorderInsets(final Component c) {
0N/A if (!(c instanceof JPopupMenu)) {
0N/A return getItemInsets();
0N/A }
0N/A
0N/A // for more info on this issue, see AquaComboBoxPopup.updateContents()
0N/A final JPopupMenu menu = (JPopupMenu)c;
0N/A final int nChildren = menu.getComponentCount();
0N/A if (nChildren > 0) {
0N/A final Component firstChild = menu.getComponent(0);
0N/A if (firstChild instanceof Box.Filler) return getEmptyInsets();
0N/A if (firstChild instanceof JScrollPane) return getEmptyInsets();
0N/A }
0N/A
0N/A // just need top and bottom, and not right and left.
0N/A // but only for non-list popups.
0N/A return getPopupInsets();
0N/A }
0N/A}
3412N/A