[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_MAC_H_ | ||||
6 | #define PRINTING_PRINTING_CONTEXT_MAC_H_ | ||||
7 | |||||
[email protected] | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/scoped_nsobject.h" |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 11 | #include "printing/printing_context.h" |
[email protected] | a44b0c14 | 2011-04-26 15:46:10 | [diff] [blame] | 12 | #include "printing/print_job_constants.h" |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 13 | |
14 | #ifdef __OBJC__ | ||||
15 | @class NSPrintInfo; | ||||
16 | #else | ||||
17 | class NSPrintInfo; | ||||
18 | #endif // __OBJC__ | ||||
19 | |||||
20 | namespace printing { | ||||
21 | |||||
22 | class PrintingContextMac : public PrintingContext { | ||||
23 | public: | ||||
[email protected] | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 24 | explicit PrintingContextMac(const std::string& app_locale); |
[email protected] | 3690ebe0 | 2011-05-25 09:08:19 | [diff] [blame] | 25 | virtual ~PrintingContextMac(); |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 26 | |
27 | // PrintingContext implementation. | ||||
28 | virtual void AskUserForSettings(gfx::NativeView parent_view, | ||||
29 | int max_pages, | ||||
30 | bool has_selection, | ||||
31 | PrintSettingsCallback* callback); | ||||
32 | virtual Result UseDefaultSettings(); | ||||
[email protected] | c82d3f21 | 2011-03-22 01:18:30 | [diff] [blame] | 33 | virtual Result UpdatePrintSettings(const DictionaryValue& job_settings, |
[email protected] | 89f5aa8c | 2011-03-21 20:58:44 | [diff] [blame] | 34 | const PageRanges& ranges); |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 35 | virtual Result InitWithSettings(const PrintSettings& settings); |
36 | virtual Result NewDocument(const string16& document_name); | ||||
37 | virtual Result NewPage(); | ||||
38 | virtual Result PageDone(); | ||||
39 | virtual Result DocumentDone(); | ||||
40 | virtual void Cancel(); | ||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 41 | virtual void ReleaseContext(); |
42 | virtual gfx::NativeDrawingContext context() const; | ||||
43 | |||||
44 | private: | ||||
[email protected] | 4274861a | 2011-06-03 19:27:00 | [diff] [blame^] | 45 | // Initializes PrintSettings from |print_info_|. This must be called |
46 | // after changes to |print_info_| in order for the changes to take effect in | ||||
47 | // printing. | ||||
48 | // This function ignores the page range information specified in the print | ||||
49 | // info object and use |ranges| instead. | ||||
[email protected] | 89f5aa8c | 2011-03-21 20:58:44 | [diff] [blame] | 50 | void InitPrintSettingsFromPrintInfo(const PageRanges& ranges); |
51 | |||||
[email protected] | 4274861a | 2011-06-03 19:27:00 | [diff] [blame^] | 52 | // Returns the set of page ranges constructed from |print_info_|. |
53 | PageRanges GetPageRangesFromPrintInfo(); | ||||
54 | |||||
[email protected] | 36fbeee2 | 2011-03-23 16:35:12 | [diff] [blame] | 55 | // Updates |print_info_| to use the given printer. |
56 | // Returns true if the printer was set else returns false. | ||||
[email protected] | 987e51f9 | 2011-05-04 21:10:15 | [diff] [blame] | 57 | bool SetPrinter(const std::string& device_name); |
[email protected] | 36fbeee2 | 2011-03-23 16:35:12 | [diff] [blame] | 58 | |
[email protected] | c97e5e8 | 2011-04-05 18:50:23 | [diff] [blame] | 59 | // Sets |copies| in PMPrintSettings. |
60 | // Returns true if the number of copies is set. | ||||
61 | bool SetCopiesInPrintSettings(int copies); | ||||
62 | |||||
63 | // Sets |collate| in PMPrintSettings. | ||||
64 | // Returns true if |collate| is set. | ||||
65 | bool SetCollateInPrintSettings(bool collate); | ||||
66 | |||||
[email protected] | d203486 | 2011-04-05 20:03:31 | [diff] [blame] | 67 | // Sets orientation in native print info object. |
68 | // Returns true if the orientation was set. | ||||
69 | bool SetOrientationIsLandscape(bool landscape); | ||||
70 | |||||
[email protected] | 770f906 | 2011-04-07 16:22:13 | [diff] [blame] | 71 | // Sets duplex mode in PMPrintSettings. |
72 | // Returns true if duplex mode is set. | ||||
[email protected] | 826e63a16 | 2011-04-20 18:00:45 | [diff] [blame] | 73 | bool SetDuplexModeInPrintSettings(DuplexMode mode); |
[email protected] | 770f906 | 2011-04-07 16:22:13 | [diff] [blame] | 74 | |
[email protected] | c7b3c63 | 2011-04-12 19:36:19 | [diff] [blame] | 75 | // Sets output color mode in PMPrintSettings. |
76 | // Returns true if color mode is set. | ||||
77 | bool SetOutputIsColor(bool color); | ||||
78 | |||||
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 79 | // The native print info object. |
[email protected] | a7d7b63 | 2011-03-15 21:55:02 | [diff] [blame] | 80 | scoped_nsobject<NSPrintInfo> print_info_; |
[email protected] | 51e8d935 | 2010-10-06 22:21:17 | [diff] [blame] | 81 | |
82 | // The current page's context; only valid between NewPage and PageDone call | ||||
83 | // pairs. | ||||
84 | CGContext* context_; | ||||
85 | |||||
86 | DISALLOW_COPY_AND_ASSIGN(PrintingContextMac); | ||||
87 | }; | ||||
88 | |||||
89 | } // namespace printing | ||||
90 | |||||
91 | #endif // PRINTING_PRINTING_CONTEXT_MAC_H_ |