diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 7a194de14..748ae5745 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -558,6 +558,8 @@ const luaL_Reg CLuaInstance::methods[] = { { "GetRevision", CLuaInstance::GetRevision }, { "PaintBox", CLuaInstance::PaintBox }, + { "paintHLine", CLuaInstance::paintHLineRel }, + { "paintVLine", CLuaInstance::paintVLineRel }, { "saveScreen", CLuaInstance::saveScreen }, { "restoreScreen", CLuaInstance::restoreScreen }, { "deleteSavedScreen", CLuaInstance::deleteSavedScreen }, @@ -783,6 +785,64 @@ int CLuaInstance::PaintBox(lua_State *L) return 0; } +int CLuaInstance::paintHLineRel(lua_State *L) +{ + int x, y, dx; + unsigned int c; + + CLuaData *W = CheckData(L, 1); + if (!W || !W->fbwin) + return 0; + x = luaL_checkint(L, 2); + dx = luaL_checkint(L, 3); + y = luaL_checkint(L, 4); + +#if HAVE_COOL_HARDWARE + c = luaL_checkunsigned(L, 5); +#else + /* luaL_checkint does not like e.g. 0xffcc0000 on powerpc (returns INT_MAX) instead */ + c = (unsigned int)luaL_checknumber(L, 5); +#endif + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (dx < 0 || x + dx > W->fbwin->dx) + dx = W->fbwin->dx - x; + checkMagicMask(c); + W->fbwin->paintHLineRel(x, dx, y, c); + return 0; +} + +int CLuaInstance::paintVLineRel(lua_State *L) +{ + int x, y, dy; + unsigned int c; + + CLuaData *W = CheckData(L, 1); + if (!W || !W->fbwin) + return 0; + x = luaL_checkint(L, 2); + y = luaL_checkint(L, 3); + dy = luaL_checkint(L, 4); + +#if HAVE_COOL_HARDWARE + c = luaL_checkunsigned(L, 5); +#else + /* luaL_checkint does not like e.g. 0xffcc0000 on powerpc (returns INT_MAX) instead */ + c = (unsigned int)luaL_checknumber(L, 5); +#endif + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (dy < 0 || y + dy > W->fbwin->dy) + dy = W->fbwin->dy - y; + checkMagicMask(c); + W->fbwin->paintVLineRel(x, y, dy, c); + return 0; +} + int CLuaInstance::PaintIcon(lua_State *L) { DBG1("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index 707850b84..2da9110cb 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -34,7 +34,7 @@ extern "C" { #include #define LUA_API_VERSION_MAJOR 1 -#define LUA_API_VERSION_MINOR 15 +#define LUA_API_VERSION_MINOR 16 typedef std::pair fontmap_pair_t; typedef std::map fontmap_t; @@ -238,6 +238,8 @@ private: static int restoreScreen(lua_State *L); static int deleteSavedScreen(lua_State *L); static int PaintBox(lua_State *L); + static int paintHLineRel(lua_State *L); + static int paintVLineRel(lua_State *L); static int PaintIcon(lua_State *L); static int RenderString(lua_State *L); static int getRenderWidth(lua_State *L);