diff --git a/src/gui/lua/Makefile.am b/src/gui/lua/Makefile.am
index d0f445f28..78ac4bfd6 100644
--- a/src/gui/lua/Makefile.am
+++ b/src/gui/lua/Makefile.am
@@ -31,6 +31,10 @@ noinst_LIBRARIES = libneutrino_gui_lua.a
libneutrino_gui_lua_a_SOURCES = \
luainstance_helpers.cpp \
luainstance.cpp \
+ lua_cc_picture.cpp \
+ lua_cc_signalbox.cpp \
+ lua_cc_text.cpp \
+ lua_cc_window.cpp \
lua_configfile.cpp \
lua_menue.cpp \
lua_video.cpp
diff --git a/src/gui/lua/lua_cc_picture.cpp b/src/gui/lua/lua_cc_picture.cpp
new file mode 100644
index 000000000..21ebed5e3
--- /dev/null
+++ b/src/gui/lua/lua_cc_picture.cpp
@@ -0,0 +1,203 @@
+/*
+ * lua components picture
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Thilo Graf (dbt)
+ * (C) 2015 Jacek Jendrzej (SatBaby)
+ *
+ * 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, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+#include "luainstance.h"
+#include "lua_cc_window.h"
+#include "lua_cc_picture.h"
+
+CLuaInstCCPicture* CLuaInstCCPicture::getInstance()
+{
+ static CLuaInstCCPicture* LuaInstCCPicture = NULL;
+
+ if(!LuaInstCCPicture)
+ LuaInstCCPicture = new CLuaInstCCPicture();
+ return LuaInstCCPicture;
+}
+
+CLuaCCPicture *CLuaInstCCPicture::CCPictureCheck(lua_State *L, int n)
+{
+ return *(CLuaCCPicture **) luaL_checkudata(L, n, "cpicture");
+}
+
+void CLuaInstCCPicture::CCPictureRegister(lua_State *L)
+{
+ luaL_Reg meth[] = {
+ { "new", CLuaInstCCPicture::CCPictureNew },
+ { "paint", CLuaInstCCPicture::CCPicturePaint },
+ { "hide", CLuaInstCCPicture::CCPictureHide },
+ { "setPicture", CLuaInstCCPicture::CCPictureSetPicture },
+ { "setCenterPos", CLuaInstCCPicture::CCPictureSetCenterPos },
+ { "__gc", CLuaInstCCPicture::CCPictureDelete },
+ { NULL, NULL }
+ };
+
+ luaL_newmetatable(L, "cpicture");
+ luaL_setfuncs(L, meth, 0);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -1, "__index");
+ lua_setglobal(L, "cpicture");
+}
+
+int CLuaInstCCPicture::CCPictureNew(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+
+ CLuaCCWindow* parent = NULL;
+ lua_Integer x=10, y=10, dx=100, dy=100;
+ std::string image_name = "";
+ lua_Integer alignment = 0;
+ lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
+ lua_Unsigned color_background = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
+ lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
+
+ /*
+ transparency = CFrameBuffer::TM_BLACK (2): Transparency when black content ('pseudo' transparency)
+ transparency = CFrameBuffer::TM_NONE (1): No 'pseudo' transparency
+ */
+ lua_Integer transparency = CFrameBuffer::TM_NONE;
+
+ tableLookup(L, "parent", (void**)&parent);
+ tableLookup(L, "x", x);
+ tableLookup(L, "y", y);
+ tableLookup(L, "dx", dx);
+ tableLookup(L, "dy", dy);
+ tableLookup(L, "image", image_name);
+ tableLookup(L, "alignment", alignment); //invalid argumet, for compatibility
+ if (alignment)
+ dprintf(DEBUG_NORMAL, "[CLuaInstance][%s - %d] invalid argument: 'alignment' has no effect!\n", __func__, __LINE__);
+
+ bool has_shadow = false;
+ if (!tableLookup(L, "has_shadow", has_shadow)) {
+ std::string tmp1 = "false";
+ if (tableLookup(L, "has_shadow", tmp1))
+ paramBoolDeprecated(L, tmp1.c_str());
+ has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
+ }
+ tableLookup(L, "color_frame", color_frame);
+ tableLookup(L, "color_background", color_background);
+ tableLookup(L, "color_shadow", color_shadow);
+ tableLookup(L, "transparency", transparency);
+
+ checkMagicMask(color_frame);
+ checkMagicMask(color_background);
+ checkMagicMask(color_shadow);
+
+ CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
+
+ CLuaCCPicture **udata = (CLuaCCPicture **) lua_newuserdata(L, sizeof(CLuaCCPicture *));
+ *udata = new CLuaCCPicture();
+ if (dx == 0 && dy == 0) /* NO_SCALE */
+ (*udata)->cp = new CComponentsPicture(x, y, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
+ else
+ (*udata)->cp = new CComponentsPicture(x, y, dx, dy, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
+ (*udata)->parent = pw;
+ luaL_getmetatable(L, "cpicture");
+ lua_setmetatable(L, -2);
+ return 1;
+}
+
+int CLuaInstCCPicture::CCPicturePaint(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCPicture *m = CCPictureCheck(L, 1);
+ if (!m) return 0;
+
+ bool do_save_bg = true;
+ if (!tableLookup(L, "do_save_bg", do_save_bg)) {
+ std::string tmp = "true";
+ if (tableLookup(L, "do_save_bg", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ m->cp->paint(do_save_bg);
+ return 0;
+}
+
+int CLuaInstCCPicture::CCPictureHide(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCPicture *m = CCPictureCheck(L, 1);
+ if (!m) return 0;
+
+ bool no_restore = false;
+ if (!tableLookup(L, "no_restore", no_restore)) {
+ std::string tmp = "false";
+ if (tableLookup(L, "no_restore", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ if (m->parent) {
+ m->cp->setPicture("");
+ m->cp->paint();
+ } else
+ m->cp->hide(no_restore);
+ return 0;
+}
+
+int CLuaInstCCPicture::CCPictureSetPicture(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCPicture *m = CCPictureCheck(L, 1);
+ if (!m) return 0;
+
+ std::string image_name = "";
+ tableLookup(L, "image", image_name);
+
+ m->cp->setPicture(image_name);
+ return 0;
+}
+
+int CLuaInstCCPicture::CCPictureSetCenterPos(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCPicture *m = CCPictureCheck(L, 1);
+ if (!m) return 0;
+ lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
+ tableLookup(L, "along_mode", tmp_along_mode);
+
+ if (tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
+ along_mode=tmp_along_mode;
+
+ m->cp->setCenterPos(along_mode);
+ return 0;
+}
+
+int CLuaInstCCPicture::CCPictureDelete(lua_State *L)
+{
+ LUA_DEBUG("CLuaInstCCPicture::%s %d\n", __func__, lua_gettop(L));
+ CLuaCCPicture *m = CCPictureCheck(L, 1);
+ if (!m) return 0;
+
+ delete m;
+ return 0;
+}
diff --git a/src/gui/lua/lua_cc_picture.h b/src/gui/lua/lua_cc_picture.h
new file mode 100644
index 000000000..2fb7c3e14
--- /dev/null
+++ b/src/gui/lua/lua_cc_picture.h
@@ -0,0 +1,52 @@
+/*
+ * lua components picture
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Thilo Graf (dbt)
+ * (C) 2015 Jacek Jendrzej (SatBaby)
+ *
+ * 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, see .
+ */
+
+#ifndef _LUACCPICTURE_H
+#define _LUACCPICTURE_H
+
+class CLuaCCPicture
+{
+ public:
+ CComponentsPicture *cp;
+ CComponentsForm *parent;
+ CLuaCCPicture() { cp = NULL; parent = NULL; }
+ ~CLuaCCPicture() { if (parent == NULL) delete cp; }
+};
+
+class CLuaInstCCPicture
+{
+ public:
+ CLuaInstCCPicture() {};
+ ~CLuaInstCCPicture() {};
+ static CLuaInstCCPicture* getInstance();
+ static void CCPictureRegister(lua_State *L);
+
+ private:
+ static CLuaCCPicture *CCPictureCheck(lua_State *L, int n);
+ static int CCPictureNew(lua_State *L);
+ static int CCPicturePaint(lua_State *L);
+ static int CCPictureHide(lua_State *L);
+ static int CCPictureSetPicture(lua_State *L);
+ static int CCPictureSetCenterPos(lua_State *L);
+ static int CCPictureDelete(lua_State *L);
+};
+
+#endif //_LUACCPICTURE_H
diff --git a/src/gui/lua/lua_cc_signalbox.cpp b/src/gui/lua/lua_cc_signalbox.cpp
new file mode 100644
index 000000000..084e702cc
--- /dev/null
+++ b/src/gui/lua/lua_cc_signalbox.cpp
@@ -0,0 +1,132 @@
+/*
+ * lua components signalbox
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Sven Hoefer (svenhoefer)
+ *
+ * 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, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+#include "luainstance.h"
+#include "lua_cc_window.h"
+#include "lua_cc_signalbox.h"
+
+CLuaInstCCSignalbox* CLuaInstCCSignalbox::getInstance()
+{
+ static CLuaInstCCSignalbox* LuaInstCCSignalbox = NULL;
+
+ if(!LuaInstCCSignalbox)
+ LuaInstCCSignalbox = new CLuaInstCCSignalbox();
+ return LuaInstCCSignalbox;
+}
+
+CLuaCCSignalBox *CLuaInstCCSignalbox::CCSignalBoxCheck(lua_State *L, int n)
+{
+ return *(CLuaCCSignalBox **) luaL_checkudata(L, n, "signalbox");
+}
+
+void CLuaInstCCSignalbox::CCSignalBoxRegister(lua_State *L)
+{
+ luaL_Reg meth[] = {
+ { "new", CLuaInstCCSignalbox::CCSignalBoxNew },
+ { "paint", CLuaInstCCSignalbox::CCSignalBoxPaint },
+ { "setCenterPos", CLuaInstCCSignalbox::CCSignalBoxSetCenterPos },
+ { "__gc", CLuaInstCCSignalbox::CCSignalBoxDelete },
+ { NULL, NULL }
+ };
+
+ luaL_newmetatable(L, "signalbox");
+ luaL_setfuncs(L, meth, 0);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -1, "__index");
+ lua_setglobal(L, "signalbox");
+}
+
+int CLuaInstCCSignalbox::CCSignalBoxNew(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+
+ lua_Integer x = 110, y = 150, dx = 430, dy = 150;
+ lua_Integer vertical = true;
+ CLuaCCWindow* parent = NULL;
+ tableLookup(L, "x", x);
+ tableLookup(L, "y", y);
+ tableLookup(L, "dx", dx);
+ tableLookup(L, "dy", dy);
+ tableLookup(L, "vertical", vertical);
+ tableLookup(L, "parent", (void**)&parent);
+
+ CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
+ CLuaCCSignalBox **udata = (CLuaCCSignalBox **) lua_newuserdata(L, sizeof(CLuaCCSignalBox *));
+ *udata = new CLuaCCSignalBox();
+ (*udata)->s = new CSignalBox(x, y, dx, dy, NULL, (vertical!=0)?true:false, pw);
+ (*udata)->parent = pw;
+ luaL_getmetatable(L, "signalbox");
+ lua_setmetatable(L, -2);
+ return 1;
+}
+
+int CLuaInstCCSignalbox::CCSignalBoxPaint(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCSignalBox *m = CCSignalBoxCheck(L, 1);
+ if (!m) return 0;
+
+ bool do_save_bg = true;
+ if (!tableLookup(L, "do_save_bg", do_save_bg)) {
+ std::string tmp = "true";
+ if (tableLookup(L, "do_save_bg", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ m->s->paint(do_save_bg);
+ return 0;
+}
+
+int CLuaInstCCSignalbox::CCSignalBoxSetCenterPos(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCSignalBox *m = CCSignalBoxCheck(L, 1);
+ if (!m) return 0;
+ lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
+ tableLookup(L, "along_mode", tmp_along_mode);
+
+ if (tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
+ along_mode=tmp_along_mode;
+
+ m->s->setCenterPos(along_mode);
+ return 0;
+}
+
+int CLuaInstCCSignalbox::CCSignalBoxDelete(lua_State *L)
+{
+ CLuaCCSignalBox *m = CCSignalBoxCheck(L, 1);
+ if (!m)
+ return 0;
+
+ delete m;
+ return 0;
+}
diff --git a/src/gui/lua/lua_cc_signalbox.h b/src/gui/lua/lua_cc_signalbox.h
new file mode 100644
index 000000000..2fa776e1d
--- /dev/null
+++ b/src/gui/lua/lua_cc_signalbox.h
@@ -0,0 +1,49 @@
+/*
+ * lua components signalbox
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Sven Hoefer (svenhoefer)
+ *
+ * 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, see .
+ */
+
+#ifndef _LUACCSIGNALBOX_H
+#define _LUACCSIGNALBOX_H
+
+class CLuaCCSignalBox
+{
+ public:
+ CSignalBox *s;
+ CComponentsForm *parent;
+ CLuaCCSignalBox() { s = NULL; parent = NULL;}
+ ~CLuaCCSignalBox() { if (parent == NULL) delete s; }
+};
+
+class CLuaInstCCSignalbox
+{
+ public:
+ CLuaInstCCSignalbox() {};
+ ~CLuaInstCCSignalbox() {};
+ static CLuaInstCCSignalbox* getInstance();
+ static void CCSignalBoxRegister(lua_State *L);
+
+ private:
+ static CLuaCCSignalBox *CCSignalBoxCheck(lua_State *L, int n);
+ static int CCSignalBoxNew(lua_State *L);
+ static int CCSignalBoxPaint(lua_State *L);
+ static int CCSignalBoxSetCenterPos(lua_State *L);
+ static int CCSignalBoxDelete(lua_State *L);
+};
+
+#endif //_LUACCSIGNALBOX_H
diff --git a/src/gui/lua/lua_cc_text.cpp b/src/gui/lua/lua_cc_text.cpp
new file mode 100644
index 000000000..e680a46b7
--- /dev/null
+++ b/src/gui/lua/lua_cc_text.cpp
@@ -0,0 +1,273 @@
+/*
+ * lua components text
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Thilo Graf (dbt)
+ * (C) 2014 Sven Hoefer (svenhoefer)
+ * (C) 2015 Jacek Jendrzej (SatBaby)
+ *
+ * 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, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "luainstance.h"
+#include "lua_cc_window.h"
+#include "lua_cc_text.h"
+
+CLuaInstCCText* CLuaInstCCText::getInstance()
+{
+ static CLuaInstCCText* LuaInstCCText = NULL;
+
+ if(!LuaInstCCText)
+ LuaInstCCText = new CLuaInstCCText();
+ return LuaInstCCText;
+}
+
+CLuaCCText *CLuaInstCCText::CCTextCheck(lua_State *L, int n)
+{
+ return *(CLuaCCText **) luaL_checkudata(L, n, "ctext");
+}
+
+void CLuaInstCCText::CCTextRegister(lua_State *L)
+{
+ luaL_Reg meth[] = {
+ { "new", CLuaInstCCText::CCTextNew },
+ { "paint", CLuaInstCCText::CCTextPaint },
+ { "hide", CLuaInstCCText::CCTextHide },
+ { "setText", CLuaInstCCText::CCTextSetText },
+ { "scroll", CLuaInstCCText::CCTextScroll },
+ { "setCenterPos", CLuaInstCCText::CCTextSetCenterPos },
+ { "enableUTF8", CLuaInstCCText::CCTextEnableUTF8 },
+ { "__gc", CLuaInstCCText::CCTextDelete },
+ { NULL, NULL }
+ };
+
+ luaL_newmetatable(L, "ctext");
+ luaL_setfuncs(L, meth, 0);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -1, "__index");
+ lua_setglobal(L, "ctext");
+}
+
+int CLuaInstCCText::CCTextNew(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+
+ CLuaCCWindow* parent = NULL;
+ lua_Integer x=10, y=10, dx=100, dy=100;
+ std::string text = "";
+ std::string tmpMode = "";
+ lua_Integer mode = CTextBox::AUTO_WIDTH;
+ lua_Integer font_text = SNeutrinoSettings::FONT_TYPE_MENU;
+ lua_Unsigned color_text = (lua_Unsigned)COL_MENUCONTENT_TEXT;
+ lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
+ lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
+ lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
+
+ tableLookup(L, "parent", (void**)&parent);
+ tableLookup(L, "x", x);
+ tableLookup(L, "y", y);
+ tableLookup(L, "dx", dx);
+ tableLookup(L, "dy", dy);
+ tableLookup(L, "text", text);
+ tableLookup(L, "mode", tmpMode);
+ tableLookup(L, "font_text", font_text);
+ if (font_text >= SNeutrinoSettings::FONT_TYPE_COUNT || font_text < 0)
+ font_text = SNeutrinoSettings::FONT_TYPE_MENU;
+
+ bool has_shadow = false;
+ if (!tableLookup(L, "has_shadow", has_shadow)) {
+ std::string tmp1 = "false";
+ if (tableLookup(L, "has_shadow", tmp1))
+ paramBoolDeprecated(L, tmp1.c_str());
+ has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
+ }
+
+ tableLookup(L, "color_text", color_text);
+ tableLookup(L, "color_frame", color_frame);
+ tableLookup(L, "color_body", color_body);
+ tableLookup(L, "color_shadow", color_shadow);
+
+ checkMagicMask(color_text);
+ checkMagicMask(color_frame);
+ checkMagicMask(color_body);
+ checkMagicMask(color_shadow);
+
+ if (!tmpMode.empty()) {
+ table_key txt_align[] = {
+ { "ALIGN_AUTO_WIDTH", CTextBox::AUTO_WIDTH },
+ { "ALIGN_AUTO_HIGH", CTextBox::AUTO_HIGH },
+ { "ALIGN_SCROLL", CTextBox::SCROLL },
+ { "ALIGN_CENTER", CTextBox::CENTER },
+ { "ALIGN_RIGHT", CTextBox::RIGHT },
+ { "ALIGN_TOP", CTextBox::TOP },
+ { "ALIGN_BOTTOM", CTextBox::BOTTOM },
+ { "ALIGN_NO_AUTO_LINEBREAK", CTextBox::NO_AUTO_LINEBREAK },
+ { "DECODE_HTML", 0 },
+ { NULL, 0 }
+ };
+ mode = 0;
+ for (int i = 0; txt_align[i].name; i++) {
+ if (tmpMode.find(txt_align[i].name) != std::string::npos)
+ mode |= txt_align[i].code;
+ }
+ if (tmpMode.find("DECODE_HTML") != std::string::npos)
+ htmlEntityDecode(text);
+ }
+
+ CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
+
+ CLuaCCText **udata = (CLuaCCText **) lua_newuserdata(L, sizeof(CLuaCCText *));
+ *udata = new CLuaCCText();
+ (*udata)->ct = new CComponentsText(x, y, dx, dy, text, mode, g_Font[font_text], pw, has_shadow, (fb_pixel_t)color_text, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow);
+ (*udata)->parent = pw;
+ (*udata)->mode = mode;
+ (*udata)->font_text = font_text;
+ luaL_getmetatable(L, "ctext");
+ lua_setmetatable(L, -2);
+ return 1;
+}
+
+int CLuaInstCCText::CCTextPaint(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m) return 0;
+
+ bool do_save_bg = true;
+ if (!tableLookup(L, "do_save_bg", do_save_bg)) {
+ std::string tmp = "true";
+ if (tableLookup(L, "do_save_bg", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ m->ct->paint(do_save_bg);
+ return 0;
+}
+
+int CLuaInstCCText::CCTextHide(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m) return 0;
+
+ bool no_restore = false;
+ if (!tableLookup(L, "no_restore", no_restore)) {
+ std::string tmp = "false";
+ if (tableLookup(L, "no_restore", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ if (m->parent) {
+ m->ct->setText("", m->mode, g_Font[m->font_text]);
+ m->ct->paint();
+ } else
+ m->ct->hide(no_restore);
+ return 0;
+}
+
+int CLuaInstCCText::CCTextSetText(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m) return 0;
+
+ std::string text = "";
+ lua_Integer mode = m->mode;
+ lua_Integer font_text = m->font_text;
+ tableLookup(L, "text", text);
+ tableLookup(L, "mode", mode);
+ tableLookup(L, "font_text", font_text);
+
+ m->ct->setText(text, mode, g_Font[font_text]);
+ return 0;
+}
+
+int CLuaInstCCText::CCTextScroll(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m) return 0;
+
+ std::string tmp = "true";
+ tableLookup(L, "dir", tmp);
+ bool scrollDown = (tmp == "down" || tmp == "1");
+
+ //get the textbox instance from lua object and use CTexBbox scroll methods
+ CTextBox* ctb = m->ct->getCTextBoxObject();
+ if (ctb) {
+ ctb->enableBackgroundPaint(true);
+ if (scrollDown)
+ ctb->scrollPageDown(1);
+ else
+ ctb->scrollPageUp(1);
+ ctb->enableBackgroundPaint(false);
+ }
+ return 0;
+}
+
+int CLuaInstCCText::CCTextSetCenterPos(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m) return 0;
+ lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
+ tableLookup(L, "along_mode", tmp_along_mode);
+
+ if (tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
+ along_mode=tmp_along_mode;
+
+ m->ct->setCenterPos(along_mode);
+ return 0;
+}
+
+int CLuaInstCCText::CCTextEnableUTF8(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m) return 0;
+
+ bool utf8_encoded = true;
+ if (!tableLookup(L, "utf8_encoded", utf8_encoded)) {
+ std::string tmp = "true";
+ if (tableLookup(L, "utf8_encoded", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ utf8_encoded = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ m->ct->enableUTF8(utf8_encoded);
+ return 0;
+}
+
+int CLuaInstCCText::CCTextDelete(lua_State *L)
+{
+ LUA_DEBUG("CLuaInstCCText::%s %d\n", __func__, lua_gettop(L));
+ CLuaCCText *m = CCTextCheck(L, 1);
+ if (!m)
+ return 0;
+
+ delete m;
+ return 0;
+}
diff --git a/src/gui/lua/lua_cc_text.h b/src/gui/lua/lua_cc_text.h
new file mode 100644
index 000000000..67728e533
--- /dev/null
+++ b/src/gui/lua/lua_cc_text.h
@@ -0,0 +1,56 @@
+/*
+ * lua components text
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Thilo Graf (dbt)
+ * (C) 2014 Sven Hoefer (svenhoefer)
+ * (C) 2015 Jacek Jendrzej (SatBaby)
+ *
+ * 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, see .
+ */
+
+#ifndef _LUACCTEXT_H
+#define _LUACCTEXT_H
+
+class CLuaCCText
+{
+ public:
+ CComponentsText *ct;
+ CComponentsForm *parent;
+ int mode, font_text;
+ CLuaCCText() { ct = NULL; parent = NULL; mode = 0; font_text = 0;}
+ ~CLuaCCText() { if (parent == NULL) delete ct; }
+};
+
+class CLuaInstCCText
+{
+ public:
+ CLuaInstCCText() {};
+ ~CLuaInstCCText() {};
+ static CLuaInstCCText* getInstance();
+ static void CCTextRegister(lua_State *L);
+
+ private:
+ static CLuaCCText *CCTextCheck(lua_State *L, int n);
+ static int CCTextNew(lua_State *L);
+ static int CCTextPaint(lua_State *L);
+ static int CCTextHide(lua_State *L);
+ static int CCTextSetText(lua_State *L);
+ static int CCTextScroll(lua_State *L);
+ static int CCTextSetCenterPos(lua_State *L);
+ static int CCTextEnableUTF8(lua_State *L);
+ static int CCTextDelete(lua_State *L);
+};
+
+#endif //_LUACCTEXT_H
diff --git a/src/gui/lua/lua_cc_window.cpp b/src/gui/lua/lua_cc_window.cpp
new file mode 100644
index 000000000..399abd7f7
--- /dev/null
+++ b/src/gui/lua/lua_cc_window.cpp
@@ -0,0 +1,326 @@
+/*
+ * lua components window
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Thilo Graf (dbt)
+ *
+ * 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, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+#include "luainstance.h"
+#include "lua_cc_window.h"
+
+CLuaInstCCWindow* CLuaInstCCWindow::getInstance()
+{
+ static CLuaInstCCWindow* LuaInstCCWindow = NULL;
+
+ if(!LuaInstCCWindow)
+ LuaInstCCWindow = new CLuaInstCCWindow();
+ return LuaInstCCWindow;
+}
+
+void CLuaInstCCWindow::CCWindowRegister(lua_State *L)
+{
+ luaL_Reg meth[] = {
+ { "new", CLuaInstCCWindow::CCWindowNew },
+ { "paint", CLuaInstCCWindow::CCWindowPaint },
+ { "hide", CLuaInstCCWindow::CCWindowHide },
+ { "setCaption", CLuaInstCCWindow::CCWindowSetCaption },
+ { "setWindowColor", CLuaInstCCWindow::CCWindowSetWindowColor },
+ { "paintHeader", CLuaInstCCWindow::CCWindowPaintHeader },
+ { "headerHeight", CLuaInstCCWindow::CCWindowGetHeaderHeight },
+ { "footerHeight", CLuaInstCCWindow::CCWindowGetFooterHeight },
+ { "header_height", CLuaInstCCWindow::CCWindowGetHeaderHeight_dep }, /* function 'header_height' is deprecated */
+ { "footer_height", CLuaInstCCWindow::CCWindowGetFooterHeight_dep }, /* function 'footer_height' is deprecated */
+ { "setCenterPos", CLuaInstCCWindow::CCWindowSetCenterPos },
+ { "__gc", CLuaInstCCWindow::CCWindowDelete },
+ { NULL, NULL }
+ };
+
+ luaL_newmetatable(L, "cwindow");
+ luaL_setfuncs(L, meth, 0);
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -1, "__index");
+ lua_setglobal(L, "cwindow");
+}
+
+int CLuaInstCCWindow::CCWindowNew(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+
+ std::string name, icon = std::string(NEUTRINO_ICON_INFO);
+ lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
+ lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
+ lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
+ std::string tmp1 = "false";
+ std::string btnRed = "";
+ std::string btnGreen = "";
+ std::string btnYellow = "";
+ std::string btnBlue = "";
+ lua_Integer x = 100, y = 100, dx = 450, dy = 250;
+ tableLookup(L, "x", x);
+ tableLookup(L, "y", y);
+ tableLookup(L, "dx", dx);
+ tableLookup(L, "dy", dy);
+ tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
+ tableLookup(L, "icon", icon);
+
+ bool has_shadow = false;
+ if (!tableLookup(L, "has_shadow", has_shadow)) {
+ tmp1 = "false";
+ if (tableLookup(L, "has_shadow", tmp1))
+ paramBoolDeprecated(L, tmp1.c_str());
+ has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
+ }
+
+ tableLookup(L, "color_frame" , color_frame);
+ tableLookup(L, "color_body" , color_body);
+ tableLookup(L, "color_shadow", color_shadow);
+ tableLookup(L, "btnRed", btnRed);
+ tableLookup(L, "btnGreen", btnGreen);
+ tableLookup(L, "btnYellow", btnYellow);
+ tableLookup(L, "btnBlue", btnBlue);
+
+ checkMagicMask(color_frame);
+ checkMagicMask(color_body);
+ checkMagicMask(color_shadow);
+
+ bool show_header = true;
+ if (!tableLookup(L, "show_header", show_header)) {
+ tmp1 = "true";
+ if (tableLookup(L, "show_header", tmp1))
+ paramBoolDeprecated(L, tmp1.c_str());
+ show_header = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
+ }
+ bool show_footer = true;
+ if (!tableLookup(L, "show_footer", show_footer)) {
+ tmp1 = "true";
+ if (tableLookup(L, "show_footer", tmp1))
+ paramBoolDeprecated(L, tmp1.c_str());
+ show_footer = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
+ }
+
+ CLuaCCWindow **udata = (CLuaCCWindow **) lua_newuserdata(L, sizeof(CLuaCCWindow *));
+ *udata = new CLuaCCWindow();
+ (*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str(), 0, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow);
+
+ if (!show_header)
+ (*udata)->w->showHeader(false);
+ if (!show_footer)
+ (*udata)->w->showFooter(false);
+ else {
+ CComponentsFooter* footer = (*udata)->w->getFooterObject();
+ if (footer) {
+ vector buttons;
+ if (!btnRed.empty()) {
+ button_label_s btnSred;
+ btnSred.button = NEUTRINO_ICON_BUTTON_RED;
+ btnSred.text = btnRed;
+ buttons.push_back(btnSred);
+ }
+ if (!btnGreen.empty()) {
+ button_label_s btnSgreen;
+ btnSgreen.button = NEUTRINO_ICON_BUTTON_GREEN;
+ btnSgreen.text = btnGreen;
+ buttons.push_back(btnSgreen);
+ }
+ if (!btnYellow.empty()) {
+ button_label_s btnSyellow;
+ btnSyellow.button = NEUTRINO_ICON_BUTTON_YELLOW;
+ btnSyellow.text = btnYellow;
+ buttons.push_back(btnSyellow);
+ }
+ if (!btnBlue.empty()) {
+ button_label_s btnSblue;
+ btnSblue.button = NEUTRINO_ICON_BUTTON_BLUE;
+ btnSblue.text = btnBlue;
+ buttons.push_back(btnSblue);
+ }
+ if (!buttons.empty())
+ footer->setButtonLabels(buttons, dx-20, (dx-20) / (buttons.size()+1));
+ }
+ }
+
+ luaL_getmetatable(L, "cwindow");
+ lua_setmetatable(L, -2);
+ return 1;
+}
+
+CLuaCCWindow *CLuaInstCCWindow::CCWindowCheck(lua_State *L, int n)
+{
+ return *(CLuaCCWindow **) luaL_checkudata(L, n, "cwindow");
+}
+
+int CLuaInstCCWindow::CCWindowPaint(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m) return 0;
+
+ bool do_save_bg = true;
+ if (!tableLookup(L, "do_save_bg", do_save_bg)) {
+ std::string tmp = "true";
+ if (tableLookup(L, "do_save_bg", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ m->w->paint(do_save_bg);
+ return 0;
+}
+
+int CLuaInstCCWindow::CCWindowHide(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m) return 0;
+
+ bool no_restore = false;
+ if (!tableLookup(L, "no_restore", no_restore)) {
+ std::string tmp = "false";
+ if (tableLookup(L, "no_restore", tmp))
+ paramBoolDeprecated(L, tmp.c_str());
+ no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
+ }
+ m->w->hide(no_restore);
+ return 0;
+}
+
+int CLuaInstCCWindow::CCWindowSetCaption(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m) return 0;
+
+ std::string name = "";
+ tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
+
+ m->w->setWindowCaption(name);
+ return 0;
+}
+
+int CLuaInstCCWindow::CCWindowSetWindowColor(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m) return 0;
+
+ lua_Unsigned color;
+ if (tableLookup(L, "color_frame" , color)) {
+ checkMagicMask(color);
+ m->w->setColorFrame(color);
+ }
+ if (tableLookup(L, "color_body" , color)) {
+ checkMagicMask(color);
+ m->w->setColorBody(color);
+ }
+ if (tableLookup(L, "color_shadow" , color)) {
+ checkMagicMask(color);
+ m->w->setColorShadow(color);
+ }
+
+ return 0;
+}
+
+int CLuaInstCCWindow::CCWindowPaintHeader(lua_State *L)
+{
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m) return 0;
+
+ CComponentsHeader* header = m->w->getHeaderObject();
+ if (header)
+ m->w->showHeader();
+ header->paint();
+
+ return 0;
+}
+
+// function 'header_height' is deprecated
+int CLuaInstCCWindow::CCWindowGetHeaderHeight_dep(lua_State *L)
+{
+ functionDeprecated(L, "header_height", "headerHeight");
+ return CCWindowGetHeaderHeight(L);
+}
+
+// function 'footer_height' is deprecated
+int CLuaInstCCWindow::CCWindowGetFooterHeight_dep(lua_State *L)
+{
+ functionDeprecated(L, "footer_height", "footerHeight");
+ return CCWindowGetFooterHeight(L);
+}
+
+int CLuaInstCCWindow::CCWindowGetHeaderHeight(lua_State *L)
+{
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m)
+ return 0;
+
+ CComponentsHeader* header = m->w->getHeaderObject();
+ int hh = 0;
+ if (header)
+ hh = header->getHeight();
+ lua_pushinteger(L, hh);
+ return 1;
+}
+
+int CLuaInstCCWindow::CCWindowGetFooterHeight(lua_State *L)
+{
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m)
+ return 0;
+
+ CComponentsFooter* footer = m->w->getFooterObject();
+ int fh = 0;
+ if (footer)
+ fh = footer->getHeight();
+ lua_pushinteger(L, fh);
+ return 1;
+}
+
+int CLuaInstCCWindow::CCWindowSetCenterPos(lua_State *L)
+{
+ lua_assert(lua_istable(L,1));
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m) return 0;
+ lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
+ tableLookup(L, "along_mode", tmp_along_mode);
+
+ if (tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
+ along_mode=tmp_along_mode;
+
+ m->w->setCenterPos(along_mode);
+ return 0;
+}
+
+int CLuaInstCCWindow::CCWindowDelete(lua_State *L)
+{
+ LUA_DEBUG("CLuaInstCCWindow::%s %d\n", __func__, lua_gettop(L));
+ CLuaCCWindow *m = CCWindowCheck(L, 1);
+ if (!m)
+ return 0;
+
+ delete m;
+ return 0;
+}
diff --git a/src/gui/lua/lua_cc_window.h b/src/gui/lua/lua_cc_window.h
new file mode 100644
index 000000000..0e32bc386
--- /dev/null
+++ b/src/gui/lua/lua_cc_window.h
@@ -0,0 +1,56 @@
+/*
+ * lua components window
+ *
+ * (C) 2014-2015 M. Liebmann (micha-bbg)
+ * (C) 2014 Thilo Graf (dbt)
+ *
+ * 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, see .
+ */
+
+#ifndef _LUACCWINDOW_H
+#define _LUACCWINDOW_H
+
+class CLuaCCWindow
+{
+ public:
+ CComponentsWindow *w;
+ CLuaCCWindow() { w = NULL; }
+ ~CLuaCCWindow() { delete w; }
+};
+
+class CLuaInstCCWindow
+{
+ public:
+ CLuaInstCCWindow() {};
+ ~CLuaInstCCWindow() {};
+ static CLuaInstCCWindow* getInstance();
+ static void CCWindowRegister(lua_State *L);
+
+ private:
+ static int CCWindowNew(lua_State *L);
+ static CLuaCCWindow *CCWindowCheck(lua_State *L, int n);
+ static int CCWindowPaint(lua_State *L);
+ static int CCWindowHide(lua_State *L);
+ static int CCWindowSetCaption(lua_State *L);
+ static int CCWindowSetWindowColor(lua_State *L);
+ static int CCWindowPaintHeader(lua_State *L);
+ static int CCWindowGetHeaderHeight(lua_State *L);
+ static int CCWindowGetFooterHeight(lua_State *L);
+ static int CCWindowGetHeaderHeight_dep(lua_State *L); // function 'header_height' is deprecated
+ static int CCWindowGetFooterHeight_dep(lua_State *L); // function 'footer_height' is deprecated
+ static int CCWindowSetCenterPos(lua_State *L);
+ static int CCWindowDelete(lua_State *L);
+};
+
+#endif //_LUACCWINDOW_H
diff --git a/src/gui/lua/luainstance.cpp b/src/gui/lua/luainstance.cpp
index bc44af0b2..74feebeec 100644
--- a/src/gui/lua/luainstance.cpp
+++ b/src/gui/lua/luainstance.cpp
@@ -37,6 +37,10 @@
#include
#include "luainstance.h"
+#include "lua_cc_picture.h"
+#include "lua_cc_signalbox.h"
+#include "lua_cc_text.h"
+#include "lua_cc_window.h"
#include "lua_configfile.h"
#include "lua_menue.h"
#include "lua_video.h"
@@ -540,10 +544,10 @@ void CLuaInstance::registerFunctions()
HintboxRegister(lua);
MessageboxRegister(lua);
- CWindowRegister(lua);
- ComponentsTextRegister(lua);
- SignalBoxRegister(lua);
- CPictureRegister(lua);
+ CLuaInstCCPicture::getInstance()->CCPictureRegister(lua);
+ CLuaInstCCSignalbox::getInstance()->CCSignalBoxRegister(lua);
+ CLuaInstCCText::getInstance()->CCTextRegister(lua);
+ CLuaInstCCWindow::getInstance()->CCWindowRegister(lua);
CLuaInstConfigFile::getInstance()->LuaConfigFileRegister(lua);
CLuaInstMenu::getInstance()->MenuRegister(lua);
}
@@ -1383,783 +1387,6 @@ int CLuaInstance::MessageboxExec(lua_State *L)
// --------------------------------------------------------------------------------
-void CLuaInstance::CWindowRegister(lua_State *L)
-{
- luaL_Reg meth[] = {
- { "new", CLuaInstance::CWindowNew },
- { "paint", CLuaInstance::CWindowPaint },
- { "hide", CLuaInstance::CWindowHide },
- { "setCaption", CLuaInstance::CWindowSetCaption },
- { "setWindowColor", CLuaInstance::CWindowSetWindowColor },
- { "paintHeader", CLuaInstance::CWindowPaintHeader },
- { "headerHeight", CLuaInstance::CWindowGetHeaderHeight },
- { "footerHeight", CLuaInstance::CWindowGetFooterHeight },
- { "header_height", CLuaInstance::CWindowGetHeaderHeight_dep }, /* function 'header_height' is deprecated */
- { "footer_height", CLuaInstance::CWindowGetFooterHeight_dep }, /* function 'footer_height' is deprecated */
- { "setCenterPos", CLuaInstance::CWindowSetCenterPos },
- { "__gc", CLuaInstance::CWindowDelete },
- { NULL, NULL }
- };
-
- luaL_newmetatable(L, "cwindow");
- luaL_setfuncs(L, meth, 0);
- lua_pushvalue(L, -1);
- lua_setfield(L, -1, "__index");
- lua_setglobal(L, "cwindow");
-}
-
-int CLuaInstance::CWindowNew(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
-
- std::string name, icon = std::string(NEUTRINO_ICON_INFO);
- lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
- lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
- lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
- std::string tmp1 = "false";
- std::string btnRed = "";
- std::string btnGreen = "";
- std::string btnYellow = "";
- std::string btnBlue = "";
- lua_Integer x = 100, y = 100, dx = 450, dy = 250;
- tableLookup(L, "x", x);
- tableLookup(L, "y", y);
- tableLookup(L, "dx", dx);
- tableLookup(L, "dy", dy);
- tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
- tableLookup(L, "icon", icon);
-
- bool has_shadow = false;
- if (!tableLookup(L, "has_shadow", has_shadow))
- {
- tmp1 = "false";
- if (tableLookup(L, "has_shadow", tmp1))
- paramBoolDeprecated(L, tmp1.c_str());
- has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
- }
-
- tableLookup(L, "color_frame" , color_frame);
- tableLookup(L, "color_body" , color_body);
- tableLookup(L, "color_shadow", color_shadow);
- tableLookup(L, "btnRed", btnRed);
- tableLookup(L, "btnGreen", btnGreen);
- tableLookup(L, "btnYellow", btnYellow);
- tableLookup(L, "btnBlue", btnBlue);
-
- checkMagicMask(color_frame);
- checkMagicMask(color_body);
- checkMagicMask(color_shadow);
-
- bool show_header = true;
- if (!tableLookup(L, "show_header", show_header))
- {
- tmp1 = "true";
- if (tableLookup(L, "show_header", tmp1))
- paramBoolDeprecated(L, tmp1.c_str());
- show_header = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
- }
- bool show_footer = true;
- if (!tableLookup(L, "show_footer", show_footer))
- {
- tmp1 = "true";
- if (tableLookup(L, "show_footer", tmp1))
- paramBoolDeprecated(L, tmp1.c_str());
- show_footer = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
- }
-
- CLuaCWindow **udata = (CLuaCWindow **) lua_newuserdata(L, sizeof(CLuaCWindow *));
- *udata = new CLuaCWindow();
- (*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str(), 0, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow);
-
- if (!show_header)
- (*udata)->w->showHeader(false);
- if (!show_footer)
- (*udata)->w->showFooter(false);
- else {
- CComponentsFooter* footer = (*udata)->w->getFooterObject();
- if (footer) {
- vector buttons;
- if (!btnRed.empty()){
- button_label_s btnSred;
- btnSred.button = NEUTRINO_ICON_BUTTON_RED;
- btnSred.text = btnRed;
- buttons.push_back(btnSred);
- }
- if (!btnGreen.empty()){
- button_label_s btnSgreen;
- btnSgreen.button = NEUTRINO_ICON_BUTTON_GREEN;
- btnSgreen.text = btnGreen;
- buttons.push_back(btnSgreen);
- }
- if (!btnYellow.empty()){
- button_label_s btnSyellow;
- btnSyellow.button = NEUTRINO_ICON_BUTTON_YELLOW;
- btnSyellow.text = btnYellow;
- buttons.push_back(btnSyellow);
- }
- if (!btnBlue.empty()){
- button_label_s btnSblue;
- btnSblue.button = NEUTRINO_ICON_BUTTON_BLUE;
- btnSblue.text = btnBlue;
- buttons.push_back(btnSblue);
- }
- if(!buttons.empty())
- footer->setButtonLabels(buttons, dx-20, (dx-20) / (buttons.size()+1));
- }
- }
-
- luaL_getmetatable(L, "cwindow");
- lua_setmetatable(L, -2);
- return 1;
-}
-
-CLuaCWindow *CLuaInstance::CWindowCheck(lua_State *L, int n)
-{
- return *(CLuaCWindow **) luaL_checkudata(L, n, "cwindow");
-}
-
-int CLuaInstance::CWindowPaint(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m) return 0;
-
- bool do_save_bg = true;
- if (!tableLookup(L, "do_save_bg", do_save_bg))
- {
- std::string tmp = "true";
- if (tableLookup(L, "do_save_bg", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- m->w->paint(do_save_bg);
- return 0;
-}
-
-int CLuaInstance::CWindowHide(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m) return 0;
-
- bool no_restore = false;
- if (!tableLookup(L, "no_restore", no_restore))
- {
- std::string tmp = "false";
- if (tableLookup(L, "no_restore", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- m->w->hide(no_restore);
- return 0;
-}
-
-int CLuaInstance::CWindowSetCaption(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m) return 0;
-
- std::string name = "";
- tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
-
- m->w->setWindowCaption(name);
- return 0;
-}
-
-int CLuaInstance::CWindowSetWindowColor(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m) return 0;
-
- lua_Unsigned color;
- if (tableLookup(L, "color_frame" , color)) {
- checkMagicMask(color);
- m->w->setColorFrame(color);
- }
- if (tableLookup(L, "color_body" , color)) {
- checkMagicMask(color);
- m->w->setColorBody(color);
- }
- if (tableLookup(L, "color_shadow" , color)) {
- checkMagicMask(color);
- m->w->setColorShadow(color);
- }
-
- return 0;
-}
-
-int CLuaInstance::CWindowPaintHeader(lua_State *L)
-{
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m) return 0;
-
- CComponentsHeader* header = m->w->getHeaderObject();
- if (header)
- m->w->showHeader();
- header->paint();
-
- return 0;
-}
-
-// function 'header_height' is deprecated
-int CLuaInstance::CWindowGetHeaderHeight_dep(lua_State *L)
-{
- functionDeprecated(L, "header_height", "headerHeight");
- return CWindowGetHeaderHeight(L);
-}
-
-// function 'footer_height' is deprecated
-int CLuaInstance::CWindowGetFooterHeight_dep(lua_State *L)
-{
- functionDeprecated(L, "footer_height", "footerHeight");
- return CWindowGetFooterHeight(L);
-}
-
-int CLuaInstance::CWindowGetHeaderHeight(lua_State *L)
-{
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m)
- return 0;
-
- CComponentsHeader* header = m->w->getHeaderObject();
- int hh = 0;
- if (header)
- hh = header->getHeight();
- lua_pushinteger(L, hh);
- return 1;
-}
-
-int CLuaInstance::CWindowGetFooterHeight(lua_State *L)
-{
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m)
- return 0;
-
- CComponentsFooter* footer = m->w->getFooterObject();
- int fh = 0;
- if (footer)
- fh = footer->getHeight();
- lua_pushinteger(L, fh);
- return 1;
-}
-
-int CLuaInstance::CWindowSetCenterPos(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m) return 0;
- lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
- tableLookup(L, "along_mode", tmp_along_mode);
-
- if(tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
- along_mode=tmp_along_mode;
-
- m->w->setCenterPos(along_mode);
- return 0;
-}
-
-int CLuaInstance::CWindowDelete(lua_State *L)
-{
- LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
- CLuaCWindow *m = CWindowCheck(L, 1);
- if (!m)
- return 0;
-
- delete m;
- return 0;
-}
-
-// --------------------------------------------------------------------------------
-
-CLuaSignalBox *CLuaInstance::SignalBoxCheck(lua_State *L, int n)
-{
- return *(CLuaSignalBox **) luaL_checkudata(L, n, "signalbox");
-}
-
-void CLuaInstance::SignalBoxRegister(lua_State *L)
-{
- luaL_Reg meth[] = {
- { "new", CLuaInstance::SignalBoxNew },
- { "paint", CLuaInstance::SignalBoxPaint },
- { "setCenterPos", CLuaInstance::SignalBoxSetCenterPos },
- { "__gc", CLuaInstance::SignalBoxDelete },
- { NULL, NULL }
- };
-
- luaL_newmetatable(L, "signalbox");
- luaL_setfuncs(L, meth, 0);
- lua_pushvalue(L, -1);
- lua_setfield(L, -1, "__index");
- lua_setglobal(L, "signalbox");
-}
-
-int CLuaInstance::SignalBoxNew(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
-
- std::string name, icon = std::string(NEUTRINO_ICON_INFO);
- lua_Integer x = 110, y = 150, dx = 430, dy = 150;
- lua_Integer vertical = true;
- CLuaCWindow* parent = NULL;
- tableLookup(L, "x", x);
- tableLookup(L, "y", y);
- tableLookup(L, "dx", dx);
- tableLookup(L, "dy", dy);
- tableLookup(L, "vertical", vertical);
- tableLookup(L, "parent", (void**)&parent);
-
- CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
- CLuaSignalBox **udata = (CLuaSignalBox **) lua_newuserdata(L, sizeof(CLuaSignalBox *));
- *udata = new CLuaSignalBox();
- (*udata)->s = new CSignalBox(x, y, dx, dy, NULL, (vertical!=0)?true:false, pw);
- (*udata)->parent = pw;
- luaL_getmetatable(L, "signalbox");
- lua_setmetatable(L, -2);
- return 1;
-}
-
-int CLuaInstance::SignalBoxPaint(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaSignalBox *m = SignalBoxCheck(L, 1);
- if (!m) return 0;
-
- bool do_save_bg = true;
- if (!tableLookup(L, "do_save_bg", do_save_bg))
- {
- std::string tmp = "true";
- if (tableLookup(L, "do_save_bg", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- m->s->paint(do_save_bg);
- return 0;
-}
-int CLuaInstance::SignalBoxSetCenterPos(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaSignalBox *m = SignalBoxCheck(L, 1);
- if (!m) return 0;
- lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
- tableLookup(L, "along_mode", tmp_along_mode);
-
- if(tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
- along_mode=tmp_along_mode;
-
- m->s->setCenterPos(along_mode);
- return 0;
-}
-
-int CLuaInstance::SignalBoxDelete(lua_State *L)
-{
- CLuaSignalBox *m = SignalBoxCheck(L, 1);
- if (!m)
- return 0;
-
- delete m;
- return 0;
-}
-
-// --------------------------------------------------------------------------------
-
-CLuaComponentsText *CLuaInstance::ComponentsTextCheck(lua_State *L, int n)
-{
- return *(CLuaComponentsText **) luaL_checkudata(L, n, "ctext");
-}
-
-void CLuaInstance::ComponentsTextRegister(lua_State *L)
-{
- luaL_Reg meth[] = {
- { "new", CLuaInstance::ComponentsTextNew },
- { "paint", CLuaInstance::ComponentsTextPaint },
- { "hide", CLuaInstance::ComponentsTextHide },
- { "setText", CLuaInstance::ComponentsTextSetText },
- { "scroll", CLuaInstance::ComponentsTextScroll },
- { "setCenterPos", CLuaInstance::ComponentsTextSetCenterPos },
- { "enableUTF8", CLuaInstance::ComponentsTextEnableUTF8 },
- { "__gc", CLuaInstance::ComponentsTextDelete },
- { NULL, NULL }
- };
-
- luaL_newmetatable(L, "ctext");
- luaL_setfuncs(L, meth, 0);
- lua_pushvalue(L, -1);
- lua_setfield(L, -1, "__index");
- lua_setglobal(L, "ctext");
-}
-
-int CLuaInstance::ComponentsTextNew(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
-
- CLuaCWindow* parent = NULL;
- lua_Integer x=10, y=10, dx=100, dy=100;
- std::string text = "";
- std::string tmpMode = "";
- lua_Integer mode = CTextBox::AUTO_WIDTH;
- lua_Integer font_text = SNeutrinoSettings::FONT_TYPE_MENU;
- lua_Unsigned color_text = (lua_Unsigned)COL_MENUCONTENT_TEXT;
- lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
- lua_Unsigned color_body = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
- lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
-
- tableLookup(L, "parent" , (void**)&parent);
- tableLookup(L, "x" , x);
- tableLookup(L, "y" , y);
- tableLookup(L, "dx" , dx);
- tableLookup(L, "dy" , dy);
- tableLookup(L, "text" , text);
- tableLookup(L, "mode" , tmpMode);
- tableLookup(L, "font_text" , font_text);
- if (font_text >= SNeutrinoSettings::FONT_TYPE_COUNT || font_text < 0)
- font_text = SNeutrinoSettings::FONT_TYPE_MENU;
-
- bool has_shadow = false;
- if (!tableLookup(L, "has_shadow", has_shadow))
- {
- std::string tmp1 = "false";
- if (tableLookup(L, "has_shadow", tmp1))
- paramBoolDeprecated(L, tmp1.c_str());
- has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
- }
-
- tableLookup(L, "color_text" , color_text);
- tableLookup(L, "color_frame" , color_frame);
- tableLookup(L, "color_body" , color_body);
- tableLookup(L, "color_shadow", color_shadow);
-
- checkMagicMask(color_text);
- checkMagicMask(color_frame);
- checkMagicMask(color_body);
- checkMagicMask(color_shadow);
-
- if (!tmpMode.empty()) {
- table_key txt_align[] = {
- { "ALIGN_AUTO_WIDTH", CTextBox::AUTO_WIDTH },
- { "ALIGN_AUTO_HIGH", CTextBox::AUTO_HIGH },
- { "ALIGN_SCROLL", CTextBox::SCROLL },
- { "ALIGN_CENTER", CTextBox::CENTER },
- { "ALIGN_RIGHT", CTextBox::RIGHT },
- { "ALIGN_TOP", CTextBox::TOP },
- { "ALIGN_BOTTOM", CTextBox::BOTTOM },
- { "ALIGN_NO_AUTO_LINEBREAK", CTextBox::NO_AUTO_LINEBREAK },
- { "DECODE_HTML", 0 },
- { NULL, 0 }
- };
- mode = 0;
- for (int i = 0; txt_align[i].name; i++) {
- if (tmpMode.find(txt_align[i].name) != std::string::npos)
- mode |= txt_align[i].code;
- }
- if (tmpMode.find("DECODE_HTML") != std::string::npos)
- htmlEntityDecode(text);
- }
-
- CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
-
- CLuaComponentsText **udata = (CLuaComponentsText **) lua_newuserdata(L, sizeof(CLuaComponentsText *));
- *udata = new CLuaComponentsText();
- (*udata)->ct = new CComponentsText(x, y, dx, dy, text, mode, g_Font[font_text], pw, has_shadow, (fb_pixel_t)color_text, (fb_pixel_t)color_frame, (fb_pixel_t)color_body, (fb_pixel_t)color_shadow);
- (*udata)->parent = pw;
- (*udata)->mode = mode;
- (*udata)->font_text = font_text;
- luaL_getmetatable(L, "ctext");
- lua_setmetatable(L, -2);
- return 1;
-}
-
-int CLuaInstance::ComponentsTextPaint(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m) return 0;
-
- bool do_save_bg = true;
- if (!tableLookup(L, "do_save_bg", do_save_bg))
- {
- std::string tmp = "true";
- if (tableLookup(L, "do_save_bg", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- m->ct->paint(do_save_bg);
- return 0;
-}
-
-int CLuaInstance::ComponentsTextHide(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m) return 0;
-
- bool no_restore = false;
- if (!tableLookup(L, "no_restore", no_restore))
- {
- std::string tmp = "false";
- if (tableLookup(L, "no_restore", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- if (m->parent) {
- m->ct->setText("", m->mode, g_Font[m->font_text]);
- m->ct->paint();
- } else
- m->ct->hide(no_restore);
- return 0;
-}
-
-int CLuaInstance::ComponentsTextSetText(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m) return 0;
-
- std::string text = "";
- lua_Integer mode = m->mode;
- lua_Integer font_text = m->font_text;
- tableLookup(L, "text", text);
- tableLookup(L, "mode", mode);
- tableLookup(L, "font_text", font_text);
-
- m->ct->setText(text, mode, g_Font[font_text]);
- return 0;
-}
-
-int CLuaInstance::ComponentsTextScroll(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m) return 0;
-
- std::string tmp = "true";
- tableLookup(L, "dir", tmp);
- bool scrollDown = (tmp == "down" || tmp == "1");
-
- //get the textbox instance from lua object and use CTexBbox scroll methods
- CTextBox* ctb = m->ct->getCTextBoxObject();
- if (ctb) {
- ctb->enableBackgroundPaint(true);
- if (scrollDown)
- ctb->scrollPageDown(1);
- else
- ctb->scrollPageUp(1);
- ctb->enableBackgroundPaint(false);
- }
- return 0;
-}
-
-int CLuaInstance::ComponentsTextSetCenterPos(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m) return 0;
- lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
- tableLookup(L, "along_mode", tmp_along_mode);
-
- if(tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
- along_mode=tmp_along_mode;
-
- m->ct->setCenterPos(along_mode);
- return 0;
-}
-
-int CLuaInstance::ComponentsTextEnableUTF8(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m) return 0;
-
- bool utf8_encoded = true;
- if (!tableLookup(L, "utf8_encoded", utf8_encoded))
- {
- std::string tmp = "true";
- if (tableLookup(L, "utf8_encoded", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- utf8_encoded = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- m->ct->enableUTF8(utf8_encoded);
- return 0;
-}
-
-int CLuaInstance::ComponentsTextDelete(lua_State *L)
-{
- LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
- CLuaComponentsText *m = ComponentsTextCheck(L, 1);
- if (!m)
- return 0;
-
- delete m;
- return 0;
-}
-
-// --------------------------------------------------------------------------------
-
-CLuaPicture *CLuaInstance::CPictureCheck(lua_State *L, int n)
-{
- return *(CLuaPicture **) luaL_checkudata(L, n, "cpicture");
-}
-
-void CLuaInstance::CPictureRegister(lua_State *L)
-{
- luaL_Reg meth[] = {
- { "new", CLuaInstance::CPictureNew },
- { "paint", CLuaInstance::CPicturePaint },
- { "hide", CLuaInstance::CPictureHide },
- { "setPicture", CLuaInstance::CPictureSetPicture },
- { "setCenterPos", CLuaInstance::CPictureSetCenterPos },
- { "__gc", CLuaInstance::CPictureDelete },
- { NULL, NULL }
- };
-
- luaL_newmetatable(L, "cpicture");
- luaL_setfuncs(L, meth, 0);
- lua_pushvalue(L, -1);
- lua_setfield(L, -1, "__index");
- lua_setglobal(L, "cpicture");
-}
-
-int CLuaInstance::CPictureNew(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
-
- CLuaCWindow* parent = NULL;
- lua_Integer x=10, y=10, dx=100, dy=100;
- std::string image_name = "";
- lua_Integer alignment = 0;
- lua_Unsigned color_frame = (lua_Unsigned)COL_MENUCONTENT_PLUS_6;
- lua_Unsigned color_background = (lua_Unsigned)COL_MENUCONTENT_PLUS_0;
- lua_Unsigned color_shadow = (lua_Unsigned)COL_MENUCONTENTDARK_PLUS_0;
-
- /*
- transparency = CFrameBuffer::TM_BLACK (2): Transparency when black content ('pseudo' transparency)
- transparency = CFrameBuffer::TM_NONE (1): No 'pseudo' transparency
- */
- lua_Integer transparency = CFrameBuffer::TM_NONE;
-
- tableLookup(L, "parent" , (void**)&parent);
- tableLookup(L, "x" , x);
- tableLookup(L, "y" , y);
- tableLookup(L, "dx" , dx);
- tableLookup(L, "dy" , dy);
- tableLookup(L, "image" , image_name);
-
- tableLookup(L, "alignment" , alignment); //invalid argumet, for compatibility
- if (alignment)
- dprintf(DEBUG_NORMAL, "[CLuaInstance][%s - %d] invalid argument: 'alignment' has no effect!\n", __func__, __LINE__);
-
- bool has_shadow = false;
- if (!tableLookup(L, "has_shadow", has_shadow))
- {
- std::string tmp1 = "false";
- if (tableLookup(L, "has_shadow", tmp1))
- paramBoolDeprecated(L, tmp1.c_str());
- has_shadow = (tmp1 == "true" || tmp1 == "1" || tmp1 == "yes");
- }
- tableLookup(L, "color_frame" , color_frame);
- tableLookup(L, "color_background" , color_background);
- tableLookup(L, "color_shadow" , color_shadow);
- tableLookup(L, "transparency" , transparency);
-
- checkMagicMask(color_frame);
- checkMagicMask(color_background);
- checkMagicMask(color_shadow);
-
- CComponentsForm* pw = (parent && parent->w) ? parent->w->getBodyObject() : NULL;
-
- CLuaPicture **udata = (CLuaPicture **) lua_newuserdata(L, sizeof(CLuaPicture *));
- *udata = new CLuaPicture();
- if (dx == 0 && dy == 0) /* NO_SCALE */
- (*udata)->cp = new CComponentsPicture(x, y, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
- else
- (*udata)->cp = new CComponentsPicture(x, y, dx, dy, image_name, pw, has_shadow, (fb_pixel_t)color_frame, (fb_pixel_t)color_background, (fb_pixel_t)color_shadow, transparency);
- (*udata)->parent = pw;
- luaL_getmetatable(L, "cpicture");
- lua_setmetatable(L, -2);
- return 1;
-}
-
-int CLuaInstance::CPicturePaint(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaPicture *m = CPictureCheck(L, 1);
- if (!m) return 0;
-
- bool do_save_bg = true;
- if (!tableLookup(L, "do_save_bg", do_save_bg))
- {
- std::string tmp = "true";
- if (tableLookup(L, "do_save_bg", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- do_save_bg = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- m->cp->paint(do_save_bg);
- return 0;
-}
-
-int CLuaInstance::CPictureHide(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaPicture *m = CPictureCheck(L, 1);
- if (!m) return 0;
-
- bool no_restore = false;
- if (!tableLookup(L, "no_restore", no_restore))
- {
- std::string tmp = "false";
- if (tableLookup(L, "no_restore", tmp))
- paramBoolDeprecated(L, tmp.c_str());
- no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
- }
- if (m->parent) {
- m->cp->setPicture("");
- m->cp->paint();
- } else
- m->cp->hide(no_restore);
- return 0;
-}
-
-int CLuaInstance::CPictureSetPicture(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaPicture *m = CPictureCheck(L, 1);
- if (!m) return 0;
-
- std::string image_name = "";
- tableLookup(L, "image", image_name);
-
- m->cp->setPicture(image_name);
- return 0;
-}
-
-int CLuaInstance::CPictureSetCenterPos(lua_State *L)
-{
- lua_assert(lua_istable(L,1));
- CLuaPicture *m = CPictureCheck(L, 1);
- if (!m) return 0;
- lua_Integer tmp_along_mode, along_mode = CC_ALONG_X | CC_ALONG_Y;
- tableLookup(L, "along_mode", tmp_along_mode);
-
- if(tmp_along_mode & CC_ALONG_X || tmp_along_mode & CC_ALONG_Y)
- along_mode=tmp_along_mode;
-
- m->cp->setCenterPos(along_mode);
- return 0;
-}
-
-int CLuaInstance::CPictureDelete(lua_State *L)
-{
- LUA_DEBUG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
- CLuaPicture *m = CPictureCheck(L, 1);
- if (!m) return 0;
-
- delete m;
- return 0;
-}
-
-// --------------------------------------------------------------------------------
-
int CLuaInstance::checkVersion(lua_State *L)
{
int numargs = lua_gettop(L);
diff --git a/src/gui/lua/luainstance.h b/src/gui/lua/luainstance.h
index 2c6ab30ea..8b9b04baa 100644
--- a/src/gui/lua/luainstance.h
+++ b/src/gui/lua/luainstance.h
@@ -28,7 +28,6 @@ extern "C" {
#include
#include
#include
-#include
#include
#include "luainstance_helpers.h"
@@ -54,42 +53,6 @@ class CLuaMessagebox
~CLuaMessagebox();
};
-class CLuaCWindow
-{
- public:
- CComponentsWindow *w;
- CLuaCWindow() { w = NULL; }
- ~CLuaCWindow() { delete w; }
-};
-
-class CLuaSignalBox
-{
- public:
- CSignalBox *s;
- CComponentsForm *parent;
- CLuaSignalBox() { s = NULL; parent = NULL;}
- ~CLuaSignalBox() { if (parent == NULL) delete s; }
-};
-
-class CLuaComponentsText
-{
- public:
- CComponentsText *ct;
- CComponentsForm *parent;
- int mode, font_text;
- CLuaComponentsText() { ct = NULL; parent = NULL; mode = 0; font_text = 0;}
- ~CLuaComponentsText() { if (parent == NULL) delete ct; }
-};
-
-class CLuaPicture
-{
- public:
- CComponentsPicture *cp;
- CComponentsForm *parent;
- CLuaPicture() { cp = NULL; parent = NULL; }
- ~CLuaPicture() { if (parent == NULL) delete cp; }
-};
-
/* inspired by Steve Kemp http://www.steve.org.uk/ */
class CLuaInstance
{
@@ -154,48 +117,6 @@ private:
static int MessageboxExec(lua_State *L);
static CLuaMessagebox *MessageboxCheck(lua_State *L, int n);
- void CWindowRegister(lua_State *L);
- static int CWindowNew(lua_State *L);
- static CLuaCWindow *CWindowCheck(lua_State *L, int n);
- static int CWindowPaint(lua_State *L);
- static int CWindowHide(lua_State *L);
- static int CWindowSetCaption(lua_State *L);
- static int CWindowSetWindowColor(lua_State *L);
- static int CWindowPaintHeader(lua_State *L);
- static int CWindowGetHeaderHeight(lua_State *L);
- static int CWindowGetFooterHeight(lua_State *L);
- static int CWindowGetHeaderHeight_dep(lua_State *L); // function 'header_height' is deprecated
- static int CWindowGetFooterHeight_dep(lua_State *L); // function 'footer_height' is deprecated
- static int CWindowSetCenterPos(lua_State *L);
- static int CWindowDelete(lua_State *L);
-
- static CLuaSignalBox *SignalBoxCheck(lua_State *L, int n);
- static void SignalBoxRegister(lua_State *L);
- static int SignalBoxNew(lua_State *L);
- static int SignalBoxPaint(lua_State *L);
- static int SignalBoxSetCenterPos(lua_State *L);
- static int SignalBoxDelete(lua_State *L);
-
- static CLuaComponentsText *ComponentsTextCheck(lua_State *L, int n);
- static void ComponentsTextRegister(lua_State *L);
- static int ComponentsTextNew(lua_State *L);
- static int ComponentsTextPaint(lua_State *L);
- static int ComponentsTextHide(lua_State *L);
- static int ComponentsTextSetText(lua_State *L);
- static int ComponentsTextScroll(lua_State *L);
- static int ComponentsTextSetCenterPos(lua_State *L);
- static int ComponentsTextEnableUTF8(lua_State *L);
- static int ComponentsTextDelete(lua_State *L);
-
- static CLuaPicture *CPictureCheck(lua_State *L, int n);
- static void CPictureRegister(lua_State *L);
- static int CPictureNew(lua_State *L);
- static int CPicturePaint(lua_State *L);
- static int CPictureHide(lua_State *L);
- static int CPictureSetPicture(lua_State *L);
- static int CPictureSetCenterPos(lua_State *L);
- static int CPictureDelete(lua_State *L);
-
static int checkVersion(lua_State *L);
static int createChannelIDfromUrl(lua_State *L);
static int enableInfoClock(lua_State *L);