This source file includes following definitions.
- InitPrintSettings
#include "printing/print_settings_initializer_win.h"
#include <windows.h>
#include "printing/print_settings.h"
namespace printing {
void PrintSettingsInitializerWin::InitPrintSettings(
HDC hdc,
const DEVMODE& dev_mode,
PrintSettings* print_settings) {
DCHECK(hdc);
DCHECK(print_settings);
print_settings->SetOrientation(dev_mode.dmOrientation == DMORIENT_LANDSCAPE);
int dpi = GetDeviceCaps(hdc, LOGPIXELSX);
print_settings->set_dpi(dpi);
const int kAlphaCaps = SB_CONST_ALPHA | SB_PIXEL_ALPHA;
print_settings->set_supports_alpha_blend(
(GetDeviceCaps(hdc, SHADEBLENDCAPS) & kAlphaCaps) == kAlphaCaps);
DCHECK_EQ(dpi, GetDeviceCaps(hdc, LOGPIXELSY));
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORX), 0);
DCHECK_EQ(GetDeviceCaps(hdc, SCALINGFACTORY), 0);
gfx::Size physical_size_device_units(GetDeviceCaps(hdc, PHYSICALWIDTH),
GetDeviceCaps(hdc, PHYSICALHEIGHT));
gfx::Rect printable_area_device_units(GetDeviceCaps(hdc, PHYSICALOFFSETX),
GetDeviceCaps(hdc, PHYSICALOFFSETY),
GetDeviceCaps(hdc, HORZRES),
GetDeviceCaps(hdc, VERTRES));
if (printable_area_device_units.IsEmpty() ||
!gfx::Rect(physical_size_device_units).Contains(
printable_area_device_units)) {
printable_area_device_units = gfx::Rect(physical_size_device_units);
}
DCHECK_EQ(print_settings->device_units_per_inch(), dpi);
print_settings->SetPrinterPrintableArea(physical_size_device_units,
printable_area_device_units,
false);
}
}