#pragma once

#include "dllinterface.h"
#include "guielement.h"
#include "panel.h"
#include "label.h"

class GAMEGUI_API Input : public GUIElement
{
	Panel*	m_Panel;
	Label*	m_Text;
	char	m_CursorChar;
	int		m_CursorPos;
	int		m_SelSize;
	bool	m_ShowCursor;
	bool	m_Multiline;
	float	m_ClientBorder;

protected:
	virtual ~Input(void);

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

	virtual void OnUpdate(void);
	virtual void OnKeyPress(BYTE key);

	void SetText(XString text){if(m_Text)m_Text->SetText(text);}
	XString GetText(void){return m_Text?m_Text->GetText():"";}

	void SetTextColor(D3DXCOLOR textcolor){if(m_Text)m_Text->SetColor(textcolor);}
	D3DXCOLOR GetTextColor(void){return m_Text?m_Text->GetColor():0;}

	void SetFont(Font*font){if(m_Text)m_Text->SetFont(font);}
	Font* GetFont(void){return m_Text?m_Text->GetFont():NULL;}

	void SetTextAlign(ALIGNMENT al){if(m_Text)m_Text->SetTextAlign(al);}
	ALIGNMENT SetTextAlign(void){return m_Text?m_Text->GetTextAlign():AL_LEFTCENTER;}

	void SetTexture(DXTexture*tex, const bool alphablend, const int fixedborder){if(m_Panel){m_Panel->SetTexture(tex); m_Panel->SetAlphaBlend(alphablend); m_Panel->SetFixedBorder(fixedborder);}}
	DXTexture* GetTexture(void){return m_Panel?m_Panel->GetTexture():NULL;}

	void SetCursorChar(char cursorchar){m_CursorChar = cursorchar;}
	char GetCursorChar(void){return m_CursorChar;}

	void SetCursorPos(int pos){m_CursorPos = pos;}
	int GetCursorPos(void){return m_CursorPos;}

	void SetSelSize(int size){m_SelSize = size;}
	int GetSelSize(void){return m_SelSize;}

	void SetShowCursor(bool sc){m_ShowCursor = sc;}
	bool GetShowCursor(void){return m_ShowCursor;}

	void SetMultiline(bool ml){m_Multiline = ml;}
	bool GetMultiline(void){return m_Multiline;}

	void SetClientBorder(const float border) { m_ClientBorder = border; m_Text->SetPosition(m_ClientBorder, m_ClientBorder); m_Text->SetSize(GetXl() - m_ClientBorder*2, GetYl() - m_ClientBorder*2);}
	float GetClientBorder(void) const { return m_ClientBorder; }

	//void SetFixedBorder(const int border) { m_Panel->SetFixedBorder(border); }
	//void SetBorder(float b,float tb){m_Panel->SetBorder(b,tb);}

	virtual void SetSize(const float xl, const float yl);
};
