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