123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- /****************************************************************************
- **
- ** Copyright (C) 2016 The Qt Company Ltd.
- ** Contact: https://www.qt.io/licensing/
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms
- ** and conditions see https://www.qt.io/terms-conditions. For further
- ** information use the contact form at https://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 3 as published by the Free Software
- ** Foundation and appearing in the file LICENSE.LGPL3 included in the
- ** packaging of this file. Please review the following information to
- ** ensure the GNU Lesser General Public License version 3 requirements
- ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
- **
- ** GNU General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU
- ** General Public License version 2.0 or (at your option) the GNU General
- ** Public license version 3 or any later version approved by the KDE Free
- ** Qt Foundation. The licenses are as published by the Free Software
- ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
- ** included in the packaging of this file. Please review the following
- ** information to ensure the GNU General Public License requirements will
- ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
- ** https://www.gnu.org/licenses/gpl-3.0.html.
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
- #ifndef QPRINTER_H
- #define QPRINTER_H
- #include <QtCore/qstring.h>
- #include <QtCore/qscopedpointer.h>
- #include <QtGui/qpagedpaintdevice.h>
- #include <QtGui/qpagelayout.h>
- #include <QtPrintSupport/qtprintsupportglobal.h>
- QT_BEGIN_NAMESPACE
- #ifndef QT_NO_PRINTER
- #if defined(B0)
- #undef B0 // Terminal hang-up. We assume that you do not want that.
- #endif
- class QPrinterPrivate;
- class QPaintEngine;
- class QPrintEngine;
- class QPrinterInfo;
- class QPageSize;
- class QPageMargins;
- class Q_PRINTSUPPORT_EXPORT QPrinter : public QPagedPaintDevice
- {
- Q_DECLARE_PRIVATE(QPrinter)
- public:
- enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution };
- explicit QPrinter(PrinterMode mode = ScreenResolution);
- explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution);
- ~QPrinter();
- int devType() const Q_DECL_OVERRIDE;
- enum Orientation { Portrait, Landscape };
- // ### Qt6 Remove in favor of QPage::PageSize
- // NOTE: Must keep in sync with QPageSize and QPagedPaintDevice
- #ifndef Q_QDOC
- typedef PageSize PaperSize;
- #else
- enum PaperSize {
- // Existing Qt sizes
- A4,
- B5,
- Letter,
- Legal,
- Executive,
- A0,
- A1,
- A2,
- A3,
- A5,
- A6,
- A7,
- A8,
- A9,
- B0,
- B1,
- B10,
- B2,
- B3,
- B4,
- B6,
- B7,
- B8,
- B9,
- C5E,
- Comm10E,
- DLE,
- Folio,
- Ledger,
- Tabloid,
- Custom,
- // New values derived from PPD standard
- A10,
- A3Extra,
- A4Extra,
- A4Plus,
- A4Small,
- A5Extra,
- B5Extra,
- JisB0,
- JisB1,
- JisB2,
- JisB3,
- JisB4,
- JisB5,
- JisB6,
- JisB7,
- JisB8,
- JisB9,
- JisB10,
- // AnsiA = Letter,
- // AnsiB = Ledger,
- AnsiC,
- AnsiD,
- AnsiE,
- LegalExtra,
- LetterExtra,
- LetterPlus,
- LetterSmall,
- TabloidExtra,
- ArchA,
- ArchB,
- ArchC,
- ArchD,
- ArchE,
- Imperial7x9,
- Imperial8x10,
- Imperial9x11,
- Imperial9x12,
- Imperial10x11,
- Imperial10x13,
- Imperial10x14,
- Imperial12x11,
- Imperial15x11,
- ExecutiveStandard,
- Note,
- Quarto,
- Statement,
- SuperA,
- SuperB,
- Postcard,
- DoublePostcard,
- Prc16K,
- Prc32K,
- Prc32KBig,
- FanFoldUS,
- FanFoldGerman,
- FanFoldGermanLegal,
- EnvelopeB4,
- EnvelopeB5,
- EnvelopeB6,
- EnvelopeC0,
- EnvelopeC1,
- EnvelopeC2,
- EnvelopeC3,
- EnvelopeC4,
- // EnvelopeC5 = C5E,
- EnvelopeC6,
- EnvelopeC65,
- EnvelopeC7,
- // EnvelopeDL = DLE,
- Envelope9,
- // Envelope10 = Comm10E,
- Envelope11,
- Envelope12,
- Envelope14,
- EnvelopeMonarch,
- EnvelopePersonal,
- EnvelopeChou3,
- EnvelopeChou4,
- EnvelopeInvite,
- EnvelopeItalian,
- EnvelopeKaku2,
- EnvelopeKaku3,
- EnvelopePrc1,
- EnvelopePrc2,
- EnvelopePrc3,
- EnvelopePrc4,
- EnvelopePrc5,
- EnvelopePrc6,
- EnvelopePrc7,
- EnvelopePrc8,
- EnvelopePrc9,
- EnvelopePrc10,
- EnvelopeYou4,
- // Last item, with commonly used synynoms from QPagedPrintEngine / QPrinter
- LastPageSize = EnvelopeYou4,
- NPageSize = LastPageSize,
- NPaperSize = LastPageSize,
- // Convenience overloads for naming consistency
- AnsiA = Letter,
- AnsiB = Ledger,
- EnvelopeC5 = C5E,
- EnvelopeDL = DLE,
- Envelope10 = Comm10E
- };
- #endif
- enum PageOrder { FirstPageFirst,
- LastPageFirst };
- enum ColorMode { GrayScale,
- Color };
- enum PaperSource { OnlyOne,
- Lower,
- Middle,
- Manual,
- Envelope,
- EnvelopeManual,
- Auto,
- Tractor,
- SmallFormat,
- LargeFormat,
- LargeCapacity,
- Cassette,
- FormSource,
- MaxPageSource, // Deprecated
- CustomSource,
- LastPaperSource = CustomSource,
- Upper = OnlyOne // As defined in Windows
- };
- enum PrinterState { Idle,
- Active,
- Aborted,
- Error };
- enum OutputFormat { NativeFormat, PdfFormat };
- // Keep in sync with QAbstractPrintDialog::PrintRange
- enum PrintRange { AllPages, Selection, PageRange, CurrentPage };
- enum Unit {
- Millimeter,
- Point,
- Inch,
- Pica,
- Didot,
- Cicero,
- DevicePixel
- };
- enum DuplexMode {
- DuplexNone = 0,
- DuplexAuto,
- DuplexLongSide,
- DuplexShortSide
- };
- void setOutputFormat(OutputFormat format);
- OutputFormat outputFormat() const;
- void setPrinterName(const QString &);
- QString printerName() const;
- bool isValid() const;
- void setOutputFileName(const QString &);
- QString outputFileName()const;
- void setPrintProgram(const QString &);
- QString printProgram() const;
- void setDocName(const QString &);
- QString docName() const;
- void setCreator(const QString &);
- QString creator() const;
- #ifdef Q_QDOC
- bool setPageLayout(const QPageLayout &pageLayout);
- bool setPageSize(const QPageSize &pageSize);
- bool setPageOrientation(QPageLayout::Orientation orientation);
- bool setPageMargins(const QMarginsF &margins);
- bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
- QPageLayout pageLayout() const;
- #else
- using QPagedPaintDevice::setPageSize;
- using QPagedPaintDevice::setPageMargins;
- #endif
- void setOrientation(Orientation);
- Orientation orientation() const;
- void setPageSize(PageSize) Q_DECL_OVERRIDE;
- PageSize pageSize() const;
- void setPageSizeMM(const QSizeF &size) Q_DECL_OVERRIDE;
- void setPaperSize(PaperSize);
- PaperSize paperSize() const;
- void setPaperSize(const QSizeF &paperSize, Unit unit);
- QSizeF paperSize(Unit unit) const;
- void setPaperName(const QString &paperName);
- QString paperName() const;
- void setPageOrder(PageOrder);
- PageOrder pageOrder() const;
- void setResolution(int);
- int resolution() const;
- void setColorMode(ColorMode);
- ColorMode colorMode() const;
- void setCollateCopies(bool collate);
- bool collateCopies() const;
- void setFullPage(bool);
- bool fullPage() const;
- void setNumCopies(int);
- int numCopies() const;
- int actualNumCopies() const;
- void setCopyCount(int);
- int copyCount() const;
- bool supportsMultipleCopies() const;
- void setPaperSource(PaperSource);
- PaperSource paperSource() const;
- void setDuplex(DuplexMode duplex);
- DuplexMode duplex() const;
- QList<int> supportedResolutions() const;
- #ifdef Q_OS_WIN
- QList<PaperSource> supportedPaperSources() const;
- #endif
- void setFontEmbeddingEnabled(bool enable);
- bool fontEmbeddingEnabled() const;
- void setDoubleSidedPrinting(bool enable);
- bool doubleSidedPrinting() const;
- void setWinPageSize(int winPageSize);
- int winPageSize() const;
- QRect paperRect() const;
- QRect pageRect() const;
- QRectF paperRect(Unit) const;
- QRectF pageRect(Unit) const;
- QString printerSelectionOption() const;
- void setPrinterSelectionOption(const QString &);
- bool newPage() Q_DECL_OVERRIDE;
- bool abort();
- PrinterState printerState() const;
- QPaintEngine *paintEngine() const Q_DECL_OVERRIDE;
- QPrintEngine *printEngine() const;
- void setFromTo(int fromPage, int toPage);
- int fromPage() const;
- int toPage() const;
- void setPrintRange(PrintRange range);
- PrintRange printRange() const;
- void setMargins(const Margins &m) Q_DECL_OVERRIDE;
- void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit);
- void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const;
- protected:
- int metric(PaintDeviceMetric) const Q_DECL_OVERRIDE;
- void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
- private:
- Q_DISABLE_COPY(QPrinter)
- QScopedPointer<QPrinterPrivate> d_ptr;
- friend class QPrintDialogPrivate;
- friend class QAbstractPrintDialog;
- friend class QAbstractPrintDialogPrivate;
- friend class QPrintPreviewWidgetPrivate;
- friend class QTextDocument;
- friend class QPageSetupWidget;
- };
- #endif // QT_NO_PRINTER
- QT_END_NAMESPACE
- #endif // QPRINTER_H
|