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