/src/qtbase/src/gui/painting/qpagelayout.h
Line | Count | Source |
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 QPAGELAYOUT_H |
6 | | #define QPAGELAYOUT_H |
7 | | |
8 | | #include <QtGui/qtguiglobal.h> |
9 | | #include <QtCore/qshareddata.h> |
10 | | #include <QtCore/qstring.h> |
11 | | #include <QtCore/qmargins.h> |
12 | | |
13 | | #include <QtGui/qpagesize.h> |
14 | | |
15 | | QT_BEGIN_NAMESPACE |
16 | | |
17 | | class QPageLayoutPrivate; |
18 | | class QMarginsF; |
19 | | |
20 | | class Q_GUI_EXPORT QPageLayout |
21 | | { |
22 | | public: |
23 | | |
24 | | // NOTE: Must keep in sync with QPageSize::Unit and QPrinter::Unit |
25 | | enum Unit { |
26 | | Millimeter, |
27 | | Point, |
28 | | Inch, |
29 | | Pica, |
30 | | Didot, |
31 | | Cicero |
32 | | }; |
33 | | |
34 | | enum Orientation { |
35 | | Portrait, |
36 | | Landscape |
37 | | }; |
38 | | |
39 | | enum Mode { |
40 | | StandardMode, // Paint Rect includes margins |
41 | | FullPageMode // Paint Rect excludes margins |
42 | | }; |
43 | | |
44 | | enum class OutOfBoundsPolicy { |
45 | | Reject, |
46 | | Clamp, |
47 | | }; |
48 | | |
49 | | QPageLayout(); |
50 | | QPageLayout(const QPageSize &pageSize, Orientation orientation, |
51 | | const QMarginsF &margins, Unit units = Point, |
52 | | const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0)); |
53 | | QPageLayout(const QPageLayout &other); |
54 | | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageLayout) |
55 | | QPageLayout &operator=(const QPageLayout &other); |
56 | | ~QPageLayout(); |
57 | | |
58 | 0 | void swap(QPageLayout &other) noexcept { d.swap(other.d); } |
59 | | |
60 | | bool isEquivalentTo(const QPageLayout &other) const; |
61 | | |
62 | | bool isValid() const; |
63 | | |
64 | | void setMode(Mode mode); |
65 | | Mode mode() const; |
66 | | |
67 | | void setPageSize(const QPageSize &pageSize, |
68 | | const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0)); |
69 | | QPageSize pageSize() const; |
70 | | |
71 | | void setOrientation(Orientation orientation); |
72 | | Orientation orientation() const; |
73 | | |
74 | | void setUnits(Unit units); |
75 | | Unit units() const; |
76 | | |
77 | | #if QT_GUI_REMOVED_SINCE(6, 8) |
78 | | bool setMargins(const QMarginsF &margins); |
79 | | bool setLeftMargin(qreal leftMargin); |
80 | | bool setRightMargin(qreal rightMargin); |
81 | | bool setTopMargin(qreal topMargin); |
82 | | bool setBottomMargin(qreal bottomMargin); |
83 | | #endif |
84 | | |
85 | | bool setMargins(const QMarginsF &margins, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject); |
86 | | bool setLeftMargin(qreal leftMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject); |
87 | | bool setRightMargin(qreal rightMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject); |
88 | | bool setTopMargin(qreal topMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject); |
89 | | bool setBottomMargin(qreal bottomMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject); |
90 | | |
91 | | QMarginsF margins() const; |
92 | | QMarginsF margins(Unit units) const; |
93 | | QMargins marginsPoints() const; |
94 | | QMargins marginsPixels(int resolution) const; |
95 | | |
96 | | void setMinimumMargins(const QMarginsF &minMargins); |
97 | | QMarginsF minimumMargins() const; |
98 | | QMarginsF maximumMargins() const; |
99 | | |
100 | | QRectF fullRect() const; |
101 | | QRectF fullRect(Unit units) const; |
102 | | QRect fullRectPoints() const; |
103 | | QRect fullRectPixels(int resolution) const; |
104 | | |
105 | | QRectF paintRect() const; |
106 | | QRectF paintRect(Unit units) const; |
107 | | QRect paintRectPoints() const; |
108 | | QRect paintRectPixels(int resolution) const; |
109 | | |
110 | | private: |
111 | | friend class QPageLayoutPrivate; |
112 | | bool equals(const QPageLayout &other) const; |
113 | | |
114 | | friend inline bool operator==(const QPageLayout &lhs, const QPageLayout &rhs) |
115 | 0 | { return lhs.equals(rhs); } |
116 | | friend inline bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs) |
117 | 0 | { return !lhs.equals(rhs); } |
118 | | |
119 | | QExplicitlySharedDataPointer<QPageLayoutPrivate> d; |
120 | | }; |
121 | | |
122 | | Q_DECLARE_SHARED(QPageLayout) |
123 | | |
124 | | #ifndef QT_NO_DEBUG_STREAM |
125 | | Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageLayout &pageLayout); |
126 | | #endif |
127 | | |
128 | | QT_END_NAMESPACE |
129 | | |
130 | | QT_DECL_METATYPE_EXTERN(QPageLayout, Q_GUI_EXPORT) |
131 | | QT_DECL_METATYPE_EXTERN_TAGGED(QPageLayout::Unit, QPageLayout__Unit, Q_GUI_EXPORT) |
132 | | QT_DECL_METATYPE_EXTERN_TAGGED(QPageLayout::Orientation, QPageLayout__Orientation, Q_GUI_EXPORT) |
133 | | |
134 | | #endif // QPAGELAYOUT_H |