Gradient theory of wetting transitions