license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // 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.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] | e0fc2f1 | 2010-03-14 23:30:59 | [diff] [blame] | 8 | #include "gfx/rect.h" |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 9 | #include "printing/page_overlays.h" |
| 10 | #include "printing/page_range.h" |
| 11 | #include "printing/page_setup.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | |
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 13 | #if defined(OS_MACOSX) |
| 14 | #import <ApplicationServices/ApplicationServices.h> |
| 15 | #endif |
| 16 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 17 | typedef struct HDC__* HDC; |
| 18 | typedef struct _devicemodeW DEVMODE; |
| 19 | |
| 20 | namespace printing { |
| 21 | |
| 22 | // OS-independent print settings. |
| 23 | class PrintSettings { |
| 24 | public: |
| 25 | PrintSettings(); |
| 26 | |
| 27 | // Reinitialize the settings to the default values. |
| 28 | void Clear(); |
| 29 | |
| 30 | #ifdef WIN32 |
| 31 | // Reads the settings from the selected device context. Calculates derived |
| 32 | // values like printable_area_. |
| 33 | void Init(HDC hdc, |
| 34 | const DEVMODE& dev_mode, |
| 35 | const PageRanges& new_ranges, |
[email protected] | c8ad40c | 2009-06-08 17:05:21 | [diff] [blame] | 36 | const std::wstring& new_device_name, |
| 37 | bool selection_only); |
[email protected] | b75dca8 | 2009-10-13 18:46:21 | [diff] [blame] | 38 | #elif defined(OS_MACOSX) |
| 39 | // Reads the settings from the given PMPrinter and PMPageFormat. |
| 40 | void Init(PMPrinter printer, PMPageFormat page_format, |
| 41 | const PageRanges& new_ranges, bool print_selection_only); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 42 | #endif |
| 43 | |
[email protected] | 4ecd0745 | 2009-03-31 14:34:43 | [diff] [blame] | 44 | // Set printer printable area in in pixels. |
| 45 | void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels, |
| 46 | gfx::Rect const& printable_area_pixels); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 48 | // Equality operator. |
| 49 | // NOTE: printer_name is NOT tested for equality since it doesn't affect the |
| 50 | // output. |
| 51 | bool Equals(const PrintSettings& rhs) const; |
| 52 | |
| 53 | const std::wstring& printer_name() const { return printer_name_; } |
| 54 | void set_device_name(const std::wstring& device_name) { |
| 55 | device_name_ = device_name; |
| 56 | } |
| 57 | const std::wstring& device_name() const { return device_name_; } |
| 58 | int dpi() const { return dpi_; } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 59 | const PageSetup& page_setup_pixels() const { return page_setup_pixels_; } |
| 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 | |
| 82 | // The various overlays (headers and footers). |
| 83 | PageOverlays overlays; |
| 84 | |
[email protected] | c8ad40c | 2009-06-08 17:05:21 | [diff] [blame] | 85 | // Indicates if the user only wants to print the current selection. |
| 86 | bool selection_only; |
| 87 | |
[email protected] | 38bba4f | 2010-03-12 05:29:07 | [diff] [blame] | 88 | // Indicates whether we should use browser-controlled page overlays |
| 89 | // (header, footer, margins etc). If it is false, the overlays are |
| 90 | // controlled by the renderer. |
| 91 | bool use_overlays; |
| 92 | |
[email protected] | d30e8e64 | 2008-08-06 12:05:24 | [diff] [blame] | 93 | // Cookie generator. It is used to initialize PrintedDocument with its |
| 94 | // associated PrintSettings, to be sure that each generated PrintedPage is |
| 95 | // correctly associated with its corresponding PrintedDocument. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 96 | static int NewCookie(); |
| 97 | |
| 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 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 108 | // Page setup in pixel units, dpi adjusted. |
| 109 | PageSetup page_setup_pixels_; |
| 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_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | } // namespace printing |
| 119 | |
[email protected] | 8ff1d42 | 2009-07-07 21:31:39 | [diff] [blame] | 120 | #endif // PRINTING_PRINT_SETTINGS_H_ |