/*
 Copyright (C) 2022 Erik Ogenvik

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#include "RegisterLua.h"
#include "components/ogre/widgets/ColouredListItem.h"

using namespace Ember::OgreView::Gui;
using namespace Ember::Lua;

template<>
void registerLua<ColouredListItem>(sol::table& space) {
	auto colouredListItem = space.new_usertype<ColouredListItem>("ColouredListItem",
																 sol::base_classes, sol::bases<CEGUI::ListboxTextItem, CEGUI::ListboxItem>());
	colouredListItem["new"] = sol::factories(
			[](const char* text) { return ColouredListItem::createColouredListItem(text); },
			[](const char* text, unsigned int item_id) { return ColouredListItem::createColouredListItem(text, item_id); },
			[](const char* text, unsigned int item_id, void* item_data) { return ColouredListItem::createColouredListItem(text, item_id, item_data); });
	colouredListItem["new_ptr"] = sol::factories(
			[](const char* text) { return std::unique_ptr<CEGUI::ListboxItem>(ColouredListItem::createColouredListItem(text)); },
			[](const char* text, unsigned int item_id) { return std::unique_ptr<CEGUI::ListboxItem>(ColouredListItem::createColouredListItem(text, item_id)); },
			[](const char* text, unsigned int item_id, void* item_data) { return std::unique_ptr<CEGUI::ListboxItem>(ColouredListItem::createColouredListItem(text, item_id, item_data)); });
	colouredListItem["tag"] = &ColouredListItem::tag;

	auto colouredTreeItem = space.new_usertype<ColouredTreeItem>("ColouredTreeItem",
																 sol::base_classes, sol::bases<CEGUI::TreeItem>());
	colouredTreeItem["new"] = sol::factories(
			[](const char* text) { return ColouredTreeItem::create(text); },
			[](const char* text, unsigned int item_id) { return ColouredTreeItem::create(text, item_id); },
			[](const char* text, unsigned int item_id, void* item_data) { return ColouredTreeItem::create(text, item_id, item_data); });
	colouredTreeItem["tag"] = &ColouredTreeItem::tag;

}