[email protected] | 71f40a7 | 2012-05-16 07:26:59 | [diff] [blame] | 1 | // Copyright (c) 2012 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/string16.h" |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 11 | #include "printing/page_range.h" |
| 12 | #include "printing/page_setup.h" |
[email protected] | 1c23b4e8 | 2011-10-15 22:30:48 | [diff] [blame] | 13 | #include "printing/print_job_constants.h" |
[email protected] | 63313ae | 2011-10-13 00:40:39 | [diff] [blame] | 14 | #include "printing/printing_export.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 15 | #include "ui/gfx/rect.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 17 | namespace printing { |
| 18 | |
[email protected] | 63313ae | 2011-10-13 00:40:39 | [diff] [blame] | 19 | // Returns true if color model is selected. |
| 20 | PRINTING_EXPORT bool isColorModelSelected(int model); |
| 21 | |
[email protected] | fa879e51 | 2011-11-08 20:39:01 | [diff] [blame] | 22 | #if defined(USE_CUPS) |
| 23 | // Get the color model setting name and value for the |color_mode|. |
| 24 | PRINTING_EXPORT void GetColorModelForMode(int color_mode, |
| 25 | std::string* color_setting_name, |
| 26 | std::string* color_value); |
[email protected] | 63313ae | 2011-10-13 00:40:39 | [diff] [blame] | 27 | #endif |
| 28 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | // OS-independent print settings. |
[email protected] | 69f5b1e6 | 2011-09-01 06:34:04 | [diff] [blame] | 30 | class PRINTING_EXPORT PrintSettings { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | public: |
| 32 | PrintSettings(); |
[email protected] | 20f0487a | 2010-09-30 20:06:30 | [diff] [blame] | 33 | ~PrintSettings(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 34 | |
| 35 | // Reinitialize the settings to the default values. |
| 36 | void Clear(); |
| 37 | |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 38 | // Set printer printable area in in device units. |
| 39 | void SetPrinterPrintableArea(gfx::Size const& physical_size_device_units, |
| 40 | gfx::Rect const& printable_area_device_units, |
| 41 | int units_per_inch); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 42 | |
[email protected] | b076a08 | 2011-10-20 01:26:32 | [diff] [blame] | 43 | void SetCustomMargins(const PageMargins& requested_margins_in_points); |
[email protected] | 1c23b4e8 | 2011-10-15 22:30:48 | [diff] [blame] | 44 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 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 | |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 50 | void set_landscape(bool landscape) { landscape_ = landscape; } |
[email protected] | a0f5900 | 2011-09-20 03:59:05 | [diff] [blame] | 51 | void set_printer_name(const string16& printer_name) { |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 52 | printer_name_ = printer_name; |
| 53 | } |
[email protected] | a0f5900 | 2011-09-20 03:59:05 | [diff] [blame] | 54 | const string16& printer_name() const { return printer_name_; } |
| 55 | void set_device_name(const string16& device_name) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 56 | device_name_ = device_name; |
| 57 | } |
[email protected] | a0f5900 | 2011-09-20 03:59:05 | [diff] [blame] | 58 | const string16& device_name() const { return device_name_; } |
[email protected] | 4993f34 | 2010-10-26 17:57:52 | [diff] [blame] | 59 | void set_dpi(int dpi) { dpi_ = dpi; } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 60 | int dpi() const { return dpi_; } |
[email protected] | b2b0fce | 2011-01-12 16:34:40 | [diff] [blame] | 61 | void set_supports_alpha_blend(bool supports_alpha_blend) { |
| 62 | supports_alpha_blend_ = supports_alpha_blend; |
| 63 | } |
| 64 | bool supports_alpha_blend() const { return supports_alpha_blend_; } |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 65 | const PageSetup& page_setup_device_units() const { |
| 66 | return page_setup_device_units_; |
| 67 | } |
| 68 | int device_units_per_inch() const { |
| 69 | #if defined(OS_MACOSX) |
| 70 | return 72; |
| 71 | #else // defined(OS_MACOSX) |
| 72 | return dpi(); |
| 73 | #endif // defined(OS_MACOSX) |
| 74 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 75 | |
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 76 | // Multi-page printing. Each PageRange describes a from-to page combination. |
| 77 | // This permits printing selected pages only. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 78 | PageRanges ranges; |
| 79 | |
| 80 | // By imaging to a width a little wider than the available pixels, thin pages |
| 81 | // will be scaled down a little, matching the way they print in IE and Camino. |
| 82 | // This lets them use fewer sheets than they would otherwise, which is |
| 83 | // presumably why other browsers do this. Wide pages will be scaled down more |
| 84 | // than this. |
| 85 | double min_shrink; |
| 86 | |
| 87 | // This number determines how small we are willing to reduce the page content |
| 88 | // in order to accommodate the widest line. If the page would have to be |
| 89 | // reduced smaller to make the widest line fit, we just clip instead (this |
| 90 | // behavior matches MacIE and Mozilla, at least) |
| 91 | double max_shrink; |
| 92 | |
| 93 | // Desired visible dots per inch rendering for output. Printing should be |
| 94 | // scaled to ScreenDpi/dpix*desired_dpi. |
| 95 | int desired_dpi; |
| 96 | |
[email protected] | c8ad40c | 2009-06-08 17:05:21 | [diff] [blame] | 97 | // Indicates if the user only wants to print the current selection. |
| 98 | bool selection_only; |
| 99 | |
[email protected] | 1c23b4e8 | 2011-10-15 22:30:48 | [diff] [blame] | 100 | // Indicates what kind of margins should be applied to the printable area. |
| 101 | MarginType margin_type; |
[email protected] | 38bba4f | 2010-03-12 05:29:07 | [diff] [blame] | 102 | |
[email protected] | d30e8e64 | 2008-08-06 12:05:24 | [diff] [blame] | 103 | // Cookie generator. It is used to initialize PrintedDocument with its |
| 104 | // associated PrintSettings, to be sure that each generated PrintedPage is |
| 105 | // correctly associated with its corresponding PrintedDocument. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 106 | static int NewCookie(); |
| 107 | |
[email protected] | c48bee2 | 2011-03-29 02:36:26 | [diff] [blame] | 108 | // Updates the orientation and flip the page if needed. |
| 109 | void SetOrientation(bool landscape); |
| 110 | |
[email protected] | 55b23a0 | 2011-08-17 23:09:36 | [diff] [blame] | 111 | // Strings to be printed as headers and footers if requested by the user. |
| 112 | string16 date; |
| 113 | string16 title; |
| 114 | string16 url; |
| 115 | |
| 116 | // True if the user wants headers and footers to be displayed. |
| 117 | bool display_header_footer; |
| 118 | |
[email protected] | 19d1c2d | 2013-01-14 00:59:46 | [diff] [blame^] | 119 | // True if the user wants to print CSS backgrounds. |
| 120 | bool should_print_backgrounds; |
| 121 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 122 | private: |
| 123 | ////////////////////////////////////////////////////////////////////////////// |
| 124 | // Settings that can't be changed without side-effects. |
| 125 | |
| 126 | // Printer name as shown to the user. |
[email protected] | a0f5900 | 2011-09-20 03:59:05 | [diff] [blame] | 127 | string16 printer_name_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 128 | |
| 129 | // Printer device name as opened by the OS. |
[email protected] | a0f5900 | 2011-09-20 03:59:05 | [diff] [blame] | 130 | string16 device_name_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 131 | |
[email protected] | 6ab86ac | 2010-05-29 07:18:29 | [diff] [blame] | 132 | // Page setup in device units. |
| 133 | PageSetup page_setup_device_units_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 134 | |
| 135 | // Printer's device effective dots per inch in both axis. |
| 136 | int dpi_; |
| 137 | |
| 138 | // Is the orientation landscape or portrait. |
| 139 | bool landscape_; |
[email protected] | b2b0fce | 2011-01-12 16:34:40 | [diff] [blame] | 140 | |
| 141 | // True if this printer supports AlphaBlend. |
| 142 | bool supports_alpha_blend_; |
[email protected] | 1c23b4e8 | 2011-10-15 22:30:48 | [diff] [blame] | 143 | |
[email protected] | b076a08 | 2011-10-20 01:26:32 | [diff] [blame] | 144 | // If margin type is custom, this is what was requested. |
| 145 | PageMargins requested_custom_margins_in_points_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | } // namespace printing |
| 149 | |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 150 | #endif // PRINTING_PRINT_SETTINGS_H_ |