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 <QtGui/qtguiglobal.h>
8#include <QtGui/qcolor.h>
9#include <QtGui/qbrush.h>
10
11QT_BEGIN_NAMESPACE
12
13
14class QVariant;
15class QPenPrivate;
16class QBrush;
17class QPen;
18
19#ifndef QT_NO_DATASTREAM
20Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
21Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
22#endif
23
24class Q_GUI_EXPORT QPen
25{
26public:
27 QPen();
28 QPen(Qt::PenStyle);
29 QPen(const QColor &color);
30 QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine,
31 Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin);
32 QPen(const QPen &pen) noexcept;
33
34 ~QPen();
35
36 QPen &operator=(const QPen &pen) noexcept;
37 QPen(QPen &&other) noexcept
38 : d(std::exchange(obj&: other.d, new_val: nullptr)) {}
39 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPen)
40 void swap(QPen &other) noexcept { qt_ptr_swap(lhs&: d, rhs&: other.d); }
41
42 Qt::PenStyle style() const;
43 void setStyle(Qt::PenStyle);
44
45 QList<qreal> dashPattern() const;
46 void setDashPattern(const QList<qreal> &pattern);
47
48 qreal dashOffset() const;
49 void setDashOffset(qreal doffset);
50
51 qreal miterLimit() const;
52 void setMiterLimit(qreal limit);
53
54 qreal widthF() const;
55 void setWidthF(qreal width);
56
57 int width() const;
58 void setWidth(int width);
59
60 QColor color() const;
61 void setColor(const QColor &color);
62
63 QBrush brush() const;
64 void setBrush(const QBrush &brush);
65
66 bool isSolid() const;
67
68 Qt::PenCapStyle capStyle() const;
69 void setCapStyle(Qt::PenCapStyle pcs);
70
71 Qt::PenJoinStyle joinStyle() const;
72 void setJoinStyle(Qt::PenJoinStyle pcs);
73
74 bool isCosmetic() const;
75 void setCosmetic(bool cosmetic);
76
77 bool operator==(const QPen &p) const;
78 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
79 operator QVariant() const;
80
81 bool isDetached();
82private:
83 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
84 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
85
86 void detach();
87 class QPenPrivate *d;
88
89public:
90 typedef QPenPrivate * DataPtr;
91 inline DataPtr &data_ptr() { return d; }
92};
93
94Q_DECLARE_SHARED(QPen)
95
96#ifndef QT_NO_DEBUG_STREAM
97Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
98#endif
99
100QT_END_NAMESPACE
101
102#endif // QPEN_H
103

source code of qtbase/src/gui/painting/qpen.h