Theory of the optical properties of semiconductor nanostructures