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