Non-LTE line formation in a magnetic field. The two-level atom with a frequency independet source function. I. Formulation