/src/qtbase/src/gui/painting/qpen.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
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 QPEN_H |
5 | | #define QPEN_H |
6 | | |
7 | | #include <QtCore/qshareddata.h> |
8 | | #include <QtGui/qtguiglobal.h> |
9 | | #include <QtGui/qcolor.h> |
10 | | #include <QtGui/qbrush.h> |
11 | | |
12 | | QT_BEGIN_NAMESPACE |
13 | | |
14 | | |
15 | | class QVariant; |
16 | | class QPenPrivate; |
17 | | class QBrush; |
18 | | class QPen; |
19 | | |
20 | | #ifndef QT_NO_DATASTREAM |
21 | | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &); |
22 | | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &); |
23 | | #endif |
24 | | |
25 | | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPenPrivate, Q_GUI_EXPORT) |
26 | | |
27 | | class Q_GUI_EXPORT QPen |
28 | | { |
29 | | public: |
30 | | QPen(); |
31 | | QPen(Qt::PenStyle); |
32 | | QPen(const QColor &color); |
33 | | QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine, |
34 | | Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin); |
35 | | QPen(const QPen &pen) noexcept; |
36 | | |
37 | | ~QPen(); |
38 | | |
39 | | QPen &operator=(const QPen &pen) noexcept; |
40 | | QPen(QPen &&other) noexcept = default; |
41 | | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPen) |
42 | 0 | void swap(QPen &other) noexcept { d.swap(other.d); } |
43 | | |
44 | | QPen &operator=(QColor color); |
45 | | QPen &operator=(Qt::PenStyle style); |
46 | | |
47 | | Qt::PenStyle style() const; |
48 | | void setStyle(Qt::PenStyle); |
49 | | |
50 | | QList<qreal> dashPattern() const; |
51 | | void setDashPattern(const QList<qreal> &pattern); |
52 | | |
53 | | qreal dashOffset() const; |
54 | | void setDashOffset(qreal doffset); |
55 | | |
56 | | qreal miterLimit() const; |
57 | | void setMiterLimit(qreal limit); |
58 | | |
59 | | qreal widthF() const; |
60 | | void setWidthF(qreal width); |
61 | | |
62 | | int width() const; |
63 | | void setWidth(int width); |
64 | | |
65 | | QColor color() const; |
66 | | void setColor(const QColor &color); |
67 | | |
68 | | QBrush brush() const; |
69 | | void setBrush(const QBrush &brush); |
70 | | |
71 | | bool isSolid() const; |
72 | | |
73 | | Qt::PenCapStyle capStyle() const; |
74 | | void setCapStyle(Qt::PenCapStyle pcs); |
75 | | |
76 | | Qt::PenJoinStyle joinStyle() const; |
77 | | void setJoinStyle(Qt::PenJoinStyle pcs); |
78 | | |
79 | | bool isCosmetic() const; |
80 | | void setCosmetic(bool cosmetic); |
81 | | |
82 | | bool operator==(const QPen &p) const; |
83 | 0 | inline bool operator!=(const QPen &p) const { return !(operator==(p)); } |
84 | | operator QVariant() const; |
85 | | |
86 | | bool isDetached(); |
87 | | |
88 | | private: |
89 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &); |
90 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &); |
91 | | |
92 | | bool isSolidDefaultLine() const noexcept; |
93 | | |
94 | | bool doCompareEqualColor(QColor rhs) const noexcept; |
95 | | friend bool comparesEqual(const QPen &lhs, QColor rhs) noexcept |
96 | 0 | { |
97 | 0 | return lhs.doCompareEqualColor(rhs); |
98 | 0 | } |
99 | | Q_DECLARE_EQUALITY_COMPARABLE(QPen, QColor) |
100 | | |
101 | | bool doCompareEqualStyle(Qt::PenStyle rhs) const; |
102 | | friend bool comparesEqual(const QPen &lhs, Qt::PenStyle rhs) |
103 | 0 | { |
104 | 0 | return lhs.doCompareEqualStyle(rhs); |
105 | 0 | } |
106 | | Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QPen, Qt::PenStyle) |
107 | | |
108 | | public: |
109 | | using DataPtr = QExplicitlySharedDataPointer<QPenPrivate>; |
110 | | |
111 | | private: |
112 | | void detach(); |
113 | | DataPtr d; |
114 | | |
115 | | public: |
116 | 0 | inline DataPtr &data_ptr() { return d; } |
117 | | }; |
118 | | |
119 | | Q_DECLARE_SHARED(QPen) |
120 | | |
121 | | #ifndef QT_NO_DEBUG_STREAM |
122 | | Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &); |
123 | | #endif |
124 | | |
125 | | QT_END_NAMESPACE |
126 | | |
127 | | #endif // QPEN_H |