A phenomenological thermodynamic theory of ferroelectric thin films epitaxially grown on cubic substrates is developed using a new form of the Gibbs function, which corresponds to the actual mechanical boundary conditions of the problem. It is found that the 2D-clamping of the films results not only in a shift of the transition temperature but also in a change of its order. For single-domain BaTiO3 and PbTiO3 films, the "misfit strain-temperature" phase diagram is constructed. For PbTiO3 films, the existence of a phase forbidden for the crystals is predicted. The intrinsic piezoelectric response of BaTiO3 films is calculated as a function of the misfit strain.