/*
 * This source file is part of KEOS (Free 3D Engine)
 * For the latest info, see http://www.keosengine.org/
 * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
 * http://www.gnu.org/copyleft/lesser.txt.
 *
 */

#ifndef KEOS_WIN32WINDOW_H
#define KEOS_WIN32WINDOW_H

#include "KeosWin32Prerequisites.h"
#include "KeosRenderWindow.h"

namespace Keos 
{
    //-----------------------------------------------------------------------
    /** OpenGL Win32 IRenderWindow implementation. 
     */
    class CWin32Window : public IRenderWindow
    {
    public:

        /** Constructor.
         */
        CWin32Window();

        /** Destructor.
         */
        ~CWin32Window();

        /** See IRenderWindow.
         */
        void Create(const String& strName, uint nWidth, uint nHeight, uint nColourDepth, bool bFullScreen);

        /** See IRenderWindow.
         */
        void Destroy(void);

        /** See IRenderWindow.
         */
        bool IsClosed(void) const;

        /** See IRenderWindow.
         */
        void Reposition(int nLeft, int nTop);

        /** See IRenderWindow.
         */
        void Resize(uint nWidth, uint nHeight);

        /** See IRenderWindow.
         */
        void SwapBuffers(bool bWaitForVSync);

        /** Return the Win32 window handle.
         */
		HWND GetWindowHandle() const { return m_HWnd; }

        /** Return the handle of the device context object.
         */
		HDC GetHDC() const { return m_HDC; }
		
		/** Method for dealing with resize / move & 3d library.
         */
		virtual void WindowMovedOrResized(void);

		bool IsReady() const { return m_bReady; }
		void SetReady(bool bSet) { m_bReady = bSet; }
		void SetActive(bool bSet) { m_bActive = bSet; }

	protected:
		
        //! Win32 Window handle
		HWND	m_HWnd;	
        //! Handle of the device context object
		HDC		m_HDC;
        //! Handle to OpenGL rendering context
		HGLRC	m_Glrc;
        //! Is ready i.e. available for update
		bool	m_bReady;	
        //! Indicates whether the window has been closed by the user
		bool	m_bClosed;

        //int		m_nOldSwapIntervall;
        
        /** Window procedure callback.
         */
		static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    };
} // namespace Keos

#endif // KEOS_WIN32WINDOW_H
