Qt 6.x
The Qt SDK
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
4#ifndef QPAGESIZE_H
5#define QPAGESIZE_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qsharedpointer.h>
9
11
12#if defined(B0)
13#undef B0 // Terminal hang-up. We assume that you do not want that.
14#endif
15
17class QString;
18class QSize;
19class QSizeF;
20
21class Q_GUI_EXPORT QPageSize
22{
23public:
24
26 // Old Qt sizes
59
60 // New values derived from PPD standard
67
79
80 // AnsiA = Letter,
81 // AnsiB = Ledger,
90
96
106
118
122
131 // EnvelopeC5 = C5E,
135 // EnvelopeDL = DLE,
136
138 // Envelope10 = Comm10E,
144
162
163 // Last item
164 LastPageSize = EnvelopeYou4,
165
166 // Convenience overloads for naming consistency
167 AnsiA = Letter,
168 AnsiB = Ledger,
169 EnvelopeC5 = C5E,
170 EnvelopeDL = DLE,
171 Envelope10 = Comm10E
172 };
173
174 // NOTE: Must keep in sync with QPageLayout::Unit and QPrinter::Unit
175 enum Unit {
181 Cicero
182 };
183
187 ExactMatch
188 };
189
190 QPageSize();
191 Q_IMPLICIT QPageSize(PageSizeId pageSizeId);
192 explicit QPageSize(const QSize &pointSize,
193 const QString &name = QString(),
194 SizeMatchPolicy matchPolicy = FuzzyMatch);
195 explicit QPageSize(const QSizeF &size, Unit units,
196 const QString &name = QString(),
197 SizeMatchPolicy matchPolicy = FuzzyMatch);
198 QPageSize(const QPageSize &other);
199 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageSize)
200 QPageSize &operator=(const QPageSize &other);
201 ~QPageSize();
202
203
204 void swap(QPageSize &other) noexcept { d.swap(other.d); }
205
206 friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
207 bool isEquivalentTo(const QPageSize &other) const;
208
209 bool isValid() const;
210
211 QString key() const;
212 QString name() const;
213
214 PageSizeId id() const;
215
216 int windowsId() const;
217
218 QSizeF definitionSize() const;
219 Unit definitionUnits() const;
220
221 QSizeF size(Unit units) const;
222 QSize sizePoints() const;
223 QSize sizePixels(int resolution) const;
224
225 QRectF rect(Unit units) const;
226 QRect rectPoints() const;
227 QRect rectPixels(int resolution) const;
228
229 static QString key(PageSizeId pageSizeId);
230 static QString name(PageSizeId pageSizeId);
231
232 static PageSizeId id(const QSize &pointSize,
233 SizeMatchPolicy matchPolicy = FuzzyMatch);
234 static PageSizeId id(const QSizeF &size, Unit units,
235 SizeMatchPolicy matchPolicy = FuzzyMatch);
236
237 static PageSizeId id(int windowsId);
238 static int windowsId(PageSizeId pageSizeId);
239
240 static QSizeF definitionSize(PageSizeId pageSizeId);
241 static Unit definitionUnits(PageSizeId pageSizeId);
242
243 static QSizeF size(PageSizeId pageSizeId, Unit units);
244 static QSize sizePoints(PageSizeId pageSizeId);
245 static QSize sizePixels(PageSizeId pageSizeId, int resolution);
246
247private:
248 friend class QPageSizePrivate;
250
251 bool equals(const QPageSize &other) const;
252 friend inline bool operator==(const QPageSize &lhs, const QPageSize &rhs)
253 { return lhs.equals(rhs); }
254 friend inline bool operator!=(const QPageSize &lhs, const QPageSize &rhs)
255 { return !(lhs == rhs); }
256
257 QPageSize(const QString &key, const QSize &pointSize, const QString &name);
258 QPageSize(int windowsId, const QSize &pointSize, const QString &name);
261};
262
263Q_DECLARE_SHARED(QPageSize)
264
265#ifndef QT_NO_DEBUG_STREAM
266Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize);
267#endif
268
270
272QT_DECL_METATYPE_EXTERN_TAGGED(QPageSize::PageSizeId, QPageSize__PageSizeId, Q_GUI_EXPORT)
273QT_DECL_METATYPE_EXTERN_TAGGED(QPageSize::Unit, QPageSize__Unit, Q_GUI_EXPORT)
274
275#endif // QPAGESIZE_H
\inmodule QtCore
\inmodule QtGui
Definition qpagesize.h:22
friend bool operator==(const QPageSize &lhs, const QPageSize &rhs)
Definition qpagesize.h:252
Unit
This enum type is used to specify the measurement unit for page sizes.
Definition qpagesize.h:175
friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs)
Returns true if page size lhs is equal to page size rhs, i.e.
void swap(QPageSize &other) noexcept
Swaps this QPageSize with other.
Definition qpagesize.h:204
friend bool operator!=(const QPageSize &lhs, const QPageSize &rhs)
Returns true if page size lhs is unequal to page size rhs, i.e.
Definition qpagesize.h:254
SizeMatchPolicy
\value FuzzyMatch Match to a standard page size if within the margin of tolerance.
Definition qpagesize.h:184
@ FuzzyOrientationMatch
Definition qpagesize.h:186
PageSizeId
This enum type lists the available page sizes as defined in the Postscript PPD standard.
Definition qpagesize.h:25
@ DoublePostcard
Definition qpagesize.h:114
@ Imperial12x11
Definition qpagesize.h:104
@ Imperial8x10
Definition qpagesize.h:98
@ Imperial10x11
Definition qpagesize.h:101
@ EnvelopePersonal
Definition qpagesize.h:143
@ EnvelopePrc10
Definition qpagesize.h:160
@ EnvelopeChou4
Definition qpagesize.h:146
@ Imperial10x13
Definition qpagesize.h:102
@ ExecutiveStandard
Definition qpagesize.h:107
@ FanFoldGerman
Definition qpagesize.h:120
@ EnvelopeKaku2
Definition qpagesize.h:149
@ Imperial9x11
Definition qpagesize.h:99
@ EnvelopeChou3
Definition qpagesize.h:145
@ TabloidExtra
Definition qpagesize.h:89
@ EnvelopeMonarch
Definition qpagesize.h:142
@ EnvelopeInvite
Definition qpagesize.h:147
@ Imperial10x14
Definition qpagesize.h:103
@ EnvelopeKaku3
Definition qpagesize.h:150
@ FanFoldGermanLegal
Definition qpagesize.h:121
@ LetterSmall
Definition qpagesize.h:88
@ EnvelopeItalian
Definition qpagesize.h:148
@ Imperial15x11
Definition qpagesize.h:105
@ LetterExtra
Definition qpagesize.h:86
@ Imperial7x9
Definition qpagesize.h:97
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qshareddata.h:35
\inmodule QtCore
Definition qsize.h:207
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
rect
[4]
Combined button and popup list for selecting options.
#define Q_IMPLICIT
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1367
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1355
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint id
[7]
GLfloat units
GLuint name
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize)
QSharedPointer< T > other(t)
[5]