| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "printing/printing_context_cairo.h" | 5 #include "printing/printing_context_cairo.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gtk/gtkprintunixdialog.h> | 8 #include <gtk/gtkprintunixdialog.h> |
| 9 #include <unicode/ulocdata.h> | 9 #include <unicode/ulocdata.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "printing/native_metafile.h" | 12 #include "printing/pdf_ps_metafile_cairo.h" |
| 13 #include "printing/print_settings_initializer_gtk.h" | 13 #include "printing/print_settings_initializer_gtk.h" |
| 14 #include "printing/units.h" | 14 #include "printing/units.h" |
| 15 | 15 |
| 16 namespace printing { | 16 namespace printing { |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 PrintingContext* PrintingContext::Create(const std::string& app_locale) { | 19 PrintingContext* PrintingContext::Create(const std::string& app_locale) { |
| 20 return static_cast<PrintingContext*>(new PrintingContextCairo(app_locale)); | 20 return static_cast<PrintingContext*>(new PrintingContextCairo(app_locale)); |
| 21 } | 21 } |
| 22 | 22 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 height = static_cast<int>(11 * dpi); | 63 height = static_cast<int>(11 * dpi); |
| 64 } else { | 64 } else { |
| 65 // ulocdata_getPaperSize returns the width and height in mm. | 65 // ulocdata_getPaperSize returns the width and height in mm. |
| 66 // Convert this to pixels based on the dpi. | 66 // Convert this to pixels based on the dpi. |
| 67 width = static_cast<int>(ConvertUnitDouble(width, 25.4, 1.0) * dpi); | 67 width = static_cast<int>(ConvertUnitDouble(width, 25.4, 1.0) * dpi); |
| 68 height = static_cast<int>(ConvertUnitDouble(height, 25.4, 1.0) * dpi); | 68 height = static_cast<int>(ConvertUnitDouble(height, 25.4, 1.0) * dpi); |
| 69 } | 69 } |
| 70 | 70 |
| 71 physical_size_device_units.SetSize(width, height); | 71 physical_size_device_units.SetSize(width, height); |
| 72 printable_area_device_units.SetRect( | 72 printable_area_device_units.SetRect( |
| 73 static_cast<int>(NativeMetafile::kLeftMarginInInch * dpi), | 73 static_cast<int>(PdfPsMetafile::kLeftMarginInInch * dpi), |
| 74 static_cast<int>(NativeMetafile::kTopMarginInInch * dpi), | 74 static_cast<int>(PdfPsMetafile::kTopMarginInInch * dpi), |
| 75 width - (NativeMetafile::kLeftMarginInInch + | 75 width - (PdfPsMetafile::kLeftMarginInInch + |
| 76 NativeMetafile::kRightMarginInInch) * dpi, | 76 PdfPsMetafile::kRightMarginInInch) * dpi, |
| 77 height - (NativeMetafile::kTopMarginInInch + | 77 height - (PdfPsMetafile::kTopMarginInInch + |
| 78 NativeMetafile::kBottomMarginInInch) * dpi); | 78 PdfPsMetafile::kBottomMarginInInch) * dpi); |
| 79 | 79 |
| 80 settings_.set_dpi(dpi); | 80 settings_.set_dpi(dpi); |
| 81 settings_.SetPrinterPrintableArea(physical_size_device_units, | 81 settings_.SetPrinterPrintableArea(physical_size_device_units, |
| 82 printable_area_device_units, | 82 printable_area_device_units, |
| 83 dpi); | 83 dpi); |
| 84 #else // defined(OS_CHROMEOS) | 84 #else // defined(OS_CHROMEOS) |
| 85 GtkWidget* dialog = gtk_print_unix_dialog_new(NULL, NULL); | 85 GtkWidget* dialog = gtk_print_unix_dialog_new(NULL, NULL); |
| 86 GtkPrintSettings* settings = | 86 GtkPrintSettings* settings = |
| 87 gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(dialog)); | 87 gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(dialog)); |
| 88 GtkPageSetup* page_setup = | 88 GtkPageSetup* page_setup = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 void PrintingContextCairo::ReleaseContext() { | 161 void PrintingContextCairo::ReleaseContext() { |
| 162 // Nothing to do yet. | 162 // Nothing to do yet. |
| 163 } | 163 } |
| 164 | 164 |
| 165 gfx::NativeDrawingContext PrintingContextCairo::context() const { | 165 gfx::NativeDrawingContext PrintingContextCairo::context() const { |
| 166 return NULL; | 166 return NULL; |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace printing | 169 } // namespace printing |
| OLD | NEW |