#pragma once

#include "dllinterface.h"
#include "guielement.h"
#include "..\Utilities\XString.h"
#include "..\dxfunctions\dllinterface.h"
#include "..\dxfunctions\dxtexture.h"
#include "..\dxfunctions\font.h"

//-----------------------------------------------------------------------------
//Name: Label
//Desc: A simple text label
//		To have best performance you have to set the static member correctly
//-----------------------------------------------------------------------------

class GAMEGUI_API Label : public GUIElement
{
	//the text to bee drawn
	XString		m_Text;
	DXVector2	m_TextSize;

	ALIGNMENT   m_TextAlign;

	//determine if the text is staic so that it is rendered in a texture which 
	//would has the best performance at the cost of some memory if the text doesnt 
	//change frequently otherwise each character is drawn seperate by DXFont
	bool		m_Static;

	//texture that contains the whole text if required
	DXTexture*	m_Texture;

	//the color of the text
	D3DXCOLOR	m_Color;

	//pointer to a fontclass that defines the look of the text
	Font*		m_Font;

	bool m_TextureOutdated;

protected:
	
	~Label(void);

public:
	Label(MenuManager*manager,DWORD id);

	bool GetStatic(void){return m_Static;}
	void SetStatic(bool _static) {} //TODO

	XString GetText(void){return m_Text;}
	void SetText(const XString &text);

	void SetFont(Font*font);
	Font*GetFont(void){return m_Font;}

	void SetTextAlign(ALIGNMENT al){m_TextAlign = al;}
	ALIGNMENT GetTextAlign(void){return m_TextAlign;}

	void SetColor(D3DXCOLOR color){m_Color = color;}
	D3DXCOLOR GetColor(void){return m_Color;}

	virtual void OnUpdate(void);
	virtual void OnDraw(void);

	//functions to manage the texture: these are public so that you can self determin to 
	//build the texture, maybe you want prepare the texture for render manually so there is 
	//no lag when first drawcall of this text comes (only relevant if label is static)
	//draw the text in the texture
	void BuildTexture(void);
};
