[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] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 10 | #include "printing/page_range.h" |
| 11 | #include "printing/page_setup.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 12 | #include "ui/gfx/rect.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | namespace printing { |
| 15 | |
| 16 | // OS-independent print settings. |
| 17 | class PrintSettings { |
| 18 | public: |
| 19 | PrintSettings(); |
[email protected] | 20f0487a | 2010-09-30 20:06:30 | [diff] [blame] | 20 | ~PrintSettings(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 21 | |
| 22 | // Reinitialize the settings to the default values. |
| 23 | void Clear(); |
| 24 | |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 25 | // Set printer printable area in in device units. |
| 26 | void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units, |
| 27 | gfx::Rect const& printable_area_device_units, |
| 28 | int units_per_inch); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 30 | // Equality operator. |
| 31 | // NOTE: printer_name is NOT tested for equality since it doesn't affect the |
| 32 | // output. |
| 33 | bool Equals(const PrintSettings& rhs) const; |
| 34 | |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 35 | void set_landscape(bool landscape) { landscape_ = landscape; } |
| 36 | void set_printer_name(const std::wstring& printer_name) { |
| 37 | printer_name_ = printer_name; |
| 38 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 39 | const std::wstring& printer_name() const { return printer_name_; } |
| 40 | void set_device_name(const std::wstring& device_name) { |
| 41 | device_name_ = device_name; |
| 42 | } |
| 43 | const std::wstring& device_name() const { return device_name_; } |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 44 | void set_dpi(int dpi) { dpi_ = dpi; } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 45 | int dpi() const { return dpi_; } |
[email protected] | b2b0fce | 2011-01-12 16:34:40 | [diff] [blame] | 46 | void set_supports_alpha_blend(bool supports_alpha_blend) { |
| 47 | supports_alpha_blend_ = supports_alpha_blend; |
| 48 | } |
| 49 | bool supports_alpha_blend() const { return supports_alpha_blend_; } |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 50 | const PageSetup& page_setup_device_units() const { |
| 51 | return page_setup_device_units_; |
| 52 | } |
| 53 | int device_units_per_inch() const { |
| 54 | #if defined(OS_MACOSX) |
| 55 | return 72; |
| 56 | #else // defined(OS_MACOSX) |
| 57 | return dpi(); |
| 58 | #endif // defined(OS_MACOSX) |
| 59 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 60 | |
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 61 | // Multi-page printing. Each PageRange describes a from-to page combination. |
| 62 | // This permits printing selected pages only. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 63 | 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 | |
[email protected] | c8ad40c | 2009-06-08 17:05:21 | [diff] [blame] | 82 | // Indicates if the user only wants to print the current selection. |
| 83 | bool selection_only; |
| 84 | |
[email protected] | 38bba4f | 2010-03-12 05:29:07 | [diff] [blame] | 85 | // Indicates whether we should use browser-controlled page overlays |
| 86 | // (header, footer, margins etc). If it is false, the overlays are |
| 87 | // controlled by the renderer. |
| 88 | bool use_overlays; |
| 89 | |
[email protected] | d30e8e64 | 2008-08-06 12:05:24 | [diff] [blame] | 90 | // Cookie generator. It is used to initialize PrintedDocument with its |
| 91 | // associated PrintSettings, to be sure that each generated PrintedPage is |
| 92 | // correctly associated with its corresponding PrintedDocument. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 93 | static int NewCookie(); |
| 94 | |
[email protected] | c48bee2 | 2011-03-29 02:36:26 | [diff] [blame] | 95 | // Updates the orientation and flip the page if needed. |
| 96 | void SetOrientation(bool landscape); |
| 97 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 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 | |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 108 | // Page setup in device units. |
| 109 | PageSetup page_setup_device_units_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 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_; |
[email protected] | b2b0fce | 2011-01-12 16:34:40 | [diff] [blame] | 116 | |
| 117 | // True if this printer supports AlphaBlend. |
| 118 | bool supports_alpha_blend_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | } // namespace printing |
| 122 | |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 123 | #endif // PRINTING_PRINT_SETTINGS_H_ |