| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QPRINTER_H |
| 41 | #define QPRINTER_H |
| 42 | |
| 43 | #include <QtPrintSupport/qtprintsupportglobal.h> |
| 44 | #include <QtCore/qstring.h> |
| 45 | #include <QtCore/qscopedpointer.h> |
| 46 | #include <QtGui/qpagedpaintdevice.h> |
| 47 | #include <QtGui/qpagelayout.h> |
| 48 | |
| 49 | QT_BEGIN_NAMESPACE |
| 50 | |
| 51 | |
| 52 | #ifndef QT_NO_PRINTER |
| 53 | |
| 54 | #if defined(B0) |
| 55 | #undef B0 // Terminal hang-up. We assume that you do not want that. |
| 56 | #endif |
| 57 | |
| 58 | class QPrinterPrivate; |
| 59 | class QRangeCollection; |
| 60 | class QPaintEngine; |
| 61 | class QPrintEngine; |
| 62 | class QPrinterInfo; |
| 63 | class QPageSize; |
| 64 | |
| 65 | class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice |
| 66 | { |
| 67 | Q_DECLARE_PRIVATE(QPrinter) |
| 68 | public: |
| 69 | enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution }; |
| 70 | |
| 71 | explicit QPrinter(PrinterMode mode = ScreenResolution); |
| 72 | explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution); |
| 73 | ~QPrinter(); |
| 74 | |
| 75 | int devType() const override; |
| 76 | |
| 77 | enum PageOrder { FirstPageFirst, |
| 78 | LastPageFirst }; |
| 79 | |
| 80 | enum ColorMode { GrayScale, |
| 81 | Color }; |
| 82 | |
| 83 | enum PaperSource { OnlyOne, |
| 84 | Lower, |
| 85 | Middle, |
| 86 | Manual, |
| 87 | Envelope, |
| 88 | EnvelopeManual, |
| 89 | Auto, |
| 90 | Tractor, |
| 91 | SmallFormat, |
| 92 | LargeFormat, |
| 93 | LargeCapacity, |
| 94 | Cassette, |
| 95 | FormSource, |
| 96 | MaxPageSource, // Deprecated |
| 97 | CustomSource, |
| 98 | LastPaperSource = CustomSource, |
| 99 | Upper = OnlyOne // As defined in Windows |
| 100 | }; |
| 101 | |
| 102 | enum PrinterState { Idle, |
| 103 | Active, |
| 104 | Aborted, |
| 105 | Error }; |
| 106 | |
| 107 | enum OutputFormat { NativeFormat, PdfFormat }; |
| 108 | |
| 109 | // Keep in sync with QAbstractPrintDialog::PrintRange |
| 110 | enum PrintRange { AllPages, Selection, , CurrentPage }; |
| 111 | |
| 112 | enum Unit { |
| 113 | Millimeter, |
| 114 | Point, |
| 115 | Inch, |
| 116 | Pica, |
| 117 | Didot, |
| 118 | Cicero, |
| 119 | DevicePixel |
| 120 | }; |
| 121 | |
| 122 | enum DuplexMode { |
| 123 | DuplexNone = 0, |
| 124 | DuplexAuto, |
| 125 | DuplexLongSide, |
| 126 | DuplexShortSide |
| 127 | }; |
| 128 | |
| 129 | void setOutputFormat(OutputFormat format); |
| 130 | OutputFormat outputFormat() const; |
| 131 | |
| 132 | void setPdfVersion(PdfVersion version); |
| 133 | PdfVersion pdfVersion() const; |
| 134 | |
| 135 | void setPrinterName(const QString &); |
| 136 | QString printerName() const; |
| 137 | |
| 138 | bool isValid() const; |
| 139 | |
| 140 | void setOutputFileName(const QString &); |
| 141 | QString outputFileName()const; |
| 142 | |
| 143 | void setPrintProgram(const QString &); |
| 144 | QString printProgram() const; |
| 145 | |
| 146 | void setDocName(const QString &); |
| 147 | QString docName() const; |
| 148 | |
| 149 | void setCreator(const QString &); |
| 150 | QString creator() const; |
| 151 | |
| 152 | void setPageOrder(PageOrder); |
| 153 | PageOrder pageOrder() const; |
| 154 | |
| 155 | void setResolution(int); |
| 156 | int resolution() const; |
| 157 | |
| 158 | void setColorMode(ColorMode); |
| 159 | ColorMode colorMode() const; |
| 160 | |
| 161 | void setCollateCopies(bool collate); |
| 162 | bool collateCopies() const; |
| 163 | |
| 164 | void setFullPage(bool); |
| 165 | bool fullPage() const; |
| 166 | |
| 167 | void setCopyCount(int); |
| 168 | int copyCount() const; |
| 169 | bool supportsMultipleCopies() const; |
| 170 | |
| 171 | void setPaperSource(PaperSource); |
| 172 | PaperSource paperSource() const; |
| 173 | |
| 174 | void setDuplex(DuplexMode duplex); |
| 175 | DuplexMode duplex() const; |
| 176 | |
| 177 | QList<int> supportedResolutions() const; |
| 178 | |
| 179 | #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) |
| 180 | QList<PaperSource> supportedPaperSources() const; |
| 181 | #endif |
| 182 | |
| 183 | void setFontEmbeddingEnabled(bool enable); |
| 184 | bool fontEmbeddingEnabled() const; |
| 185 | |
| 186 | QRectF paperRect(Unit) const; |
| 187 | QRectF (Unit) const; |
| 188 | |
| 189 | QString printerSelectionOption() const; |
| 190 | void setPrinterSelectionOption(const QString &); |
| 191 | |
| 192 | bool newPage() override; |
| 193 | bool abort(); |
| 194 | |
| 195 | PrinterState printerState() const; |
| 196 | |
| 197 | QPaintEngine *paintEngine() const override; |
| 198 | QPrintEngine *printEngine() const; |
| 199 | |
| 200 | void setFromTo(int fromPage, int toPage); |
| 201 | int fromPage() const; |
| 202 | int toPage() const; |
| 203 | |
| 204 | QRangeCollection *rangeCollection(); |
| 205 | |
| 206 | void setPrintRange(PrintRange range); |
| 207 | PrintRange printRange() const; |
| 208 | |
| 209 | protected: |
| 210 | int metric(PaintDeviceMetric) const override; |
| 211 | void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine); |
| 212 | |
| 213 | private: |
| 214 | Q_DISABLE_COPY(QPrinter) |
| 215 | |
| 216 | QScopedPointer<QPrinterPrivate> d_ptr; |
| 217 | |
| 218 | friend class QPrintDialogPrivate; |
| 219 | friend class QAbstractPrintDialog; |
| 220 | friend class QAbstractPrintDialogPrivate; |
| 221 | friend class QPrintPreviewWidgetPrivate; |
| 222 | friend class QTextDocument; |
| 223 | friend class QPageSetupWidget; |
| 224 | }; |
| 225 | |
| 226 | #endif // QT_NO_PRINTER |
| 227 | |
| 228 | QT_END_NAMESPACE |
| 229 | |
| 230 | #endif // QPRINTER_H |
| 231 | |