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___
10 #include "nsISupports.h"
13 class nsIPrintSettings
;
17 class DrawEventRecorder
;
20 } // namespace mozilla
22 #define NS_IDEVICE_CONTEXT_SPEC_IID \
24 0xf407cfba, 0xbe28, 0x46c9, { \
25 0x8a, 0xba, 0x04, 0x2d, 0xae, 0xbb, 0x4f, 0x23 \
29 class nsIDeviceContextSpec
: public nsISupports
{
31 typedef mozilla::gfx::PrintTarget PrintTarget
;
33 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID
)
36 * Initialize the device context spec.
37 * @param aWidget A widget a dialog can be hosted in
38 * @param aPrintSettings Print settings for the print operation
39 * @param aIsPrintPreview True if creating Spec for PrintPreview
40 * @return NS_OK or a suitable error code.
42 NS_IMETHOD
Init(nsIWidget
* aWidget
, nsIPrintSettings
* aPrintSettings
,
43 bool aIsPrintPreview
) = 0;
45 virtual already_AddRefed
<PrintTarget
> MakePrintTarget() = 0;
48 * If required override to return a recorder to record the print.
50 * @param aDrawEventRecorder out param for the recorder to use
51 * @return NS_OK or a suitable error code
53 NS_IMETHOD
GetDrawEventRecorder(
54 mozilla::gfx::DrawEventRecorder
** aDrawEventRecorder
) {
55 MOZ_ASSERT(aDrawEventRecorder
);
56 *aDrawEventRecorder
= nullptr;
61 * Override to return something other than the default.
63 * @return DPI for printing.
65 virtual float GetDPI() { return 72.0f
; }
68 * Override to return something other than the default.
70 * @return the printing scale to be applied to the context for printing.
72 virtual float GetPrintingScale() { return 1.0f
; }
75 * Override to return something other than the default.
77 * @return the point to translate the context to for printing.
79 virtual gfxPoint
GetPrintingTranslate() { return gfxPoint(0, 0); }
81 NS_IMETHOD
BeginDocument(const nsAString
& aTitle
,
82 const nsAString
& aPrintToFileName
,
83 int32_t aStartPage
, int32_t aEndPage
) = 0;
85 NS_IMETHOD
EndDocument() = 0;
86 NS_IMETHOD
AbortDocument() { return EndDocument(); }
87 NS_IMETHOD
BeginPage() = 0;
88 NS_IMETHOD
EndPage() = 0;
91 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContextSpec
, NS_IDEVICE_CONTEXT_SPEC_IID
)