
package polarDust.calculator;

/*
 * Copyright (c) 1996 Sorin Lazareanu, All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies.
 *
 */

import java.awt.*;

/**
 * NumDisplayPanel01 is a container for a NumDisplay01 component.
 *
 * <br><br><a href=../source/polarDust/calculator/NumDisplayPanel01.java>
 * The source code.</a>
 *
 * @version 0.9, 1996.06.04
 * @author Sorin Lazareanu
 */

public class NumDisplayPanel01 extends Panel implements CalcDisplay {
	NumDisplay01 display;

	/**
	* Constructs a new panel.
	*/
	public NumDisplayPanel01() {
		display = new NumDisplay01();
	}

	/**
	* Constructs a new display panel, driver for a printer.
	* @param aPrinter the printer to use.
	* @see PrinterPanel01
	*/
	public NumDisplayPanel01(PrinterPanel01 aPrinter) {
		display = new NumDisplay01(aPrinter);
	}

	/**
	* Prepares the layout of the panel.
	*/
	public void configure() {
		GridBagLayout gridBag = new GridBagLayout();
		GridBagConstraints c = new GridBagConstraints();
		GridBagLayoutHelper aHelper;

		setLayout(gridBag);
		c.fill = GridBagConstraints.BOTH;
		c.anchor = GridBagConstraints.CENTER;
		c.insets = new Insets(2, 2, 2, 2);
		aHelper = new GridBagLayoutHelper(this, gridBag, c, 1, 1);

		aHelper.addComponent(0, 0, 1, 1, display);
	}


	/**
	* Answers the maxDigitsFactor for the display component.
	* @see NumDisplay01#maxDigitsFactor
	*/
	public long maxDigitsFactor() {
		return display.maxDigitsFactor();
	}

	/**
	* @see NumDisplay01#assign
	*/
	public double assign(double dReg1) {
		return display.assign(dReg1);
	}

	/**
	* @see NumDisplay01#show
	*/
	public double show(double dReg1) {
		return display.show(dReg1);
	}

	/**
	* @see NumDisplay01#showOp
	*/
	public void showOp(String oper) {
		display.showOp(oper);
	}

	/**
	* @see NumDisplay01#assignWithDecimals
	*/
	public double assignWithDecimals(double dReg1, int iDecimals) {
		return display.assignWithDecimals(dReg1, iDecimals);
	}

	/**
	* @see NumDisplay01#showWithDecimals
	*/
	public double showWithDecimals(double dReg1, int iDecimals) {
		return display.showWithDecimals(dReg1, iDecimals);
	}

	/**
	* @see NumDisplay01#setNumber
	*/
	public void setNumber( String aString ) {
		display.setNumber(aString);
	}

	/**
	* @see NumDisplay01#showM
	*/
	public double showM(double dRegM) {
		return display.showM(dRegM);
	}

	/**
	* @see NumDisplay01#isError
	*/
	public boolean isError() {
		return display.isError();

	}

	/**
	* Stops the thread of the display component.
	* @see NumDisplay01
	*/
   	public void stop() {
	if (display.isAlive())
		 display.stop();
	}

	/**
	* Toggles runnable for the display component.
	* @see NumDisplay01#toggleRunnable
	*/
	public boolean mouseUp(Event e, int iX, int iY) {
		if (display.isAlive()) {
			display.toggleRunnable();
		};
		return true;
	}

}


