Generalized spline spaces over T-meshes: Dimension formula and locally refined generalized B-splines