kmadhusu@chromium.org | 7868ecab | 2011-03-05 00:12:53 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
jhawkins@chromium.org | 51e8d93 | 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 | |
sanjeevr@chromium.org | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 8 | #include <string> |
| 9 | |
levin@chromium.org | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/scoped_nsobject.h" |
jhawkins@chromium.org | 51e8d93 | 2010-10-06 22:21:17 | [diff] [blame] | 11 | #include "printing/printing_context.h" |
| 12 | |
| 13 | #ifdef __OBJC__ |
| 14 | @class NSPrintInfo; |
| 15 | #else |
| 16 | class NSPrintInfo; |
| 17 | #endif // __OBJC__ |
| 18 | |
| 19 | namespace printing { |
| 20 | |
| 21 | class PrintingContextMac : public PrintingContext { |
| 22 | public: |
sanjeevr@chromium.org | ee5f36e4 | 2010-12-03 22:40:37 | [diff] [blame] | 23 | explicit PrintingContextMac(const std::string& app_locale); |
jhawkins@chromium.org | 51e8d93 | 2010-10-06 22:21:17 | [diff] [blame] | 24 | ~PrintingContextMac(); |
| 25 | |
| 26 | // PrintingContext implementation. |
| 27 | virtual void AskUserForSettings(gfx::NativeView parent_view, |
| 28 | int max_pages, |
| 29 | bool has_selection, |
| 30 | PrintSettingsCallback* callback); |
| 31 | virtual Result UseDefaultSettings(); |
thestig@chromium.org | c82d3f21 | 2011-03-22 01:18:30 | [diff] [blame] | 32 | virtual Result UpdatePrintSettings(const DictionaryValue& job_settings, |
kmadhusu@chromium.org | 89f5aa8c | 2011-03-21 20:58:44 | [diff] [blame] | 33 | const PageRanges& ranges); |
jhawkins@chromium.org | 51e8d93 | 2010-10-06 22:21:17 | [diff] [blame] | 34 | virtual Result InitWithSettings(const PrintSettings& settings); |
| 35 | virtual Result NewDocument(const string16& document_name); |
| 36 | virtual Result NewPage(); |
| 37 | virtual Result PageDone(); |
| 38 | virtual Result DocumentDone(); |
| 39 | virtual void Cancel(); |
jhawkins@chromium.org | 51e8d93 | 2010-10-06 22:21:17 | [diff] [blame] | 40 | virtual void ReleaseContext(); |
| 41 | virtual gfx::NativeDrawingContext context() const; |
| 42 | |
| 43 | private: |
| 44 | // Read the settings from the given NSPrintInfo (and cache it for later use). |
| 45 | void ParsePrintInfo(NSPrintInfo* print_info); |
| 46 | |
kmadhusu@chromium.org | 89f5aa8c | 2011-03-21 20:58:44 | [diff] [blame] | 47 | // Initializes PrintSettings from native print info object. |
| 48 | void InitPrintSettingsFromPrintInfo(const PageRanges& ranges); |
| 49 | |
kmadhusu@chromium.org | 36fbeee2 | 2011-03-23 16:35:12 | [diff] [blame] | 50 | // Updates |print_info_| to use the given printer. |
| 51 | // Returns true if the printer was set else returns false. |
| 52 | bool SetPrinter(const std::string& printer_name); |
| 53 | |
kmadhusu@chromium.org | c97e5e8 | 2011-04-05 18:50:23 | [diff] [blame] | 54 | // Sets |copies| in PMPrintSettings. |
| 55 | // Returns true if the number of copies is set. |
| 56 | bool SetCopiesInPrintSettings(int copies); |
| 57 | |
| 58 | // Sets |collate| in PMPrintSettings. |
| 59 | // Returns true if |collate| is set. |
| 60 | bool SetCollateInPrintSettings(bool collate); |
| 61 | |
kmadhusu@chromium.org | d203486 | 2011-04-05 20:03:31 | [diff] [blame] | 62 | // Sets orientation in native print info object. |
| 63 | // Returns true if the orientation was set. |
| 64 | bool SetOrientationIsLandscape(bool landscape); |
| 65 | |
kmadhusu@chromium.org | 770f906 | 2011-04-07 16:22:13 | [diff] [blame] | 66 | // Sets duplex mode in PMPrintSettings. |
| 67 | // Returns true if duplex mode is set. |
| 68 | bool SetDuplexModeIsTwoSided(bool two_sided); |
| 69 | |
kmadhusu@chromium.org | c7b3c63 | 2011-04-12 19:36:19 | [diff] [blame^] | 70 | // Sets output color mode in PMPrintSettings. |
| 71 | // Returns true if color mode is set. |
| 72 | bool SetOutputIsColor(bool color); |
| 73 | |
jhawkins@chromium.org | 51e8d93 | 2010-10-06 22:21:17 | [diff] [blame] | 74 | // The native print info object. |
kmadhusu@chromium.org | a7d7b63 | 2011-03-15 21:55:02 | [diff] [blame] | 75 | scoped_nsobject<NSPrintInfo> print_info_; |
jhawkins@chromium.org | 51e8d93 | 2010-10-06 22:21:17 | [diff] [blame] | 76 | |
| 77 | // The current page's context; only valid between NewPage and PageDone call |
| 78 | // pairs. |
| 79 | CGContext* context_; |
| 80 | |
| 81 | DISALLOW_COPY_AND_ASSIGN(PrintingContextMac); |
| 82 | }; |
| 83 | |
| 84 | } // namespace printing |
| 85 | |
| 86 | #endif // PRINTING_PRINTING_CONTEXT_MAC_H_ |