blob: 07d2c544b229e92fb72042d0547cb512984f4f5b [file] [log] [blame]
[email protected]c48bee22011-03-29 02:36:261// Copyright (c) 2011 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]dcd1e8862011-08-09 06:06:588#include <string>
9
[email protected]55b23a02011-08-17 23:09:3610#include "base/memory/scoped_ptr.h"
11#include "base/string16.h"
[email protected]8ff1d422009-07-07 21:31:3912#include "printing/page_range.h"
13#include "printing/page_setup.h"
[email protected]1c23b4e82011-10-15 22:30:4814#include "printing/print_job_constants.h"
[email protected]63313ae2011-10-13 00:40:3915#include "printing/printing_export.h"
[email protected]08397d52011-02-05 01:53:3816#include "ui/gfx/rect.h"
initial.commit09911bf2008-07-26 23:55:2917
initial.commit09911bf2008-07-26 23:55:2918namespace printing {
19
[email protected]63313ae2011-10-13 00:40:3920// Returns true if color model is selected.
21PRINTING_EXPORT bool isColorModelSelected(int model);
22
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
29
initial.commit09911bf2008-07-26 23:55:2930// OS-independent print settings.
[email protected]69f5b1e62011-09-01 06:34:0431class PRINTING_EXPORT PrintSettings {
initial.commit09911bf2008-07-26 23:55:2932 public:
33 PrintSettings();
[email protected]20f0487a2010-09-30 20:06:3034 ~PrintSettings();
initial.commit09911bf2008-07-26 23:55:2935
36 // Reinitialize the settings to the default values.
37 void Clear();
38
[email protected]6ab86ac2010-05-29 07:18:2939 // 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);
initial.commit09911bf2008-07-26 23:55:2943
[email protected]b076a082011-10-20 01:26:3244 void SetCustomMargins(const PageMargins& requested_margins_in_points);
[email protected]1c23b4e82011-10-15 22:30:4845
initial.commit09911bf2008-07-26 23:55:2946 // 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;
50
[email protected]4993f342010-10-26 17:57:5251 void set_landscape(bool landscape) { landscape_ = landscape; }
[email protected]a0f59002011-09-20 03:59:0552 void set_printer_name(const string16& printer_name) {
[email protected]4993f342010-10-26 17:57:5253 printer_name_ = printer_name;
54 }
[email protected]a0f59002011-09-20 03:59:0555 const string16& printer_name() const { return printer_name_; }
56 void set_device_name(const string16& device_name) {
initial.commit09911bf2008-07-26 23:55:2957 device_name_ = device_name;
58 }
[email protected]a0f59002011-09-20 03:59:0559 const string16& device_name() const { return device_name_; }
[email protected]4993f342010-10-26 17:57:5260 void set_dpi(int dpi) { dpi_ = dpi; }
initial.commit09911bf2008-07-26 23:55:2961 int dpi() const { return dpi_; }
[email protected]b2b0fce2011-01-12 16:34:4062 void set_supports_alpha_blend(bool supports_alpha_blend) {
63 supports_alpha_blend_ = supports_alpha_blend;
64 }
65 bool supports_alpha_blend() const { return supports_alpha_blend_; }
[email protected]6ab86ac2010-05-29 07:18:2966 const PageSetup& page_setup_device_units() const {
67 return page_setup_device_units_;
68 }
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)
75 }
initial.commit09911bf2008-07-26 23:55:2976
[email protected]4ecd07452009-03-31 14:34:4377 // Multi-page printing. Each PageRange describes a from-to page combination.
78 // This permits printing selected pages only.
initial.commit09911bf2008-07-26 23:55:2979 PageRanges ranges;
80
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;
87
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;
93
94 // Desired visible dots per inch rendering for output. Printing should be
95 // scaled to ScreenDpi/dpix*desired_dpi.
96 int desired_dpi;
97
[email protected]c8ad40c2009-06-08 17:05:2198 // Indicates if the user only wants to print the current selection.
99 bool selection_only;
100
[email protected]1c23b4e82011-10-15 22:30:48101 // Indicates what kind of margins should be applied to the printable area.
102 MarginType margin_type;
[email protected]38bba4f2010-03-12 05:29:07103
[email protected]d30e8e642008-08-06 12:05:24104 // 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.
initial.commit09911bf2008-07-26 23:55:29107 static int NewCookie();
108
[email protected]c48bee22011-03-29 02:36:26109 // Updates the orientation and flip the page if needed.
110 void SetOrientation(bool landscape);
111
[email protected]55b23a02011-08-17 23:09:36112 // Strings to be printed as headers and footers if requested by the user.
113 string16 date;
114 string16 title;
115 string16 url;
116
117 // True if the user wants headers and footers to be displayed.
118 bool display_header_footer;
119
initial.commit09911bf2008-07-26 23:55:29120 private:
121 //////////////////////////////////////////////////////////////////////////////
122 // Settings that can't be changed without side-effects.
123
124 // Printer name as shown to the user.
[email protected]a0f59002011-09-20 03:59:05125 string16 printer_name_;
initial.commit09911bf2008-07-26 23:55:29126
127 // Printer device name as opened by the OS.
[email protected]a0f59002011-09-20 03:59:05128 string16 device_name_;
initial.commit09911bf2008-07-26 23:55:29129
[email protected]6ab86ac2010-05-29 07:18:29130 // Page setup in device units.
131 PageSetup page_setup_device_units_;
initial.commit09911bf2008-07-26 23:55:29132
133 // Printer's device effective dots per inch in both axis.
134 int dpi_;
135
136 // Is the orientation landscape or portrait.
137 bool landscape_;
[email protected]b2b0fce2011-01-12 16:34:40138
139 // True if this printer supports AlphaBlend.
140 bool supports_alpha_blend_;
[email protected]1c23b4e82011-10-15 22:30:48141
[email protected]b076a082011-10-20 01:26:32142 // If margin type is custom, this is what was requested.
143 PageMargins requested_custom_margins_in_points_;
initial.commit09911bf2008-07-26 23:55:29144};
145
146} // namespace printing
147
[email protected]8ff1d422009-07-07 21:31:39148#endif // PRINTING_PRINT_SETTINGS_H_