Make QRegion not need to be friends with QVector
[profile/ivi/qtbase.git] / src / gui / painting / qpen.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QPEN_H
43 #define QPEN_H
44
45 #include <QtGui/qcolor.h>
46 #include <QtGui/qbrush.h>
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52
53 class QVariant;
54 class QPenPrivate;
55 class QBrush;
56 class QPen;
57
58 #ifndef QT_NO_DATASTREAM
59 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
60 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
61 #endif
62
63 class Q_GUI_EXPORT QPen
64 {
65 public:
66     QPen();
67     QPen(Qt::PenStyle);
68     QPen(const QColor &color);
69     QPen(const QBrush &brush, qreal width, Qt::PenStyle s = Qt::SolidLine,
70          Qt::PenCapStyle c = Qt::SquareCap, Qt::PenJoinStyle j = Qt::BevelJoin);
71     QPen(const QPen &pen);
72
73     ~QPen();
74
75     QPen &operator=(const QPen &pen);
76 #ifdef Q_COMPILER_RVALUE_REFS
77     inline QPen &operator=(QPen &&other)
78     { qSwap(d, other.d); return *this; }
79 #endif
80     inline void swap(QPen &other) { qSwap(d, other.d); }
81
82     Qt::PenStyle style() const;
83     void setStyle(Qt::PenStyle);
84
85     QVector<qreal> dashPattern() const;
86     void setDashPattern(const QVector<qreal> &pattern);
87
88     qreal dashOffset() const;
89     void setDashOffset(qreal doffset);
90
91     qreal miterLimit() const;
92     void setMiterLimit(qreal limit);
93
94     qreal widthF() const;
95     void setWidthF(qreal width);
96
97     int width() const;
98     void setWidth(int width);
99
100     QColor color() const;
101     void setColor(const QColor &color);
102
103     QBrush brush() const;
104     void setBrush(const QBrush &brush);
105
106     bool isSolid() const;
107
108     Qt::PenCapStyle capStyle() const;
109     void setCapStyle(Qt::PenCapStyle pcs);
110
111     Qt::PenJoinStyle joinStyle() const;
112     void setJoinStyle(Qt::PenJoinStyle pcs);
113
114     bool isCosmetic() const;
115     void setCosmetic(bool cosmetic);
116
117     bool operator==(const QPen &p) const;
118     inline bool operator!=(const QPen &p) const { return !(operator==(p)); }
119     operator QVariant() const;
120
121     bool isDetached();
122 private:
123     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPen &);
124     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPen &);
125
126     void detach();
127     class QPenPrivate *d;
128
129 public:
130     typedef QPenPrivate * DataPtr;
131     inline DataPtr &data_ptr() { return d; }
132 };
133 Q_DECLARE_TYPEINFO(QPen, Q_MOVABLE_TYPE);
134 Q_DECLARE_SHARED(QPen)
135
136 #ifndef QT_NO_DEBUG_STREAM
137 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPen &);
138 #endif
139
140 QT_END_NAMESPACE
141
142 QT_END_HEADER
143
144 #endif // QPEN_H