blob: 298fcd2bf1f926b7f8d875c3f0c752754ff2fef8 [file] [log] [blame]
[email protected]6d156892010-10-05 20:49:221// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]8ff1d422009-07-07 21:31:395#ifndef PRINTING_PRINT_SETTINGS_H_
6#define PRINTING_PRINT_SETTINGS_H_
initial.commit09911bf2008-07-26 23:55:297
[email protected]e0fc2f12010-03-14 23:30:598#include "gfx/rect.h"
[email protected]8ff1d422009-07-07 21:31:399#include "printing/page_overlays.h"
10#include "printing/page_range.h"
11#include "printing/page_setup.h"
initial.commit09911bf2008-07-26 23:55:2912
initial.commit09911bf2008-07-26 23:55:2913namespace printing {
14
15// OS-independent print settings.
16class PrintSettings {
17 public:
18 PrintSettings();
[email protected]20f0487a2010-09-30 20:06:3019 ~PrintSettings();
initial.commit09911bf2008-07-26 23:55:2920
21 // Reinitialize the settings to the default values.
22 void Clear();
23
[email protected]6ab86ac2010-05-29 07:18:2924 // Set printer printable area in in device units.
25 void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units,
26 gfx::Rect const& printable_area_device_units,
27 int units_per_inch);
initial.commit09911bf2008-07-26 23:55:2928
initial.commit09911bf2008-07-26 23:55:2929 // Equality operator.
30 // NOTE: printer_name is NOT tested for equality since it doesn't affect the
31 // output.
32 bool Equals(const PrintSettings& rhs) const;
33
[email protected]4993f342010-10-26 17:57:5234 void set_landscape(bool landscape) { landscape_ = landscape; }
35 void set_printer_name(const std::wstring& printer_name) {
36 printer_name_ = printer_name;
37 }
initial.commit09911bf2008-07-26 23:55:2938 const std::wstring& printer_name() const { return printer_name_; }
39 void set_device_name(const std::wstring& device_name) {
40 device_name_ = device_name;
41 }
42 const std::wstring& device_name() const { return device_name_; }
[email protected]4993f342010-10-26 17:57:5243 void set_dpi(int dpi) { dpi_ = dpi; }
initial.commit09911bf2008-07-26 23:55:2944 int dpi() const { return dpi_; }
[email protected]b2b0fce2011-01-12 16:34:4045 void set_supports_alpha_blend(bool supports_alpha_blend) {
46 supports_alpha_blend_ = supports_alpha_blend;
47 }
48 bool supports_alpha_blend() const { return supports_alpha_blend_; }
[email protected]6ab86ac2010-05-29 07:18:2949 const PageSetup& page_setup_device_units() const {
50 return page_setup_device_units_;
51 }
52 int device_units_per_inch() const {
53#if defined(OS_MACOSX)
54 return 72;
55#else // defined(OS_MACOSX)
56 return dpi();
57#endif // defined(OS_MACOSX)
58 }
initial.commit09911bf2008-07-26 23:55:2959
[email protected]4ecd07452009-03-31 14:34:4360 // Multi-page printing. Each PageRange describes a from-to page combination.
61 // This permits printing selected pages only.
initial.commit09911bf2008-07-26 23:55:2962 PageRanges ranges;
63
64 // By imaging to a width a little wider than the available pixels, thin pages
65 // will be scaled down a little, matching the way they print in IE and Camino.
66 // This lets them use fewer sheets than they would otherwise, which is
67 // presumably why other browsers do this. Wide pages will be scaled down more
68 // than this.
69 double min_shrink;
70
71 // This number determines how small we are willing to reduce the page content
72 // in order to accommodate the widest line. If the page would have to be
73 // reduced smaller to make the widest line fit, we just clip instead (this
74 // behavior matches MacIE and Mozilla, at least)
75 double max_shrink;
76
77 // Desired visible dots per inch rendering for output. Printing should be
78 // scaled to ScreenDpi/dpix*desired_dpi.
79 int desired_dpi;
80
81 // The various overlays (headers and footers).
82 PageOverlays overlays;
83
[email protected]c8ad40c2009-06-08 17:05:2184 // Indicates if the user only wants to print the current selection.
85 bool selection_only;
86
[email protected]38bba4f2010-03-12 05:29:0787 // Indicates whether we should use browser-controlled page overlays
88 // (header, footer, margins etc). If it is false, the overlays are
89 // controlled by the renderer.
90 bool use_overlays;
91
[email protected]d30e8e642008-08-06 12:05:2492 // Cookie generator. It is used to initialize PrintedDocument with its
93 // associated PrintSettings, to be sure that each generated PrintedPage is
94 // correctly associated with its corresponding PrintedDocument.
initial.commit09911bf2008-07-26 23:55:2995 static int NewCookie();
96
97 private:
98 //////////////////////////////////////////////////////////////////////////////
99 // Settings that can't be changed without side-effects.
100
101 // Printer name as shown to the user.
102 std::wstring printer_name_;
103
104 // Printer device name as opened by the OS.
105 std::wstring device_name_;
106
[email protected]6ab86ac2010-05-29 07:18:29107 // Page setup in device units.
108 PageSetup page_setup_device_units_;
initial.commit09911bf2008-07-26 23:55:29109
110 // Printer's device effective dots per inch in both axis.
111 int dpi_;
112
113 // Is the orientation landscape or portrait.
114 bool landscape_;
[email protected]b2b0fce2011-01-12 16:34:40115
116 // True if this printer supports AlphaBlend.
117 bool supports_alpha_blend_;
initial.commit09911bf2008-07-26 23:55:29118};
119
120} // namespace printing
121
[email protected]8ff1d422009-07-07 21:31:39122#endif // PRINTING_PRINT_SETTINGS_H_