1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PRINT_SETTINGS_H_
6 #define PRINTING_PRINT_SETTINGS_H_
10 #include "base/strings/string16.h"
11 #include "printing/page_range.h"
12 #include "printing/page_setup.h"
13 #include "printing/print_job_constants.h"
14 #include "printing/printing_export.h"
15 #include "ui/gfx/rect.h"
19 // Returns true if color model is selected.
20 PRINTING_EXPORT
bool isColorModelSelected(int model
);
23 // Get the color model setting name and value for the |color_mode|.
24 PRINTING_EXPORT
void GetColorModelForMode(int color_mode
,
25 std::string
* color_setting_name
,
26 std::string
* color_value
);
29 // OS-independent print settings.
30 class PRINTING_EXPORT PrintSettings
{
35 // Reinitialize the settings to the default values.
38 // Set printer printable area in in device units.
39 void SetPrinterPrintableArea(gfx::Size
const& physical_size_device_units
,
40 gfx::Rect
const& printable_area_device_units
,
43 void SetCustomMargins(const PageMargins
& requested_margins_in_points
);
46 // NOTE: printer_name is NOT tested for equality since it doesn't affect the
48 bool Equals(const PrintSettings
& rhs
) const;
50 void set_landscape(bool landscape
) { landscape_
= landscape
; }
51 void set_printer_name(const string16
& printer_name
) {
52 printer_name_
= printer_name
;
54 const string16
& printer_name() const { return printer_name_
; }
55 void set_device_name(const string16
& device_name
) {
56 device_name_
= device_name
;
58 const string16
& device_name() const { return device_name_
; }
59 void set_dpi(int dpi
) { dpi_
= dpi
; }
60 int dpi() const { return dpi_
; }
61 void set_supports_alpha_blend(bool supports_alpha_blend
) {
62 supports_alpha_blend_
= supports_alpha_blend
;
64 bool supports_alpha_blend() const { return supports_alpha_blend_
; }
65 const PageSetup
& page_setup_device_units() const {
66 return page_setup_device_units_
;
68 int device_units_per_inch() const {
69 #if defined(OS_MACOSX)
71 #else // defined(OS_MACOSX)
73 #endif // defined(OS_MACOSX)
76 // Multi-page printing. Each PageRange describes a from-to page combination.
77 // This permits printing selected pages only.
80 // By imaging to a width a little wider than the available pixels, thin pages
81 // will be scaled down a little, matching the way they print in IE and Camino.
82 // This lets them use fewer sheets than they would otherwise, which is
83 // presumably why other browsers do this. Wide pages will be scaled down more
87 // This number determines how small we are willing to reduce the page content
88 // in order to accommodate the widest line. If the page would have to be
89 // reduced smaller to make the widest line fit, we just clip instead (this
90 // behavior matches MacIE and Mozilla, at least)
93 // Desired visible dots per inch rendering for output. Printing should be
94 // scaled to ScreenDpi/dpix*desired_dpi.
97 // Indicates if the user only wants to print the current selection.
100 // Indicates what kind of margins should be applied to the printable area.
101 MarginType margin_type
;
103 // Cookie generator. It is used to initialize PrintedDocument with its
104 // associated PrintSettings, to be sure that each generated PrintedPage is
105 // correctly associated with its corresponding PrintedDocument.
106 static int NewCookie();
108 // Updates the orientation and flip the page if needed.
109 void SetOrientation(bool landscape
);
111 // Strings to be printed as headers and footers if requested by the user.
116 // True if the user wants headers and footers to be displayed.
117 bool display_header_footer
;
119 // True if the user wants to print CSS backgrounds.
120 bool should_print_backgrounds
;
123 //////////////////////////////////////////////////////////////////////////////
124 // Settings that can't be changed without side-effects.
126 // Printer name as shown to the user.
127 string16 printer_name_
;
129 // Printer device name as opened by the OS.
130 string16 device_name_
;
132 // Page setup in device units.
133 PageSetup page_setup_device_units_
;
135 // Printer's device effective dots per inch in both axis.
138 // Is the orientation landscape or portrait.
141 // True if this printer supports AlphaBlend.
142 bool supports_alpha_blend_
;
144 // If margin type is custom, this is what was requested.
145 PageMargins requested_custom_margins_in_points_
;
148 } // namespace printing
150 #endif // PRINTING_PRINT_SETTINGS_H_