| 1 | // Copyright (C) 2020 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 | #include "qpagedpaintdevice_p.h" |
| 5 | #include <qpagedpaintdevice.h> |
| 6 | |
| 7 | QT_BEGIN_NAMESPACE |
| 8 | |
| 9 | |
| 10 | QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate() = default; |
| 11 | |
| 12 | /*! |
| 13 | \class QPagedPaintDevice |
| 14 | \inmodule QtGui |
| 15 | |
| 16 | \brief The QPagedPaintDevice class represents a paint device that supports |
| 17 | multiple pages. |
| 18 | |
| 19 | \ingroup painting |
| 20 | |
| 21 | Paged paint devices are used to generate output for printing or for formats like PDF. |
| 22 | QPdfWriter and QPrinter inherit from it. |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | /*! |
| 27 | \internal |
| 28 | Constructs a new paged paint device with the derived private class. |
| 29 | */ |
| 30 | QPagedPaintDevice::QPagedPaintDevice(QPagedPaintDevicePrivate *dd) |
| 31 | : d(dd) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | /*! |
| 36 | Destroys the object. |
| 37 | */ |
| 38 | QPagedPaintDevice::~QPagedPaintDevice() |
| 39 | { |
| 40 | delete d; |
| 41 | } |
| 42 | |
| 43 | /*! |
| 44 | \internal |
| 45 | Returns the QPagedPaintDevicePrivate. |
| 46 | */ |
| 47 | QPagedPaintDevicePrivate *QPagedPaintDevice::dd() |
| 48 | { |
| 49 | return d; |
| 50 | } |
| 51 | |
| 52 | /*! |
| 53 | \fn bool QPagedPaintDevice::newPage() |
| 54 | |
| 55 | Starts a new page. Returns \c true on success. |
| 56 | */ |
| 57 | |
| 58 | /*! |
| 59 | \enum QPagedPaintDevice::PdfVersion |
| 60 | |
| 61 | The PdfVersion enum describes the version of the PDF file that |
| 62 | is produced by QPrinter or QPdfWriter. |
| 63 | |
| 64 | \value PdfVersion_1_4 A PDF 1.4 compatible document is produced. |
| 65 | |
| 66 | \value PdfVersion_A1b A PDF/A-1b compatible document is produced. |
| 67 | |
| 68 | \value PdfVersion_1_6 A PDF 1.6 compatible document is produced. |
| 69 | This value was added in Qt 5.12. |
| 70 | |
| 71 | \value [since 6.8] PdfVersion_X4 A PDF/X-4 compatible document is |
| 72 | produced. |
| 73 | */ |
| 74 | |
| 75 | /*! |
| 76 | \since 5.3 |
| 77 | |
| 78 | Sets the page layout to \a newPageLayout. |
| 79 | |
| 80 | You should call this before calling QPainter::begin(), or immediately |
| 81 | before calling newPage() to apply the new page layout to a new page. |
| 82 | You should not call any painting methods between a call to setPageLayout() |
| 83 | and newPage() as the wrong paint metrics may be used. |
| 84 | |
| 85 | Returns true if the page layout was successfully set to \a newPageLayout. |
| 86 | |
| 87 | \sa pageLayout() |
| 88 | */ |
| 89 | |
| 90 | bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout) |
| 91 | { |
| 92 | return d->setPageLayout(newPageLayout); |
| 93 | } |
| 94 | |
| 95 | /*! |
| 96 | \since 5.3 |
| 97 | |
| 98 | Sets the page size to \a pageSize. |
| 99 | |
| 100 | To get the current QPageSize use pageLayout().pageSize(). |
| 101 | |
| 102 | You should call this before calling QPainter::begin(), or immediately |
| 103 | before calling newPage() to apply the new page size to a new page. |
| 104 | You should not call any painting methods between a call to setPageSize() |
| 105 | and newPage() as the wrong paint metrics may be used. |
| 106 | |
| 107 | Returns true if the page size was successfully set to \a pageSize. |
| 108 | |
| 109 | \sa pageLayout() |
| 110 | */ |
| 111 | |
| 112 | bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize) |
| 113 | { |
| 114 | return d->setPageSize(pageSize); |
| 115 | } |
| 116 | |
| 117 | /*! |
| 118 | \since 5.3 |
| 119 | |
| 120 | Sets the page \a orientation. |
| 121 | |
| 122 | The page orientation is used to define the orientation of the |
| 123 | page size when obtaining the page rect. |
| 124 | |
| 125 | You should call this before calling QPainter::begin(), or immediately |
| 126 | before calling newPage() to apply the new orientation to a new page. |
| 127 | You should not call any painting methods between a call to setPageOrientation() |
| 128 | and newPage() as the wrong paint metrics may be used. |
| 129 | |
| 130 | To get the current QPageLayout::Orientation use pageLayout().orientation(). |
| 131 | |
| 132 | Returns true if the page orientation was successfully set to \a orientation. |
| 133 | |
| 134 | \sa pageLayout() |
| 135 | */ |
| 136 | |
| 137 | bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation) |
| 138 | { |
| 139 | return d->setPageOrientation(orientation); |
| 140 | } |
| 141 | |
| 142 | /*! |
| 143 | \since 5.3 |
| 144 | |
| 145 | Set the page \a margins defined in the given \a units. |
| 146 | |
| 147 | You should call this before calling QPainter::begin(), or immediately |
| 148 | before calling newPage() to apply the new margins to a new page. |
| 149 | You should not call any painting methods between a call to setPageMargins() |
| 150 | and newPage() as the wrong paint metrics may be used. |
| 151 | |
| 152 | To get the current page margins use pageLayout().margins(). |
| 153 | |
| 154 | Returns true if the page margins were successfully set to \a margins. |
| 155 | |
| 156 | \sa pageLayout() |
| 157 | */ |
| 158 | |
| 159 | bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) |
| 160 | { |
| 161 | return d->setPageMargins(margins, units); |
| 162 | } |
| 163 | |
| 164 | /*! |
| 165 | \since 5.3 |
| 166 | |
| 167 | Returns the current page layout. Use this method to access the current |
| 168 | QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect(). |
| 169 | |
| 170 | Note that you cannot use the setters on the returned object, you must either |
| 171 | call the individual QPagedPaintDevice setters or use setPageLayout(). |
| 172 | |
| 173 | \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins() |
| 174 | */ |
| 175 | |
| 176 | QPageLayout QPagedPaintDevice::pageLayout() const |
| 177 | { |
| 178 | return d->pageLayout(); |
| 179 | } |
| 180 | |
| 181 | /*! |
| 182 | \since 6.0 |
| 183 | |
| 184 | Returns the page ranges associated with this device. |
| 185 | |
| 186 | \sa QPageRanges, QPrinter::fromPage(), QPrinter::toPage() |
| 187 | */ |
| 188 | QPageRanges QPagedPaintDevice::() const |
| 189 | { |
| 190 | return d->pageRanges; |
| 191 | } |
| 192 | |
| 193 | /*! |
| 194 | \since 6.0 |
| 195 | |
| 196 | Sets the page ranges for this device to \a ranges. |
| 197 | */ |
| 198 | void QPagedPaintDevice::(const QPageRanges &ranges) |
| 199 | { |
| 200 | d->pageRanges = ranges; |
| 201 | } |
| 202 | |
| 203 | QT_END_NAMESPACE |
| 204 | |