package jp.ac.kyutech.mns.ist.sheetmap;

import java.awt.Color;

import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
import edu.umd.cs.piccolo.event.PInputEvent;

/**
 * （教師が書き込みするときの）色を選択するPMenuItem
 * @author miuramo
 *
 */
@SuppressWarnings("serial")
public class PMenuItem_Color extends PMenuItem_Abstract {

	public PMenuItem_Color(String arg, boolean m, Color color) {
		super(arg, m, color);

		addInputEventListener(new PBasicInputEventHandler() {
			public void mouseEntered(PInputEvent e) {
				setPaint(defaultcolor);
			}

			public void mouseExited(PInputEvent e) {
				setSelected(isSelected);
			}

			public void mousePressed(PInputEvent e) {
				setPaint(Color.red);
			}

			public void mouseReleased(PInputEvent e) {
				setSelected(isSelected);
			}

			public void mouseClicked(PInputEvent e) {
//				doClick(e);
			}
		});

		// とてもアドホックな方法
		addCapitalShortcutKeyListener(new PActionListener() {
			public void actionPerformed(PInputEvent e) {
				// System.out.println(defaultcolor.toString());
			}
		});
	}

	public void doClick(PInputEvent e) {
//		System.out.println(text + " is clicked.");
		if (al != null){
			e.setActionCommand(text);
			al.actionPerformed(e);
		}
		if (isToggle) {
			isSelected = !isSelected;
			parent.setSelected(PMenuItem_Color.this);
		}
	}
}
