package com.apple.laf;
import java.awt.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicMenuItemUI;
import apple.laf.JRSUIConstants.Size;
public class extends BasicMenuItemUI implements AquaMenuPainter.Client {
static final int = 0, = 1, = 2;
static final String [] = { "MenuItem", "CheckBoxMenuItem", "RadioButtonMenuItem" };
boolean = false;
boolean = false;
int ;
(final int type) {
super();
fType = type;
}
public static ComponentUI (final JComponent c) {
int type = kPlain;
if (c instanceof JCheckBoxMenuItem) type = kCheckBox;
if (c instanceof JRadioButtonMenuItem) type = kRadioButton;
return new AquaMenuItemUI(type);
}
protected String () {
return sPropertyPrefixes[fType];
}
@Override
protected void () {
super.installListeners();
IndeterminateListener.install(menuItem);
}
@Override
protected void () {
IndeterminateListener.uninstall(menuItem);
super.uninstallListeners();
}
public void () {
setIsScreenMenu(true);
}
protected void (final boolean isScreenMenuItem) {
if (fIsScreenMenuItem != isScreenMenuItem) {
fIsScreenMenuItem = isScreenMenuItem;
if (fIsScreenMenuItem) removeListeners();
else addListeners();
}
}
protected void () {
menuItem.removeMouseListener(mouseInputListener);
menuItem.removeMouseMotionListener(mouseInputListener);
menuItem.removeMenuDragMouseListener(menuDragMouseListener);
}
protected void () {
menuItem.addMouseListener(mouseInputListener);
menuItem.addMouseMotionListener(mouseInputListener);
menuItem.addMenuDragMouseListener(menuDragMouseListener);
}
protected void (final Graphics g, final JComponent c, final Icon localCheckIcon, final Icon localArrowIcon, final Color background, final Color foreground, final int localDefaultTextIconGap) {
AquaMenuPainter.instance().paintMenuItem(this, g, c, localCheckIcon, localArrowIcon, background, foreground, disabledForeground, selectionForeground, localDefaultTextIconGap, acceleratorFont);
}
protected Dimension (final JComponent c, final Icon localCheckIcon, final Icon localArrowIcon, final int localDefaultTextIconGap) {
return AquaMenuPainter.instance().getPreferredMenuItemSize(c, localCheckIcon, localArrowIcon, localDefaultTextIconGap, acceleratorFont);
}
public void (final Graphics g, final JComponent c) {
if (c.isOpaque()) {
final Color oldColor = g.getColor();
g.setColor(c.getBackground());
g.fillRect(0, 0, c.getWidth(), c.getHeight());
g.setColor(oldColor);
}
paint(g, c);
}
public void (final Graphics g, final JComponent c, final int menuWidth, final int menuHeight) {
if ((c.getParent() instanceof JMenuBar)) return;
final Color oldColor = g.getColor();
g.setColor(c.getBackground());
g.fillRect(0, 0, menuWidth, menuHeight);
if (((JMenuItem)c).isBorderPainted()) {
if (((JMenuItem)c).getModel().isArmed()) {
AquaMenuPainter.instance().paintSelectedMenuItemBackground(g, menuWidth, menuHeight);
}
} else {
if (((JMenuItem)c).getModel().isArmed()) {
final Color holdc = g.getColor();
g.setColor(Color.black);
g.fillRect(0, 0, menuWidth, menuHeight);
g.setColor(holdc);
} else {
g.setColor(Color.green);
g.fillRect(0, 0, menuWidth, menuHeight);
}
}
g.setColor(oldColor);
}
protected void (final MenuSelectionManager msm) {
final Dimension size = menuItem.getSize();
AquaUtils.blinkMenu(new AquaUtils.Selectable() {
public void (final boolean selected) {
menuItem.setArmed(selected);
menuItem.paintImmediately(0, 0, size.width, size.height);
}
});
super.doClick(msm);
}
static final IndeterminateListener = new IndeterminateListener();
static class implements PropertyChangeListener {
static final String = "JMenuItem.selectedState";
static void (final JMenuItem menuItem) {
menuItem.addPropertyChangeListener(CLIENT_PROPERTY_KEY, INDETERMINATE_LISTENER);
apply(menuItem, menuItem.getClientProperty(CLIENT_PROPERTY_KEY));
}
static void (final JMenuItem menuItem) {
menuItem.removePropertyChangeListener(CLIENT_PROPERTY_KEY, INDETERMINATE_LISTENER);
}
public void (final PropertyChangeEvent evt) {
final String key = evt.getPropertyName();
if (!CLIENT_PROPERTY_KEY.equalsIgnoreCase(key)) return;
final Object source = evt.getSource();
if (!(source instanceof JMenuItem)) return;
final JMenuItem c = (JMenuItem)source;
apply(c, evt.getNewValue());
}
static void (final JMenuItem menuItem, final Object value) {
final ButtonUI ui = menuItem.getUI();
if (!(ui instanceof AquaMenuItemUI)) return;
final AquaMenuItemUI aquaUI = (AquaMenuItemUI)ui;
if (aquaUI.fIsIndeterminate = "indeterminate".equals(value)) {
aquaUI.checkIcon = UIManager.getIcon(aquaUI.getPropertyPrefix() + ".dashIcon");
} else {
aquaUI.checkIcon = UIManager.getIcon(aquaUI.getPropertyPrefix() + ".checkIcon");
}
}
public static boolean (final JMenuItem menuItem) {
return "indeterminate".equals(menuItem.getClientProperty(CLIENT_PROPERTY_KEY));
}
}
}