//..............................................................................
//
// Ninja UI - list widgets
//

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

namespace ui {

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

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

opaque class ListWidget: Widget {
	char const* autoget property m_placeholderText;
	bool autoget property m_isAlternatingRowColors;
	bool autoget property m_isCheckable;

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

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

	event m_onReturnPressed();
	event m_onDoubleClicked();

	event m_onItemCheckStateChanged(
		size_t index,
		bool isChecked
	);

	construct();
	destruct();

	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(
		ListItem const* itemArray,
		size_t count
	);

	void clear();

	size_t findData(variant data);
}

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

//! @}

} // namespace ui
