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
12QT_BEGIN_NAMESPACE
13
14
15class QVariant;
16class QPenPrivate;
17class QBrush;
18class QPen;
19
20#ifndef QT_NO_DATASTREAM
21Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
22Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
23#endif
24
25QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QPenPrivate, Q_GUI_EXPORT)
26
27class Q_GUI_EXPORT QPen
28{
29public:
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 void swap(QPen &other) noexcept { d.swap(other&: other.d); }
43
44 Qt::PenStyle style() const;
45 void setStyle(Qt::PenStyle);
46
47 QList<qreal> dashPattern() const;
48 void setDashPattern(const QList<qreal> &pattern);
49
50 qreal dashOffset() const;
51 void setDashOffset(qreal doffset);
52
53 qreal miterLimit() const;
54 void setMiterLimit(qreal limit);
55
56 qreal widthF() const;
57 void setWidthF(qreal width);
58
59 int width() const;
60 void setWidth(int width);
61
62 QColor color() const;
63 void setColor(const QColor &color);
64
65 QBrush brush() const;
66 void setBrush(const QBrush &brush);
67
68 bool isSolid() const;
69
70 Qt::PenCapStyle capStyle() const;
71 void setCapStyle(Qt::PenCapStyle pcs);
72
73 Qt::PenJoinStyle joinStyle() const;
74 void setJoinStyle(Qt::PenJoinStyle pcs);
75
76 bool isCosmetic() const;
77 void setCosmetic(bool cosmetic);
78
79 bool operator==(const QPen &p) const;
80 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
81 operator QVariant() const;
82
83 bool isDetached();
84
85private:
86 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
87 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
88
89public:
90 using DataPtr = QExplicitlySharedDataPointer<QPenPrivate>;
91
92private:
93 void detach();
94 DataPtr d;
95
96public:
97 inline DataPtr &data_ptr() { return d; }
98};
99
100Q_DECLARE_SHARED(QPen)
101
102#ifndef QT_NO_DEBUG_STREAM
103Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
104#endif
105
106QT_END_NAMESPACE
107
108#endif // QPEN_H
109