OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PRINTING_PRINT_SETTINGS_H_ | 5 #ifndef PRINTING_PRINT_SETTINGS_H_ |
6 #define PRINTING_PRINT_SETTINGS_H_ | 6 #define PRINTING_PRINT_SETTINGS_H_ |
7 | 7 |
8 #include <algorithm> | |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "printing/page_range.h" | 12 #include "printing/page_range.h" |
12 #include "printing/page_setup.h" | 13 #include "printing/page_setup.h" |
13 #include "printing/print_job_constants.h" | 14 #include "printing/print_job_constants.h" |
14 #include "printing/printing_export.h" | 15 #include "printing/printing_export.h" |
15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
16 | 17 |
17 namespace printing { | 18 namespace printing { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 bool landscape_needs_flip); | 93 bool landscape_needs_flip); |
93 const PageSetup& page_setup_device_units() const { | 94 const PageSetup& page_setup_device_units() const { |
94 return page_setup_device_units_; | 95 return page_setup_device_units_; |
95 } | 96 } |
96 | 97 |
97 void set_device_name(const base::string16& device_name) { | 98 void set_device_name(const base::string16& device_name) { |
98 device_name_ = device_name; | 99 device_name_ = device_name; |
99 } | 100 } |
100 const base::string16& device_name() const { return device_name_; } | 101 const base::string16& device_name() const { return device_name_; } |
101 | 102 |
102 void set_dpi(int dpi) { dpi_ = dpi; } | 103 void set_dpi(int dpi) { |
103 int dpi() const { return dpi_; } | 104 dpi_[0] = dpi; |
105 dpi_[1] = dpi; | |
106 } | |
107 int dpi() const { return std::min(dpi_[0], dpi_[1]); } | |
rbpotter
2017/04/01 00:08:02
What do you think makes sense here? The previous i
Lei Zhang
2017/04/01 01:14:13
Well, for most printers, it doesn't matter right?
| |
104 | 108 |
105 void set_scale_factor(double scale_factor) { scale_factor_ = scale_factor; } | 109 void set_scale_factor(double scale_factor) { scale_factor_ = scale_factor; } |
106 double scale_factor() const { return scale_factor_; } | 110 double scale_factor() const { return scale_factor_; } |
107 | 111 |
108 void set_rasterize_pdf(bool rasterize_pdf) { rasterize_pdf_ = rasterize_pdf; } | 112 void set_rasterize_pdf(bool rasterize_pdf) { rasterize_pdf_ = rasterize_pdf; } |
109 bool rasterize_pdf() const { return rasterize_pdf_; } | 113 bool rasterize_pdf() const { return rasterize_pdf_; } |
110 | 114 |
115 void set_dpi(int dpi_horizontal, int dpi_vertical) { | |
116 dpi_[0] = dpi_horizontal; | |
117 dpi_[1] = dpi_vertical; | |
118 } | |
119 | |
111 void set_supports_alpha_blend(bool supports_alpha_blend) { | 120 void set_supports_alpha_blend(bool supports_alpha_blend) { |
112 supports_alpha_blend_ = supports_alpha_blend; | 121 supports_alpha_blend_ = supports_alpha_blend; |
113 } | 122 } |
114 bool supports_alpha_blend() const { return supports_alpha_blend_; } | 123 bool supports_alpha_blend() const { return supports_alpha_blend_; } |
115 | 124 |
116 int device_units_per_inch() const { | 125 int device_units_per_inch() const { |
117 #if defined(OS_MACOSX) | 126 #if defined(OS_MACOSX) |
118 return 72; | 127 return 72; |
119 #else // defined(OS_MACOSX) | 128 #else // defined(OS_MACOSX) |
120 return dpi(); | 129 return dpi(); |
(...skipping 29 matching lines...) Expand all Loading... | |
150 | 159 |
151 void set_color(ColorModel color) { color_ = color; } | 160 void set_color(ColorModel color) { color_ = color; } |
152 ColorModel color() const { return color_; } | 161 ColorModel color() const { return color_; } |
153 | 162 |
154 void set_copies(int copies) { copies_ = copies; } | 163 void set_copies(int copies) { copies_ = copies; } |
155 int copies() const { return copies_; } | 164 int copies() const { return copies_; } |
156 | 165 |
157 void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; } | 166 void set_duplex_mode(DuplexMode duplex_mode) { duplex_mode_ = duplex_mode; } |
158 DuplexMode duplex_mode() const { return duplex_mode_; } | 167 DuplexMode duplex_mode() const { return duplex_mode_; } |
159 | 168 |
160 int desired_dpi() const { return desired_dpi_; } | 169 int dpi_horizontal() const { return dpi_[0]; } |
170 int dpi_vertical() const { return dpi_[1]; } | |
161 | 171 |
162 #if defined(OS_WIN) | 172 #if defined(OS_WIN) |
163 void set_print_text_with_gdi(bool use_gdi) { print_text_with_gdi_ = use_gdi; } | 173 void set_print_text_with_gdi(bool use_gdi) { print_text_with_gdi_ = use_gdi; } |
164 bool print_text_with_gdi() const { return print_text_with_gdi_; } | 174 bool print_text_with_gdi() const { return print_text_with_gdi_; } |
165 | 175 |
166 void set_printer_type(PrinterType type) { printer_type_ = type; } | 176 void set_printer_type(PrinterType type) { printer_type_ = type; } |
167 bool printer_is_xps() const { return printer_type_ == PrinterType::TYPE_XPS;} | 177 bool printer_is_xps() const { return printer_type_ == PrinterType::TYPE_XPS;} |
168 bool printer_is_ps2() const { | 178 bool printer_is_ps2() const { |
169 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL2; | 179 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL2; |
170 } | 180 } |
171 bool printer_is_ps3() const { | 181 bool printer_is_ps3() const { |
172 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL3; | 182 return printer_type_ == PrinterType::TYPE_POSTSCRIPT_LEVEL3; |
173 } | 183 } |
174 #endif | 184 #endif |
175 | 185 |
176 // Cookie generator. It is used to initialize PrintedDocument with its | 186 // Cookie generator. It is used to initialize PrintedDocument with its |
177 // associated PrintSettings, to be sure that each generated PrintedPage is | 187 // associated PrintSettings, to be sure that each generated PrintedPage is |
178 // correctly associated with its corresponding PrintedDocument. | 188 // correctly associated with its corresponding PrintedDocument. |
179 static int NewCookie(); | 189 static int NewCookie(); |
180 | 190 |
181 private: | 191 private: |
182 // Multi-page printing. Each PageRange describes a from-to page combination. | 192 // Multi-page printing. Each PageRange describes a from-to page combination. |
183 // This permits printing selected pages only. | 193 // This permits printing selected pages only. |
184 PageRanges ranges_; | 194 PageRanges ranges_; |
185 | 195 |
186 // Desired visible dots per inch rendering for output. Printing should be | |
187 // scaled to ScreenDpi/dpix*desired_dpi. | |
188 int desired_dpi_; | |
189 | |
190 // Indicates if the user only wants to print the current selection. | 196 // Indicates if the user only wants to print the current selection. |
191 bool selection_only_; | 197 bool selection_only_; |
192 | 198 |
193 // Indicates what kind of margins should be applied to the printable area. | 199 // Indicates what kind of margins should be applied to the printable area. |
194 MarginType margin_type_; | 200 MarginType margin_type_; |
195 | 201 |
196 // Strings to be printed as headers and footers if requested by the user. | 202 // Strings to be printed as headers and footers if requested by the user. |
197 base::string16 title_; | 203 base::string16 title_; |
198 base::string16 url_; | 204 base::string16 url_; |
199 | 205 |
(...skipping 18 matching lines...) Expand all Loading... | |
218 // Printer device name as opened by the OS. | 224 // Printer device name as opened by the OS. |
219 base::string16 device_name_; | 225 base::string16 device_name_; |
220 | 226 |
221 // Media requested by the user. | 227 // Media requested by the user. |
222 RequestedMedia requested_media_; | 228 RequestedMedia requested_media_; |
223 | 229 |
224 // Page setup in device units. | 230 // Page setup in device units. |
225 PageSetup page_setup_device_units_; | 231 PageSetup page_setup_device_units_; |
226 | 232 |
227 // Printer's device effective dots per inch in both axis. | 233 // Printer's device effective dots per inch in both axis. |
228 int dpi_; | 234 int dpi_[2]; |
229 | 235 |
230 // Scale factor | 236 // Scale factor |
231 double scale_factor_; | 237 double scale_factor_; |
232 | 238 |
233 // True if PDF should be printed as a raster PDF | 239 // True if PDF should be printed as a raster PDF |
234 bool rasterize_pdf_; | 240 bool rasterize_pdf_; |
235 | 241 |
236 // Is the orientation landscape or portrait. | 242 // Is the orientation landscape or portrait. |
237 bool landscape_; | 243 bool landscape_; |
238 | 244 |
239 // True if this printer supports AlphaBlend. | 245 // True if this printer supports AlphaBlend. |
240 bool supports_alpha_blend_; | 246 bool supports_alpha_blend_; |
241 | 247 |
242 #if defined(OS_WIN) | 248 #if defined(OS_WIN) |
243 // True to print text with GDI. | 249 // True to print text with GDI. |
244 bool print_text_with_gdi_; | 250 bool print_text_with_gdi_; |
245 | 251 |
246 PrinterType printer_type_; | 252 PrinterType printer_type_; |
247 #endif | 253 #endif |
248 | 254 |
249 // If margin type is custom, this is what was requested. | 255 // If margin type is custom, this is what was requested. |
250 PageMargins requested_custom_margins_in_points_; | 256 PageMargins requested_custom_margins_in_points_; |
251 }; | 257 }; |
252 | 258 |
253 } // namespace printing | 259 } // namespace printing |
254 | 260 |
255 #endif // PRINTING_PRINT_SETTINGS_H_ | 261 #endif // PRINTING_PRINT_SETTINGS_H_ |
OLD | NEW |