//..............................................................................
//
// Ninja UI - combo boxes
//

import "ui_Widget.jnc"
import "ui_ListItem.jnc"

namespace ui {

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

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

typedef ListItem ComboItem;

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

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

	string_t bindable autoget property m_editText;
	string_t autoget property m_placeholderText;
	uint_t autoget property m_backgroundColor;

	size_t readonly m_itemCount;
	string_t property m_itemText(size_t index);
	variant_t property m_itemData(size_t index);
	string_t property m_itemToolTip(size_t index);

	size_t bindable autoget property m_currentIndex;
	string_t bindable const property m_currentText;
	variant_t bindable property m_currentData;

	event m_onReturnPressed();

	construct();

	construct(
		ComboItem const* itemArray,
		size_t count
	);

	destruct();

	void adjustSizeToContents();

	size_t addItem(
		string_t text,
		variant_t data = null
	) {
		return insertItem(-1, text, data);
	}

	size_t addItemSetCurrent(
		string_t text,
		variant_t data = null
	) {
		return insertItemSetCurrent(-1, text, data);
	}

	size_t insertItem(
		size_t index,
		string_t text,
		variant_t data = null
	);

	size_t insertItemSetCurrent(
		size_t index,
		string_t text,
		variant_t data = null
	) {
		return m_currentIndex = insertItem(index, text, data);
	}

	bool removeItem(size_t index);

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

	void clear();
	void selectAllEditText();

	size_t findData(variant_t data);
}

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

//! @}

} // namespace ui
