package mpi.eudico.client.mac;


import com.apple.eawt.Application;
import com.apple.eawt.ApplicationAdapter;
import com.apple.eawt.ApplicationEvent;

/**
 * A class to handle the Mac OS X default application menu items, like "About" 
 * and "Quit" (Command Q). This adapter passes the handling to the (one)
 * MacApplicationListener. 
 * 
 * @version 1.0 nov 04
 * @author han sloetjes
 */
public class MacAppHandler extends ApplicationAdapter {
	private Application app;
	private MacApplicationListener macApp;
	
	/**
	 * Constructs the MacAppHandler. Only one listener allowed.
	 * 
	 * @param macApp the listener to be notified
	 */
	public MacAppHandler(MacApplicationListener macApp){
		this.macApp = macApp;
		app = Application.getApplication();
		app.addApplicationListener(this);
	}

	/**
	 * Forwards the handling of the main screen menu "Quit" event to the listener.
	 * 
	 * @param ae the Application event from the OS
	 */
	public void handleQuit(ApplicationEvent ae) {
		macApp.macHandleQuit();
		ae.setHandled(true);
	}
	
	/**
	 * Forwards the handling of the main screen menu "About" event to the listener.
	 * 
	 * @param ae the Application event from the OS
	 */
	public void handleAbout(ApplicationEvent ae) {
		macApp.macHandleAbout();
		ae.setHandled(true);
	}

}
