Multiwave diffraction theory of magnetic phase gratings and its application to ferromagnetic stripe domains in K2CuF4