0N/A/*
2362N/A * Copyright (c) 2004, 2006, 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.sun.java.swing.plaf.windows;
0N/A
0N/Aimport java.awt.*;
0N/A
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.plaf.basic.BasicPopupMenuSeparatorUI;
0N/Aimport javax.swing.plaf.ComponentUI;
0N/A
0N/Aimport com.sun.java.swing.plaf.windows.TMSchema.Part;
0N/Aimport com.sun.java.swing.plaf.windows.TMSchema.State;
0N/Aimport com.sun.java.swing.plaf.windows.XPStyle.Skin;
0N/A
0N/A/**
0N/A * Windows L&F implementation of PopupMenuSeparatorUI.
0N/A *
0N/A * @author Leif Samuelsson
0N/A * @author Igor Kushnirskiy
0N/A */
0N/A
0N/Apublic class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI {
0N/A
0N/A public static ComponentUI createUI(JComponent c) {
0N/A return new WindowsPopupMenuSeparatorUI();
0N/A }
0N/A
0N/A public void paint(Graphics g, JComponent c) {
0N/A Dimension s = c.getSize();
0N/A if (WindowsMenuItemUI.isVistaPainting()) {
0N/A int x = 1;
0N/A Component parent = c.getParent();
0N/A if (parent instanceof JComponent) {
0N/A Object gutterOffsetObject =
0N/A ((JComponent) parent).getClientProperty(
0N/A WindowsPopupMenuUI.GUTTER_OFFSET_KEY);
0N/A if (gutterOffsetObject instanceof Integer) {
0N/A /*
0N/A * gutter offset is in parent's coordinates.
0N/A * See comment in
0N/A * WindowsPopupMenuUI.getTextOffset(JComponent)
0N/A */
0N/A x = ((Integer) gutterOffsetObject).intValue() - c.getX();
0N/A x += WindowsPopupMenuUI.getGutterWidth();
0N/A }
0N/A }
0N/A Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR);
0N/A int skinHeight = skin.getHeight();
0N/A int y = (s.height - skinHeight) / 2;
0N/A skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
0N/A } else {
0N/A int y = s.height / 2;
0N/A g.setColor(c.getForeground());
0N/A g.drawLine(1, y - 1, s.width - 2, y - 1);
0N/A
0N/A g.setColor(c.getBackground());
0N/A g.drawLine(1, y, s.width - 2, y);
0N/A }
0N/A }
0N/A
0N/A public Dimension getPreferredSize(JComponent c) {
0N/A int fontHeight = 0;
0N/A Font font = c.getFont();
0N/A if (font != null) {
0N/A fontHeight = c.getFontMetrics(font).getHeight();
0N/A }
0N/A
0N/A return new Dimension(0, fontHeight/2 + 2);
0N/A }
0N/A
0N/A}