
#ifndef PLATFORM_WIN32_DISPLAY_H
#define PLATFORM_WIN32_DISPLAY_H

#include "Win32GLContext.h"
#include <Platform/PlatformDisplay.h>
#include <Windows.h>

class Win32Display : public PlatformDisplay
{
public :
	Win32Display();
	virtual ~Win32Display();

	virtual bool	create(DisplayDescription description);

	virtual void	destroy();

	virtual bool	isValid();

	virtual void*	getHandle() const;

	virtual void	setSize(unsigned int width, unsigned int height);

	virtual Vector2u getSize() const;

	virtual void	setPosition(unsigned int x, unsigned int y);

	virtual void	setCaption(const std::string& caption);

	virtual void setIcon(const std::string& icon);

	virtual void	showCursor(bool value);

protected :

	void registerClass();

	DWORD getWin32Flags(unsigned int flags);

	void centerWindow(int &x, int &y, int width, int height);

	void processMessage(UINT message, WPARAM wParam, LPARAM lParam);

	void processResizeMessage(const Vector2u& new_size);

	static LRESULT CALLBACK staticWndProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam);

protected :

	HWND		m_handle;

	HCURSOR		m_cursor;

	HICON		m_icon;

	// True if this window is in a resize loop.
	bool		m_inResizeModalLoop;

	// Client area size. cached here to check if a resize has been made.
	Vector2u	m_size;

	Vector2u	m_minSize;
};

#endif /* PLATFORM_WIN32_DISPLAY_H */
