Added SpellCheckUnderlineStyle theme hint.
[profile/ivi/qtbase.git] / src / gui / painting / qpolygon.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 QPOLYGON_H
43 #define QPOLYGON_H
44
45 #include <QtCore/qvector.h>
46 #include <QtCore/qpoint.h>
47 #include <QtCore/qrect.h>
48
49 QT_BEGIN_HEADER
50
51 QT_BEGIN_NAMESPACE
52
53
54 class QMatrix;
55 class QTransform;
56 class QRect;
57 class QVariant;
58
59 class Q_GUI_EXPORT QPolygon : public QVector<QPoint>
60 {
61 public:
62     inline QPolygon() {}
63     inline ~QPolygon() {}
64     inline explicit QPolygon(int size);
65     inline QPolygon(const QPolygon &a) : QVector<QPoint>(a) {}
66     inline /*implicit*/ QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
67     QPolygon(const QRect &r, bool closed=false);
68     QPolygon(int nPoints, const int *points);
69     inline void swap(QPolygon &other) { QVector<QPoint>::swap(other); } // prevent QVector<QPoint><->QPolygon swaps
70
71     operator QVariant() const;
72
73     void translate(int dx, int dy);
74     void translate(const QPoint &offset);
75
76     QPolygon translated(int dx, int dy) const;
77     inline QPolygon translated(const QPoint &offset) const;
78
79     QRect boundingRect() const;
80
81     void point(int i, int *x, int *y) const;
82     QPoint point(int i) const;
83     void setPoint(int index, int x, int y);
84     void setPoint(int index, const QPoint &p);
85     void setPoints(int nPoints, const int *points);
86     void setPoints(int nPoints, int firstx, int firsty, ...);
87     void putPoints(int index, int nPoints, const int *points);
88     void putPoints(int index, int nPoints, int firstx, int firsty, ...);
89     void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
90
91     bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
92
93     QPolygon united(const QPolygon &r) const;
94     QPolygon intersected(const QPolygon &r) const;
95     QPolygon subtracted(const QPolygon &r) const;
96 };
97
98 inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {}
99
100 #ifndef QT_NO_DEBUG_STREAM
101 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygon &);
102 #endif
103
104 /*****************************************************************************
105   QPolygon stream functions
106  *****************************************************************************/
107 #ifndef QT_NO_DATASTREAM
108 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygon &polygon);
109 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygon &polygon);
110 #endif
111
112 /*****************************************************************************
113   Misc. QPolygon functions
114  *****************************************************************************/
115
116 inline void QPolygon::setPoint(int index, const QPoint &pt)
117 { (*this)[index] = pt; }
118
119 inline void QPolygon::setPoint(int index, int x, int y)
120 { (*this)[index] = QPoint(x, y); }
121
122 inline QPoint QPolygon::point(int index) const
123 { return at(index); }
124
125 inline void QPolygon::translate(const QPoint &offset)
126 { translate(offset.x(), offset.y()); }
127
128 inline QPolygon QPolygon::translated(const QPoint &offset) const
129 { return translated(offset.x(), offset.y()); }
130
131 class QRectF;
132
133 class Q_GUI_EXPORT QPolygonF : public QVector<QPointF>
134 {
135 public:
136     inline QPolygonF() {}
137     inline ~QPolygonF() {}
138     inline explicit QPolygonF(int size);
139     inline QPolygonF(const QPolygonF &a) : QVector<QPointF>(a) {}
140     inline /*implicit*/ QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
141     QPolygonF(const QRectF &r);
142     /*implicit*/ QPolygonF(const QPolygon &a);
143     inline void swap(QPolygonF &other) { QVector<QPointF>::swap(other); } // prevent QVector<QPointF><->QPolygonF swaps
144
145     inline void translate(qreal dx, qreal dy);
146     void translate(const QPointF &offset);
147
148     inline QPolygonF translated(qreal dx, qreal dy) const;
149     QPolygonF translated(const QPointF &offset) const;
150
151     QPolygon toPolygon() const;
152
153     bool isClosed() const { return !isEmpty() && first() == last(); }
154
155     QRectF boundingRect() const;
156
157     bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
158
159     QPolygonF united(const QPolygonF &r) const;
160     QPolygonF intersected(const QPolygonF &r) const;
161     QPolygonF subtracted(const QPolygonF &r) const;
162 };
163
164 inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
165
166 #ifndef QT_NO_DEBUG_STREAM
167 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPolygonF &);
168 #endif
169
170 /*****************************************************************************
171   QPolygonF stream functions
172  *****************************************************************************/
173 #ifndef QT_NO_DATASTREAM
174 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QPolygonF &array);
175 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QPolygonF &array);
176 #endif
177
178 inline void QPolygonF::translate(qreal dx, qreal dy)
179 { translate(QPointF(dx, dy)); }
180
181 inline QPolygonF QPolygonF::translated(qreal dx, qreal dy) const
182 { return translated(QPointF(dx, dy)); }
183
184 QT_END_NAMESPACE
185
186 QT_END_HEADER
187
188 #endif // QPOLYGON_H