Bug 1614845 [wpt PR 21744] - Revert "[Shape Detection] Use IDL dictionaries for resul...
[gecko.git] / widget / nsIPrintSettings.idl
blob3c8a0b4367ff714cea910a779743b2830c894a24
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #include "nsISupports.idl"
9 %{ C++
10 #include "nsMargin.h"
11 #include "nsTArray.h"
14 /**
15 * Native types
17 [ref] native nsNativeIntMarginRef(nsIntMargin);
18 [ref] native IntegerArray(nsTArray<int32_t>);
20 interface nsIPrintSession;
22 /**
23 * Simplified graphics interface for JS rendering.
25 [scriptable, uuid(ecc5cbad-57fc-4731-b0bd-09e865bd62ad)]
26 interface nsIPrintSettings : nsISupports
28 /**
29 * PrintSettings to be Saved Navigation Constants
31 const unsigned long kInitSaveOddEvenPages = 0x00000001;
32 const unsigned long kInitSaveHeaderLeft = 0x00000002;
33 const unsigned long kInitSaveHeaderCenter = 0x00000004;
34 const unsigned long kInitSaveHeaderRight = 0x00000008;
35 const unsigned long kInitSaveFooterLeft = 0x00000010;
36 const unsigned long kInitSaveFooterCenter = 0x00000020;
37 const unsigned long kInitSaveFooterRight = 0x00000040;
38 const unsigned long kInitSaveBGColors = 0x00000080;
39 const unsigned long kInitSaveBGImages = 0x00000100;
40 const unsigned long kInitSavePaperSize = 0x00000200;
41 const unsigned long kInitSaveResolution = 0x00000400;
42 const unsigned long kInitSaveDuplex = 0x00000800;
43 /* Flag 0x00001000 is unused */
44 const unsigned long kInitSavePaperData = 0x00002000;
45 const unsigned long kInitSaveUnwriteableMargins = 0x00004000;
46 const unsigned long kInitSaveEdges = 0x00008000;
48 const unsigned long kInitSaveReversed = 0x00010000;
49 const unsigned long kInitSaveInColor = 0x00020000;
50 const unsigned long kInitSaveOrientation = 0x00040000;
52 const unsigned long kInitSavePrinterName = 0x00100000;
53 const unsigned long kInitSavePrintToFile = 0x00200000;
54 const unsigned long kInitSaveToFileName = 0x00400000;
55 const unsigned long kInitSavePageDelay = 0x00800000;
56 const unsigned long kInitSaveMargins = 0x01000000;
57 const unsigned long kInitSaveNativeData = 0x02000000;
59 const unsigned long kInitSaveShrinkToFit = 0x08000000;
60 const unsigned long kInitSaveScaling = 0x10000000;
62 const unsigned long kInitSaveAll = 0xFFFFFFFF;
64 /* Print Option Flags for Bit Field*/
65 const long kPrintOddPages = 0x00000001;
66 const long kPrintEvenPages = 0x00000002;
67 const long kEnableSelectionRB = 0x00000004;
69 /* Print Range Enums */
70 const long kRangeAllPages = 0;
71 const long kRangeSpecifiedPageRange = 1;
72 const long kRangeSelection = 2;
74 /* Justification Enums */
75 const long kJustLeft = 0;
76 const long kJustCenter = 1;
77 const long kJustRight = 2;
79 /**
80 * Page Size Type Constants
82 const short kPaperSizeNativeData = 0;
83 const short kPaperSizeDefined = 1;
85 /**
86 * Page Size Unit Constants
88 const short kPaperSizeInches = 0;
89 const short kPaperSizeMillimeters = 1;
91 /**
92 * Orientation Constants
94 const short kPortraitOrientation = 0;
95 const short kLandscapeOrientation = 1;
97 /**
98 * Output file format
100 const short kOutputFormatNative = 0;
101 const short kOutputFormatPS = 1;
102 const short kOutputFormatPDF = 2;
105 * Set PrintOptions
107 void SetPrintOptions(in int32_t aType, in boolean aTurnOnOff);
110 * Get PrintOptions
112 boolean GetPrintOptions(in int32_t aType);
115 * Get PrintOptions Bit field
117 int32_t GetPrintOptionsBits();
120 * Set PrintOptions Bit field
122 void SetPrintOptionsBits(in int32_t bits);
125 * Get the page size in twips, considering the
126 * orientation (portrait or landscape).
128 void GetEffectivePageSize(out double aWidth, out double aHeight);
131 * Makes a new copy
133 nsIPrintSettings clone();
136 * Assigns the internal values from the "in" arg to the current object
138 void assign(in nsIPrintSettings aPS);
141 * Data Members
143 [noscript] attribute nsIPrintSession printSession; /* We hold a weak reference */
145 attribute long startPageRange;
146 attribute long endPageRange;
149 * The edge measurements define the positioning of the headers
150 * and footers on the page. They're measured as an offset from
151 * the "unwriteable margin" (described below).
153 attribute double edgeTop; /* these are in inches */
154 attribute double edgeLeft;
155 attribute double edgeBottom;
156 attribute double edgeRight;
159 * The margins define the positioning of the content on the page.
160 * They're treated as an offset from the "unwriteable margin"
161 * (described below).
163 attribute double marginTop; /* these are in inches */
164 attribute double marginLeft;
165 attribute double marginBottom;
166 attribute double marginRight;
168 * The unwriteable margin defines the printable region of the paper, creating
169 * an invisible border from which the edge and margin attributes are measured.
171 attribute double unwriteableMarginTop; /* these are in inches */
172 attribute double unwriteableMarginLeft;
173 attribute double unwriteableMarginBottom;
174 attribute double unwriteableMarginRight;
176 attribute double scaling; /* values 0.0 - 1.0 */
177 attribute boolean printBGColors; /* Print Background Colors */
178 attribute boolean printBGImages; /* Print Background Images */
180 attribute short printRange;
182 attribute AString title;
183 attribute AString docURL;
185 attribute AString headerStrLeft;
186 attribute AString headerStrCenter;
187 attribute AString headerStrRight;
189 attribute AString footerStrLeft;
190 attribute AString footerStrCenter;
191 attribute AString footerStrRight;
193 attribute boolean isCancelled; /* indicates whether the print job has been cancelled */
194 readonly attribute boolean saveOnCancel; /* indicates whether the print settings should be saved after a cancel */
195 attribute boolean printSilent; /* print without putting up the dialog */
196 attribute boolean shrinkToFit; /* shrinks content to fit on page */
197 attribute boolean showPrintProgress; /* indicates whether the progress dialog should be shown */
199 /* Additional XP Related */
200 attribute AString paperName; /* name of paper */
201 attribute short paperData; /* native data value */
202 attribute double paperWidth; /* width of the paper in inches or mm */
203 attribute double paperHeight; /* height of the paper in inches or mm */
204 attribute short paperSizeUnit; /* paper is in inches or mm */
206 attribute boolean printReversed;
207 attribute boolean printInColor; /* a false means grayscale */
208 attribute long orientation; /* see orientation consts */
209 attribute long numCopies;
211 attribute AString printerName; /* name of destination printer */
213 attribute boolean printToFile;
214 attribute AString toFileName;
215 attribute short outputFormat;
217 attribute long printPageDelay; /* in milliseconds */
219 attribute long resolution; /* print resolution (dpi) */
221 attribute long duplex; /* duplex mode */
223 /* initialize helpers */
225 * This attribute tracks whether the PS has been initialized
226 * from a printer specified by the "printerName" attr.
227 * If a different name is set into the "printerName"
228 * attribute than the one it was initialized with the PS
229 * will then get intialized from that printer.
231 attribute boolean isInitializedFromPrinter;
234 * This attribute tracks whether the PS has been initialized
235 * from prefs. If a different name is set into the "printerName"
236 * attribute than the one it was initialized with the PS
237 * will then get intialized from prefs again.
239 attribute boolean isInitializedFromPrefs;
241 /* C++ Helper Functions */
242 [noscript] void SetMarginInTwips(in nsNativeIntMarginRef aMargin);
243 [noscript] void SetEdgeInTwips(in nsNativeIntMarginRef aEdge);
244 /* Purposely made this an "in" arg */
245 [noscript] void GetMarginInTwips(in nsNativeIntMarginRef aMargin);
246 [noscript] void GetEdgeInTwips(in nsNativeIntMarginRef aEdge);
249 * We call this function so that anything that requires a run of the event loop
250 * can do so safely. The print dialog runs the event loop but in silent printing
251 * that doesn't happen.
253 * Either this or ShowPrintDialog (but not both) MUST be called by the print engine
254 * before printing, otherwise printing can fail on some platforms.
256 [noscript] void SetupSilentPrinting();
259 * Sets/Gets the "unwriteable margin" for the page format. This defines
260 * the boundary from which we'll measure the EdgeInTwips and MarginInTwips
261 * attributes, to place the headers and content, respectively.
263 * Note: Implementations of SetUnwriteableMarginInTwips should handle
264 * negative margin values by falling back on the system default for
265 * that margin.
267 [noscript] void SetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge);
268 [noscript] void GetUnwriteableMarginInTwips(in nsNativeIntMarginRef aEdge);
271 * Get more accurate print ranges from the superior interval
272 * (startPageRange, endPageRange). The aPages array is populated with a
273 * list of pairs (start, end), where the endpoints are included. The print
274 * ranges (start, end), must not overlap and must be in the
275 * (startPageRange, endPageRange) scope.
277 * If there are no print ranges the aPages array is cleared.
279 [noscript] void GetPageRanges(in IntegerArray aPages);