[email protected] | 7868ecab | 2011-03-05 00:12:53 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef PRINTING_PRINTING_CONTEXT_WIN_H_ | ||||
6 | #define PRINTING_PRINTING_CONTEXT_WIN_H_ | ||||
7 | |||||
dcheng | c3df9ba | 2016-04-07 23:09:32 | [diff] [blame] | 8 | #include <memory> |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 9 | #include <string> |
10 | |||||
avi | 126e93c | 2015-12-21 21:48:16 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 12 | #include "printing/printing_context.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 13 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 14 | |
15 | namespace printing { | ||||
16 | |||||
vitalybuka | f9d0c0c | 2014-09-09 19:53:33 | [diff] [blame] | 17 | class PrintSettings; |
18 | |||||
[email protected] | f487ac2 | 2014-02-13 17:04:31 | [diff] [blame] | 19 | class PRINTING_EXPORT PrintingContextWin : public PrintingContext { |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 20 | public: |
Vitaly Buka | bd7c981 | 2014-08-26 08:57:54 | [diff] [blame] | 21 | explicit PrintingContextWin(Delegate* delegate); |
nick | bc76161 | 2015-04-27 23:30:46 | [diff] [blame] | 22 | ~PrintingContextWin() override; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 23 | |
thestig | 5f68391 | 2016-09-30 22:42:16 | [diff] [blame] | 24 | // Initializes with predefined settings. |
25 | Result InitWithSettingsForTest(const PrintSettings& settings); | ||||
26 | |||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 27 | // PrintingContext implementation. |
Vladislav Kuzkokov | 48ceab2 | 2018-02-14 16:29:28 | [diff] [blame] | 28 | void AskUserForSettings(int max_pages, |
29 | bool has_selection, | ||||
30 | bool is_scripted, | ||||
31 | PrintSettingsCallback callback) override; | ||||
nick | bc76161 | 2015-04-27 23:30:46 | [diff] [blame] | 32 | Result UseDefaultSettings() override; |
33 | gfx::Size GetPdfPaperSizeDeviceUnits() override; | ||||
34 | Result UpdatePrinterSettings(bool external_preview, | ||||
vitalybuka | 95fa3c9 | 2015-05-05 03:03:32 | [diff] [blame] | 35 | bool show_system_dialog, |
36 | int page_count) override; | ||||
nick | bc76161 | 2015-04-27 23:30:46 | [diff] [blame] | 37 | Result NewDocument(const base::string16& document_name) override; |
38 | Result NewPage() override; | ||||
39 | Result PageDone() override; | ||||
40 | Result DocumentDone() override; | ||||
41 | void Cancel() override; | ||||
42 | void ReleaseContext() override; | ||||
Nico Weber | 8e55956 | 2017-10-03 01:25:26 | [diff] [blame] | 43 | printing::NativeDrawingContext context() const override; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 44 | |
[email protected] | 97a8063 | 2014-03-27 17:50:39 | [diff] [blame] | 45 | protected: |
vitalybuka | f9d0c0c | 2014-09-09 19:53:33 | [diff] [blame] | 46 | static HWND GetRootWindow(gfx::NativeView view); |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 47 | |
48 | // Reads the settings from the selected device context. Updates settings_ and | ||||
49 | // its margins. | ||||
vitalybuka | 92ab8ce | 2014-08-26 23:41:45 | [diff] [blame] | 50 | virtual Result InitializeSettings(const base::string16& device_name, |
51 | DEVMODE* dev_mode); | ||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 52 | |
vitalybuka | f9d0c0c | 2014-09-09 19:53:33 | [diff] [blame] | 53 | void set_context(HDC context) { context_ = context; } |
54 | |||||
55 | private: | ||||
vitalybuka | f9d0c0c | 2014-09-09 19:53:33 | [diff] [blame] | 56 | // Used in response to the user canceling the printing. |
57 | static BOOL CALLBACK AbortProc(HDC hdc, int nCode); | ||||
58 | |||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 59 | // The selected printer context. |
60 | HDC context_; | ||||
61 | |||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 62 | DISALLOW_COPY_AND_ASSIGN(PrintingContextWin); |
63 | }; | ||||
64 | |||||
65 | } // namespace printing | ||||
66 | |||||
67 | #endif // PRINTING_PRINTING_CONTEXT_WIN_H_ |