summaryrefslogtreecommitdiff
path: root/client/widgets/listbox.h
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/listbox.h')
-rw-r--r--client/widgets/listbox.h70
1 files changed, 69 insertions, 1 deletions
diff --git a/client/widgets/listbox.h b/client/widgets/listbox.h
index fcfc1b0..82c5dfc 100644
--- a/client/widgets/listbox.h
+++ b/client/widgets/listbox.h
@@ -31,10 +31,28 @@
#include <QDomNode>
+#ifdef LUA_CLASS
+#undef LUA_CLASS
+#endif
+#define LUA_CLASS "ListBox"
+
/***
* ListBox Widget
* @tag listbox
- * @screenshot
+ * @screenshot Example
+ * <listbox name="x" value="item1">
+ * <item type="header" value="" caption="Numbers"/>
+ * <item value="item1" caption="Item 1"/>
+ * <item value="item2" caption="Item 2"/>
+ * <item value="item3" caption="Item 3"/>
+ * <item value="item4" caption="Item 4"/>
+ * <item value="" caption="" type="separator"/>
+ * <item type="header" value="" caption="Letters"/>
+ * <item value="itemA" caption="Item A"/>
+ * <item value="itemB" caption="Item B"/>
+ * <item value="itemC" caption="Item C"/>
+ * <item value="itemD" caption="Item D"/>
+ * </listbox>
* @extends widget
* This widget is a list of selectable items.
* @att value [item] The value of the item and the value of the widget if this
@@ -54,12 +72,17 @@ public:
ListBox(QDomNode &node, MacroWindow *macrowindow);
~ListBox();
+ virtual QString luaclass() { return LUA_CLASS; }
+
QString value();
void setValue(QString value, QString source);
bool preValid();
void setWdgValid(bool valid);
+ void clear();
+ void addItem(QString text, QString type);
+
public slots:
void changed();
@@ -68,4 +91,49 @@ private:
QListWidget *listwidget;
};
+/***
+ * @method nil clear()
+ * This method removes all items from the listbox.
+ */
+int lst_clear(lua_State *L);
+
+/***
+ * @method nil addItem(string text)
+ * This method adds an item to the list.
+ * @param text The item text to be added. It will be added both as the value
+ * and caption of the item.
+ */
+int lst_add_item(lua_State *L);
+
+/***
+ * @method nil addHeader(string text)
+ * This method adds a header item to the list.
+ * @param text The caption of the header.
+ */
+int lst_add_header(lua_State *L);
+
+/***
+ * @method nil addSeparator()
+ * This method adds a separator item to the list.
+ */
+int lst_add_separator(lua_State *L);
+
+#define LSTBOX_METHS \
+ {"clear", lst_clear},\
+ {"addItem", lst_add_item}, \
+ {"addHeader", lst_add_header}, \
+ {"addSeparator", lst_add_separator}
+
+const struct luaL_Reg lstbox_meths[] =
+ { WDG_METHS, LSTBOX_METHS, {NULL, NULL} };
+
+inline void register_listbox(lua_State *L)
+{
+ luaL_newmetatable(L, LUA_CLASS);
+ lua_pushliteral(L, "__index");
+ lua_pushvalue(L, -2);
+ lua_rawset(L, -3);
+ luaL_register(L, NULL, lstbox_meths);
+}
+
#endif/*__PRACRO_LISTBOX_H__*/