Dichroism and resonant diffraction in x-ray scattering by complex materials