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
qpagesize.h
Go to the documentation of this file.
1// Copyright (C) 2014 John Layt <jlayt@kde.org>
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
5#ifndef QPAGESIZE_H
6#define QPAGESIZE_H
7
8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qmetatype.h>
10#include <QtCore/qshareddata.h>
11
12QT_BEGIN_NAMESPACE
13
14#if defined(B0)
15#undef B0 // Terminal hang-up. We assume that you do not want that.
16#endif
17
18class QPageSizePrivate;
19class QString;
20class QSize;
21class QSizeF;
22
23class Q_GUI_EXPORT QPageSize
24{
25public:
26
27 enum PageSizeId {
28 // Old Qt sizes
29 Letter,
30 Legal,
31 Executive,
32 A0,
33 A1,
34 A2,
35 A3,
36 A4,
37 A5,
38 A6,
39 A7,
40 A8,
41 A9,
42 A10,
43 B0,
44 B1,
45 B2,
46 B3,
47 B4,
48 B5,
49 B6,
50 B7,
51 B8,
52 B9,
53 B10,
54 C5E,
55 Comm10E,
56 DLE,
57 Folio,
58 Ledger,
59 Tabloid,
60 Custom,
61
62 // New values derived from PPD standard
63 A3Extra,
64 A4Extra,
65 A4Plus,
66 A4Small,
67 A5Extra,
68 B5Extra,
69
70 JisB0,
71 JisB1,
72 JisB2,
73 JisB3,
74 JisB4,
75 JisB5,
76 JisB6,
77 JisB7,
78 JisB8,
79 JisB9,
80 JisB10,
81
82 // AnsiA = Letter,
83 // AnsiB = Ledger,
84 AnsiC,
85 AnsiD,
86 AnsiE,
87 LegalExtra,
88 LetterExtra,
89 LetterPlus,
90 LetterSmall,
91 TabloidExtra,
92
93 ArchA,
94 ArchB,
95 ArchC,
96 ArchD,
97 ArchE,
98
99 Imperial7x9,
100 Imperial8x10,
101 Imperial9x11,
102 Imperial9x12,
103 Imperial10x11,
104 Imperial10x13,
105 Imperial10x14,
106 Imperial12x11,
107 Imperial15x11,
108
109 ExecutiveStandard,
110 Note,
111 Quarto,
112 Statement,
113 SuperA,
114 SuperB,
115 Postcard,
116 DoublePostcard,
117 Prc16K,
118 Prc32K,
119 Prc32KBig,
120
121 FanFoldUS,
122 FanFoldGerman,
123 FanFoldGermanLegal,
124
125 EnvelopeB4,
126 EnvelopeB5,
127 EnvelopeB6,
128 EnvelopeC0,
129 EnvelopeC1,
130 EnvelopeC2,
131 EnvelopeC3,
132 EnvelopeC4,
133 // EnvelopeC5 = C5E,
134 EnvelopeC6,
135 EnvelopeC65,
136 EnvelopeC7,
137 // EnvelopeDL = DLE,
138
139 Envelope9,
140 // Envelope10 = Comm10E,
141 Envelope11,
142 Envelope12,
143 Envelope14,
144 EnvelopeMonarch,
145 EnvelopePersonal,
146
147 EnvelopeChou3,
148 EnvelopeChou4,
149 EnvelopeInvite,
150 EnvelopeItalian,
151 EnvelopeKaku2,
152 EnvelopeKaku3,
153 EnvelopePrc1,
154 EnvelopePrc2,
155 EnvelopePrc3,
156 EnvelopePrc4,
157 EnvelopePrc5,
158 EnvelopePrc6,
159 EnvelopePrc7,
160 EnvelopePrc8,
161 EnvelopePrc9,
162 EnvelopePrc10,
163 EnvelopeYou4,
164
165 // Last item
166 LastPageSize = EnvelopeYou4,
167
168 // Convenience overloads for naming consistency
169 AnsiA = Letter,
170 AnsiB = Ledger,
171 EnvelopeC5 = C5E,
172 EnvelopeDL = DLE,
173 Envelope10 = Comm10E
174 };
175
176 // NOTE: Must keep in sync with QPageLayout::Unit and QPrinter::Unit
177 enum Unit {
178 Millimeter,
179 Point,
180 Inch,
181 Pica,
182 Didot,
183 Cicero
184 };
185
186 enum SizeMatchPolicy {
187 FuzzyMatch,
188 FuzzyOrientationMatch,
189 ExactMatch
190 };
191
192 QPageSize();
193 Q_IMPLICIT QPageSize(PageSizeId pageSizeId);
194 explicit QPageSize(const QSize &pointSize,
195 const QString &name = QString(),
196 SizeMatchPolicy matchPolicy = FuzzyMatch);
197 explicit QPageSize(const QSizeF &size, Unit units,
198 const QString &name = QString(),
199 SizeMatchPolicy matchPolicy = FuzzyMatch);
200 QPageSize(const QPageSize &other);
201 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageSize)
202 QPageSize &operator=(const QPageSize &other);
203 ~QPageSize();
204
205
206 void swap(QPageSize &other) noexcept { d.swap(other.d); }
207
208#if QT_GUI_REMOVED_SINCE(6, 4)
209 friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
210#endif
211 bool isEquivalentTo(const QPageSize &other) const;
212
213 bool isValid() const;
214
215 QString key() const;
216 QString name() const;
217
218 PageSizeId id() const;
219
220 int windowsId() const;
221
222 QSizeF definitionSize() const;
223 Unit definitionUnits() const;
224
225 QSizeF size(Unit units) const;
226 QSize sizePoints() const;
227 QSize sizePixels(int resolution) const;
228
229 QRectF rect(Unit units) const;
230 QRect rectPoints() const;
231 QRect rectPixels(int resolution) const;
232
233 static QString key(PageSizeId pageSizeId);
234 static QString name(PageSizeId pageSizeId);
235
236 static PageSizeId id(const QSize &pointSize,
237 SizeMatchPolicy matchPolicy = FuzzyMatch);
238 static PageSizeId id(const QSizeF &size, Unit units,
239 SizeMatchPolicy matchPolicy = FuzzyMatch);
240
241 static PageSizeId id(int windowsId);
242 static int windowsId(PageSizeId pageSizeId);
243
244 static QSizeF definitionSize(PageSizeId pageSizeId);
245 static Unit definitionUnits(PageSizeId pageSizeId);
246
247 static QSizeF size(PageSizeId pageSizeId, Unit units);
248 static QSize sizePoints(PageSizeId pageSizeId);
249 static QSize sizePixels(PageSizeId pageSizeId, int resolution);
250
251private:
252 friend class QPageSizePrivate;
253 friend class QPlatformPrintDevice;
254
255 bool equals(const QPageSize &other) const;
256 friend inline bool operator==(const QPageSize &lhs, const QPageSize &rhs)
257 { return lhs.equals(rhs); }
258 friend inline bool operator!=(const QPageSize &lhs, const QPageSize &rhs)
259 { return !(lhs == rhs); }
260
261 QPageSize(const QString &key, const QSize &pointSize, const QString &name);
262 QPageSize(int windowsId, const QSize &pointSize, const QString &name);
263 QPageSize(QPageSizePrivate &dd);
264 QSharedDataPointer<QPageSizePrivate> d;
265};
266
268
269#ifndef QT_NO_DEBUG_STREAM
270Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize);
271#endif
272
273QT_END_NAMESPACE
274
275QT_DECL_METATYPE_EXTERN(QPageSize, Q_GUI_EXPORT)
276QT_DECL_METATYPE_EXTERN_TAGGED(QPageSize::PageSizeId, QPageSize__PageSizeId, Q_GUI_EXPORT)
277QT_DECL_METATYPE_EXTERN_TAGGED(QPageSize::Unit, QPageSize__Unit, Q_GUI_EXPORT)
278
279#endif // QPAGESIZE_H
bool operator==(const QPageSizePrivate &other) const
QSizeF size(QPageSize::Unit units) const
bool isValid() const
bool isEquivalentTo(const QPageSizePrivate &other) const
QPageSizePrivate(int windowsId, const QSize &pointSize, const QString &name)
QPageSizePrivate(const QSize &pointSize, const QString &name, QPageSize::SizeMatchPolicy matchPolicy)
QPageSizePrivate(QPageSize::PageSizeId pageSizeId)
QPageSizePrivate(const QSizeF &size, QPageSize::Unit units, const QString &name, QPageSize::SizeMatchPolicy matchPolicy)
QPageSizePrivate(const QString &key, const QSize &size, const QString &name)
QSize sizePixels(int resolution) const
\inmodule QtGui
Definition qpagesize.h:24
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2582
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
static QSizeF qt_definitionSize(QPageSize::PageSizeId pageSizeId)
static QString msgImperialPageSizeInch(int width, int height)
static QString qt_keyForPageSizeId(QPageSize::PageSizeId id)
static qreal qt_pointMultiplier(QPageSize::Unit unit)
static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match=nullptr)
static QPageSize::PageSizeId qt_idForSize(const QSizeF &size, QPageSize::Unit units, QPageSize::SizeMatchPolicy matchPolicy, QSize *match)
static QSizeF qt_unitSize(QPageSize::PageSizeId pageSizeId, QPageSize::Unit units)
static QSize qt_convertUnitsToPoints(const QSizeF &size, QPageSize::Unit units)
static QSize qt_convertPointsToPixels(const QSize &size, int resolution)
static const int qt_windowsConversion[][2]
static const int pageSizesCount
static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match=nullptr)
static QString qt_nameForCustomSize(const QSizeF &size, QPageSize::Unit units)
static QString qt_keyForCustomSize(const QSizeF &size, QPageSize::Unit units)
static QSizeF qt_convertUnits(const QSizeF &size, QPageSize::Unit fromUnits, QPageSize::Unit toUnits)
static const StandardPageSize qt_pageSizes[]
static QSizeF qt_convertPointsToUnits(const QSize &size, QPageSize::Unit units)
static QPageSize::PageSizeId qt_idForPointSize(const QSize &size, QPageSize::SizeMatchPolicy matchPolicy, QSize *match)
const char mediaOption[20]