/* * Copyright (c) 2010-2011 OTClient * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "luainterface.h" #include #include #include #include #include void LuaInterface::registerFunctions() { // UIWidget g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create); g_lua.bindClassMemberFunction("getId", &UIWidget::getId); g_lua.bindClassMemberFunction("setId", &UIWidget::setId); g_lua.bindClassMemberFunction("isEnabled", &UIWidget::isEnabled); g_lua.bindClassMemberFunction("setEnabled", &UIWidget::setEnabled); g_lua.bindClassMemberFunction("isExplicitlyVisible", &UIWidget::isExplicitlyVisible); g_lua.bindClassMemberFunction("setVisible", &UIWidget::setVisible); g_lua.bindClassMemberFunction("getWidth", &UIWidget::getWidth); g_lua.bindClassMemberFunction("setWidth", &UIWidget::setWidth); g_lua.bindClassMemberFunction("getHeight", &UIWidget::getHeight); g_lua.bindClassMemberFunction("setHeight", &UIWidget::setHeight); g_lua.bindClassMemberFunction("getParent", &UIWidget::getParent); g_lua.bindClassMemberFunction("setParent", &UIWidget::setParent); g_lua.bindClassMemberFunction("getBackgroundColor", &UIWidget::getBackgroundColor); g_lua.bindClassMemberFunction("setBackgroundColor", &UIWidget::setBackgroundColor); g_lua.bindClassMemberFunction("getForegroundColor", &UIWidget::getForegroundColor); g_lua.bindClassMemberFunction("setForegroundColor", &UIWidget::setForegroundColor); g_lua.bindClassMemberFunction("getOpacity", &UIWidget::getOpacity); g_lua.bindClassMemberFunction("setOpacity", &UIWidget::setOpacity); g_lua.bindClassMemberFunction("setStyle", &UIWidget::setStyle); g_lua.bindClassMemberFunction("getMarginTop", &UIWidget::getMarginTop); g_lua.bindClassMemberFunction("setMarginTop", &UIWidget::setMarginTop); g_lua.bindClassMemberFunction("getMarginBottom", &UIWidget::getMarginBottom); g_lua.bindClassMemberFunction("setMarginBottom", &UIWidget::setMarginBottom); g_lua.bindClassMemberFunction("getMarginLeft", &UIWidget::getMarginLeft); g_lua.bindClassMemberFunction("setMarginLeft", &UIWidget::setMarginLeft); g_lua.bindClassMemberFunction("getMarginRight", &UIWidget::getMarginRight); g_lua.bindClassMemberFunction("setMarginRight", &UIWidget::setMarginRight); g_lua.bindClassMemberFunction("isVisible", &UIWidget::isVisible); g_lua.bindClassMemberFunction("isHidden", &UIWidget::isHidden); g_lua.bindClassMemberFunction("isHovered", &UIWidget::isHovered); g_lua.bindClassMemberFunction("isFocused", &UIWidget::isFocused); g_lua.bindClassMemberFunction("isPressed", &UIWidget::isPressed); g_lua.bindClassMemberFunction("isEnabled", &UIWidget::isEnabled); g_lua.bindClassMemberFunction("isDisabled", &UIWidget::isDisabled); g_lua.bindClassMemberFunction("isActive", &UIWidget::isActive); g_lua.bindClassMemberFunction("hide", &UIWidget::hide); g_lua.bindClassMemberFunction("show", &UIWidget::show); g_lua.bindClassMemberFunction("lock", &UIWidget::lock); g_lua.bindClassMemberFunction("unlock", &UIWidget::unlock); g_lua.bindClassMemberFunction("getChildById", &UIWidget::getChildById); g_lua.bindClassMemberFunction("getChildByIndex", &UIWidget::getChildByIndex); g_lua.bindClassMemberFunction("getChildCount", &UIWidget::getChildCount); g_lua.bindClassMemberFunction("getFocusedChild", &UIWidget::getFocusedChild); g_lua.bindClassMemberFunction("insertChild", &UIWidget::insertChild); g_lua.bindClassMemberFunction("removeChild", &UIWidget::removeChild); g_lua.bindClassMemberFunction("addChild", &UIWidget::addChild); g_lua.bindClassMemberFunction("focusChild", &UIWidget::focusChild); g_lua.bindClassMemberFunction("focusNextChild", &UIWidget::focusNextChild); g_lua.bindClassMemberFunction("focusPreviousChild", &UIWidget::focusPreviousChild); g_lua.bindClassMemberFunction("lockChild", &UIWidget::lockChild); g_lua.bindClassMemberFunction("unlockChild", &UIWidget::unlockChild); g_lua.bindClassMemberFunction("updateLayout", &UIWidget::updateLayout); g_lua.bindClassMemberFunction("updateParentLayout", &UIWidget::updateParentLayout); g_lua.bindClassMemberFunction("destroy", &UIWidget::destroy); // UILabel g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create); g_lua.bindClassMemberFunction("getText", &UILabel::getText); g_lua.bindClassMemberFunction("setText", &UILabel::setText); g_lua.bindClassMemberFunction("resizeToText", &UILabel::resizeToText); // UIButton g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create); g_lua.bindClassMemberFunction("getText", &UIButton::getText); g_lua.bindClassMemberFunction("setText", &UIButton::setText); // UILineEdit g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create); g_lua.bindClassMemberFunction("getText", &UILineEdit::getText); g_lua.bindClassMemberFunction("setText", &UILineEdit::setText); g_lua.bindClassMemberFunction("clearText", &UILineEdit::clearText); // UIWindow g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create); g_lua.bindClassMemberFunction("getTitle", &UIWindow::getTitle); g_lua.bindClassMemberFunction("setTitle", &UIWindow::setTitle); // Protocol g_lua.registerClass(); // ConfigManager g_lua.registerClass(); g_lua.bindClassStaticFunction("set", std::bind(&Configs::set, &g_configs, _1, _2)); g_lua.bindClassStaticFunction("get", std::bind(&Configs::get, &g_configs, _1)); // Logger g_lua.registerClass(); g_lua.bindClassStaticFunction("log", std::bind(&Logger::log, &g_logger, _1, _2)); g_lua.bindClassStaticFunction("fireOldMessages", std::bind(&Logger::fireOldMessages, &g_logger)); g_lua.bindClassStaticFunction("setOnLog", std::bind(&Logger::setOnLog, &g_logger, _1)); // global functions g_lua.bindGlobalFunction("importFont", std::bind(&FontManager::importFont, &g_fonts, _1)); g_lua.bindGlobalFunction("importStyles", std::bind(&UIManager::importStyles, &g_ui, _1)); g_lua.bindGlobalFunction("setDefaultFont", std::bind(&FontManager::setDefaultFont, &g_fonts, _1)); g_lua.bindGlobalFunction("loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2)); g_lua.bindGlobalFunction("getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); g_lua.bindGlobalFunction("addEvent", std::bind(&EventDispatcher::addEvent, &g_dispatcher, _1, false)); g_lua.bindGlobalFunction("scheduleEvent", std::bind(&EventDispatcher::scheduleEvent, &g_dispatcher, _1, _2)); }