From 165afd0d36abc8729b28e303077ed285b577caea Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 18 Mar 2011 07:18:56 +0000 Subject: Moved lua methods into their respective Qt widget implementation files. --- client/widgets/combobox.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'client/widgets/combobox.cc') diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc index c06e145..768f035 100644 --- a/client/widgets/combobox.cc +++ b/client/widgets/combobox.cc @@ -40,6 +40,7 @@ #include "common.h" #include "debug.h" +#include "luawidget.h" // Enable this to make the combobox drawn in windows style. // This will make its background red even when not expanded. @@ -267,3 +268,59 @@ void ComboBox::setLineEditValue(QString value) } ignoreChangeEvents = false; } + +int cmb_clear(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox"); + luaL_argcheck(L, wdgu, 1, "combobox expected"); + + ComboBox *cmb = (ComboBox*)wdgu->widget; + cmb->clear(); + + return 0; +} + +int cmb_add_item(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox"); + luaL_argcheck(L, wdgu, 1, "combobox expected"); + + QString val = luaL_checkstring(L, 2); + + ComboBox *cmb = (ComboBox*)wdgu->widget; + cmb->addItem(val); + + return 0; +} + +int cmb_le_value(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox"); + luaL_argcheck(L, wdgu, 1, "combobox expected"); + + ComboBox *cmb = (ComboBox*)wdgu->widget; + lua_pushstring(L, cmb->lineEditValue().toStdString().c_str()); + + return 1; +} + +int cmb_le_set_value(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)luaL_isudata(L, 1, "ComboBox"); + luaL_argcheck(L, wdgu, 1, "combobox expected"); + + const char *val = luaL_checkstring(L, 2); + + ComboBox *cmb = (ComboBox*)wdgu->widget; + cmb->setLineEditValue(val); + + return 0; +} -- cgit v1.2.3