/************************************************************************
 * This library is free software; you can redistribute it and/or        *
 * modify it under the terms of the GNU Library General Public          *
 * License as published by the Free Software Foundation; either         *
 * version 2 of the License, or (at your option) any later version.     *
 *                                                                      *
 * This library 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    *
 * Library General Public License for more details.                     *
 *                                                                      *
 * You should have received a copy of the GNU Library General Public    *
 * License along with this library; if not, write to the                *
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,         *
 * Boston, MA  02111-1307, USA.                                         *
 *                                                                      *
 * The GNU Library General Public License file is included in           *
 * Online-Documentation                                                 *
 *                                                                      *
 * GNU's Homepage - http://www.gnu.org/                                 *
 *                                                                      *
 * Questions & comments referring to Hexi: please contact us:           *
 *                                                                      *
 * eMail:                                                               *
 *      ramsey@dbai.tuwien.ac.at                                        *
 * WWW:                                                                 *
 *      http://www.dbai.tuwien.ac.at/proj/ramsey/                       *
 *                                                                      *
 * (c) Wolfgang Slany 1987, Bidan Zhu 1996, Andreas Beer 1999           *
 * HexiConsole.java               Version 2.1                14.07.1999 *
 ***********************************************************************/

import java.awt.*;
import java.net.*;
import java.io.*;

public class HexiConsole extends Dialog
{
	Hexi hexi;
	Button Button_Demo, Button_NewGame, Button_Hint, Button_PHint, Button_Undo, Button_Ready;
 	Checkbox computer, user,allow_more, allow_shaking;
	Label status_label;

	public HexiConsole(Hexi parent,Frame f)
	{
		super(f,"Hexi Console",false);
		hexi  = parent;
		setBackground(hexi.GRAY);
		Panel FormPanel = new Panel();
		FormPanel.setLayout(new BorderLayout());
		allow_more  = new Checkbox("Allow more moves each time");
		allow_shaking  = new Checkbox("Allow shaking");
		allow_shaking.setState(true);
		status_label = new Label(" Welcome to play Hexi  !") ;
		status_label.setFont(new Font("Helvetica", Font.BOLD, 14));
		status_label.setForeground(Color.red) ;
		FormPanel.add("North",allow_more);
		FormPanel.add("West",allow_shaking);
		FormPanel.add("South",status_label);
		Panel playPanel = new Panel() ;
		playPanel.setLayout(new GridLayout(5,1,0,20));
		Button_NewGame = new Button("New Game");
		Button_Undo    = new Button("Undo");
		Button_Hint    = new Button("Show Hint");
		Button_PHint   = new Button("Play Hint");
		Button_Demo    = new Button("Demo");
		Button_Ready   = new Button("Ready");
		playPanel.add(Button_Undo);
		playPanel.add(Button_Hint);
		playPanel.add(Button_PHint);
		playPanel.add(Button_NewGame);
		playPanel.add(Button_Demo);
		Panel OptionPanel = new Panel();
		setFont(new Font("Helvetica", Font.BOLD, 14));
		GridBagLayout gridbag = new GridBagLayout();
		OptionPanel.setLayout(gridbag);
		GridBagConstraints c = new GridBagConstraints();
		c.anchor=GridBagConstraints.WEST;
		Label label1 = new Label("Who first:");
		c.gridx = 4;
		c.gridy = 0;
		gridbag.setConstraints(label1, c);
		OptionPanel.add(label1);
		CheckboxGroup WhoFirst  = new CheckboxGroup();
		computer  = new Checkbox("Computer", WhoFirst , false);
		computer.setForeground(Color.green);
		c.gridy = 3;
		gridbag.setConstraints(computer, c);
		OptionPanel.add(computer);
		user  = new Checkbox("Player", WhoFirst, true);
		user.setForeground(Color.red);
		c.gridy = 5;
		gridbag.setConstraints(user, c);
		OptionPanel.add(user);
		Panel p = new Panel();
		add("North",p);
		add("Center",OptionPanel);
		add("East",playPanel);
 		add("South",FormPanel);
	}

	public boolean action(Event evt, Object obj)
	{
		return hexi.action(evt,obj);
	}

	public boolean handleEvent(Event evt)
	{
		if (evt.id == Event.WINDOW_DESTROY)
		{
			System.out.println("Controlbox destroyed");
			dispose();
			return true;
		}
		return super.handleEvent(evt);
	}
}