1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QPEN_H
41#define QPEN_H
42
43#include <QtGui/qtguiglobal.h>
44#include <QtGui/qcolor.h>
45#include <QtGui/qbrush.h>
46
47QT_BEGIN_NAMESPACE
48
49
50class QVariant;
51class QPenPrivate;
52class QBrush;
53class QPen;
54
55#ifndef QT_NO_DATASTREAM
56Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
57Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
58#endif
59
60class Q_GUI_EXPORT QPen
61{
62public:
63 QPen();
64 QPen(Qt::PenStyle);
65 QPen(const QColor &color);
66 QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine,
67 Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin);
68 QPen(const QPen &pen) noexcept;
69
70 ~QPen();
71
72 QPen &operator=(const QPen &pen) noexcept;
73 QPen(QPen &&other) noexcept
74 : d(other.d) { other.d = nullptr; }
75 QPen &operator=(QPen &&other) noexcept
76 { qSwap(value1&: d, value2&: other.d); return *this; }
77 void swap(QPen &other) noexcept { qSwap(value1&: d, value2&: other.d); }
78
79 Qt::PenStyle style() const;
80 void setStyle(Qt::PenStyle);
81
82 QVector<qreal> dashPattern() const;
83 void setDashPattern(const QVector<qreal> &pattern);
84
85 qreal dashOffset() const;
86 void setDashOffset(qreal doffset);
87
88 qreal miterLimit() const;
89 void setMiterLimit(qreal limit);
90
91 qreal widthF() const;
92 void setWidthF(qreal width);
93
94 int width() const;
95 void setWidth(int width);
96
97 QColor color() const;
98 void setColor(const QColor &color);
99
100 QBrush brush() const;
101 void setBrush(const QBrush &brush);
102
103 bool isSolid() const;
104
105 Qt::PenCapStyle capStyle() const;
106 void setCapStyle(Qt::PenCapStyle pcs);
107
108 Qt::PenJoinStyle joinStyle() const;
109 void setJoinStyle(Qt::PenJoinStyle pcs);
110
111 bool isCosmetic() const;
112 void setCosmetic(bool cosmetic);
113
114 bool operator==(const QPen &p) const;
115 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
116 operator QVariant() const;
117
118 bool isDetached();
119private:
120 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
121 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
122
123 void detach();
124 class QPenPrivate *d;
125
126public:
127 typedef QPenPrivate * DataPtr;
128 inline DataPtr &data_ptr() { return d; }
129};
130
131Q_DECLARE_SHARED(QPen)
132
133#ifndef QT_NO_DEBUG_STREAM
134Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
135#endif
136
137QT_END_NAMESPACE
138
139#endif // QPEN_H
140

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