Esempio n. 1
0
	static int l_clear_cell(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		unsigned int colNum = luaL_checkinteger(l, 2);
		unsigned int rowNum = luaL_checkinteger(l, 3);
		g->ClearCell(colNum, rowNum);
		return 0;
	}
Esempio n. 2
0
	static int l_set_column(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		size_t colNum = luaL_checkinteger(l, 2);
		luaL_checktype(l, 3, LUA_TTABLE);

		if (colNum >= g->GetNumCols()) {
			luaL_error(l, "no such column %d (max is %d)", colNum, g->GetNumCols()-1);
			return 0;
		}

		for (size_t i = 0; i < g->GetNumRows() && i < lua_rawlen(l, 3); i++) {
			lua_rawgeti(l, 3, i+1);
			g->SetCell(colNum, i, LuaObject<UI::Widget>::CheckFromLua(-1));
			lua_pop(l, 1);
		}

		lua_pushvalue(l, 1);
		return 1;
	}
Esempio n. 3
0
	static int l_set_cell(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		UI::Context *c = g->GetContext();

		size_t colNum = luaL_checkinteger(l, 2);
		size_t rowNum = luaL_checkinteger(l, 3);
		UI::Widget *w = UI::Lua::CheckWidget(c, l, 4);

		if (colNum >= g->GetNumCols()) {
			luaL_error(l, "no such column %d (max is %d)", colNum, g->GetNumCols()-1);
			return 0;
		}
		if (rowNum >= g->GetNumRows()) {
			luaL_error(l, "no such row %d (max is %d)", rowNum, g->GetNumRows()-1);
			return 0;
		}

		g->SetCell(colNum, rowNum, w);

		lua_pushvalue(l, 1);
		return 1;
	}
Esempio n. 4
0
	static int l_set_row(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		UI::Context *c = g->GetContext();

		size_t rowNum = luaL_checkinteger(l, 2);
		luaL_checktype(l, 3, LUA_TTABLE);

		if (rowNum >= g->GetNumRows()) {
			luaL_error(l, "no such row %d (max is %d)", rowNum, g->GetNumRows()-1);
			return 0;
		}

		for (size_t i = 0; i < g->GetNumCols() && i < lua_rawlen(l, 3); i++) {
			lua_rawgeti(l, 3, i+1);
			if (lua_isnil(l, -1))
				g->ClearCell(i, rowNum);
			else
				g->SetCell(i, rowNum, UI::Lua::CheckWidget(c, l, -1));
			lua_pop(l, 1);
		}

		lua_pushvalue(l, 1);
		return 1;
	}
Esempio n. 5
0
	static int l_clear_column(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		g->ClearColumn(luaL_checkinteger(l, 2));
		return 0;
	}
Esempio n. 6
0
	static int l_clear(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		g->Clear();
		return 0;
	}