| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2014 John Layt <jlayt@kde.org> | 
|---|
| 4 | ** Contact: https://www.qt.io/licensing/ | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial License Usage | 
|---|
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
|---|
| 11 | ** accordance with the commercial license agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
|---|
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
|---|
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
|---|
| 16 | ** | 
|---|
| 17 | ** GNU Lesser General Public License Usage | 
|---|
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 19 | ** General Public License version 3 as published by the Free Software | 
|---|
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
|---|
| 21 | ** packaging of this file. Please review the following information to | 
|---|
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
|---|
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
|---|
| 24 | ** | 
|---|
| 25 | ** GNU General Public License Usage | 
|---|
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
|---|
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
|---|
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
|---|
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
|---|
| 31 | ** included in the packaging of this file. Please review the following | 
|---|
| 32 | ** information to ensure the GNU General Public License requirements will | 
|---|
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
|---|
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** $QT_END_LICENSE$ | 
|---|
| 37 | ** | 
|---|
| 38 | ****************************************************************************/ | 
|---|
| 39 |  | 
|---|
| 40 | #ifndef QPAGESIZE_H | 
|---|
| 41 | #define QPAGESIZE_H | 
|---|
| 42 |  | 
|---|
| 43 | #include <QtGui/qtguiglobal.h> | 
|---|
| 44 | #include <QtCore/qsharedpointer.h> | 
|---|
| 45 |  | 
|---|
| 46 | QT_BEGIN_NAMESPACE | 
|---|
| 47 |  | 
|---|
| 48 | #if defined(B0) | 
|---|
| 49 | #undef B0 // Terminal hang-up.  We assume that you do not want that. | 
|---|
| 50 | #endif | 
|---|
| 51 |  | 
|---|
| 52 | class QPageSizePrivate; | 
|---|
| 53 | class QString; | 
|---|
| 54 | class QSize; | 
|---|
| 55 | class QSizeF; | 
|---|
| 56 |  | 
|---|
| 57 | class Q_GUI_EXPORT QPageSize | 
|---|
| 58 | { | 
|---|
| 59 | public: | 
|---|
| 60 |  | 
|---|
| 61 | enum PageSizeId { | 
|---|
| 62 | // Old Qt sizes | 
|---|
| 63 | Letter, | 
|---|
| 64 | Legal, | 
|---|
| 65 | Executive, | 
|---|
| 66 | A0, | 
|---|
| 67 | A1, | 
|---|
| 68 | A2, | 
|---|
| 69 | A3, | 
|---|
| 70 | A4, | 
|---|
| 71 | A5, | 
|---|
| 72 | A6, | 
|---|
| 73 | A7, | 
|---|
| 74 | A8, | 
|---|
| 75 | A9, | 
|---|
| 76 | A10, | 
|---|
| 77 | B0, | 
|---|
| 78 | B1, | 
|---|
| 79 | B2, | 
|---|
| 80 | B3, | 
|---|
| 81 | B4, | 
|---|
| 82 | B5, | 
|---|
| 83 | B6, | 
|---|
| 84 | B7, | 
|---|
| 85 | B8, | 
|---|
| 86 | B9, | 
|---|
| 87 | B10, | 
|---|
| 88 | C5E, | 
|---|
| 89 | Comm10E, | 
|---|
| 90 | DLE, | 
|---|
| 91 | Folio, | 
|---|
| 92 | Ledger, | 
|---|
| 93 | Tabloid, | 
|---|
| 94 | Custom, | 
|---|
| 95 |  | 
|---|
| 96 | // New values derived from PPD standard | 
|---|
| 97 | , | 
|---|
| 98 | , | 
|---|
| 99 | A4Plus, | 
|---|
| 100 | A4Small, | 
|---|
| 101 | , | 
|---|
| 102 | , | 
|---|
| 103 |  | 
|---|
| 104 | JisB0, | 
|---|
| 105 | JisB1, | 
|---|
| 106 | JisB2, | 
|---|
| 107 | JisB3, | 
|---|
| 108 | JisB4, | 
|---|
| 109 | JisB5, | 
|---|
| 110 | JisB6, | 
|---|
| 111 | JisB7, | 
|---|
| 112 | JisB8, | 
|---|
| 113 | JisB9, | 
|---|
| 114 | JisB10, | 
|---|
| 115 |  | 
|---|
| 116 | // AnsiA = Letter, | 
|---|
| 117 | // AnsiB = Ledger, | 
|---|
| 118 | AnsiC, | 
|---|
| 119 | AnsiD, | 
|---|
| 120 | AnsiE, | 
|---|
| 121 | , | 
|---|
| 122 | , | 
|---|
| 123 | LetterPlus, | 
|---|
| 124 | LetterSmall, | 
|---|
| 125 | , | 
|---|
| 126 |  | 
|---|
| 127 | ArchA, | 
|---|
| 128 | ArchB, | 
|---|
| 129 | ArchC, | 
|---|
| 130 | ArchD, | 
|---|
| 131 | ArchE, | 
|---|
| 132 |  | 
|---|
| 133 | Imperial7x9, | 
|---|
| 134 | Imperial8x10, | 
|---|
| 135 | Imperial9x11, | 
|---|
| 136 | Imperial9x12, | 
|---|
| 137 | Imperial10x11, | 
|---|
| 138 | Imperial10x13, | 
|---|
| 139 | Imperial10x14, | 
|---|
| 140 | Imperial12x11, | 
|---|
| 141 | Imperial15x11, | 
|---|
| 142 |  | 
|---|
| 143 | ExecutiveStandard, | 
|---|
| 144 | Note, | 
|---|
| 145 | Quarto, | 
|---|
| 146 | Statement, | 
|---|
| 147 | SuperA, | 
|---|
| 148 | SuperB, | 
|---|
| 149 | Postcard, | 
|---|
| 150 | DoublePostcard, | 
|---|
| 151 | Prc16K, | 
|---|
| 152 | Prc32K, | 
|---|
| 153 | Prc32KBig, | 
|---|
| 154 |  | 
|---|
| 155 | FanFoldUS, | 
|---|
| 156 | FanFoldGerman, | 
|---|
| 157 | FanFoldGermanLegal, | 
|---|
| 158 |  | 
|---|
| 159 | EnvelopeB4, | 
|---|
| 160 | EnvelopeB5, | 
|---|
| 161 | EnvelopeB6, | 
|---|
| 162 | EnvelopeC0, | 
|---|
| 163 | EnvelopeC1, | 
|---|
| 164 | EnvelopeC2, | 
|---|
| 165 | EnvelopeC3, | 
|---|
| 166 | EnvelopeC4, | 
|---|
| 167 | // EnvelopeC5 = C5E, | 
|---|
| 168 | EnvelopeC6, | 
|---|
| 169 | EnvelopeC65, | 
|---|
| 170 | EnvelopeC7, | 
|---|
| 171 | // EnvelopeDL = DLE, | 
|---|
| 172 |  | 
|---|
| 173 | Envelope9, | 
|---|
| 174 | // Envelope10 = Comm10E, | 
|---|
| 175 | Envelope11, | 
|---|
| 176 | Envelope12, | 
|---|
| 177 | Envelope14, | 
|---|
| 178 | EnvelopeMonarch, | 
|---|
| 179 | EnvelopePersonal, | 
|---|
| 180 |  | 
|---|
| 181 | EnvelopeChou3, | 
|---|
| 182 | EnvelopeChou4, | 
|---|
| 183 | EnvelopeInvite, | 
|---|
| 184 | EnvelopeItalian, | 
|---|
| 185 | EnvelopeKaku2, | 
|---|
| 186 | EnvelopeKaku3, | 
|---|
| 187 | EnvelopePrc1, | 
|---|
| 188 | EnvelopePrc2, | 
|---|
| 189 | EnvelopePrc3, | 
|---|
| 190 | EnvelopePrc4, | 
|---|
| 191 | EnvelopePrc5, | 
|---|
| 192 | EnvelopePrc6, | 
|---|
| 193 | EnvelopePrc7, | 
|---|
| 194 | EnvelopePrc8, | 
|---|
| 195 | EnvelopePrc9, | 
|---|
| 196 | EnvelopePrc10, | 
|---|
| 197 | EnvelopeYou4, | 
|---|
| 198 |  | 
|---|
| 199 | // Last item | 
|---|
| 200 | LastPageSize = EnvelopeYou4, | 
|---|
| 201 |  | 
|---|
| 202 | // Convenience overloads for naming consistency | 
|---|
| 203 | AnsiA = Letter, | 
|---|
| 204 | AnsiB = Ledger, | 
|---|
| 205 | EnvelopeC5 = C5E, | 
|---|
| 206 | EnvelopeDL = DLE, | 
|---|
| 207 | Envelope10 = Comm10E | 
|---|
| 208 | }; | 
|---|
| 209 |  | 
|---|
| 210 | // NOTE: Must keep in sync with QPageLayout::Unit and QPrinter::Unit | 
|---|
| 211 | enum Unit { | 
|---|
| 212 | Millimeter, | 
|---|
| 213 | Point, | 
|---|
| 214 | Inch, | 
|---|
| 215 | Pica, | 
|---|
| 216 | Didot, | 
|---|
| 217 | Cicero | 
|---|
| 218 | }; | 
|---|
| 219 |  | 
|---|
| 220 | enum SizeMatchPolicy { | 
|---|
| 221 | FuzzyMatch, | 
|---|
| 222 | FuzzyOrientationMatch, | 
|---|
| 223 | ExactMatch | 
|---|
| 224 | }; | 
|---|
| 225 |  | 
|---|
| 226 | QPageSize(); | 
|---|
| 227 | explicit QPageSize(PageSizeId pageSizeId); | 
|---|
| 228 | explicit QPageSize(const QSize &pointSize, | 
|---|
| 229 | const QString &name = QString(), | 
|---|
| 230 | SizeMatchPolicy matchPolicy = FuzzyMatch); | 
|---|
| 231 | explicit QPageSize(const QSizeF &size, Unit units, | 
|---|
| 232 | const QString &name = QString(), | 
|---|
| 233 | SizeMatchPolicy matchPolicy = FuzzyMatch); | 
|---|
| 234 | QPageSize(const QPageSize &other); | 
|---|
| 235 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageSize) | 
|---|
| 236 | QPageSize &operator=(const QPageSize &other); | 
|---|
| 237 | ~QPageSize(); | 
|---|
| 238 |  | 
|---|
| 239 |  | 
|---|
| 240 | void swap(QPageSize &other) noexcept { qSwap(d, other.d); } | 
|---|
| 241 |  | 
|---|
| 242 | friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs); | 
|---|
| 243 | bool isEquivalentTo(const QPageSize &other) const; | 
|---|
| 244 |  | 
|---|
| 245 | bool isValid() const; | 
|---|
| 246 |  | 
|---|
| 247 | QString key() const; | 
|---|
| 248 | QString name() const; | 
|---|
| 249 |  | 
|---|
| 250 | PageSizeId id() const; | 
|---|
| 251 |  | 
|---|
| 252 | int windowsId() const; | 
|---|
| 253 |  | 
|---|
| 254 | QSizeF definitionSize() const; | 
|---|
| 255 | Unit definitionUnits() const; | 
|---|
| 256 |  | 
|---|
| 257 | QSizeF size(Unit units) const; | 
|---|
| 258 | QSize sizePoints() const; | 
|---|
| 259 | QSize sizePixels(int resolution) const; | 
|---|
| 260 |  | 
|---|
| 261 | QRectF rect(Unit units) const; | 
|---|
| 262 | QRect rectPoints() const; | 
|---|
| 263 | QRect rectPixels(int resolution) const; | 
|---|
| 264 |  | 
|---|
| 265 | static QString key(PageSizeId pageSizeId); | 
|---|
| 266 | static QString name(PageSizeId pageSizeId); | 
|---|
| 267 |  | 
|---|
| 268 | static PageSizeId id(const QSize &pointSize, | 
|---|
| 269 | SizeMatchPolicy matchPolicy = FuzzyMatch); | 
|---|
| 270 | static PageSizeId id(const QSizeF &size, Unit units, | 
|---|
| 271 | SizeMatchPolicy matchPolicy = FuzzyMatch); | 
|---|
| 272 |  | 
|---|
| 273 | static PageSizeId id(int windowsId); | 
|---|
| 274 | static int windowsId(PageSizeId pageSizeId); | 
|---|
| 275 |  | 
|---|
| 276 | static QSizeF definitionSize(PageSizeId pageSizeId); | 
|---|
| 277 | static Unit definitionUnits(PageSizeId pageSizeId); | 
|---|
| 278 |  | 
|---|
| 279 | static QSizeF size(PageSizeId pageSizeId, Unit units); | 
|---|
| 280 | static QSize sizePoints(PageSizeId pageSizeId); | 
|---|
| 281 | static QSize sizePixels(PageSizeId pageSizeId, int resolution); | 
|---|
| 282 |  | 
|---|
| 283 | private: | 
|---|
| 284 | friend class QPageSizePrivate; | 
|---|
| 285 | friend class QPlatformPrintDevice; | 
|---|
| 286 | QPageSize(const QString &key, const QSize &pointSize, const QString &name); | 
|---|
| 287 | QPageSize(int windowsId, const QSize &pointSize, const QString &name); | 
|---|
| 288 | QPageSize(QPageSizePrivate &dd); | 
|---|
| 289 | QSharedDataPointer<QPageSizePrivate> d; | 
|---|
| 290 | }; | 
|---|
| 291 |  | 
|---|
| 292 | Q_DECLARE_SHARED(QPageSize) | 
|---|
| 293 |  | 
|---|
| 294 | Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs); | 
|---|
| 295 | inline bool operator!=(const QPageSize &lhs, const QPageSize &rhs) | 
|---|
| 296 | { return !operator==(lhs, rhs); } | 
|---|
| 297 |  | 
|---|
| 298 | #ifndef QT_NO_DEBUG_STREAM | 
|---|
| 299 | Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize); | 
|---|
| 300 | #endif | 
|---|
| 301 |  | 
|---|
| 302 | QT_END_NAMESPACE | 
|---|
| 303 |  | 
|---|
| 304 | Q_DECLARE_METATYPE(QPageSize) | 
|---|
| 305 | Q_DECLARE_METATYPE(QPageSize::PageSizeId) | 
|---|
| 306 | Q_DECLARE_METATYPE(QPageSize::Unit) | 
|---|
| 307 |  | 
|---|
| 308 | #endif // QPAGESIZE_H | 
|---|
| 309 |  | 
|---|