Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpagelayout.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 QPAGELAYOUT_H
5#define QPAGELAYOUT_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qshareddata.h>
9#include <QtCore/qstring.h>
10#include <QtCore/qmargins.h>
11
12#include <QtGui/qpagesize.h>
13
15
17class QMarginsF;
18
19class Q_GUI_EXPORT QPageLayout
20{
21public:
22
23 // NOTE: Must keep in sync with QPageSize::Unit and QPrinter::Unit
32
35 Landscape
36 };
37
38 enum Mode {
39 StandardMode, // Paint Rect includes margins
40 FullPageMode // Paint Rect excludes margins
41 };
42
43 enum class OutOfBoundsPolicy {
44 Reject,
45 Clamp
46 };
47
49 QPageLayout(const QPageSize &pageSize, Orientation orientation,
50 const QMarginsF &margins, Unit units = Point,
51 const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0));
53 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPageLayout)
54 QPageLayout &operator=(const QPageLayout &other);
56
57 void swap(QPageLayout &other) noexcept { d.swap(other.d); }
58
59 bool isEquivalentTo(const QPageLayout &other) const;
60
61 bool isValid() const;
62
63 void setMode(Mode mode);
64 Mode mode() const;
65
66 void setPageSize(const QPageSize &pageSize,
67 const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0));
68 QPageSize pageSize() const;
69
70 void setOrientation(Orientation orientation);
71 Orientation orientation() const;
72
73 void setUnits(Unit units);
74 Unit units() const;
75
76#if QT_GUI_REMOVED_SINCE(6, 8)
77 bool setMargins(const QMarginsF &margins);
78 bool setLeftMargin(qreal leftMargin);
79 bool setRightMargin(qreal rightMargin);
80 bool setTopMargin(qreal topMargin);
81 bool setBottomMargin(qreal bottomMargin);
82#endif
83
84 bool setMargins(const QMarginsF &margins, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject);
85 bool setLeftMargin(qreal leftMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject);
86 bool setRightMargin(qreal rightMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject);
87 bool setTopMargin(qreal topMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject);
88 bool setBottomMargin(qreal bottomMargin, OutOfBoundsPolicy outOfBoundsPolicy = OutOfBoundsPolicy::Reject);
89
90 QMarginsF margins() const;
91 QMarginsF margins(Unit units) const;
92 QMargins marginsPoints() const;
93 QMargins marginsPixels(int resolution) const;
94
95 void setMinimumMargins(const QMarginsF &minMargins);
96 QMarginsF minimumMargins() const;
97 QMarginsF maximumMargins() const;
98
99 QRectF fullRect() const;
100 QRectF fullRect(Unit units) const;
101 QRect fullRectPoints() const;
102 QRect fullRectPixels(int resolution) const;
103
104 QRectF paintRect() const;
105 QRectF paintRect(Unit units) const;
106 QRect paintRectPoints() const;
107 QRect paintRectPixels(int resolution) const;
108
109private:
110 friend class QPageLayoutPrivate;
111 bool equals(const QPageLayout &other) const;
112
113 friend inline bool operator==(const QPageLayout &lhs, const QPageLayout &rhs)
114 { return lhs.equals(rhs); }
115 friend inline bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs)
116 { return !lhs.equals(rhs); }
117
118 QExplicitlySharedDataPointer<QPageLayoutPrivate> d;
119};
120
121Q_DECLARE_SHARED(QPageLayout)
122
123#ifndef QT_NO_DEBUG_STREAM
124Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageLayout &pageLayout);
125#endif
126
128
130QT_DECL_METATYPE_EXTERN_TAGGED(QPageLayout::Unit, QPageLayout__Unit, Q_GUI_EXPORT)
131QT_DECL_METATYPE_EXTERN_TAGGED(QPageLayout::Orientation, QPageLayout__Orientation, Q_GUI_EXPORT)
132
133#endif // QPAGELAYOUT_H
\inmodule QtCore
\inmodule QtCore
Definition qmargins.h:270
\inmodule QtCore
Definition qmargins.h:24
\inmodule QtGui
Definition qpagelayout.h:20
friend bool operator==(const QPageLayout &lhs, const QPageLayout &rhs)
Returns true if page layout lhs is equal to page layout rhs, i.e.
Unit
This enum type is used to specify the measurement unit for page layout and margins.
Definition qpagelayout.h:24
friend bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs)
Returns true if page layout lhs is not equal to page layout rhs, i.e.
void swap(QPageLayout &other) noexcept
Swaps this page layout with other.
Definition qpagelayout.h:57
Mode
Defines the page layout mode.
Definition qpagelayout.h:38
Orientation
This enum type defines the page orientation.
Definition qpagelayout.h:33
\inmodule QtGui
Definition qpagesize.h:22
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
Combined button and popup list for selecting options.
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1388
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1376
GLenum mode
GLfloat units
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageLayout &pageLayout)
double qreal
Definition qtypes.h:187
QSharedPointer< T > other(t)
[5]
Definition parser.h:19