| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PRINTING_CONTEXT_WIN_H_ | 5 #ifndef PRINTING_PRINTING_CONTEXT_WIN_H_ |
| 6 #define PRINTING_PRINTING_CONTEXT_WIN_H_ | 6 #define PRINTING_PRINTING_CONTEXT_WIN_H_ |
| 7 | 7 |
| 8 #include <ocidl.h> | 8 #include <ocidl.h> |
| 9 #include <commdlg.h> | 9 #include <commdlg.h> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 ~PrintingContextWin(); | 23 ~PrintingContextWin(); |
| 24 | 24 |
| 25 // PrintingContext implementation. | 25 // PrintingContext implementation. |
| 26 virtual void AskUserForSettings( | 26 virtual void AskUserForSettings( |
| 27 gfx::NativeView parent_view, | 27 gfx::NativeView parent_view, |
| 28 int max_pages, | 28 int max_pages, |
| 29 bool has_selection, | 29 bool has_selection, |
| 30 const PrintSettingsCallback& callback) OVERRIDE; | 30 const PrintSettingsCallback& callback) OVERRIDE; |
| 31 virtual Result UseDefaultSettings() OVERRIDE; | 31 virtual Result UseDefaultSettings() OVERRIDE; |
| 32 virtual gfx::Size GetPdfPaperSizeDeviceUnits() OVERRIDE; | 32 virtual gfx::Size GetPdfPaperSizeDeviceUnits() OVERRIDE; |
| 33 virtual Result UpdatePrinterSettings(bool external_preview) OVERRIDE; | 33 virtual Result UpdatePrinterSettings(bool external_preview, |
| 34 bool show_system_dialog, |
| 35 gfx::NativeView parent_view) OVERRIDE; |
| 34 virtual Result InitWithSettings(const PrintSettings& settings) OVERRIDE; | 36 virtual Result InitWithSettings(const PrintSettings& settings) OVERRIDE; |
| 35 virtual Result NewDocument(const base::string16& document_name) OVERRIDE; | 37 virtual Result NewDocument(const base::string16& document_name) OVERRIDE; |
| 36 virtual Result NewPage() OVERRIDE; | 38 virtual Result NewPage() OVERRIDE; |
| 37 virtual Result PageDone() OVERRIDE; | 39 virtual Result PageDone() OVERRIDE; |
| 38 virtual Result DocumentDone() OVERRIDE; | 40 virtual Result DocumentDone() OVERRIDE; |
| 39 virtual void Cancel() OVERRIDE; | 41 virtual void Cancel() OVERRIDE; |
| 40 virtual void ReleaseContext() OVERRIDE; | 42 virtual void ReleaseContext() OVERRIDE; |
| 41 virtual gfx::NativeDrawingContext context() const OVERRIDE; | 43 virtual gfx::NativeDrawingContext context() const OVERRIDE; |
| 42 | 44 |
| 43 // Allocates the HDC for a specific DEVMODE. | |
| 44 static bool AllocateContext(const std::wstring& printer_name, | |
| 45 const DEVMODE* dev_mode, | |
| 46 gfx::NativeDrawingContext* context); | |
| 47 | |
| 48 protected: | 45 protected: |
| 49 virtual HRESULT ShowPrintDialog(PRINTDLGEX* options); | 46 virtual scoped_ptr<DEVMODE, base::FreeDeleter> ShowPrintDialog( |
| 47 HANDLE printer, |
| 48 gfx::NativeView parent_view, |
| 49 DEVMODE* dev_mode); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 // Class that manages the PrintDlgEx() callbacks. This is meant to be a | |
| 53 // temporary object used during the Print... dialog display. | |
| 54 class CallbackHandler; | |
| 55 | |
| 56 // Used in response to the user canceling the printing. | 52 // Used in response to the user canceling the printing. |
| 57 static BOOL CALLBACK AbortProc(HDC hdc, int nCode); | 53 static BOOL CALLBACK AbortProc(HDC hdc, int nCode); |
| 58 | 54 |
| 59 // Reads the settings from the selected device context. Updates settings_ and | 55 // Reads the settings from the selected device context. Updates settings_ and |
| 60 // its margins. | 56 // its margins. |
| 61 bool InitializeSettings(const DEVMODE& dev_mode, | 57 virtual Result InitializeSettings(const base::string16& device_name, |
| 62 const std::wstring& new_device_name, | 58 DEVMODE* dev_mode); |
| 63 const PRINTPAGERANGE* ranges, | |
| 64 int number_ranges, | |
| 65 bool selection_only); | |
| 66 | |
| 67 // Retrieves the printer's default low-level settings. On Windows, context_ is | |
| 68 // allocated with this call. | |
| 69 bool GetPrinterSettings(HANDLE printer, | |
| 70 const std::wstring& device_name); | |
| 71 | |
| 72 // Parses the result of a PRINTDLGEX result. | |
| 73 Result ParseDialogResultEx(const PRINTDLGEX& dialog_options); | |
| 74 Result ParseDialogResult(const PRINTDLG& dialog_options); | |
| 75 | 59 |
| 76 // The selected printer context. | 60 // The selected printer context. |
| 77 HDC context_; | 61 HDC context_; |
| 78 | 62 |
| 79 // The dialog box for the time it is shown. | |
| 80 volatile HWND dialog_box_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(PrintingContextWin); | 63 DISALLOW_COPY_AND_ASSIGN(PrintingContextWin); |
| 83 }; | 64 }; |
| 84 | 65 |
| 85 } // namespace printing | 66 } // namespace printing |
| 86 | 67 |
| 87 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_ | 68 #endif // PRINTING_PRINTING_CONTEXT_WIN_H_ |
| OLD | NEW |