#ifndef __WINDOWSHPP__
#define __WINDOWSHPP__

#include <windows.h>
#include <utils\utils.h>
#include <dib surface\dibsection.hpp>

class CWindow  
{
protected:
	int m_BackWidth,m_BackHeight;
	HWND m_Window;
	bool m_Scale;

public:
	CWindow (void);
	~CWindow (void);
	virtual void Create (const CString& title,int width,int height,int offw=0,int offh=0,bool scale=false);

	void Window (HWND newwnd)
	{
		m_Window = newwnd;
	}
	HWND Window (void) const
	{
		return m_Window;
	}
	bool IsValid (void) const
	{
		return m_Window != NULL;
	}

	operator HWND() const 
	{ 
		return m_Window; 
	}
	virtual LRESULT WndProc (HWND thewnd,UINT themsg,WPARAM wParam,LPARAM lParam);
	virtual void Render (HDC thedc,LPPAINTSTRUCT data = NULL) {}
	virtual void InitialUpdate(void) {};
	virtual void LButtonDown (int x,int y) {}
	virtual void RButtonDown (int x,int y) {}
	virtual void LButtonUp (int x,int y) {}
	virtual void RButtonUp (int x,int y) {}
	virtual void MouseMove (int x,int y) {}
};

class CDIBWindow : public CWindow
{
protected:
	CDIBSurface m_Background;

public:
	CDIBWindow (void) {};
	~CDIBWindow (void) {};
	virtual void Create (const CString& title,int width,int height,int offw=0,int offh=0,bool scale=false);

	bool IsValid (void) const
	{
		return (m_Background.IsValid () && CWindow::IsValid ());
	}

	CDIBSurface& GetSurface(void) 
	{ 
		return m_Background; 
	}
	virtual void Render (HDC thedc,LPPAINTSTRUCT data = NULL);
};
#if 0
class CDDWindow : public CDIBWindow
{
protected:
	CDDRenderSurface m_DirectBackground;

public:
	CDDWindow (void) {};
	~CDDWindow (void) {};
	virtual void Create (const CString& title,int width,int height,int offw=0,int offh=0,bool scale=false);

	bool IsValid (void) const
	{
		return (m_DirectBackground.IsValid () && CDIBWindow::IsValid ());
	}

	CDDRenderSurface& GetSurface (void)  
	{ 
		return m_DirectBackground; 
	}
	virtual void Render (HDC thedc,LPPAINTSTRUCT data = NULL);
};
#endif

#endif