1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QPRINTER_H |
5 | #define QPRINTER_H |
6 | |
7 | #include <QtPrintSupport/qtprintsupportglobal.h> |
8 | #include <QtCore/qstring.h> |
9 | #include <QtCore/qscopedpointer.h> |
10 | #include <QtGui/qpagedpaintdevice.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | |
15 | #ifndef QT_NO_PRINTER |
16 | |
17 | #if defined(B0) |
18 | #undef B0 // Terminal hang-up. We assume that you do not want that. |
19 | #endif |
20 | |
21 | class QPrinterPrivate; |
22 | class QPaintEngine; |
23 | class QPrintEngine; |
24 | class QPrinterInfo; |
25 | class QPageSize; |
26 | |
27 | class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice |
28 | { |
29 | Q_DECLARE_PRIVATE(QPrinter) |
30 | public: |
31 | enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution }; |
32 | |
33 | explicit QPrinter(PrinterMode mode = ScreenResolution); |
34 | explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution); |
35 | ~QPrinter(); |
36 | |
37 | int devType() const override; |
38 | |
39 | enum PageOrder { FirstPageFirst, |
40 | LastPageFirst }; |
41 | |
42 | enum ColorMode { GrayScale, |
43 | Color }; |
44 | |
45 | enum PaperSource { OnlyOne, |
46 | Lower, |
47 | Middle, |
48 | Manual, |
49 | Envelope, |
50 | EnvelopeManual, |
51 | Auto, |
52 | Tractor, |
53 | SmallFormat, |
54 | LargeFormat, |
55 | LargeCapacity, |
56 | Cassette, |
57 | FormSource, |
58 | MaxPageSource, // Deprecated |
59 | CustomSource, |
60 | LastPaperSource = CustomSource, |
61 | Upper = OnlyOne // As defined in Windows |
62 | }; |
63 | |
64 | enum PrinterState { Idle, |
65 | Active, |
66 | Aborted, |
67 | Error }; |
68 | |
69 | enum OutputFormat { NativeFormat, PdfFormat }; |
70 | |
71 | // Keep in sync with QAbstractPrintDialog::PrintRange |
72 | enum PrintRange { AllPages, Selection, , CurrentPage }; |
73 | |
74 | enum Unit { |
75 | Millimeter, |
76 | Point, |
77 | Inch, |
78 | Pica, |
79 | Didot, |
80 | Cicero, |
81 | DevicePixel |
82 | }; |
83 | |
84 | enum DuplexMode { |
85 | DuplexNone = 0, |
86 | DuplexAuto, |
87 | DuplexLongSide, |
88 | DuplexShortSide |
89 | }; |
90 | |
91 | void setOutputFormat(OutputFormat format); |
92 | OutputFormat outputFormat() const; |
93 | |
94 | void setPdfVersion(PdfVersion version); |
95 | PdfVersion pdfVersion() const; |
96 | |
97 | void setPrinterName(const QString &); |
98 | QString printerName() const; |
99 | |
100 | bool isValid() const; |
101 | |
102 | void setOutputFileName(const QString &); |
103 | QString outputFileName()const; |
104 | |
105 | void setPrintProgram(const QString &); |
106 | QString printProgram() const; |
107 | |
108 | void setDocName(const QString &); |
109 | QString docName() const; |
110 | |
111 | void setCreator(const QString &); |
112 | QString creator() const; |
113 | |
114 | void setPageOrder(PageOrder); |
115 | PageOrder pageOrder() const; |
116 | |
117 | void setResolution(int); |
118 | int resolution() const; |
119 | |
120 | void setColorMode(ColorMode); |
121 | ColorMode colorMode() const; |
122 | |
123 | void setCollateCopies(bool collate); |
124 | bool collateCopies() const; |
125 | |
126 | void setFullPage(bool); |
127 | bool fullPage() const; |
128 | |
129 | void setCopyCount(int); |
130 | int copyCount() const; |
131 | bool supportsMultipleCopies() const; |
132 | |
133 | void setPaperSource(PaperSource); |
134 | PaperSource paperSource() const; |
135 | |
136 | void setDuplex(DuplexMode duplex); |
137 | DuplexMode duplex() const; |
138 | |
139 | QList<int> supportedResolutions() const; |
140 | |
141 | #if defined(Q_OS_WIN) || defined(Q_QDOC) |
142 | QList<PaperSource> supportedPaperSources() const; |
143 | #endif |
144 | |
145 | void setFontEmbeddingEnabled(bool enable); |
146 | bool fontEmbeddingEnabled() const; |
147 | |
148 | QRectF paperRect(Unit) const; |
149 | QRectF (Unit) const; |
150 | |
151 | QString printerSelectionOption() const; |
152 | void setPrinterSelectionOption(const QString &); |
153 | |
154 | bool newPage() override; |
155 | bool abort(); |
156 | |
157 | PrinterState printerState() const; |
158 | |
159 | QPaintEngine *paintEngine() const override; |
160 | QPrintEngine *printEngine() const; |
161 | |
162 | void setFromTo(int fromPage, int toPage); |
163 | int fromPage() const; |
164 | int toPage() const; |
165 | |
166 | void setPrintRange(PrintRange range); |
167 | PrintRange printRange() const; |
168 | |
169 | protected: |
170 | int metric(PaintDeviceMetric) const override; |
171 | void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine); |
172 | |
173 | private: |
174 | Q_DISABLE_COPY(QPrinter) |
175 | |
176 | QScopedPointer<QPrinterPrivate> d_ptr; |
177 | |
178 | friend class QPrintDialogPrivate; |
179 | friend class QAbstractPrintDialog; |
180 | friend class QAbstractPrintDialogPrivate; |
181 | friend class QPrintPreviewWidgetPrivate; |
182 | friend class QTextDocument; |
183 | friend class QPageSetupWidget; |
184 | }; |
185 | |
186 | #endif // QT_NO_PRINTER |
187 | |
188 | QT_END_NAMESPACE |
189 | |
190 | #endif // QPRINTER_H |
191 | |