Updating trunk VERSION from 968.0 to 969.0
[chromium-blink-merge.git] / printing / print_settings.h
blob44d6aa5716bcb0aae4d98cda0d3e0d988edca3a6
1 // Copyright (c) 2011 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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/string16.h"
12 #include "printing/page_range.h"
13 #include "printing/page_setup.h"
14 #include "printing/print_job_constants.h"
15 #include "printing/printing_export.h"
16 #include "ui/gfx/rect.h"
18 namespace printing {
20 // Returns true if color model is selected.
21 PRINTING_EXPORT bool isColorModelSelected(int model);
23 #if defined(USE_CUPS)
24 // Get the color model setting name and value for the |color_mode|.
25 PRINTING_EXPORT void GetColorModelForMode(int color_mode,
26 std::string* color_setting_name,
27 std::string* color_value);
28 #endif
30 // OS-independent print settings.
31 class PRINTING_EXPORT PrintSettings {
32 public:
33 PrintSettings();
34 ~PrintSettings();
36 // Reinitialize the settings to the default values.
37 void Clear();
39 // Set printer printable area in in device units.
40 void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units,
41 gfx::Rect const& printable_area_device_units,
42 int units_per_inch);
44 void SetCustomMargins(const PageMargins& requested_margins_in_points);
46 // Equality operator.
47 // NOTE: printer_name is NOT tested for equality since it doesn't affect the
48 // output.
49 bool Equals(const PrintSettings& rhs) const;
51 void set_landscape(bool landscape) { landscape_ = landscape; }
52 void set_printer_name(const string16& printer_name) {
53 printer_name_ = printer_name;
55 const string16& printer_name() const { return printer_name_; }
56 void set_device_name(const string16& device_name) {
57 device_name_ = device_name;
59 const string16& device_name() const { return device_name_; }
60 void set_dpi(int dpi) { dpi_ = dpi; }
61 int dpi() const { return dpi_; }
62 void set_supports_alpha_blend(bool supports_alpha_blend) {
63 supports_alpha_blend_ = supports_alpha_blend;
65 bool supports_alpha_blend() const { return supports_alpha_blend_; }
66 const PageSetup& page_setup_device_units() const {
67 return page_setup_device_units_;
69 int device_units_per_inch() const {
70 #if defined(OS_MACOSX)
71 return 72;
72 #else // defined(OS_MACOSX)
73 return dpi();
74 #endif // defined(OS_MACOSX)
77 // Multi-page printing. Each PageRange describes a from-to page combination.
78 // This permits printing selected pages only.
79 PageRanges ranges;
81 // By imaging to a width a little wider than the available pixels, thin pages
82 // will be scaled down a little, matching the way they print in IE and Camino.
83 // This lets them use fewer sheets than they would otherwise, which is
84 // presumably why other browsers do this. Wide pages will be scaled down more
85 // than this.
86 double min_shrink;
88 // This number determines how small we are willing to reduce the page content
89 // in order to accommodate the widest line. If the page would have to be
90 // reduced smaller to make the widest line fit, we just clip instead (this
91 // behavior matches MacIE and Mozilla, at least)
92 double max_shrink;
94 // Desired visible dots per inch rendering for output. Printing should be
95 // scaled to ScreenDpi/dpix*desired_dpi.
96 int desired_dpi;
98 // Indicates if the user only wants to print the current selection.
99 bool selection_only;
101 // Indicates what kind of margins should be applied to the printable area.
102 MarginType margin_type;
104 // Cookie generator. It is used to initialize PrintedDocument with its
105 // associated PrintSettings, to be sure that each generated PrintedPage is
106 // correctly associated with its corresponding PrintedDocument.
107 static int NewCookie();
109 // Updates the orientation and flip the page if needed.
110 void SetOrientation(bool landscape);
112 // Strings to be printed as headers and footers if requested by the user.
113 string16 date;
114 string16 title;
115 string16 url;
117 // True if the user wants headers and footers to be displayed.
118 bool display_header_footer;
120 private:
121 //////////////////////////////////////////////////////////////////////////////
122 // Settings that can't be changed without side-effects.
124 // Printer name as shown to the user.
125 string16 printer_name_;
127 // Printer device name as opened by the OS.
128 string16 device_name_;
130 // Page setup in device units.
131 PageSetup page_setup_device_units_;
133 // Printer's device effective dots per inch in both axis.
134 int dpi_;
136 // Is the orientation landscape or portrait.
137 bool landscape_;
139 // True if this printer supports AlphaBlend.
140 bool supports_alpha_blend_;
142 // If margin type is custom, this is what was requested.
143 PageMargins requested_custom_margins_in_points_;
146 } // namespace printing
148 #endif // PRINTING_PRINT_SETTINGS_H_