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