/*
 * MyFirst solo Project Spring 2014
 * Matching Card Game
 */

package view;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;

import javax.swing.JFrame;

import model.MatchingGame;

/**
 * This class instantiates the MatchingGame object, and creates a GUI which coordinates button 
 * pushes with logic contained in "myGame".
 * 
 * @author Brian Dennis
 * @version 3-25-2014
 */
@SuppressWarnings("serial")
public class MatchingGameGUI extends JFrame {
    
    /** The variable representing the game itself. */
    private final MatchingGame myGame;
    
    /**
     * This constructor instantiates myGame to a new MatchingGame object.
     * @param theNewValues the values for new game
     */
    public MatchingGameGUI(final List<String> theNewValues) {
        
        super("Matching Game");
        myGame = new MatchingGame(theNewValues);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //setLayout(new GridBagLayout());
    }

    /**
     * This method starts the construction of the GUI.
     */
    public void start() {
        
        final CardPanel cardPanel = new CardPanel(myGame, this);
        final ScorePanel scorePanel = new ScorePanel(myGame, this);
        final MenuBar menuBar = new MenuBar(this);
        myGame.addObserver(cardPanel);
        myGame.addObserver(scorePanel);
        setJMenuBar(menuBar);
        /*GridBagConstraints c = new GridBagConstraints();
        
        c.gridy = 0;
        c.weightx = 200;
        c.weighty = 200;
        c.gridheight = 500;
        c.gridwidth = 1000;
        add(cardPanel, c);*/
        add(cardPanel);
        
        //c.anchor = GridBagConstraints.SOUTH;
        //c.gridy = 1;
        //c.gridwidth = 1000;
        //add(scorePanel, c);
        add(scorePanel, BorderLayout.SOUTH);
        pack();
        setResizable(true);
        setVisible(true);
        
    }
}