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/altcombobox.h | 51 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'client/widgets/altcombobox.h') diff --git a/client/widgets/altcombobox.h b/client/widgets/altcombobox.h index ccc81cd..e6a21d7 100644 --- a/client/widgets/altcombobox.h +++ b/client/widgets/altcombobox.h @@ -30,16 +30,37 @@ #include "widget.h" #include "combobox.h" +#include "frame.h" #include #include +#ifdef LUA_CLASS +#undef LUA_CLASS +#endif +#define LUA_CLASS "AltComboBox" + /*** * ComboBox Widget with Alternate Value * @tag altcombobox * @extends combobox + * @screenshot Example: altitem selected. + * + * + * + * + * + * @screenshot Example: altitem not selected. + * + * + * + * + * * @container - * @screenshot * The AltComboBox is used to make a normal selection with a ComboBox but with * a special list item that shows an alternate widget and uses this widget for * input. The AltComboBox contains <item> tags in the same @@ -56,33 +77,45 @@ */ class QFrame; -class AltComboBox : public Widget +class QComboBox; +class AltComboBox : public ComboBox { Q_OBJECT public: AltComboBox(QDomNode &node, MacroWindow *macrowindow); ~AltComboBox(); + virtual QString luaclass() { return LUA_CLASS; } + QString value(); void setValue(QString value, QString source = ""); bool preValid(); - void setWdgValid(bool valid); - bool setKeyboardFocus(); + QComboBox *qcombobox(); public slots: - void onValueChange(int index); - void onValueChange(const QString &text); + void comboChanged(); void onChildChange(); private: QFrame *frame; - ComboBox *combobox; + QComboBox *combobox; Widget *innerwidget; QString altvalue; - QWidget *altframe; - QWidget *altframerepl; + Frame *altframe; }; +const struct luaL_Reg acmbbox_meths[] = + { WDG_METHS, CMBBOX_METHS, {NULL, NULL} }; + +inline void register_altcombobox(lua_State *L) +{ + luaL_newmetatable(L, LUA_CLASS); + lua_pushliteral(L, "__index"); + lua_pushvalue(L, -2); + lua_rawset(L, -3); + luaL_register(L, NULL, acmbbox_meths); +} + #endif/*__PRACRO_ALTCOMBOBOX_H__*/ -- cgit v1.2.3