Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:09:33

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QPRINTER_H
0006 #define QPRINTER_H
0007 
0008 #include <QtPrintSupport/qtprintsupportglobal.h>
0009 #include <QtCore/qstring.h>
0010 #include <QtCore/qscopedpointer.h>
0011 #include <QtGui/qpagedpaintdevice.h>
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 
0016 #ifndef QT_NO_PRINTER
0017 
0018 #if defined(B0)
0019 #undef B0 // Terminal hang-up.  We assume that you do not want that.
0020 #endif
0021 
0022 class QPrinterPrivate;
0023 class QPaintEngine;
0024 class QPrintEngine;
0025 class QPrinterInfo;
0026 class QPageSize;
0027 
0028 class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice
0029 {
0030     Q_DECLARE_PRIVATE(QPrinter)
0031 public:
0032     enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution };
0033 
0034     explicit QPrinter(PrinterMode mode = ScreenResolution);
0035     explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution);
0036     ~QPrinter();
0037 
0038     int devType() const override;
0039 
0040     enum PageOrder   { FirstPageFirst,
0041                        LastPageFirst };
0042 
0043     enum ColorMode   { GrayScale,
0044                        Color };
0045 
0046     enum PaperSource { OnlyOne,
0047                        Lower,
0048                        Middle,
0049                        Manual,
0050                        Envelope,
0051                        EnvelopeManual,
0052                        Auto,
0053                        Tractor,
0054                        SmallFormat,
0055                        LargeFormat,
0056                        LargeCapacity,
0057                        Cassette,
0058                        FormSource,
0059                        MaxPageSource, // Deprecated
0060                        CustomSource,
0061                        LastPaperSource = CustomSource,
0062                        Upper = OnlyOne  // As defined in Windows
0063     };
0064 
0065     enum PrinterState { Idle,
0066                         Active,
0067                         Aborted,
0068                         Error };
0069 
0070     enum OutputFormat { NativeFormat, PdfFormat };
0071 
0072     // Keep in sync with QAbstractPrintDialog::PrintRange
0073     enum PrintRange { AllPages, Selection, PageRange, CurrentPage };
0074 
0075     enum Unit {
0076         Millimeter,
0077         Point,
0078         Inch,
0079         Pica,
0080         Didot,
0081         Cicero,
0082         DevicePixel
0083     };
0084 
0085     enum DuplexMode {
0086         DuplexNone = 0,
0087         DuplexAuto,
0088         DuplexLongSide,
0089         DuplexShortSide
0090     };
0091 
0092     void setOutputFormat(OutputFormat format);
0093     OutputFormat outputFormat() const;
0094 
0095     void setPdfVersion(PdfVersion version);
0096     PdfVersion pdfVersion() const;
0097 
0098     void setPrinterName(const QString &);
0099     QString printerName() const;
0100 
0101     bool isValid() const;
0102 
0103     void setOutputFileName(const QString &);
0104     QString outputFileName()const;
0105 
0106     void setPrintProgram(const QString &);
0107     QString printProgram() const;
0108 
0109     void setDocName(const QString &);
0110     QString docName() const;
0111 
0112     void setCreator(const QString &);
0113     QString creator() const;
0114 
0115     void setPageOrder(PageOrder);
0116     PageOrder pageOrder() const;
0117 
0118     void setResolution(int);
0119     int resolution() const;
0120 
0121     void setColorMode(ColorMode);
0122     ColorMode colorMode() const;
0123 
0124     void setCollateCopies(bool collate);
0125     bool collateCopies() const;
0126 
0127     void setFullPage(bool);
0128     bool fullPage() const;
0129 
0130     void setCopyCount(int);
0131     int copyCount() const;
0132     bool supportsMultipleCopies() const;
0133 
0134     void setPaperSource(PaperSource);
0135     PaperSource paperSource() const;
0136 
0137     void setDuplex(DuplexMode duplex);
0138     DuplexMode duplex() const;
0139 
0140     QList<int> supportedResolutions() const;
0141 
0142 #if defined(Q_OS_WIN) || defined(Q_QDOC)
0143     QList<PaperSource> supportedPaperSources() const;
0144 #endif
0145 
0146     void setFontEmbeddingEnabled(bool enable);
0147     bool fontEmbeddingEnabled() const;
0148 
0149     QRectF paperRect(Unit) const;
0150     QRectF pageRect(Unit) const;
0151 
0152     QString printerSelectionOption() const;
0153     void setPrinterSelectionOption(const QString &);
0154 
0155     bool newPage() override;
0156     bool abort();
0157 
0158     PrinterState printerState() const;
0159 
0160     QPaintEngine *paintEngine() const override;
0161     QPrintEngine *printEngine() const;
0162 
0163     void setFromTo(int fromPage, int toPage);
0164     int fromPage() const;
0165     int toPage() const;
0166 
0167     void setPrintRange(PrintRange range);
0168     PrintRange printRange() const;
0169 
0170 protected:
0171     int metric(PaintDeviceMetric) const override;
0172     void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
0173 
0174 private:
0175     Q_DISABLE_COPY(QPrinter)
0176 
0177     QScopedPointer<QPrinterPrivate> d_ptr;
0178 
0179     friend class QPrintDialogPrivate;
0180     friend class QAbstractPrintDialog;
0181     friend class QAbstractPrintDialogPrivate;
0182     friend class QPrintPreviewWidgetPrivate;
0183     friend class QTextDocument;
0184     friend class QPageSetupWidget;
0185 };
0186 
0187 #endif // QT_NO_PRINTER
0188 
0189 QT_END_NAMESPACE
0190 
0191 #endif // QPRINTER_H