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"
11 #include "mozilla/StaticPrefs_print.h"
14 class nsIPrintSettings
;
18 class DrawEventRecorder
;
21 } // namespace mozilla
23 #define NS_IDEVICE_CONTEXT_SPEC_IID \
25 0xf407cfba, 0xbe28, 0x46c9, { \
26 0x8a, 0xba, 0x04, 0x2d, 0xae, 0xbb, 0x4f, 0x23 \
30 class nsIDeviceContextSpec
: public nsISupports
{
32 typedef mozilla::gfx::PrintTarget PrintTarget
;
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID
)
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;
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;
62 * Override to return something other than the default.
64 * @return DPI for printing.
66 virtual float GetDPI() { return mozilla::StaticPrefs::print_default_dpi(); }
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(); }
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
)