1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the painting module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#ifndef QPAINTERPATH_P_H
30
#define QPAINTERPATH_P_H
36
// This file is not part of the Qt API. It exists for the convenience
37
// of other Qt classes. This header file may change from version to
38
// version without notice, or even be removed.
45
#include <qpainterpath.h>
49
class QPainterPathData : public QPainterPathPrivate
53
cStart(0), fillRule(Qt::OddEvenFill)
58
QPainterPathData(const QPainterPathData &other) :
59
QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), containsCache(other.containsCache)
62
elements = other.elements;
65
inline bool isClosed() const;
68
inline void makeDirty();
71
Qt::FillRule fillRule;
73
QRegion containsCache;
77
void Q_GUI_EXPORT qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length,
78
QPointF* startPoint, QPointF *endPoint);
80
inline bool QPainterPathData::isClosed() const
82
const QPainterPath::Element &first = elements.at(cStart);
83
const QPainterPath::Element &last = elements.last();
84
return first.x == last.x && first.y == last.y;
87
inline void QPainterPathData::close()
90
const QPainterPath::Element &first = elements.at(cStart);
91
const QPainterPath::Element &last = elements.last();
92
if (first.x != last.x || first.y != last.y) {
93
QPainterPath::Element e = { first.x, first.y, QPainterPath::LineToElement };
98
inline void QPainterPathData::makeDirty()
100
if (!containsCache.isEmpty())
101
containsCache = QRegion();
104
/*******************************************************************************
105
* class QSubpathIterator
106
* Iterates through a path, subpath by subpath, element by element.
108
class QSubpathIterator
111
QSubpathIterator(const QPainterPath *path);
113
inline bool hasSubpath() const;
114
inline QPointF nextSubpath();
116
inline bool hasNext() const;
117
inline QPainterPath::Element next();
119
inline int position() const { return m_pos; }
122
const QPainterPath *m_path;
126
/*******************************************************************************
127
* QSubpathReverseIterator
129
* Iterates through all subpaths backwards. The order of the subpaths
130
* are the same as their order in the original path.
132
class QSubpathReverseIterator
135
QSubpathReverseIterator(const QPainterPath *path);
137
inline bool hasSubpath() const;
138
inline QPointF nextSubpath();
140
inline bool hasNext() const;
141
QPainterPath::Element next();
144
inline int indexOfSubpath(int startIndex);
146
const QPainterPath *m_path;
151
/*******************************************************************************
152
* QSubpathFlatIterator
154
* Iterates through all subpaths, element by element, but converts any
155
* curve element to a number of line segments so all elements retrieved
156
* are of type QPainterPath::LineToElement.
158
class QSubpathFlatIterator
161
QSubpathFlatIterator(const QPainterPath *path);
163
inline bool hasSubpath() const;
164
inline QPointF nextSubpath();
166
inline bool hasNext() const;
167
QPainterPath::Element next();
170
const QPainterPath *m_path;
177
/*******************************************************************************
178
* QSubpathIterator inline implemetations
181
inline QSubpathIterator::QSubpathIterator(const QPainterPath *path)
187
inline bool QSubpathIterator::hasSubpath() const
189
return m_pos + 1 < m_path->elementCount()
190
&& m_path->elementAt(m_pos).type == QPainterPath::MoveToElement;
193
inline QPointF QSubpathIterator::nextSubpath()
195
Q_ASSERT(hasSubpath());
196
const QPainterPath::Element &e = m_path->elementAt(m_pos);
198
Q_ASSERT(!hasSubpath());
199
return QPointF(e.x, e.y);
202
inline bool QSubpathIterator::hasNext() const
204
return m_pos < m_path->elementCount()
205
&& m_path->elementAt(m_pos).type != QPainterPath::MoveToElement;
208
inline QPainterPath::Element QSubpathIterator::next()
211
return m_path->elementAt(m_pos++);
215
/*******************************************************************************
216
* QSubpathReverseIterator inline implementations
219
inline QSubpathReverseIterator::QSubpathReverseIterator(const QPainterPath *path)
223
m_end = indexOfSubpath(1);
227
inline bool QSubpathReverseIterator::hasSubpath() const
229
return (m_start < m_end) & (m_pos == m_end);
232
inline QPointF QSubpathReverseIterator::nextSubpath()
234
Q_ASSERT(hasSubpath());
235
const QPainterPath::Element &e = m_path->elementAt(m_pos);
237
return QPointF(e.x, e.y);
240
inline bool QSubpathReverseIterator::hasNext() const
242
return (m_start < m_end) & (m_pos < m_end) & (m_pos >= m_start);
245
inline int QSubpathReverseIterator::indexOfSubpath(int i)
247
int max = m_path->elementCount();
248
while (i < max && m_path->elementAt(i).type != QPainterPath::MoveToElement)
254
/*******************************************************************************
255
* QSubpathFlatIterator inline implemetations
258
inline QSubpathFlatIterator::QSubpathFlatIterator(const QPainterPath *path)
266
inline bool QSubpathFlatIterator::hasNext() const
268
return m_curve_index >= 0 || (m_pos < m_path->elementCount()
269
&& m_path->elementAt(m_pos).type != QPainterPath::MoveToElement);
272
inline bool QSubpathFlatIterator::hasSubpath() const
274
return m_pos + 1 < m_path->elementCount()
275
&& m_path->elementAt(m_pos).type == QPainterPath::MoveToElement;
278
inline QPointF QSubpathFlatIterator::nextSubpath()
280
Q_ASSERT(hasSubpath());
281
const QPainterPath::Element &e = m_path->elementAt(m_pos);
283
Q_ASSERT(!hasSubpath());
284
return QPointF(e.x, e.y);
287
#endif // QPAINTERPATH_P_H