diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-11-08 10:46:30 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-11-08 10:46:30 +0100 |
commit | 01ab57dabbc15f52143089e53317bb51b71dc7f2 (patch) | |
tree | a2ec194709f0d60d6162225d084340e1a7ab3cb8 /client/widgets/widget.cc | |
parent | df2f71c7021e507bdc6ba9c11b5b02775af19561 (diff) |
New lua and xml attr methods for setting widget foreground and background colours.
Diffstat (limited to 'client/widgets/widget.cc')
-rw-r--r-- | client/widgets/widget.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 2374c6f..ac90ef2 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -401,6 +401,26 @@ void Widget::setValues() else emit eventOnChange(); // Make sure we run validation on the unset widget. } +void Widget::setForegroundColour(unsigned char red, + unsigned char green, + unsigned char blue) +{ + char style[128]; + sprintf(style, "* { color: #%02x%02x%02x; }", + red, green, blue); + qwidget()->setStyleSheet(style); +} + +void Widget::setBackgroundColour(unsigned char red, + unsigned char green, + unsigned char blue) +{ + char style[128]; + sprintf(style, "* { background-color: #%02x%02x%02x; }", + red, green, blue); + qwidget()->setStyleSheet(style); +} + void Widget::createWidget(QDomNode &xml_node, QLayout *layout) { QDomElement xml_elem = xml_node.toElement(); @@ -655,3 +675,36 @@ int wdg_set_valid(lua_State *L) return 0; } + +int wdg_set_bgcol(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)lua_touserdata(L, 1); + luaL_argcheck(L, wdgu, 1, "widget expected"); + + int r = luaL_checknumber(L, 2); + int g = luaL_checknumber(L, 3); + int b = luaL_checknumber(L, 4); + + wdgu->widget->setBackgroundColour((unsigned char)r, (unsigned char)g, (unsigned char)b); + + return 0; +} + +int wdg_set_fgcol(lua_State *L) +{ + wdg_userdata *wdgu; + + wdgu = (wdg_userdata *)lua_touserdata(L, 1); + luaL_argcheck(L, wdgu, 1, "widget expected"); + + int r = luaL_checknumber(L, 2); + int g = luaL_checknumber(L, 3); + int b = luaL_checknumber(L, 4); + + wdgu->widget->setForegroundColour((unsigned char)r, (unsigned char)g, (unsigned char)b); + + return 0; +} + |