示例#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;
	}
示例#2
0
	static int l_set_column(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		UI::Context *c = g->GetContext();

		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);
			if (lua_isnil(l, -1))
				g->ClearCell(colNum, i);
			else
				g->SetCell(colNum, i, UI::Lua::CheckWidget(c, l, -1));
			lua_pop(l, 1);
		}

		lua_pushvalue(l, 1);
		return 1;
	}