mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 17:01:15 +02:00
CLuaInstance: Add setText function to ctext
This commit is contained in:
@@ -1537,6 +1537,7 @@ void CLuaInstance::ComponentsTextRegister(lua_State *L)
|
|||||||
{ "new", CLuaInstance::ComponentsTextNew },
|
{ "new", CLuaInstance::ComponentsTextNew },
|
||||||
{ "paint", CLuaInstance::ComponentsTextPaint },
|
{ "paint", CLuaInstance::ComponentsTextPaint },
|
||||||
{ "hide", CLuaInstance::ComponentsTextHide },
|
{ "hide", CLuaInstance::ComponentsTextHide },
|
||||||
|
{ "setText", CLuaInstance::ComponentsTextSetText },
|
||||||
{ "scroll", CLuaInstance::ComponentsTextScroll },
|
{ "scroll", CLuaInstance::ComponentsTextScroll },
|
||||||
{ "__gc", CLuaInstance::ComponentsTextDelete },
|
{ "__gc", CLuaInstance::ComponentsTextDelete },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
@@ -1610,6 +1611,8 @@ int CLuaInstance::ComponentsTextNew(lua_State *L)
|
|||||||
*udata = new 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)->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)->parent = pw;
|
||||||
|
(*udata)->mode = mode;
|
||||||
|
(*udata)->font_text = font_text;
|
||||||
luaL_getmetatable(L, "ctext");
|
luaL_getmetatable(L, "ctext");
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1639,8 +1642,28 @@ int CLuaInstance::ComponentsTextHide(lua_State *L)
|
|||||||
tableLookup(L, "no_restore", tmp);
|
tableLookup(L, "no_restore", tmp);
|
||||||
bool no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
|
bool no_restore = (tmp == "true" || tmp == "1" || tmp == "yes");
|
||||||
|
|
||||||
m->ct->hide(no_restore);
|
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 = "";
|
||||||
|
int mode = m->mode;
|
||||||
|
int 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,7 +139,8 @@ class CLuaComponentsText
|
|||||||
public:
|
public:
|
||||||
CComponentsText *ct;
|
CComponentsText *ct;
|
||||||
CComponentsForm *parent;
|
CComponentsForm *parent;
|
||||||
CLuaComponentsText() { ct = NULL; parent = NULL;}
|
int mode, font_text;
|
||||||
|
CLuaComponentsText() { ct = NULL; parent = NULL; mode = 0; font_text = 0;}
|
||||||
~CLuaComponentsText() { if (parent == NULL) delete ct; }
|
~CLuaComponentsText() { if (parent == NULL) delete ct; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -214,6 +215,7 @@ private:
|
|||||||
static int ComponentsTextNew(lua_State *L);
|
static int ComponentsTextNew(lua_State *L);
|
||||||
static int ComponentsTextPaint(lua_State *L);
|
static int ComponentsTextPaint(lua_State *L);
|
||||||
static int ComponentsTextHide(lua_State *L);
|
static int ComponentsTextHide(lua_State *L);
|
||||||
|
static int ComponentsTextSetText(lua_State *L);
|
||||||
static int ComponentsTextScroll(lua_State *L);
|
static int ComponentsTextScroll(lua_State *L);
|
||||||
static int ComponentsTextDelete(lua_State *L);
|
static int ComponentsTextDelete(lua_State *L);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user