//..............................................................................
//
// Ninja GUI - combo boxes
//

import "ui_ComboItem.jnc"

namespace ui {

//! \addtogroup api-ui
//! @{

//..............................................................................

opaque class ComboBox {
	bool autoget property m_isVisible;
	bool autoget property m_isEnabled;
	bool autoget property m_isEditable; // for editable combo boxes: if itemData is non-null, it's used as the actual value

	char const* bindable autoget property m_editText;
	char const* autoget property m_placeholderText;
	char const* autoget property m_toolTipText;
	uint_t autoget property m_backgroundColor;

	size_t readonly m_itemCount;
	char const* property m_itemText(size_t index);
	variant property m_itemData(size_t index);

	size_t bindable autoget property m_currentIndex;
	char const* bindable const property m_currentText;
	variant bindable property m_currentData;

	event m_onEnter();

	destruct();

	void adjustSizeToContents();

	size_t addItem(
		char const* text,
		variant data = null
	) {
		return insertItem(-1, text, data);
	}

	size_t addItemSetCurrent(
		char const* text,
		variant data = null
	) {
		return insertItemSetCurrent(-1, text, data);
	}

	size_t insertItem(
		size_t index,
		char const* text,
		variant data = null
	);

	size_t insertItemSetCurrent(
		size_t index,
		char const* text,
		variant data = null
	) {
		return m_currentIndex = insertItem(index, text, data);
	}

	bool removeItem(size_t index);

	void setItems(
		ComboItem const* itemArray,
		size_t count
	);

	void clear();

	size_t findData(variant data);
}

//..............................................................................

//! @}

} // namespace ui
