/* GveCalc---an experimental mathematical program
 * Copyright (C) 1997, 1998, 1999, 2000, Geert Vernaeve.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * You can contact the author by e-mail at geert.vernaeve@rug.ac.be
 * or by snail-mail at Brouwerijstraat 39, 9300 Aalst, Belgium.
 */

package gve.calc;

import awt.*;
import awt.Label;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
//import java.applet.AppletContext;
import java.net.URL;

public class GveCalc extends Applet implements MouseListener
{
	public final static String versionString = "0.014 Alpha (25-Jan-2001)";
	private Label lab;
//	public static AppletContext appContext;
	public static URL documentBase,codeBase;
	public static final int debuglevel = gve.calc.formula.Part.debuglevel;

	static { gve.calc.formula.StandardOperators.registerStandardOps(); }

	public void init() {
		add(lab = new Label("Click to start GveCalc"));
		if (checkjava(this)) lab.addMouseListener(this);
		documentBase = getDocumentBase();
		codeBase = getCodeBase();
//		appContext = getAppletContext();
//		netscape.security.PrivilegeManager.enablePrivilege("Debugger");
	}

	public void mouseClicked(MouseEvent evt) {}
	public void mouseEntered(MouseEvent evt) {}
	public void mouseExited(MouseEvent evt) {}

	public void mousePressed(MouseEvent evt) {
		lab.setText("Starting ...");
		startup(this);
		lab.setText("Click to start GveCalc");
	}

	public void mouseReleased(MouseEvent evt) {}

	public static void main(String argv[])
	{
		if (checkjava(null)) startup(null);
	}

	private static void startup(Applet applet) {
		new SplashWindow(new StackWindow(applet));
	}

	public static final boolean checkjava(Applet applet) {
		try {
			new Frame().getMinimumSize();
		} catch (NoSuchMethodError e) {
			if (applet != null)
				applet.add(new Label("Need JDK 1.1 or higher!"));
			else System.out.println("Need JDK 1.1 or higher!");
			return false;
		}
		return true;
	}
}