From 6389aabffe198ece92b58ae34a905902c7eefe7c Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 28 Jun 2011 06:38:10 +0000 Subject: Complete rewrite of the way lua widget methods, 'inheritance' in particular, are handled. --- client/widgets/combobox.h | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'client/widgets/combobox.h') diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h index 92a0e39..bf61b1a 100644 --- a/client/widgets/combobox.h +++ b/client/widgets/combobox.h @@ -32,11 +32,19 @@ #include "widget.h" +#ifdef LUA_CLASS +#undef LUA_CLASS +#endif +#define LUA_CLASS "ComboBox" + /*** * ComboBox Widget * @tag combobox + * @screenshot Example + * + * + * * @extends widget - * @screenshot * The ComboBox is used to make a selection from a list of items. * The ComboBox contains <item> tags each describing * an entry in the selection list. @@ -67,6 +75,8 @@ public: ComboBox(QDomNode &node, MacroWindow *macrowindow); ~ComboBox(); + virtual QString luaclass() { return LUA_CLASS; } + QString value(); void setValue(QString value, QString source = ""); @@ -78,7 +88,7 @@ public: void setWdgValid(bool valid); void clear(); - void addItem(QString item); + void addItem(QString item, QString value); public slots: void changed(); @@ -89,17 +99,48 @@ protected: void changeEvent(QEvent *event); private: + void updateSearchList(); + QRegExp rx; types_t combotype; bool ischangingbyuser; QComboBox *combobox; bool ignoreChangeEvents; + + QStringList itemlist; }; +/*** + * @method nil clear() + * This method removes all items from the combobox. + */ int cmb_clear(lua_State *L); + +/*** + * @method nil addItem(string caption, string value) + * This method adds an item to the selectionlist of the combobox. + * @param caption The item text to be added. It will be added both as the value + * and caption of the item. + * @param value The item value. This value is optional. If left out, the + * caption will be used as the item value. + */ int cmb_add_item(lua_State *L); + +/*** + * @method string lineEditValue() + * This method is used to get the value from the combobox lineedit (in case it + * is in edit mode). + * @return a string containing the current value of the combobox lineedit. + */ int cmb_le_value(lua_State *L); + +/*** + * @method nil setLineEditValue(string text) + * This method is used to set the value of the combobox lineedit (in case it + * is in edit mode). + * @param text The text string to be set. + */ int cmb_le_set_value(lua_State *L); #define CMBBOX_METHS \ @@ -113,7 +154,7 @@ const struct luaL_Reg cmbbox_meths[] = inline void register_combobox(lua_State *L) { - luaL_newmetatable(L, "ComboBox"); + luaL_newmetatable(L, LUA_CLASS); lua_pushliteral(L, "__index"); lua_pushvalue(L, -2); lua_rawset(L, -3); -- cgit v1.2.3