mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 00:41:17 +02:00
lua: add paintItem() for menu items
menu1:setSelected{id=<id>}
This commit is contained in:
@@ -77,6 +77,7 @@ void CLuaInstMenu::MenuRegister(lua_State *L)
|
|||||||
{ "setName", CLuaInstMenu::MenuSetName },
|
{ "setName", CLuaInstMenu::MenuSetName },
|
||||||
{ "setSelected", CLuaInstMenu::MenuSetSelected },
|
{ "setSelected", CLuaInstMenu::MenuSetSelected },
|
||||||
{ "setValue", CLuaInstMenu::MenuSetValue },
|
{ "setValue", CLuaInstMenu::MenuSetValue },
|
||||||
|
{ "paintItem", CLuaInstMenu::MenuPaintItem },
|
||||||
{ "__gc", CLuaInstMenu::MenuDelete },
|
{ "__gc", CLuaInstMenu::MenuDelete },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
@@ -612,3 +613,23 @@ int CLuaInstMenu::MenuSetValue(lua_State *L)
|
|||||||
static_cast<CMenuForwarder*>(item)->setOption(value);
|
static_cast<CMenuForwarder*>(item)->setOption(value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CLuaInstMenu::MenuPaintItem(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_assert(lua_istable(L, 2));
|
||||||
|
CLuaMenu *D = MenuCheck(L, 1);
|
||||||
|
if (!D) return 0;
|
||||||
|
|
||||||
|
lua_Integer id; tableLookup(L, "item", id);
|
||||||
|
|
||||||
|
CMenuItem* item = NULL;
|
||||||
|
for (itemmap_iterator_t it = D->itemmap.begin(); it != D->itemmap.end(); ++it) {
|
||||||
|
if (it->first == id) {
|
||||||
|
item = it->second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item)
|
||||||
|
item->paint();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -129,6 +129,7 @@ class CLuaInstMenu
|
|||||||
static int MenuDelete(lua_State *L);
|
static int MenuDelete(lua_State *L);
|
||||||
static int MenuSetSelected(lua_State *L);
|
static int MenuSetSelected(lua_State *L);
|
||||||
static int MenuSetValue(lua_State *L);
|
static int MenuSetValue(lua_State *L);
|
||||||
|
static int MenuPaintItem(lua_State *L);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_LUAMENUE_H
|
#endif //_LUAMENUE_H
|
||||||
|
Reference in New Issue
Block a user