예제 #1
0
파일: LuaGrid.cpp 프로젝트: Helioth/pioneer
	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;
	}
예제 #2
0
파일: LuaGrid.cpp 프로젝트: Helioth/pioneer
	static int l_set_cell(lua_State *l) {
		UI::Grid *g = LuaObject<UI::Grid>::CheckFromLua(1);
		size_t colNum = luaL_checkinteger(l, 2);
		size_t rowNum = luaL_checkinteger(l, 3);
		UI::Widget *w = LuaObject<UI::Widget>::CheckFromLua(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;
	}
예제 #3
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;
	}