| 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 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | #if defined(B0) |
| 13 | #undef B0 // Terminal hang-up. We assume that you do not want that. |
| 14 | #endif |
| 15 | |
| 16 | class QPageSizePrivate; |
| 17 | class QString; |
| 18 | class QSize; |
| 19 | class QSizeF; |
| 20 | |
| 21 | class Q_GUI_EXPORT QPageSize |
| 22 | { |
| 23 | public: |
| 24 | |
| 25 | enum PageSizeId { |
| 26 | // Old Qt sizes |
| 27 | Letter, |
| 28 | Legal, |
| 29 | Executive, |
| 30 | A0, |
| 31 | A1, |
| 32 | A2, |
| 33 | A3, |
| 34 | A4, |
| 35 | A5, |
| 36 | A6, |
| 37 | A7, |
| 38 | A8, |
| 39 | A9, |
| 40 | A10, |
| 41 | B0, |
| 42 | B1, |
| 43 | B2, |
| 44 | B3, |
| 45 | B4, |
| 46 | B5, |
| 47 | B6, |
| 48 | B7, |
| 49 | B8, |
| 50 | B9, |
| 51 | B10, |
| 52 | C5E, |
| 53 | Comm10E, |
| 54 | DLE, |
| 55 | Folio, |
| 56 | Ledger, |
| 57 | Tabloid, |
| 58 | Custom, |
| 59 | |
| 60 | // New values derived from PPD standard |
| 61 | , |
| 62 | , |
| 63 | A4Plus, |
| 64 | A4Small, |
| 65 | , |
| 66 | , |
| 67 | |
| 68 | JisB0, |
| 69 | JisB1, |
| 70 | JisB2, |
| 71 | JisB3, |
| 72 | JisB4, |
| 73 | JisB5, |
| 74 | JisB6, |
| 75 | JisB7, |
| 76 | JisB8, |
| 77 | JisB9, |
| 78 | JisB10, |
| 79 | |
| 80 | // AnsiA = Letter, |
| 81 | // AnsiB = Ledger, |
| 82 | AnsiC, |
| 83 | AnsiD, |
| 84 | AnsiE, |
| 85 | , |
| 86 | , |
| 87 | LetterPlus, |
| 88 | LetterSmall, |
| 89 | , |
| 90 | |
| 91 | ArchA, |
| 92 | ArchB, |
| 93 | ArchC, |
| 94 | ArchD, |
| 95 | ArchE, |
| 96 | |
| 97 | Imperial7x9, |
| 98 | Imperial8x10, |
| 99 | Imperial9x11, |
| 100 | Imperial9x12, |
| 101 | Imperial10x11, |
| 102 | Imperial10x13, |
| 103 | Imperial10x14, |
| 104 | Imperial12x11, |
| 105 | Imperial15x11, |
| 106 | |
| 107 | ExecutiveStandard, |
| 108 | Note, |
| 109 | Quarto, |
| 110 | Statement, |
| 111 | SuperA, |
| 112 | SuperB, |
| 113 | Postcard, |
| 114 | DoublePostcard, |
| 115 | Prc16K, |
| 116 | Prc32K, |
| 117 | Prc32KBig, |
| 118 | |
| 119 | FanFoldUS, |
| 120 | FanFoldGerman, |
| 121 | FanFoldGermanLegal, |
| 122 | |
| 123 | EnvelopeB4, |
| 124 | EnvelopeB5, |
| 125 | EnvelopeB6, |
| 126 | EnvelopeC0, |
| 127 | EnvelopeC1, |
| 128 | EnvelopeC2, |
| 129 | EnvelopeC3, |
| 130 | EnvelopeC4, |
| 131 | // EnvelopeC5 = C5E, |
| 132 | EnvelopeC6, |
| 133 | EnvelopeC65, |
| 134 | EnvelopeC7, |
| 135 | // EnvelopeDL = DLE, |
| 136 | |
| 137 | Envelope9, |
| 138 | // Envelope10 = Comm10E, |
| 139 | Envelope11, |
| 140 | Envelope12, |
| 141 | Envelope14, |
| 142 | EnvelopeMonarch, |
| 143 | EnvelopePersonal, |
| 144 | |
| 145 | EnvelopeChou3, |
| 146 | EnvelopeChou4, |
| 147 | EnvelopeInvite, |
| 148 | EnvelopeItalian, |
| 149 | EnvelopeKaku2, |
| 150 | EnvelopeKaku3, |
| 151 | EnvelopePrc1, |
| 152 | EnvelopePrc2, |
| 153 | EnvelopePrc3, |
| 154 | EnvelopePrc4, |
| 155 | EnvelopePrc5, |
| 156 | EnvelopePrc6, |
| 157 | EnvelopePrc7, |
| 158 | EnvelopePrc8, |
| 159 | EnvelopePrc9, |
| 160 | EnvelopePrc10, |
| 161 | EnvelopeYou4, |
| 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 { |
| 176 | Millimeter, |
| 177 | Point, |
| 178 | Inch, |
| 179 | Pica, |
| 180 | Didot, |
| 181 | Cicero |
| 182 | }; |
| 183 | |
| 184 | enum SizeMatchPolicy { |
| 185 | FuzzyMatch, |
| 186 | FuzzyOrientationMatch, |
| 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&: other.d); } |
| 205 | |
| 206 | #if QT_GUI_REMOVED_SINCE(6, 4) |
| 207 | friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs); |
| 208 | #endif |
| 209 | bool isEquivalentTo(const QPageSize &other) const; |
| 210 | |
| 211 | bool isValid() const; |
| 212 | |
| 213 | QString key() const; |
| 214 | QString name() const; |
| 215 | |
| 216 | PageSizeId id() const; |
| 217 | |
| 218 | int windowsId() const; |
| 219 | |
| 220 | QSizeF definitionSize() const; |
| 221 | Unit definitionUnits() const; |
| 222 | |
| 223 | QSizeF size(Unit units) const; |
| 224 | QSize sizePoints() const; |
| 225 | QSize sizePixels(int resolution) const; |
| 226 | |
| 227 | QRectF rect(Unit units) const; |
| 228 | QRect rectPoints() const; |
| 229 | QRect rectPixels(int resolution) const; |
| 230 | |
| 231 | static QString key(PageSizeId pageSizeId); |
| 232 | static QString name(PageSizeId pageSizeId); |
| 233 | |
| 234 | static PageSizeId id(const QSize &pointSize, |
| 235 | SizeMatchPolicy matchPolicy = FuzzyMatch); |
| 236 | static PageSizeId id(const QSizeF &size, Unit units, |
| 237 | SizeMatchPolicy matchPolicy = FuzzyMatch); |
| 238 | |
| 239 | static PageSizeId id(int windowsId); |
| 240 | static int windowsId(PageSizeId pageSizeId); |
| 241 | |
| 242 | static QSizeF definitionSize(PageSizeId pageSizeId); |
| 243 | static Unit definitionUnits(PageSizeId pageSizeId); |
| 244 | |
| 245 | static QSizeF size(PageSizeId pageSizeId, Unit units); |
| 246 | static QSize sizePoints(PageSizeId pageSizeId); |
| 247 | static QSize sizePixels(PageSizeId pageSizeId, int resolution); |
| 248 | |
| 249 | private: |
| 250 | friend class QPageSizePrivate; |
| 251 | friend class QPlatformPrintDevice; |
| 252 | |
| 253 | bool equals(const QPageSize &other) const; |
| 254 | friend inline bool operator==(const QPageSize &lhs, const QPageSize &rhs) |
| 255 | { return lhs.equals(other: rhs); } |
| 256 | friend inline bool operator!=(const QPageSize &lhs, const QPageSize &rhs) |
| 257 | { return !(lhs == rhs); } |
| 258 | |
| 259 | QPageSize(const QString &key, const QSize &pointSize, const QString &name); |
| 260 | QPageSize(int windowsId, const QSize &pointSize, const QString &name); |
| 261 | QPageSize(QPageSizePrivate &dd); |
| 262 | QSharedDataPointer<QPageSizePrivate> d; |
| 263 | }; |
| 264 | |
| 265 | Q_DECLARE_SHARED(QPageSize) |
| 266 | |
| 267 | #ifndef QT_NO_DEBUG_STREAM |
| 268 | Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize); |
| 269 | #endif |
| 270 | |
| 271 | QT_END_NAMESPACE |
| 272 | |
| 273 | QT_DECL_METATYPE_EXTERN(QPageSize, Q_GUI_EXPORT) |
| 274 | QT_DECL_METATYPE_EXTERN_TAGGED(QPageSize::PageSizeId, QPageSize__PageSizeId, Q_GUI_EXPORT) |
| 275 | QT_DECL_METATYPE_EXTERN_TAGGED(QPageSize::Unit, QPageSize__Unit, Q_GUI_EXPORT) |
| 276 | |
| 277 | #endif // QPAGESIZE_H |
| 278 | |