[email protected] | c48bee2 | 2011-03-29 02:36:26 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 5 | #ifndef PRINTING_PRINT_SETTINGS_H_ |
| 6 | #define PRINTING_PRINT_SETTINGS_H_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
[email protected] | dcd1e886 | 2011-08-09 06:06:58 | [diff] [blame] | 8 | #include <string> |
| 9 | |
[email protected] | 55b23a0 | 2011-08-17 23:09:36 | [diff] [blame] | 10 | #include "base/memory/scoped_ptr.h" |
| 11 | #include "base/string16.h" |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 12 | #include "printing/page_range.h" |
| 13 | #include "printing/page_setup.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 14 | #include "ui/gfx/rect.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 15 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | namespace printing { |
| 17 | |
| 18 | // OS-independent print settings. |
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame^] | 19 | class PRINTING_EXPORT PrintSettings { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | public: |
| 21 | PrintSettings(); |
[email protected] | 20f0487a | 2010-09-30 20:06:30 | [diff] [blame] | 22 | ~PrintSettings(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 23 | |
| 24 | // Reinitialize the settings to the default values. |
| 25 | void Clear(); |
| 26 | |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 27 | // Set printer printable area in in device units. |
| 28 | void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units, |
| 29 | gfx::Rect const& printable_area_device_units, |
| 30 | int units_per_inch); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 32 | // Equality operator. |
| 33 | // NOTE: printer_name is NOT tested for equality since it doesn't affect the |
| 34 | // output. |
| 35 | bool Equals(const PrintSettings& rhs) const; |
| 36 | |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 37 | void set_landscape(bool landscape) { landscape_ = landscape; } |
| 38 | void set_printer_name(const std::wstring& printer_name) { |
| 39 | printer_name_ = printer_name; |
| 40 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 41 | const std::wstring& printer_name() const { return printer_name_; } |
| 42 | void set_device_name(const std::wstring& device_name) { |
| 43 | device_name_ = device_name; |
| 44 | } |
| 45 | const std::wstring& device_name() const { return device_name_; } |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 46 | void set_dpi(int dpi) { dpi_ = dpi; } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | int dpi() const { return dpi_; } |
[email protected] | b2b0fce | 2011-01-12 16:34:40 | [diff] [blame] | 48 | void set_supports_alpha_blend(bool supports_alpha_blend) { |
| 49 | supports_alpha_blend_ = supports_alpha_blend; |
| 50 | } |
| 51 | bool supports_alpha_blend() const { return supports_alpha_blend_; } |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 52 | const PageSetup& page_setup_device_units() const { |
| 53 | return page_setup_device_units_; |
| 54 | } |
| 55 | int device_units_per_inch() const { |
| 56 | #if defined(OS_MACOSX) |
| 57 | return 72; |
| 58 | #else // defined(OS_MACOSX) |
| 59 | return dpi(); |
| 60 | #endif // defined(OS_MACOSX) |
| 61 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 62 | |
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 63 | // Multi-page printing. Each PageRange describes a from-to page combination. |
| 64 | // This permits printing selected pages only. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 65 | PageRanges ranges; |
| 66 | |
| 67 | // By imaging to a width a little wider than the available pixels, thin pages |
| 68 | // will be scaled down a little, matching the way they print in IE and Camino. |
| 69 | // This lets them use fewer sheets than they would otherwise, which is |
| 70 | // presumably why other browsers do this. Wide pages will be scaled down more |
| 71 | // than this. |
| 72 | double min_shrink; |
| 73 | |
| 74 | // This number determines how small we are willing to reduce the page content |
| 75 | // in order to accommodate the widest line. If the page would have to be |
| 76 | // reduced smaller to make the widest line fit, we just clip instead (this |
| 77 | // behavior matches MacIE and Mozilla, at least) |
| 78 | double max_shrink; |
| 79 | |
| 80 | // Desired visible dots per inch rendering for output. Printing should be |
| 81 | // scaled to ScreenDpi/dpix*desired_dpi. |
| 82 | int desired_dpi; |
| 83 | |
[email protected] | c8ad40c | 2009-06-08 17:05:21 | [diff] [blame] | 84 | // Indicates if the user only wants to print the current selection. |
| 85 | bool selection_only; |
| 86 | |
[email protected] | 38bba4f | 2010-03-12 05:29:07 | [diff] [blame] | 87 | // 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] | d30e8e64 | 2008-08-06 12:05:24 | [diff] [blame] | 92 | // 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 95 | static int NewCookie(); |
| 96 | |
[email protected] | c48bee2 | 2011-03-29 02:36:26 | [diff] [blame] | 97 | // Updates the orientation and flip the page if needed. |
| 98 | void SetOrientation(bool landscape); |
| 99 | |
[email protected] | 55b23a0 | 2011-08-17 23:09:36 | [diff] [blame] | 100 | // Strings to be printed as headers and footers if requested by the user. |
| 101 | string16 date; |
| 102 | string16 title; |
| 103 | string16 url; |
| 104 | |
| 105 | // True if the user wants headers and footers to be displayed. |
| 106 | bool display_header_footer; |
| 107 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 108 | private: |
| 109 | ////////////////////////////////////////////////////////////////////////////// |
| 110 | // Settings that can't be changed without side-effects. |
| 111 | |
| 112 | // Printer name as shown to the user. |
| 113 | std::wstring printer_name_; |
| 114 | |
| 115 | // Printer device name as opened by the OS. |
| 116 | std::wstring device_name_; |
| 117 | |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 118 | // Page setup in device units. |
| 119 | PageSetup page_setup_device_units_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 120 | |
| 121 | // Printer's device effective dots per inch in both axis. |
| 122 | int dpi_; |
| 123 | |
| 124 | // Is the orientation landscape or portrait. |
| 125 | bool landscape_; |
[email protected] | b2b0fce | 2011-01-12 16:34:40 | [diff] [blame] | 126 | |
| 127 | // True if this printer supports AlphaBlend. |
| 128 | bool supports_alpha_blend_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | } // namespace printing |
| 132 | |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 133 | #endif // PRINTING_PRINT_SETTINGS_H_ |