/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__NWINDOW__
#define	__NWINDOW__


		#include "ui/widget.h"
		#include "ui/ui_sprite.h"
		#include "ui/ui_window_skin.h"


namespace GS {
	struct RenderResourceFactory;

	namespace S2D {

/*!
	@short	Window class.
	@author	Emmanuel Julien (ejulien@nworks.fr)
*/
class	Window : public Sprite
{
public:

enum
{
	FlagNoDecoration	=	(1 << 0),
	FlagNoTitleBar		=	(1 << 1),

	// Non-serializable
	FlagCacheDirty		=	(1 << 2),
	FlagRenderDirty		=	(1 << 3)
};

protected:

		sWindowSkin		skin;
		sPicture		cache;

		sWidget			title_widget;
		sWidget			base_widget;

		BitField		window_flags;

public:

		Picture			*GetCache() const { return cache; }

		void			Invalidate();

		void			SetSkin(WindowSkin *);
		void			ComposeSkin();
		void			Compose();

		void			SetSize(float w, float h);

		sPicture		background_picture;
		Color			background_color;

		Widget			*GetWidget(uint id);

		Widget			*GetTitleWidget() const;
		void			SetTitleWidget(Widget *);
		Widget			*GetBaseWidget() const;
		void			SetBaseWidget(Widget *);

		iRect			GetRect() const;
		iRect			GetClientRect() const;

virtual	void			RenderSetup(Core::ResourceFactories * = 0);
virtual	void			Render(Renderer &, GPU::TriangleBatch * = 0);

virtual	bool			FromMetaTag(NML::Tag &);
virtual	NML::Tag		*AsMetaTag() const;

		Window();
};

	} // S2D
} // GS


#endif	// __NWINDOW__
