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/widget.h | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'client/widgets/widget.h') diff --git a/client/widgets/widget.h b/client/widgets/widget.h index 3de148f..d0f1799 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -32,9 +32,15 @@ #include #include #include +#include #include "lua.h" +#ifdef LUA_CLASS +#undef LUA_CLASS +#endif +#define LUA_CLASS "Widget" + /*** * Virtual Base Widget * This tag is purely virtual. It is inherited by all other widgets. @@ -71,6 +77,8 @@ public: QString type(); bool local(); + virtual QString luaclass() { return LUA_CLASS; } + virtual QString value() = 0; virtual void setValue(QString value, QString source) = 0; @@ -93,9 +101,12 @@ public: virtual void setVisible(bool visible); virtual bool visible(); + virtual void setHidden(bool hidden); + virtual bool hidden(); + virtual bool setKeyboardFocus(); - QWidget *qwidget() { return widget; } + virtual QWidget *qwidget() { return widget; } // Set deep to true to search through inner widgets. Widget *findWidget(QString name, bool deep = false); @@ -153,6 +164,8 @@ protected: bool hasOnInitEvent; QString onInitEventScript; + + QFrame *replwidget; }; /*** @@ -206,8 +219,8 @@ int wdg_set_enabled(lua_State *L); /*** * @method boolean visible() - * This method is used to get the current enable state of the widget. - * @return a boolean value. If the widget is enabled the method returns true + * This method is used to get the current visibility state of the widget. + * @return a boolean value. If the widget is visible the method returns true * otherwise it returns false. */ int wdg_visible(lua_State *L); @@ -218,13 +231,32 @@ int wdg_visible(lua_State *L); * The widget will take up an equal amount of layout space regardless of its * visibility state meaning that the layout will remain static after a * hiding/showing of the widget. - * NOTE: A hidden widget will not supply its value to the server + * NOTE: An invisble widget will not supply its value to the server * during a commit. * @param visible A boolean value. If true the widget is shown. If false the * widget is hidden. */ int wdg_set_visible(lua_State *L); +/*** + * @method boolean hidden() + * This method is used to get the current hide state of the widget. + * @return a boolean value. If the widget is hidden the method returns true + * otherwise it returns false. + */ +int wdg_hidden(lua_State *L); + +/*** + * @method nil setHidden(boolean hidden) + * This method is used to either show or hide the widget, collapsing the occupied + * space. + * NOTE: A hidden widget will not supply its value to the server + * during a commit. + * @param hidden A boolean value. If true the widget is hidden. If false the + * widget is shown. + */ +int wdg_set_hidden(lua_State *L); + /*** * @method boolean valid() * This method is used to get the current validity state of the widget. See @@ -255,6 +287,8 @@ int wdg_set_valid(lua_State *L); {"setEnabled", wdg_set_enabled},\ {"visible", wdg_visible},\ {"setVisible", wdg_set_visible},\ + {"hidden", wdg_hidden},\ + {"setHidden", wdg_set_hidden},\ {"valid", wdg_valid},\ {"setValid", wdg_set_valid} @@ -263,7 +297,7 @@ const struct luaL_Reg wdg_meths[] = inline void register_widget(lua_State *L) { - luaL_newmetatable(L, "Widget"); + luaL_newmetatable(L, LUA_CLASS); lua_pushliteral(L, "__index"); lua_pushvalue(L, -2); lua_rawset(L, -3); -- cgit v1.2.3