/// Barely started implementation for the -show option.

#include <windows.h>

#include "02SolutionWindow.h"

LRESULT CALLBACK WindowProc(HWND win, UINT message, WPARAM wParam, LPARAM lParam);

static SolutionWindow * gSolutionWindow;
	// as there is only one solution window, this is the
	// easiest way to find the SolutionWindow object from the
	// window procedure.

SolutionWindow::SolutionWindow(Board *aBoard)
:itsBoard(aBoard)
{
	gSolutionWindow = this;

	static bool classRegistered = false;
	if(!classRegistered)
	{
		WNDCLASS cls;
		cls.style = CS_HREDRAW | CS_VREDRAW;
		cls.lpfnWndProc = WindowProc;
		cls.cbClsExtra = 0;
		cls.cbWndExtra = 0;
		cls.hInstance = NULL;
		cls.hIcon = NULL;
		cls.hCursor = NULL;
		cls.hbrBackground = NULL;
		cls.lpszMenuName = NULL;
		cls.lpszClassName = "MyClass";
		RegisterClass(&cls);
	}
	window = CreateWindowEx(
		WS_EX_OVERLAPPEDWINDOW,
		"MyClass",
		"02 - Game \"15\"",
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		0,
		128,
		128,
		NULL ,
		NULL,
		NULL,
		NULL);

	ShowWindow(window,SW_NORMAL);
	UpdateWindow(window);
}

void SolutionWindow::DrawBoard(HDC hdc)
{
	RECT r;
	SetRect(&r,0,0,128,128);
	FillRect(hdc,&r,GetStockObject(WHITE_BRUSH));
}

void SolutionWindow::DrawMove(card type,int fromX,int fromY, int toX, int toY)
{
}

void SolutionWindow::DrawCard(HDC hdc,card type, int x, int y)
{
}

LRESULT CALLBACK WindowProc(HWND win, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_PAINT:	{
							PAINTSTRUCT ps;
							HDC hdc = BeginPaint(win,&ps);
							gSolutionWindow->DrawBoard(hdc);
							EndPaint(win,&ps);
						}
						break;
		case WM_DESTROY:{
							PostQuitMessage(0);
						}
						break;
	}
	return DefWindowProc(win,message,wParam,lParam);
}


