blob: 3a269f78471b9c17a49ec11279b1675a475b430e [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// Copyright (c) 2006-2008 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.
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
[email protected]b75dca82009-10-13 18:46:2113#if defined(OS_MACOSX)
14#import <ApplicationServices/ApplicationServices.h>
15#endif
16
initial.commit09911bf2008-07-26 23:55:2917typedef struct HDC__* HDC;
18typedef struct _devicemodeW DEVMODE;
19
20namespace printing {
21
22// OS-independent print settings.
23class PrintSettings {
24 public:
25 PrintSettings();
26
27 // Reinitialize the settings to the default values.
28 void Clear();
29
30#ifdef WIN32
31 // Reads the settings from the selected device context. Calculates derived
32 // values like printable_area_.
33 void Init(HDC hdc,
34 const DEVMODE& dev_mode,
35 const PageRanges& new_ranges,
[email protected]c8ad40c2009-06-08 17:05:2136 const std::wstring& new_device_name,
37 bool selection_only);
[email protected]b75dca82009-10-13 18:46:2138#elif defined(OS_MACOSX)
39 // Reads the settings from the given PMPrinter and PMPageFormat.
40 void Init(PMPrinter printer, PMPageFormat page_format,
41 const PageRanges& new_ranges, bool print_selection_only);
initial.commit09911bf2008-07-26 23:55:2942#endif
43
[email protected]4ecd07452009-03-31 14:34:4344 // Set printer printable area in in pixels.
45 void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels,
46 gfx::Rect const& printable_area_pixels);
initial.commit09911bf2008-07-26 23:55:2947
initial.commit09911bf2008-07-26 23:55:2948 // Equality operator.
49 // NOTE: printer_name is NOT tested for equality since it doesn't affect the
50 // output.
51 bool Equals(const PrintSettings& rhs) const;
52
53 const std::wstring& printer_name() const { return printer_name_; }
54 void set_device_name(const std::wstring& device_name) {
55 device_name_ = device_name;
56 }
57 const std::wstring& device_name() const { return device_name_; }
58 int dpi() const { return dpi_; }
initial.commit09911bf2008-07-26 23:55:2959 const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
60
[email protected]4ecd07452009-03-31 14:34:4361 // Multi-page printing. Each PageRange describes a from-to page combination.
62 // This permits printing selected pages only.
initial.commit09911bf2008-07-26 23:55:2963 PageRanges ranges;
64
65 // By imaging to a width a little wider than the available pixels, thin pages
66 // will be scaled down a little, matching the way they print in IE and Camino.
67 // This lets them use fewer sheets than they would otherwise, which is
68 // presumably why other browsers do this. Wide pages will be scaled down more
69 // than this.
70 double min_shrink;
71
72 // This number determines how small we are willing to reduce the page content
73 // in order to accommodate the widest line. If the page would have to be
74 // reduced smaller to make the widest line fit, we just clip instead (this
75 // behavior matches MacIE and Mozilla, at least)
76 double max_shrink;
77
78 // Desired visible dots per inch rendering for output. Printing should be
79 // scaled to ScreenDpi/dpix*desired_dpi.
80 int desired_dpi;
81
82 // The various overlays (headers and footers).
83 PageOverlays overlays;
84
[email protected]c8ad40c2009-06-08 17:05:2185 // Indicates if the user only wants to print the current selection.
86 bool selection_only;
87
[email protected]38bba4f2010-03-12 05:29:0788 // Indicates whether we should use browser-controlled page overlays
89 // (header, footer, margins etc). If it is false, the overlays are
90 // controlled by the renderer.
91 bool use_overlays;
92
[email protected]d30e8e642008-08-06 12:05:2493 // Cookie generator. It is used to initialize PrintedDocument with its
94 // associated PrintSettings, to be sure that each generated PrintedPage is
95 // correctly associated with its corresponding PrintedDocument.
initial.commit09911bf2008-07-26 23:55:2996 static int NewCookie();
97
98 private:
99 //////////////////////////////////////////////////////////////////////////////
100 // Settings that can't be changed without side-effects.
101
102 // Printer name as shown to the user.
103 std::wstring printer_name_;
104
105 // Printer device name as opened by the OS.
106 std::wstring device_name_;
107
initial.commit09911bf2008-07-26 23:55:29108 // Page setup in pixel units, dpi adjusted.
109 PageSetup page_setup_pixels_;
110
111 // Printer's device effective dots per inch in both axis.
112 int dpi_;
113
114 // Is the orientation landscape or portrait.
115 bool landscape_;
initial.commit09911bf2008-07-26 23:55:29116};
117
118} // namespace printing
119
[email protected]8ff1d422009-07-07 21:31:39120#endif // PRINTING_PRINT_SETTINGS_H_