//
/*Sw8Reg.java    --- rrs@isi.edu ---   03-29-97   */
/* this class generates the switch register for munching squares.   */
/* It uses 8 binary waited check boxes in a separate frame (Window)   */
/* to create the swReg01 class */

import java.awt.*;
import java.applet.*;

public class Sw8Reg extends Applet	
{
	Frame f;
    	SwtchCnvs sw128, sw64, sw32, sw16, sw8, sw4, sw2, sw1;
	SwtchCnvs swrst;
	int lx=00, cx=15, rx=29, wx=30;
	int by=29, cy=15, ty=0,  wy=30;
	Label lab;


	public Sw8Reg()
		 {
			f = new Frame( );
			f.setTitle( "SReg");
			f.setLayout( new GridLayout( 1, 10 ) );
			f.add( sw128 = new SwtchCnvs( "ss7"  ));
			sw128.reshape( 0, 0,   wx, wy+15 );
			sw128.setState( false );
			f.add( sw64 = new SwtchCnvs( "ss6" ));
			sw64.reshape( wx, 0,   wx, wy+15 );
			sw64.setState( false );
			f.add( sw32 = new SwtchCnvs( "ss5" ));
			sw32.reshape( 2*wx, 0,   wx, wy+15 );
			sw32.setState( false );
			f.add( sw16 = new SwtchCnvs( "ss4" ));
			sw16.reshape( 3*wx, 0,   wx, wy+15 );
			sw16.setState( false );
			f.add( sw8 = new SwtchCnvs( "ss3" ));
			sw8.reshape( 4*wx, 0,   wx, wy+15 );
			sw8.setState( false );
			f.add( sw4 = new SwtchCnvs( "ss2" ));
			sw4.reshape( 5*wx, 0,   wx, wy+15 );
			sw4.setState( false );
			f.add( sw2 = new SwtchCnvs( "ss1" ));
			sw2.reshape( 6*wx, 0,   wx, wy+15 );
			sw2.setState( false );
			 f.add( sw1 = new SwtchCnvs( "ss0", true ));
			sw1.reshape( 7*wx, 0,   wx, wy+15 );
			// sw1.setState( false );
			f.add( lab = new Label( "   " ));
			lab.reshape( 8*wx, 0,   wx, wy+15 );
			f.add( swrst = new SwtchCnvs( "load" ));
			swrst.reshape( 9*wx, 0,   wx, wy+15 );
			swrst.setState( false );
			 f.pack();
			 f.show();
	   	}

	public void destroy( )
		{
			//f.destroy();
			f.dispose();
			super.destroy();
		}

	public int  getSwReg( ) 
		{
			int boxSum = 0;
			if( sw128.getState()) boxSum += 128;
			if( sw64.getState()) boxSum += 64;
			if( sw32.getState()) boxSum += 32;
			if( sw16.getState()) boxSum += 16;
			if( sw8.getState()) boxSum += 8;
			if( sw4.getState()) boxSum += 4;
			if( sw2.getState()) boxSum += 2;
			if( sw1.getState()) boxSum += 1;
			return boxSum;
		}

	public boolean  getRst( )
		{
			return swrst.getState();
		}

	public void setRst( boolean state )
		{
			swrst.setState( state );
		}

}

//