/* * Copyright (c) 2010-2012 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 #include #include #include #include #include #include #include #include #include void Application::registerLuaFunctions() { // conversion globals g_lua.bindGlobalFunction("torect", [](const std::string& v) { return Fw::fromstring(v); }); g_lua.bindGlobalFunction("topoint", [](const std::string& v) { return Fw::fromstring(v); }); g_lua.bindGlobalFunction("tocolor", [](const std::string& v) { return Fw::fromstring(v); }); g_lua.bindGlobalFunction("tosize", [](const std::string& v) { return Fw::fromstring(v); }); g_lua.bindGlobalFunction("recttostring", [](const Rect& v) { return Fw::tostring(v); }); g_lua.bindGlobalFunction("pointtostring", [](const Point& v) { return Fw::tostring(v); }); g_lua.bindGlobalFunction("colortostring", [](const Color& v) { return Fw::tostring(v); }); g_lua.bindGlobalFunction("sizetostring", [](const Size& v) { return Fw::tostring(v); }); // Event g_lua.registerClass(); g_lua.bindClassMemberFunction("isCanceled", &Event::isCanceled); g_lua.bindClassMemberFunction("isExecuted", &Event::isExecuted); // ScheduledEvent g_lua.registerClass(); // UIWidget g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIWidgetPtr(new UIWidget); }); g_lua.bindClassMemberFunction("addChild", &UIWidget::addChild); g_lua.bindClassMemberFunction("insertChild", &UIWidget::insertChild); g_lua.bindClassMemberFunction("removeChild", &UIWidget::removeChild); g_lua.bindClassMemberFunction("focusChild", &UIWidget::focusChild); g_lua.bindClassMemberFunction("focusNextChild", &UIWidget::focusNextChild); g_lua.bindClassMemberFunction("focusPreviousChild", &UIWidget::focusPreviousChild); g_lua.bindClassMemberFunction("moveChildToTop", &UIWidget::moveChildToTop); g_lua.bindClassMemberFunction("moveChildToIndex", &UIWidget::moveChildToIndex); g_lua.bindClassMemberFunction("lockChild", &UIWidget::lockChild); g_lua.bindClassMemberFunction("unlockChild", &UIWidget::unlockChild); g_lua.bindClassMemberFunction("applyStyle", &UIWidget::applyStyle); g_lua.bindClassMemberFunction("addAnchor", &UIWidget::addAnchor); g_lua.bindClassMemberFunction("fill", &UIWidget::fill); g_lua.bindClassMemberFunction("centerIn", &UIWidget::centerIn); g_lua.bindClassMemberFunction("breakAnchors", &UIWidget::breakAnchors); g_lua.bindClassMemberFunction("updateParentLayout", &UIWidget::updateParentLayout); g_lua.bindClassMemberFunction("updateLayout", &UIWidget::updateLayout); g_lua.bindClassMemberFunction("lock", &UIWidget::lock); g_lua.bindClassMemberFunction("unlock", &UIWidget::unlock); g_lua.bindClassMemberFunction("focus", &UIWidget::focus); g_lua.bindClassMemberFunction("grabMouse", &UIWidget::grabMouse); g_lua.bindClassMemberFunction("ungrabMouse", &UIWidget::ungrabMouse); g_lua.bindClassMemberFunction("grabKeyboard", &UIWidget::grabKeyboard); g_lua.bindClassMemberFunction("ungrabKeyboard", &UIWidget::ungrabKeyboard); g_lua.bindClassMemberFunction("bindRectToParent", &UIWidget::bindRectToParent); g_lua.bindClassMemberFunction("destroy", &UIWidget::destroy); g_lua.bindClassMemberFunction("setId", &UIWidget::setId); g_lua.bindClassMemberFunction("setParent", &UIWidget::setParent); g_lua.bindClassMemberFunction("setLayout", &UIWidget::setLayout); g_lua.bindClassMemberFunction("setRect", &UIWidget::setRect); g_lua.bindClassMemberFunction("setStyle", &UIWidget::setStyle); g_lua.bindClassMemberFunction("setStyleFromNode", &UIWidget::setStyleFromNode); g_lua.bindClassMemberFunction("setEnabled", &UIWidget::setEnabled); g_lua.bindClassMemberFunction("setVisible", &UIWidget::setVisible); g_lua.bindClassMemberFunction("setPressed", &UIWidget::setPressed); g_lua.bindClassMemberFunction("setOn", &UIWidget::setOn); g_lua.bindClassMemberFunction("setChecked", &UIWidget::setChecked); g_lua.bindClassMemberFunction("setFocusable", &UIWidget::setFocusable); g_lua.bindClassMemberFunction("setPhantom", &UIWidget::setPhantom); g_lua.bindClassMemberFunction("setFixedSize", &UIWidget::setFixedSize); g_lua.bindClassMemberFunction("setLastFocusReason", &UIWidget::setLastFocusReason); g_lua.bindClassMemberFunction("isVisible", &UIWidget::isVisible); g_lua.bindClassMemberFunction("isChildLocked", &UIWidget::isChildLocked); g_lua.bindClassMemberFunction("hasChild", &UIWidget::hasChild); g_lua.bindClassMemberFunction("getChildIndex", &UIWidget::getChildIndex); g_lua.bindClassMemberFunction("getChildrenRect", &UIWidget::getChildrenRect); g_lua.bindClassMemberFunction("getAnchoredLayout", &UIWidget::getAnchoredLayout); g_lua.bindClassMemberFunction("getRootParent", &UIWidget::getRootParent); g_lua.bindClassMemberFunction("getChildAfter", &UIWidget::getChildAfter); g_lua.bindClassMemberFunction("getChildBefore", &UIWidget::getChildBefore); g_lua.bindClassMemberFunction("getChildById", &UIWidget::getChildById); g_lua.bindClassMemberFunction("getChildByPos", &UIWidget::getChildByPos); g_lua.bindClassMemberFunction("getChildByIndex", &UIWidget::getChildByIndex); g_lua.bindClassMemberFunction("recursiveGetChildById", &UIWidget::recursiveGetChildById); g_lua.bindClassMemberFunction("recursiveGetChildByPos", &UIWidget::recursiveGetChildByPos); g_lua.bindClassMemberFunction("backwardsGetWidgetById", &UIWidget::backwardsGetWidgetById); g_lua.bindClassMemberFunction("asUIWidget", &UIWidget::asUIWidget); g_lua.bindClassMemberFunction("resize", &UIWidget::resize); g_lua.bindClassMemberFunction("move", &UIWidget::move); g_lua.bindClassMemberFunction("hide", &UIWidget::hide); g_lua.bindClassMemberFunction("show", &UIWidget::show); g_lua.bindClassMemberFunction("disable", &UIWidget::disable); g_lua.bindClassMemberFunction("enable", &UIWidget::enable); g_lua.bindClassMemberFunction("isActive", &UIWidget::isActive); g_lua.bindClassMemberFunction("isEnabled", &UIWidget::isEnabled); g_lua.bindClassMemberFunction("isDisabled", &UIWidget::isDisabled); g_lua.bindClassMemberFunction("isFocused", &UIWidget::isFocused); g_lua.bindClassMemberFunction("isHovered", &UIWidget::isHovered); g_lua.bindClassMemberFunction("isPressed", &UIWidget::isPressed); g_lua.bindClassMemberFunction("isFirst", &UIWidget::isFirst); g_lua.bindClassMemberFunction("isMiddle", &UIWidget::isMiddle); g_lua.bindClassMemberFunction("isLast", &UIWidget::isLast); g_lua.bindClassMemberFunction("isAlternate", &UIWidget::isAlternate); g_lua.bindClassMemberFunction("isChecked", &UIWidget::isChecked); g_lua.bindClassMemberFunction("isOn", &UIWidget::isOn); g_lua.bindClassMemberFunction("isHidden", &UIWidget::isHidden); g_lua.bindClassMemberFunction("isExplicitlyEnabled", &UIWidget::isExplicitlyEnabled); g_lua.bindClassMemberFunction("isExplicitlyVisible", &UIWidget::isExplicitlyVisible); g_lua.bindClassMemberFunction("isFocusable", &UIWidget::isFocusable); g_lua.bindClassMemberFunction("isPhantom", &UIWidget::isPhantom); g_lua.bindClassMemberFunction("isFixedSize", &UIWidget::isFixedSize); g_lua.bindClassMemberFunction("isDestroyed", &UIWidget::isDestroyed); g_lua.bindClassMemberFunction("hasChildren", &UIWidget::hasChildren); g_lua.bindClassMemberFunction("containsPoint", &UIWidget::containsPoint); g_lua.bindClassMemberFunction("getId", &UIWidget::getId); g_lua.bindClassMemberFunction("getParent", &UIWidget::getParent); g_lua.bindClassMemberFunction("getFocusedChild", &UIWidget::getFocusedChild); g_lua.bindClassMemberFunction("getChildren", &UIWidget::getChildren); g_lua.bindClassMemberFunction("getFirstChild", &UIWidget::getFirstChild); g_lua.bindClassMemberFunction("getLastChild", &UIWidget::getLastChild); g_lua.bindClassMemberFunction("getLayout", &UIWidget::getLayout); g_lua.bindClassMemberFunction("getStyle", &UIWidget::getStyle); g_lua.bindClassMemberFunction("getChildCount", &UIWidget::getChildCount); g_lua.bindClassMemberFunction("getLastFocusReason", &UIWidget::getLastFocusReason); g_lua.bindClassMemberFunction("getStyleName", &UIWidget::getStyleName); g_lua.bindClassMemberFunction("setX", &UIWidget::setX); g_lua.bindClassMemberFunction("setY", &UIWidget::setY); g_lua.bindClassMemberFunction("setWidth", &UIWidget::setWidth); g_lua.bindClassMemberFunction("setHeight", &UIWidget::setHeight); g_lua.bindClassMemberFunction("setSize", &UIWidget::setSize); g_lua.bindClassMemberFunction("setPos", &UIWidget::setPos); g_lua.bindClassMemberFunction("setColor", &UIWidget::setColor); g_lua.bindClassMemberFunction("setBackgroundColor", &UIWidget::setBackgroundColor); g_lua.bindClassMemberFunction("setBackgroundOffsetX", &UIWidget::setBackgroundOffsetX); g_lua.bindClassMemberFunction("setBackgroundOffsetY", &UIWidget::setBackgroundOffsetY); g_lua.bindClassMemberFunction("setBackgroundOffset", &UIWidget::setBackgroundOffset); g_lua.bindClassMemberFunction("setBackgroundWidth", &UIWidget::setBackgroundWidth); g_lua.bindClassMemberFunction("setBackgroundHeight", &UIWidget::setBackgroundHeight); g_lua.bindClassMemberFunction("setBackgroundSize", &UIWidget::setBackgroundSize); g_lua.bindClassMemberFunction("setBackgroundRect", &UIWidget::setBackgroundRect); g_lua.bindClassMemberFunction("setIcon", &UIWidget::setIcon); g_lua.bindClassMemberFunction("setIconColor", &UIWidget::setIconColor); g_lua.bindClassMemberFunction("setIconOffsetX", &UIWidget::setIconOffsetX); g_lua.bindClassMemberFunction("setIconOffsetY", &UIWidget::setIconOffsetY); g_lua.bindClassMemberFunction("setIconOffset", &UIWidget::setIconOffset); g_lua.bindClassMemberFunction("setIconWidth", &UIWidget::setIconWidth); g_lua.bindClassMemberFunction("setIconHeight", &UIWidget::setIconHeight); g_lua.bindClassMemberFunction("setIconSize", &UIWidget::setIconSize); g_lua.bindClassMemberFunction("setIconRect", &UIWidget::setIconRect); g_lua.bindClassMemberFunction("setBorderWidth", &UIWidget::setBorderWidth); g_lua.bindClassMemberFunction("setBorderColor", &UIWidget::setBorderColor); g_lua.bindClassMemberFunction("setMargin", &UIWidget::setMargin); g_lua.bindClassMemberFunction("setMarginHorizontal", &UIWidget::setMarginHorizontal); g_lua.bindClassMemberFunction("setMarginVertical", &UIWidget::setMarginVertical); g_lua.bindClassMemberFunction("setMarginTop", &UIWidget::setMarginTop); g_lua.bindClassMemberFunction("setMarginRight", &UIWidget::setMarginRight); g_lua.bindClassMemberFunction("setMarginBottom", &UIWidget::setMarginBottom); g_lua.bindClassMemberFunction("setMarginLeft", &UIWidget::setMarginLeft); g_lua.bindClassMemberFunction("setPadding", &UIWidget::setPadding); g_lua.bindClassMemberFunction("setPaddingHorizontal", &UIWidget::setPaddingHorizontal); g_lua.bindClassMemberFunction("setPaddingVertical", &UIWidget::setPaddingVertical); g_lua.bindClassMemberFunction("setPaddingTop", &UIWidget::setPaddingTop); g_lua.bindClassMemberFunction("setPaddingRight", &UIWidget::setPaddingRight); g_lua.bindClassMemberFunction("setPaddingBottom", &UIWidget::setPaddingBottom); g_lua.bindClassMemberFunction("setPaddingLeft", &UIWidget::setPaddingLeft); g_lua.bindClassMemberFunction("setOpacity", &UIWidget::setOpacity); g_lua.bindClassMemberFunction("getX", &UIWidget::getX); g_lua.bindClassMemberFunction("getY", &UIWidget::getY); g_lua.bindClassMemberFunction("getPos", &UIWidget::getPos); g_lua.bindClassMemberFunction("getWidth", &UIWidget::getWidth); g_lua.bindClassMemberFunction("getHeight", &UIWidget::getHeight); g_lua.bindClassMemberFunction("getSize", &UIWidget::getSize); g_lua.bindClassMemberFunction("getRect", &UIWidget::getRect); g_lua.bindClassMemberFunction("getColor", &UIWidget::getColor); g_lua.bindClassMemberFunction("getBackgroundColor", &UIWidget::getBackgroundColor); g_lua.bindClassMemberFunction("getBackgroundOffsetX", &UIWidget::getBackgroundOffsetX); g_lua.bindClassMemberFunction("getBackgroundOffsetY", &UIWidget::getBackgroundOffsetY); g_lua.bindClassMemberFunction("getBackgroundOffset", &UIWidget::getBackgroundOffset); g_lua.bindClassMemberFunction("getBackgroundWidth", &UIWidget::getBackgroundWidth); g_lua.bindClassMemberFunction("getBackgroundHeight", &UIWidget::getBackgroundHeight); g_lua.bindClassMemberFunction("getBackgroundSize", &UIWidget::getBackgroundSize); g_lua.bindClassMemberFunction("getBackgroundRect", &UIWidget::getBackgroundRect); g_lua.bindClassMemberFunction("getIconColor", &UIWidget::getIconColor); g_lua.bindClassMemberFunction("getIconOffsetX", &UIWidget::getIconOffsetX); g_lua.bindClassMemberFunction("getIconOffsetY", &UIWidget::getIconOffsetY); g_lua.bindClassMemberFunction("getIconOffset", &UIWidget::getIconOffset); g_lua.bindClassMemberFunction("getIconWidth", &UIWidget::getIconWidth); g_lua.bindClassMemberFunction("getIconHeight", &UIWidget::getIconHeight); g_lua.bindClassMemberFunction("getIconSize", &UIWidget::getIconSize); g_lua.bindClassMemberFunction("getIconRect", &UIWidget::getIconRect); g_lua.bindClassMemberFunction("getBorderTopColor", &UIWidget::getBorderTopColor); g_lua.bindClassMemberFunction("getBorderRightColor", &UIWidget::getBorderRightColor); g_lua.bindClassMemberFunction("getBorderBottomColor", &UIWidget::getBorderBottomColor); g_lua.bindClassMemberFunction("getBorderLeftColor", &UIWidget::getBorderLeftColor); g_lua.bindClassMemberFunction("getBorderTopWidth", &UIWidget::getBorderTopWidth); g_lua.bindClassMemberFunction("getBorderRightWidth", &UIWidget::getBorderRightWidth); g_lua.bindClassMemberFunction("getBorderBottomWidth", &UIWidget::getBorderBottomWidth); g_lua.bindClassMemberFunction("getBorderLeftWidth", &UIWidget::getBorderLeftWidth); g_lua.bindClassMemberFunction("getMarginTop", &UIWidget::getMarginTop); g_lua.bindClassMemberFunction("getMarginRight", &UIWidget::getMarginRight); g_lua.bindClassMemberFunction("getMarginBottom", &UIWidget::getMarginBottom); g_lua.bindClassMemberFunction("getMarginLeft", &UIWidget::getMarginLeft); g_lua.bindClassMemberFunction("getPaddingTop", &UIWidget::getPaddingTop); g_lua.bindClassMemberFunction("getPaddingRight", &UIWidget::getPaddingRight); g_lua.bindClassMemberFunction("getPaddingBottom", &UIWidget::getPaddingBottom); g_lua.bindClassMemberFunction("getPaddingLeft", &UIWidget::getPaddingLeft); g_lua.bindClassMemberFunction("getOpacity", &UIWidget::getOpacity); g_lua.bindClassMemberFunction("setImageSource", &UIWidget::setImageSource); g_lua.bindClassMemberFunction("setImageClip", &UIWidget::setImageClip); g_lua.bindClassMemberFunction("setImageOffsetX", &UIWidget::setImageOffsetX); g_lua.bindClassMemberFunction("setImageOffsetY", &UIWidget::setImageOffsetY); g_lua.bindClassMemberFunction("setImageOffset", &UIWidget::setImageOffset); g_lua.bindClassMemberFunction("setImageWidth", &UIWidget::setImageWidth); g_lua.bindClassMemberFunction("setImageHeight", &UIWidget::setImageHeight); g_lua.bindClassMemberFunction("setImageSize", &UIWidget::setImageSize); g_lua.bindClassMemberFunction("setImageRect", &UIWidget::setImageRect); g_lua.bindClassMemberFunction("setImageColor", &UIWidget::setImageColor); g_lua.bindClassMemberFunction("setImageFixedRatio", &UIWidget::setImageFixedRatio); g_lua.bindClassMemberFunction("setImageRepeated", &UIWidget::setImageRepeated); g_lua.bindClassMemberFunction("setImageSmooth", &UIWidget::setImageSmooth); g_lua.bindClassMemberFunction("setImageBorderTop", &UIWidget::setImageBorderTop); g_lua.bindClassMemberFunction("setImageBorderRight", &UIWidget::setImageBorderRight); g_lua.bindClassMemberFunction("setImageBorderBottom", &UIWidget::setImageBorderBottom); g_lua.bindClassMemberFunction("setImageBorderLeft", &UIWidget::setImageBorderLeft); g_lua.bindClassMemberFunction("setImageBorder", &UIWidget::setImageBorder); g_lua.bindClassMemberFunction("getImageClip", &UIWidget::getImageClip); g_lua.bindClassMemberFunction("getImageOffsetX", &UIWidget::getImageOffsetX); g_lua.bindClassMemberFunction("getImageOffsetY", &UIWidget::getImageOffsetY); g_lua.bindClassMemberFunction("getImageOffset", &UIWidget::getImageOffset); g_lua.bindClassMemberFunction("getImageWidth", &UIWidget::getImageWidth); g_lua.bindClassMemberFunction("getImageHeight", &UIWidget::getImageHeight); g_lua.bindClassMemberFunction("getImageSize", &UIWidget::getImageSize); g_lua.bindClassMemberFunction("getImageRect", &UIWidget::getImageRect); g_lua.bindClassMemberFunction("getImageColor", &UIWidget::getImageColor); g_lua.bindClassMemberFunction("isImageFixedRatio", &UIWidget::isImageFixedRatio); g_lua.bindClassMemberFunction("isImageSmooth", &UIWidget::isImageSmooth); g_lua.bindClassMemberFunction("getImageBorderTop", &UIWidget::getImageBorderTop); g_lua.bindClassMemberFunction("getImageBorderRight", &UIWidget::getImageBorderRight); g_lua.bindClassMemberFunction("getImageBorderBottom", &UIWidget::getImageBorderBottom); g_lua.bindClassMemberFunction("getImageBorderLeft", &UIWidget::getImageBorderLeft); g_lua.bindClassMemberFunction("resizeToText", &UIWidget::resizeToText); g_lua.bindClassMemberFunction("clearText", &UIWidget::clearText); g_lua.bindClassMemberFunction("wrapText", &UIWidget::wrapText); g_lua.bindClassMemberFunction("setText", &UIWidget::setText); g_lua.bindClassMemberFunction("setTextAlign", &UIWidget::setTextAlign); g_lua.bindClassMemberFunction("setTextOffset", &UIWidget::setTextOffset); g_lua.bindClassMemberFunction("setFont", &UIWidget::setFont); g_lua.bindClassMemberFunction("getText", &UIWidget::getText); g_lua.bindClassMemberFunction("getTextAlign", &UIWidget::getTextAlign); g_lua.bindClassMemberFunction("getTextOffset", &UIWidget::getTextOffset); g_lua.bindClassMemberFunction("getFont", &UIWidget::getFont); g_lua.bindClassMemberFunction("getTextSize", &UIWidget::getTextSize); // UILayout g_lua.registerClass(); g_lua.bindClassMemberFunction("update", &UILayout::update); g_lua.bindClassMemberFunction("updateLater", &UILayout::updateLater); g_lua.bindClassMemberFunction("applyStyle", &UILayout::applyStyle); g_lua.bindClassMemberFunction("addWidget", &UILayout::addWidget); g_lua.bindClassMemberFunction("removeWidget", &UILayout::removeWidget); g_lua.bindClassMemberFunction("disableUpdates", &UILayout::disableUpdates); g_lua.bindClassMemberFunction("enableUpdates", &UILayout::enableUpdates); g_lua.bindClassMemberFunction("setParent", &UILayout::setParent); g_lua.bindClassMemberFunction("getParentWidget", &UILayout::getParentWidget); g_lua.bindClassMemberFunction("isUpdateDisabled", &UILayout::isUpdateDisabled); g_lua.bindClassMemberFunction("isUpdating", &UILayout::isUpdating); g_lua.bindClassMemberFunction("asUILayout", &UILayout::asUILayout); g_lua.bindClassMemberFunction("asUIAnchorLayout", &UILayout::asUIAnchorLayout); g_lua.bindClassMemberFunction("asUIBoxLayout", &UILayout::asUIBoxLayout); g_lua.bindClassMemberFunction("asUIHorizontalLayout", &UILayout::asUIHorizontalLayout); g_lua.bindClassMemberFunction("asUIVerticalLayout", &UILayout::asUIVerticalLayout); g_lua.bindClassMemberFunction("asUIGridLayout", &UILayout::asUIGridLayout); // UIBoxLayout g_lua.registerClass(); g_lua.bindClassMemberFunction("setSpacing", &UIBoxLayout::setSpacing); g_lua.bindClassMemberFunction("setFitChildren", &UIBoxLayout::setFitChildren); // UIVerticalLayout g_lua.registerClass(); g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIVerticalLayoutPtr(new UIVerticalLayout(parent)); } ); g_lua.bindClassMemberFunction("setAlignBottom", &UIVerticalLayout::setAlignBottom); // UIHorizontalLayout g_lua.registerClass(); g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIHorizontalLayoutPtr(new UIHorizontalLayout(parent)); } ); g_lua.bindClassMemberFunction("setAlignRight", &UIHorizontalLayout::setAlignRight); // UIGridLayout g_lua.registerClass(); g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIGridLayoutPtr(new UIGridLayout(parent)); }); g_lua.bindClassMemberFunction("setCellSize", &UIGridLayout::setCellSize); g_lua.bindClassMemberFunction("setCellWidth", &UIGridLayout::setCellWidth); g_lua.bindClassMemberFunction("setCellHeight", &UIGridLayout::setCellHeight); g_lua.bindClassMemberFunction("setCellSpacing", &UIGridLayout::setCellSpacing); g_lua.bindClassMemberFunction("setNumColumns", &UIGridLayout::setNumColumns); g_lua.bindClassMemberFunction("setNumLines", &UIGridLayout::setNumLines); g_lua.bindClassMemberFunction("asUIGridLayout", &UIGridLayout::asUIGridLayout); // UIAnchorLayout g_lua.registerClass(); g_lua.bindClassStaticFunction("create", [](UIWidgetPtr parent){ return UIAnchorLayoutPtr(new UIAnchorLayout(parent)); } ); g_lua.bindClassMemberFunction("removeAnchors", &UIAnchorLayout::removeAnchors); g_lua.bindClassMemberFunction("centerIn", &UIAnchorLayout::centerIn); g_lua.bindClassMemberFunction("fill", &UIAnchorLayout::fill); // UILineEdit g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UILineEditPtr(new UILineEdit); } ); g_lua.bindClassMemberFunction("setTextHorizontalMargin", &UILineEdit::setTextHorizontalMargin); g_lua.bindClassMemberFunction("setCursorPos", &UILineEdit::setCursorPos); g_lua.bindClassMemberFunction("setCursorEnabled", &UILineEdit::setCursorEnabled); g_lua.bindClassMemberFunction("setTextHidden", &UILineEdit::setTextHidden); g_lua.bindClassMemberFunction("setAlwaysActive", &UILineEdit::setAlwaysActive); g_lua.bindClassMemberFunction("moveCursor", &UILineEdit::moveCursor); g_lua.bindClassMemberFunction("appendText", &UILineEdit::appendText); g_lua.bindClassMemberFunction("removeCharacter", &UILineEdit::removeCharacter); g_lua.bindClassMemberFunction("getDisplayedText", &UILineEdit::getDisplayedText); g_lua.bindClassMemberFunction("getTextPos", &UILineEdit::getTextPos); g_lua.bindClassMemberFunction("getTextHorizontalMargin", &UILineEdit::getTextHorizontalMargin); g_lua.bindClassMemberFunction("getCursorPos", &UILineEdit::getCursorPos); g_lua.bindClassMemberFunction("isCursorEnabled", &UILineEdit::isCursorEnabled); g_lua.bindClassMemberFunction("isAlwaysActive", &UILineEdit::isAlwaysActive); g_lua.bindClassMemberFunction("isTextHidden", &UILineEdit::isTextHidden); // UIFrameCounter g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIFrameCounterPtr(new UIFrameCounter); } ); g_lua.bindClassMemberFunction("getFrameCount", &UIFrameCounter::getFrameCount); // OutputMessage g_lua.registerClass(); g_lua.bindClassStaticFunction("new", []{ return OutputMessagePtr(new OutputMessage); }); g_lua.bindClassMemberFunction("reset", &OutputMessage::reset); g_lua.bindClassMemberFunction("addU8", &OutputMessage::addU8); g_lua.bindClassMemberFunction("addU16", &OutputMessage::addU16); g_lua.bindClassMemberFunction("addU32", &OutputMessage::addU32); g_lua.bindClassMemberFunction("addU64", &OutputMessage::addU64); g_lua.bindClassMemberFunction("addString", (void(OutputMessage::*)(const std::string&))&OutputMessage::addString); // Protocol g_lua.registerClass(); g_lua.bindClassStaticFunction("send", [](const ProtocolPtr proto, OutputMessagePtr msg) { proto->send(*msg.get()); }); // Application g_lua.registerStaticClass("g_app"); g_lua.bindClassStaticFunction("g_app", "exit", std::bind(&Application::exit, g_app)); // ConfigManager g_lua.registerStaticClass("g_configs"); g_lua.bindClassStaticFunction("g_configs", "set", std::bind(&ConfigManager::set, &g_configs, _1, _2)); g_lua.bindClassStaticFunction("g_configs", "setList", std::bind(&ConfigManager::setList, &g_configs, _1, _2)); g_lua.bindClassStaticFunction("g_configs", "get", std::bind(&ConfigManager::get, &g_configs, _1)); g_lua.bindClassStaticFunction("g_configs", "getList", std::bind(&ConfigManager::getList, &g_configs, _1)); g_lua.bindClassStaticFunction("g_configs", "exists", std::bind(&ConfigManager::exists, &g_configs, _1)); g_lua.bindClassStaticFunction("g_configs", "remove", std::bind(&ConfigManager::remove, &g_configs, _1)); // PlatformWindow g_lua.registerStaticClass("g_window"); g_lua.bindClassStaticFunction("g_window", "move", std::bind(&PlatformWindow::move, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "resize", std::bind(&PlatformWindow::resize, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "show", std::bind(&PlatformWindow::show, &g_window)); g_lua.bindClassStaticFunction("g_window", "hide", std::bind(&PlatformWindow::hide, &g_window)); g_lua.bindClassStaticFunction("g_window", "maximize", std::bind(&PlatformWindow::maximize, &g_window)); g_lua.bindClassStaticFunction("g_window", "restoreMouseCursor", std::bind(&PlatformWindow::restoreMouseCursor, &g_window)); g_lua.bindClassStaticFunction("g_window", "showMouse", std::bind(&PlatformWindow::showMouse, &g_window)); g_lua.bindClassStaticFunction("g_window", "hideMouse", std::bind(&PlatformWindow::hideMouse, &g_window)); g_lua.bindClassStaticFunction("g_window", "setTitle", std::bind(&PlatformWindow::setTitle, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setMouseCursor", std::bind(&PlatformWindow::setMouseCursor, &g_window, _1, _2)); g_lua.bindClassStaticFunction("g_window", "setMinimumSize", std::bind(&PlatformWindow::setMinimumSize, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setFullscreen", std::bind(&PlatformWindow::setFullscreen, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setVerticalSync", std::bind(&PlatformWindow::setVerticalSync, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setIcon", std::bind(&PlatformWindow::setIcon, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "setClipboardText", std::bind(&PlatformWindow::setClipboardText, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "getDisplaySize", std::bind(&PlatformWindow::getDisplaySize, &g_window)); g_lua.bindClassStaticFunction("g_window", "getClipboardText", std::bind(&PlatformWindow::getClipboardText, &g_window)); g_lua.bindClassStaticFunction("g_window", "getPlatformType", std::bind(&PlatformWindow::getPlatformType, &g_window)); g_lua.bindClassStaticFunction("g_window", "getDisplayWidth", std::bind(&PlatformWindow::getDisplayWidth, &g_window)); g_lua.bindClassStaticFunction("g_window", "getDisplayHeight", std::bind(&PlatformWindow::getDisplayHeight, &g_window)); g_lua.bindClassStaticFunction("g_window", "getUnmaximizedSize", std::bind(&PlatformWindow::getUnmaximizedSize, &g_window)); g_lua.bindClassStaticFunction("g_window", "getSize", std::bind(&PlatformWindow::getSize, &g_window)); g_lua.bindClassStaticFunction("g_window", "getWidth", std::bind(&PlatformWindow::getWidth, &g_window)); g_lua.bindClassStaticFunction("g_window", "getHeight", std::bind(&PlatformWindow::getHeight, &g_window)); g_lua.bindClassStaticFunction("g_window", "getUnmaximizedPos", std::bind(&PlatformWindow::getUnmaximizedPos, &g_window)); g_lua.bindClassStaticFunction("g_window", "getPos", std::bind(&PlatformWindow::getPos, &g_window)); g_lua.bindClassStaticFunction("g_window", "getX", std::bind(&PlatformWindow::getX, &g_window)); g_lua.bindClassStaticFunction("g_window", "getY", std::bind(&PlatformWindow::getY, &g_window)); g_lua.bindClassStaticFunction("g_window", "getMousePos", std::bind(&PlatformWindow::getMousePos, &g_window)); g_lua.bindClassStaticFunction("g_window", "getKeyboardModifiers", std::bind(&PlatformWindow::getKeyboardModifiers, &g_window)); g_lua.bindClassStaticFunction("g_window", "isKeyPressed", std::bind(&PlatformWindow::isKeyPressed, &g_window, _1)); g_lua.bindClassStaticFunction("g_window", "isVisible", std::bind(&PlatformWindow::isVisible, &g_window)); g_lua.bindClassStaticFunction("g_window", "isFullscreen", std::bind(&PlatformWindow::isFullscreen, &g_window)); g_lua.bindClassStaticFunction("g_window", "isMaximized", std::bind(&PlatformWindow::isMaximized, &g_window)); g_lua.bindClassStaticFunction("g_window", "hasFocus", std::bind(&PlatformWindow::hasFocus, &g_window)); // 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)); // Lua g_lua.registerStaticClass("g_lua"); g_lua.bindClassStaticFunction("g_lua", "runScript", std::bind(&LuaInterface::runScript, &g_lua, _1)); // UI g_lua.registerStaticClass("g_ui"); g_lua.bindClassStaticFunction("g_ui", "importStyle", std::bind(&UIManager::importStyle, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "getStyle", std::bind(&UIManager::getStyle, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "getStyleClass", std::bind(&UIManager::getStyleClass, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "loadUI", std::bind(&UIManager::loadUI, &g_ui, _1, _2)); g_lua.bindClassStaticFunction("g_ui", "getRootWidget", std::bind(&UIManager::getRootWidget, &g_ui)); g_lua.bindClassStaticFunction("g_ui", "getDraggingWidget", std::bind(&UIManager::getDraggingWidget, &g_ui)); g_lua.bindClassStaticFunction("g_ui", "setDebugBoxesDrawing", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1)); g_lua.bindClassStaticFunction("g_ui", "isDrawingDebugBoxes", std::bind(&UIManager::setDebugBoxesDrawing, &g_ui, _1)); // FontManager g_lua.registerStaticClass("g_fonts"); g_lua.bindClassStaticFunction("g_fonts", "importFont", std::bind(&FontManager::importFont, &g_fonts, _1)); g_lua.bindClassStaticFunction("g_fonts", "fontExists", std::bind(&FontManager::fontExists, &g_fonts, _1)); g_lua.bindClassStaticFunction("g_fonts", "setDefaultFont", std::bind(&FontManager::setDefaultFont, &g_fonts, _1)); // EventDispatcher g_lua.registerStaticClass("g_dispatcher"); g_lua.bindClassStaticFunction("g_dispatcher", "addEvent", std::bind(&EventDispatcher::addEvent, &g_dispatcher, _1, _2)); g_lua.bindClassStaticFunction("g_dispatcher", "scheduleEvent", std::bind(&EventDispatcher::scheduleEvent, &g_dispatcher, _1, _2)); }