blob: d1929c319d9de795f3e25814f380f522e7e39b55 [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
8#include "base/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:2913typedef struct HDC__* HDC;
14typedef struct _devicemodeW DEVMODE;
15
16namespace printing {
17
18// OS-independent print settings.
19class PrintSettings {
20 public:
21 PrintSettings();
22
23 // Reinitialize the settings to the default values.
24 void Clear();
25
26#ifdef WIN32
27 // Reads the settings from the selected device context. Calculates derived
28 // values like printable_area_.
29 void Init(HDC hdc,
30 const DEVMODE& dev_mode,
31 const PageRanges& new_ranges,
[email protected]c8ad40c2009-06-08 17:05:2132 const std::wstring& new_device_name,
33 bool selection_only);
initial.commit09911bf2008-07-26 23:55:2934#endif
35
[email protected]4ecd07452009-03-31 14:34:4336 // Set printer printable area in in pixels.
37 void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels,
38 gfx::Rect const& printable_area_pixels);
initial.commit09911bf2008-07-26 23:55:2939
initial.commit09911bf2008-07-26 23:55:2940 // Equality operator.
41 // NOTE: printer_name is NOT tested for equality since it doesn't affect the
42 // output.
43 bool Equals(const PrintSettings& rhs) const;
44
45 const std::wstring& printer_name() const { return printer_name_; }
46 void set_device_name(const std::wstring& device_name) {
47 device_name_ = device_name;
48 }
49 const std::wstring& device_name() const { return device_name_; }
50 int dpi() const { return dpi_; }
initial.commit09911bf2008-07-26 23:55:2951 const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
52
[email protected]4ecd07452009-03-31 14:34:4353 // Multi-page printing. Each PageRange describes a from-to page combination.
54 // This permits printing selected pages only.
initial.commit09911bf2008-07-26 23:55:2955 PageRanges ranges;
56
57 // By imaging to a width a little wider than the available pixels, thin pages
58 // will be scaled down a little, matching the way they print in IE and Camino.
59 // This lets them use fewer sheets than they would otherwise, which is
60 // presumably why other browsers do this. Wide pages will be scaled down more
61 // than this.
62 double min_shrink;
63
64 // This number determines how small we are willing to reduce the page content
65 // in order to accommodate the widest line. If the page would have to be
66 // reduced smaller to make the widest line fit, we just clip instead (this
67 // behavior matches MacIE and Mozilla, at least)
68 double max_shrink;
69
70 // Desired visible dots per inch rendering for output. Printing should be
71 // scaled to ScreenDpi/dpix*desired_dpi.
72 int desired_dpi;
73
74 // The various overlays (headers and footers).
75 PageOverlays overlays;
76
[email protected]c8ad40c2009-06-08 17:05:2177 // Indicates if the user only wants to print the current selection.
78 bool selection_only;
79
[email protected]d30e8e642008-08-06 12:05:2480 // Cookie generator. It is used to initialize PrintedDocument with its
81 // associated PrintSettings, to be sure that each generated PrintedPage is
82 // correctly associated with its corresponding PrintedDocument.
initial.commit09911bf2008-07-26 23:55:2983 static int NewCookie();
84
85 private:
86 //////////////////////////////////////////////////////////////////////////////
87 // Settings that can't be changed without side-effects.
88
89 // Printer name as shown to the user.
90 std::wstring printer_name_;
91
92 // Printer device name as opened by the OS.
93 std::wstring device_name_;
94
initial.commit09911bf2008-07-26 23:55:2995 // Page setup in pixel units, dpi adjusted.
96 PageSetup page_setup_pixels_;
97
98 // Printer's device effective dots per inch in both axis.
99 int dpi_;
100
101 // Is the orientation landscape or portrait.
102 bool landscape_;
initial.commit09911bf2008-07-26 23:55:29103};
104
105} // namespace printing
106
[email protected]8ff1d422009-07-07 21:31:39107#endif // PRINTING_PRINT_SETTINGS_H_