A Comprehensive Theory of Electron Probe Microanalysis