#pragma once
#include "guielement.h"
#include "Label.h"
#include "Panel.h"

class GAMEGUI_API ListBox : public GUIElement
{
	Panel*	m_pBox;
	Image*	m_pSel;

	LList<Label> m_lItems;

	float m_ItemHeight;

	int m_SelectionIndex;
	bool m_bHightlightMouseItem;

	Font*	m_pFont;
	D3DXCOLOR	m_TextColor;
	int			m_TextSelColor;
	ALIGNMENT m_TextAlign;
	
	float	m_ClientBorder;

	//TODO: scrollbar

	static void OnItemClick(GUIElement* const sender, const GUIEVENT evnt, void* pData);

protected:
	virtual ~ListBox(void);

public:
	ListBox(MenuManager* const pManager, const DWORD id);

	virtual void OnUpdate(void);
	virtual void SetSize(const float xl, const float yl);
	
	void SetTexture(DXTexture* const box, DXTexture* const sel, const bool alphablend, const int fixedborder);
	
	int GetItemCount(void) const { return m_lItems.GetElementCount(); }
	XString GetItem(const int index) { return m_lItems[index]->GetInfo()->GetText(); }
	void AddItem(const XString& item);
	void DeleteItem(const int index);

	void SetItemHeight(const float height);
	float GetItemHeight(void) const { return m_ItemHeight; }

	void SetSelectedIndex(const int index);
	int GetSelectedIndex(void) const { return m_SelectionIndex; }

	void SetFont(Font* const pFont);
	Font* GetFont(void) const { return m_pFont; }

	void SetClientBorder(const float border);
	void SetTextColor(const D3DXCOLOR color, const D3DXCOLOR selcolor);
	void SetTextAlign(const ALIGNMENT align);

	void SetHightlightMouseItemEnable(const bool hl) { m_bHightlightMouseItem = hl; }
};
