#pragma once

#include <map>
#include <vector>
#include "xmlfontstring.h"
#include "xmltexture.h"

using namespace std;

class CXmlBackdrop : public IXmlBase
{
public:
	CXmlBackdrop();

	virtual	bool				LoadFromDOMNode( const DOMNode* node );
public:
	CXmlInset					m_bgInsets;
	CXmlValue					m_tileSize;
	CXmlValue					m_edgeSize;
	string						m_tileFile;
	string						m_edgeFile;
	bool						m_isTile;
};

class CXmlResizeBounds : public IXmlBase
{
public:
	CXmlResizeBounds();
	virtual ~CXmlResizeBounds();

	virtual	bool				LoadFromDOMNode( const DOMNode* node );
public:	
	CXmlDimension*				m_maxBounds;
	CXmlDimension*				m_minBounds;
};

class CXmlFrame : public CXmlLayout
{
public:

	enum {
		eOn_Load					= 0,
		eOn_Update					,
		eOn_Resize					,
		eOn_Show					,
		eOn_Hide					,
		eOn_TabPressed				,
		eOn_EnterPressed			,
		eOn_EscapePressed			,
		eOn_SpacePressed			,
		eOn_ArrowUpPressed			,
		eOn_ArrowDownPressed		,
		eOn_KeyDown					,
		eOn_KeyUp					,
		eOn_Char					,		
		eOn_MouseDown				,
		eOn_MouseUp					,
		eOn_Click					,
		eOn_DoublebClick			,
		eOn_MouseWheel				,
		eOn_MouseEnter				,
		eOn_MouseLeave				,		
		eOn_DragStart				,
		eOn_DragStop				,
		eOn_ReceiveDrag				,
		eOn_ValueChanged			,
		eOn_TextChanged				,
		eOn_VerticalScroll			,
		eOn_HorizontalScroll		,
		eOn_ScrollRangeChanged		,
		eOn_Event					,
	};

	enum {
		eLayer_Background			= 0,
		eLayer_Border,
		eLayer_Artwork,
		eLayer_Overlay,
		eLayer_Highlight
	};

	enum {
		eStrata_Background			= 0,
		eStrata_Low,
		eStrata_Medium,
		eStrata_High,
		eStrata_Dialog,
		eStrata_Tooltip
	};
	
	CXmlFrame(CXmlUi* pXmlUi=NULL, CXmlLayout* pParent=NULL);
	virtual ~CXmlFrame();

	static	int					XmlValueToLayerLevel(const char* valueStr);
	static	int					XmlValueToFrameStrata(const char* valueStr);
	
	virtual	void				LoadNodeAttribute(const DOMNamedNodeMap* nodeMap);
	virtual	void				LoadNodeElement(const DOMNode* node, const char* nodeName);
	virtual	void				Inherit(CXmlLayout* pXmlLayout);	

protected:

	// layers
	virtual	void				LoadXmlLayers(const DOMNode* node);
	virtual	void				LoadXmlLayer(const DOMNode* node);

	virtual void				LoadXmlFrames(const DOMNode* node);

	// scripts
	virtual void				LoadXmlScripts(const DOMNode* node);
	virtual bool				InsertScript(int key, const XMLCh* content);
	
	virtual	void				InheritFrames(CXmlFrame* pXmlFrame);
	virtual	void				InheritLayers(CXmlFrame* pXmlFrame);

public:
	// member values
	multimap<int, CXmlLayout*>	m_layers;
	vector<CXmlFrame*>			m_frames;
	map<int, string>			m_scripts;

	CXmlResizeBounds			m_resizeBounds;
	CXmlInset					m_hitRectInsets;
	CXmlBackdrop*				m_pBackdrop;
	CXmlLayout*					m_pTitleRegion;
	float						m_alpha;
	int							m_id;
	int							m_frameStrata;
	int							m_frameLevel;
	bool						m_topLevel;
	bool						m_isEnableMouse;
	bool						m_isEnableKeyboard;
	bool						m_isMovable;
	bool						m_isResizable;	
};