package dotsboxes.gui;
import java.awt.EventQueue;

import javax.swing.*;

import dotsboxes.gui.Field;
import dotsboxes.gui.newgame.NewGameGUI;

import java.awt.*;
import java.awt.geom.*;

import dotsboxes.callbacks.EventCallback;
import dotsboxes.events.EventType;
import dotsboxes.events.GameTurnEvent;
import dotsboxes.game.TurnDesc;
import dotsboxes.utils.Debug;

import java.awt.Component;

import javax.swing.Box;

import java.awt.Color;
import java.awt.Event;
//import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.GridBagLayout;

import javax.swing.JButton;

import java.awt.GridBagConstraints;

import javax.swing.AbstractAction;

import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.Action;

import java.awt.event.ActionListener;
import java.awt.geom.Line2D;

import javax.swing.JRadioButton;

import java.awt.Insets;
import java.awt.BorderLayout;

import dotsboxes.*;

import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JLayeredPane;
import javax.swing.JSplitPane;
import javax.swing.JDesktopPane;

import java.awt.FlowLayout;

import javax.swing.JInternalFrame;

import java.awt.Panel;
import java.awt.Button;

import javax.swing.JLabel;


public class GUI implements EventCallback{

	public JFrame m_frame = new JFrame();

	public GUI() {
		m_this = this;
		initialize();
	}

	Panel Menu = new Panel();
	Field Field = new Field(m_frame);
	Panel Config = new Panel();
	NewGameGUI NewGameGUI = new NewGameGUI();
	GUI m_this;
	
	public void ShowMenu()
	{
		Menu.setBounds(m_frame.getBounds());
		Menu.repaint();
		Menu.setVisible(true);	
		Config.setVisible(false);
		Field.setVisible(false);
	}
	
	public void ShowConfig()
	{
		Menu.setVisible(false);
		Config.setVisible(true);
		Field.setVisible(false);
	}
	
	public void ShowField()
	{
		Menu.setVisible(false);
		Config.setVisible(false);
		Field.setBounds(m_frame.getBounds());
		Field.repaint();
		Field.setVisible(true);	
	}
	
	public void ShowNewGameGUI()
	{
		Menu.setVisible(false);
		Config.setVisible(false);
		Field.setVisible(false);
		NewGameGUI.setBounds(m_frame.getBounds());
		NewGameGUI.repaint();
		NewGameGUI.setVisible(true);	
	}
	
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() 
	{
		//Field.Init(6, 8, 3); // TODO Get from event.

		m_frame.addComponentListener( new ComponentListener()
		{  
				@Override
				public void componentResized(ComponentEvent e) {
					Menu.setSize(m_frame.getWidth(), m_frame.getHeight());
					Menu.repaint();
					Field.setSize(m_frame.getWidth(), m_frame.getHeight());
					Config.setSize(m_frame.getWidth(), m_frame.getHeight());
					Field.repaint();
				}

				@Override
				public void componentMoved(ComponentEvent e) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void componentShown(ComponentEvent e) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void componentHidden(ComponentEvent e) {
					// TODO Auto-generated method stub
					
				}
		});
		
		m_frame.setBounds(10, 10, 756, 505);
		Menu.setBounds(m_frame.getBounds());
		m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//frame.getContentPane().setLayout(null);
		
		
		Menu.setLayout(new GridLayout(0, 1, 0, 0));
		
		Button StartGame = new Button("Lets start game!");
		StartGame.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				
				EventManager.NewEvent( new dotsboxes.events.Event(EventType.GUI_game_Start), m_this);
			}
		});
		Menu.add(StartGame);
		
		Button button = new Button("Exit");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				EventManager.NewEvent( new dotsboxes.events.Event(EventType.GUI_game_exit), m_this);
			}
		});
		Menu.add(button);
		m_frame.add(Menu);
		Field.setBounds(m_frame.getBounds());
		
		Field.setLayout(null);
		m_frame.add(Field);
		
		
		
		Config.setBounds(0, 0, 10, 10);
		m_frame.add(Config);
		
		NewGameGUI.setBounds(m_frame.getBounds());
		m_frame.add(NewGameGUI);
		
		Menu.setVisible(false);
		Config.setVisible(false);
		Field.setVisible(false);
		NewGameGUI.setVisible(false);
		m_frame.setVisible(true);
	}

	@Override
	public void HandleEvent(dotsboxes.events.Event event) 
	{
		// TODO Auto-generated method stub
		
	}
}

@@ -259,16 +259,60 @@
 ntType;%0A
+import dotsboxes.events.GUI_NewGameRequest;%0A
 import d
@@ -3727,24 +3727,359 @@
 rtGame);%0A%09%09%0A
+%09%09if ( Debug.isEnabled() ) %7B%0A%09%09%09JButton debug_call_field = new JButton(%22debug call field%22);%0A%09%09%09debug_call_field.addActionListener(new ActionListener() %7B%0A%09%09%09%09public void actionPerformed(ActionEvent e) %0A%09%09%09%09%7B%0A%09%09%09%09%09EventManager.NewEvent(new GUI_NewGameRequest( 2, 0, 6, 8), m_this);%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%09%09%09Menu.add(debug_call_field);%09%0A%09%09%7D%0A%09%09%0A%09%09%0A
 %09%09Button but
@@ -4577,24 +4577,27 @@
 ameGUI);%0A%09%09%0A
+%09%09%0A
 %09%09Menu.setVi

add debug button to init game start