#pragma once
#include "guielement.h"
#include "Button.h"
#include "Input.h"
#include "ListBox.h"

class GAMEGUI_API ComboBox : public GUIElement
{
	Input* m_pInput;
	Button* m_pButton;
	ListBox* m_pDrop;

	int m_SelectedIndex;
	
	static void OnOpenClick(GUIElement* const sender, const GUIEVENT evnt, void* pData);
	static void OnDropDownSel(GUIElement* const sender, const GUIEVENT evnt, void* pData);
		
protected:
	virtual ~ComboBox(void);

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

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

	void SetTexture(DXTexture* const input, const bool inputalphablend, const int inputborder, DXTexture* const btn, const bool btnalphablend, DXTexture* const drop, DXTexture* const dropsel, const bool dropalphablend, const int dropborder);
	
	int GetItemCount(void) const { return m_pDrop->GetItemCount(); }
	XString GetItem(const int index) const { return m_pDrop->GetItem(index); }
	void AddItem(const XString& item) { m_pDrop->AddItem(item); }
	void DeleteItem(const int index) { m_pDrop->DeleteItem(index); }

	void SetDropDownHeight(const float height) { m_pDrop->SetSize(m_pDrop->GetXl(), height); }
	float GetDropDownHeight(void) const { return m_pDrop->GetYl(); }

	void SetDropDownItemHeight(const float height) { m_pDrop->SetItemHeight(height); }

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

	void SetTextColor(const D3DXCOLOR color, const D3DXCOLOR selcolor) { m_pInput->SetTextColor(color); m_pDrop->SetTextColor(color, selcolor); }

	void SetFont(Font* const font) { m_pInput->SetFont(font); m_pDrop->SetFont(font); }

	void SetClientBorder(const float border) { m_pDrop->SetClientBorder(border); m_pInput->SetClientBorder(border); }

	void OpenDropDown(void);
};
