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