blob: af6f9f63c73fd71af3e6f87735381f38d0051b62 [file] [log] [blame]
[email protected]7868ecab2011-03-05 00:12:531// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]51e8d9352010-10-06 22:21:172// 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]ee5f36e42010-12-03 22:40:378#include <string>
9
[email protected]3b63f8f42011-03-28 01:54:1510#include "base/memory/scoped_nsobject.h"
[email protected]51e8d9352010-10-06 22:21:1711#include "printing/printing_context.h"
[email protected]a44b0c142011-04-26 15:46:1012#include "printing/print_job_constants.h"
[email protected]51e8d9352010-10-06 22:21:1713
14#ifdef __OBJC__
15@class NSPrintInfo;
16#else
17class NSPrintInfo;
18#endif // __OBJC__
19
20namespace printing {
21
22class PrintingContextMac : public PrintingContext {
23 public:
[email protected]ee5f36e42010-12-03 22:40:3724 explicit PrintingContextMac(const std::string& app_locale);
[email protected]3690ebe02011-05-25 09:08:1925 virtual ~PrintingContextMac();
[email protected]51e8d9352010-10-06 22:21:1726
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]c82d3f212011-03-22 01:18:3033 virtual Result UpdatePrintSettings(const DictionaryValue& job_settings,
[email protected]89f5aa8c2011-03-21 20:58:4434 const PageRanges& ranges);
[email protected]51e8d9352010-10-06 22:21:1735 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]51e8d9352010-10-06 22:21:1741 virtual void ReleaseContext();
42 virtual gfx::NativeDrawingContext context() const;
43
44 private:
[email protected]4274861a2011-06-03 19:27:0045 // 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]89f5aa8c2011-03-21 20:58:4450 void InitPrintSettingsFromPrintInfo(const PageRanges& ranges);
51
[email protected]4274861a2011-06-03 19:27:0052 // Returns the set of page ranges constructed from |print_info_|.
53 PageRanges GetPageRangesFromPrintInfo();
54
[email protected]36fbeee22011-03-23 16:35:1255 // Updates |print_info_| to use the given printer.
56 // Returns true if the printer was set else returns false.
[email protected]987e51f92011-05-04 21:10:1557 bool SetPrinter(const std::string& device_name);
[email protected]36fbeee22011-03-23 16:35:1258
[email protected]c97e5e82011-04-05 18:50:2359 // 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]d2034862011-04-05 20:03:3167 // Sets orientation in native print info object.
68 // Returns true if the orientation was set.
69 bool SetOrientationIsLandscape(bool landscape);
70
[email protected]770f9062011-04-07 16:22:1371 // Sets duplex mode in PMPrintSettings.
72 // Returns true if duplex mode is set.
[email protected]826e63a162011-04-20 18:00:4573 bool SetDuplexModeInPrintSettings(DuplexMode mode);
[email protected]770f9062011-04-07 16:22:1374
[email protected]c7b3c632011-04-12 19:36:1975 // Sets output color mode in PMPrintSettings.
76 // Returns true if color mode is set.
77 bool SetOutputIsColor(bool color);
78
[email protected]51e8d9352010-10-06 22:21:1779 // The native print info object.
[email protected]a7d7b632011-03-15 21:55:0280 scoped_nsobject<NSPrintInfo> print_info_;
[email protected]51e8d9352010-10-06 22:21:1781
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_