/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
\table 100%
\row
- \o \inlineimage qpainterpath-construction.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 0
+ \li \inlineimage qpainterpath-construction.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 0
\endtable
The painter path is initially empty when constructed. We first add
\table
\header
- \o Qt::OddEvenFill
- \o Qt::WindingFill
+ \li Qt::OddEvenFill
+ \li Qt::WindingFill
\row
- \o \inlineimage qt-fillrule-oddeven.png
- \o \inlineimage qt-fillrule-winding.png
+ \li \inlineimage qt-fillrule-oddeven.png
+ \li \inlineimage qt-fillrule-winding.png
\endtable
See the Qt::FillRule documentation for the definition of the
\section1 Examples
Qt provides the \l {painting/painterpaths}{Painter Paths Example}
- and the \l {demos/deform}{Vector Deformation Demo} which are
- located in Qt's example and demo directories respectively.
+ and the \l {painting/deform}{Vector Deformation example} which are
+ located in Qt's example directory.
The \l {painting/painterpaths}{Painter Paths Example} shows how
painter paths can be used to build complex shapes for rendering
and lets the user experiment with the filling and stroking. The
- \l {demos/deform}{Vector Deformation Demo} shows how to use
+ \l {painting/deform}{Vector Deformation Example} shows how to use
QPainterPath to draw text.
\table
\header
- \o \l {painting/painterpaths}{Painter Paths Example}
- \o \l {demos/deform}{Vector Deformation Demo}
+ \li \l {painting/painterpaths}{Painter Paths Example}
+ \li \l {painting/deform}{Vector Deformation Example}
\row
- \o \inlineimage qpainterpath-example.png
- \o \inlineimage qpainterpath-demo.png
+ \li \inlineimage qpainterpath-example.png
+ \li \inlineimage qpainterpath-demo.png
\endtable
\sa QPainterPathStroker, QPainter, QRegion, {Painter Paths Example}
\value CurveToDataElement The extra data required to describe a curve in
a CurveToElement element.
- \sa elementAt(), elementCount()
+ \sa elementAt(), elementCount()
*/
/*!
\sa ElementType, elementAt(), isEmpty()
*/
+int QPainterPath::elementCount() const
+{
+ return d_ptr ? d_ptr->elements.size() : 0;
+}
+
/*!
- \fn const QPainterPath::Element &QPainterPath::elementAt(int index) const
+ \fn QPainterPath::Element QPainterPath::elementAt(int index) const
Returns the element at the given \a index in the painter path.
\sa ElementType, elementCount(), isEmpty()
*/
+QPainterPath::Element QPainterPath::elementAt(int i) const
+{
+ Q_ASSERT(d_ptr);
+ Q_ASSERT(i >= 0 && i < elementCount());
+ return d_ptr->elements.at(i);
+}
+
/*!
\fn void QPainterPath::setElementPositionAt(int index, qreal x, qreal y)
\since 4.2
x and \a y.
*/
+void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
+{
+ Q_ASSERT(d_ptr);
+ Q_ASSERT(i >= 0 && i < elementCount());
+ detach();
+ QPainterPath::Element &e = d_ptr->elements[i];
+ e.x = x;
+ e.y = y;
+}
+
+
/*###
\fn QPainterPath &QPainterPath::operator +=(const QPainterPath &other)
d_func()->elements << e;
}
+void QPainterPath::detach()
+{
+ if (d_ptr->ref.load() != 1)
+ detach_helper();
+ setDirty(true);
+}
+
/*!
\internal
*/
\table 100%
\row
- \o \inlineimage qpainterpath-cubicto.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 1
+ \li \inlineimage qpainterpath-cubicto.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 1
\endtable
\sa quadTo(), {QPainterPath#Composing a QPainterPath}{Composing
\table 100%
\row
- \o \inlineimage qpainterpath-arcto.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 2
+ \li \inlineimage qpainterpath-arcto.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 2
\endtable
\sa arcMoveTo(), addEllipse(), QPainter::drawArc(), QPainter::drawPie(),
\table 100%
\row
- \o \inlineimage qpainterpath-addrectangle.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 3
+ \li \inlineimage qpainterpath-addrectangle.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 3
\endtable
\sa addRegion(), lineTo(), {QPainterPath#Composing a
\table 100%
\row
- \o \inlineimage qpainterpath-addpolygon.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 4
+ \li \inlineimage qpainterpath-addpolygon.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 4
\endtable
\sa lineTo(), {QPainterPath#Composing a QPainterPath}{Composing
\table 100%
\row
- \o \inlineimage qpainterpath-addellipse.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 5
+ \li \inlineimage qpainterpath-addellipse.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 5
\endtable
\sa arcTo(), QPainter::drawEllipse(), {QPainterPath#Composing a
\table 100%
\row
- \o \inlineimage qpainterpath-addtext.png
- \o
- \snippet doc/src/snippets/code/src_gui_painting_qpainterpath.cpp 6
+ \li \inlineimage qpainterpath-addtext.png
+ \li
+ \snippet code/src_gui_painting_qpainterpath.cpp 6
\endtable
\sa QPainter::drawText(), {QPainterPath#Composing a
\table
\header
- \o Qt::OddEvenFill (default)
- \o Qt::WindingFill
+ \li Qt::OddEvenFill (default)
+ \li Qt::WindingFill
\row
- \o \inlineimage qt-fillrule-oddeven.png
- \o \inlineimage qt-fillrule-winding.png
+ \li \inlineimage qt-fillrule-oddeven.png
+ \li \inlineimage qt-fillrule-winding.png
\endtable
\sa fillRule()
\sa elementCount()
*/
+bool QPainterPath::isEmpty() const
+{
+ return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
+}
+
/*!
Creates and returns a reversed copy of the path.
#endif
continue;
}
- QPainterPath::Element elm = { x, y, QPainterPath::ElementType(type) };
+ QPainterPath::Element elm = { qreal(x), qreal(y), QPainterPath::ElementType(type) };
p.d_func()->elements.append(elm);
}
s >> p.d_func()->cStart;
functions:
\list
- \o setWidth()
- \o setCapStyle()
- \o setJoinStyle()
- \o setDashPattern()
+ \li setWidth()
+ \li setCapStyle()
+ \li setJoinStyle()
+ \li setDashPattern()
\endlist
The setDashPattern() function accepts both a Qt::PenStyle object
return QLineF(0, 0, m1, m2).angle();
}
-#if defined(Q_WS_WINCE)
-#pragma warning( disable : 4056 4756 )
-#endif
/*!
Returns the slope of the path at the percentage \a t. The