package ola.jsame;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.*;
import javax.swing.*;

/**
 * Same game Core for Applet and Application
 * <P>
 * 
 * @author Owen Astrachan
 */
public class SameGameCore extends JPanel implements ISameGameView
{
    private SameGameModel myModel;
    private ButtonPanel myButtonPanel;
    
    /**
     * Create a view with a model
     * @param model is the model for this view
     */
    public SameGameCore(SameGameModel model)
    {
	setLayout(new BorderLayout());

        myModel = model;
	myButtonPanel = new ButtonPanel(myModel.getRows(),
                                        myModel.getCols(),
					myModel);
	
	add(myButtonPanel, BorderLayout.CENTER);
        myModel.addView(this); // draws board
    }

    /**
     * Required by interface, show the grid that's the model
     * @param list represents the model
     */
    public void showGrid(int[][] list)
    {
	myButtonPanel.setGrid(list);	
    }

    public void highlight(GridPoint[] list)
    {
        myButtonPanel.highlight(list);
    }
}
