diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-17 11:20:58 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-17 11:20:58 (GMT) |
| commit | 6e44ebc358d1206c147f514225373da07b43c015 (patch) | |
| tree | 35e97c28991c4aff46a9e5a4182b53dedb26e7ee /src/cat/LuaProgressBar.cpp | |
| parent | e52e9ce91ccca13115fec0fdb0111e7e5d39d10d (diff) | |
| download | powder-6e44ebc358d1206c147f514225373da07b43c015.zip powder-6e44ebc358d1206c147f514225373da07b43c015.tar.gz | |
Checkbox, Slider and ProgressBar components for ui API
Diffstat (limited to 'src/cat/LuaProgressBar.cpp')
| -rw-r--r-- | src/cat/LuaProgressBar.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/cat/LuaProgressBar.cpp b/src/cat/LuaProgressBar.cpp new file mode 100644 index 0000000..71b8f7b --- /dev/null +++ b/src/cat/LuaProgressBar.cpp @@ -0,0 +1,71 @@ +extern "C" +{ +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" +} + +#include <iostream> +#include "LuaProgressBar.h" +#include "LuaScriptInterface.h" +#include "interface/ProgressBar.h" + +const char LuaProgressBar::className[] = "ProgressBar"; + +#define method(class, name) {#name, &class::name} +Luna<LuaProgressBar>::RegType LuaProgressBar::methods[] = { + method(LuaProgressBar, position), + method(LuaProgressBar, size), + method(LuaProgressBar, visible), + method(LuaProgressBar, progress), + method(LuaProgressBar, status), + {0, 0} +}; + +LuaProgressBar::LuaProgressBar(lua_State * l) : + LuaComponent(l) +{ + int posX = luaL_optinteger(l, 1, 0); + int posY = luaL_optinteger(l, 2, 0); + int sizeX = luaL_optinteger(l, 3, 10); + int sizeY = luaL_optinteger(l, 4, 10); + int value = luaL_optinteger(l, 5, 0); + std::string status = luaL_optstring(l, 6, ""); + + progressBar = new ui::ProgressBar(ui::Point(posX, posY), ui::Point(sizeX, sizeY), value, status); + component = progressBar; +} + +int LuaProgressBar::progress(lua_State * l) +{ + int args = lua_gettop(l); + if(args) + { + progressBar->SetProgress(lua_tointeger(l, 1)); + return 0; + } + else + { + lua_pushinteger(l, progressBar->GetProgress()); + return 1; + } +} + +int LuaProgressBar::status(lua_State * l) +{ + int args = lua_gettop(l); + if(args) + { + progressBar->SetStatus(std::string(lua_tostring(l, 1))); + return 0; + } + else + { + lua_pushstring(l, progressBar->GetStatus().c_str()); + return 1; + } +} + +LuaProgressBar::~LuaProgressBar() +{ +}
\ No newline at end of file |
