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(qExchange(other.d, nullptr)) {}
75 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPen)
76 void swap(QPen &other) noexcept { qSwap(d, other.d); }
77
78 Qt::PenStyle style() const;
79 void setStyle(Qt::PenStyle);
80
81 QList<qreal> dashPattern() const;
82 void setDashPattern(const QList<qreal> &pattern);
83
84 qreal dashOffset() const;
85 void setDashOffset(qreal doffset);
86
87 qreal miterLimit() const;
88 void setMiterLimit(qreal limit);
89
90 qreal widthF() const;
91 void setWidthF(qreal width);
92
93 int width() const;
94 void setWidth(int width);
95
96 QColor color() const;
97 void setColor(const QColor &color);
98
99 QBrush brush() const;
100 void setBrush(const QBrush &brush);
101
102 bool isSolid() const;
103
104 Qt::PenCapStyle capStyle() const;
105 void setCapStyle(Qt::PenCapStyle pcs);
106
107 Qt::PenJoinStyle joinStyle() const;
108 void setJoinStyle(Qt::PenJoinStyle pcs);
109
110 bool isCosmetic() const;
111 void setCosmetic(bool cosmetic);
112
113 bool operator==(const QPen &p) const;
114 inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
115 operator QVariant() const;
116
117 bool isDetached();
118private:
119 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
120 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
121
122 void detach();
123 class QPenPrivate *d;
124
125public:
126 typedef QPenPrivate * DataPtr;
127 inline DataPtr &data_ptr() { return d; }
128};
129
130Q_DECLARE_SHARED(QPen)
131
132#ifndef QT_NO_DEBUG_STREAM
133Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
134#endif
135
136QT_END_NAMESPACE
137
138#endif // QPEN_H
139