Bug 1705532 use async/await instead of callbacks r=annyG
[gecko.git] / widget / nsIDeviceContextSpec.h
blobcbcaf1535e38069a88f9f3fe28f17cb66b2449ad
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIDeviceContextSpec_h___
7 #define nsIDeviceContextSpec_h___
9 #include "gfxPoint.h"
10 #include "nsISupports.h"
11 #include "mozilla/StaticPrefs_print.h"
13 class nsIWidget;
14 class nsIPrintSettings;
16 namespace mozilla {
17 namespace gfx {
18 class DrawEventRecorder;
19 class PrintTarget;
20 } // namespace gfx
21 } // namespace mozilla
23 #define NS_IDEVICE_CONTEXT_SPEC_IID \
24 { \
25 0xf407cfba, 0xbe28, 0x46c9, { \
26 0x8a, 0xba, 0x04, 0x2d, 0xae, 0xbb, 0x4f, 0x23 \
27 } \
30 class nsIDeviceContextSpec : public nsISupports {
31 public:
32 typedef mozilla::gfx::PrintTarget PrintTarget;
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
36 /**
37 * Initialize the device context spec.
38 * @param aWidget A widget a dialog can be hosted in
39 * @param aPrintSettings Print settings for the print operation
40 * @param aIsPrintPreview True if creating Spec for PrintPreview
41 * @return NS_OK or a suitable error code.
43 NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPrintSettings,
44 bool aIsPrintPreview) = 0;
46 virtual already_AddRefed<PrintTarget> MakePrintTarget() = 0;
48 /**
49 * If required override to return a recorder to record the print.
51 * @param aDrawEventRecorder out param for the recorder to use
52 * @return NS_OK or a suitable error code
54 NS_IMETHOD GetDrawEventRecorder(
55 mozilla::gfx::DrawEventRecorder** aDrawEventRecorder) {
56 MOZ_ASSERT(aDrawEventRecorder);
57 *aDrawEventRecorder = nullptr;
58 return NS_OK;
61 /**
62 * Override to return something other than the default.
64 * @return DPI for printing.
66 virtual float GetDPI() { return mozilla::StaticPrefs::print_default_dpi(); }
68 /**
69 * Override to return something other than the default.
71 * @return the printing scale to be applied to the context for printing.
73 virtual float GetPrintingScale() { return 72.0f / GetDPI(); }
75 /**
76 * Override to return something other than the default.
78 * @return the point to translate the context to for printing.
80 virtual gfxPoint GetPrintingTranslate() { return gfxPoint(0, 0); }
82 NS_IMETHOD BeginDocument(const nsAString& aTitle,
83 const nsAString& aPrintToFileName,
84 int32_t aStartPage, int32_t aEndPage) = 0;
86 NS_IMETHOD EndDocument() = 0;
87 NS_IMETHOD AbortDocument() { return EndDocument(); }
88 NS_IMETHOD BeginPage() = 0;
89 NS_IMETHOD EndPage() = 0;
92 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContextSpec, NS_IDEVICE_CONTEXT_SPEC_IID)
93 #endif