1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVERECT_H
43 #define QDECLARATIVERECT_H
45 #include "qdeclarativeitem.h"
47 #include <QtGui/qbrush.h>
49 #include <QtDeclarative/private/qdeclarativeglobal_p.h>
55 class Q_QTQUICK1_EXPORT QDeclarative1Pen : public QObject
59 Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged)
60 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
62 QDeclarative1Pen(QObject *parent=0)
63 : QObject(parent), _width(1), _color("#000000"), _valid(false)
66 int width() const { return _width; }
69 QColor color() const { return _color; }
70 void setColor(const QColor &c);
72 bool isValid() { return _valid; }
83 class Q_AUTOTEST_EXPORT QDeclarative1GradientStop : public QObject
87 Q_PROPERTY(qreal position READ position WRITE setPosition)
88 Q_PROPERTY(QColor color READ color WRITE setColor)
91 QDeclarative1GradientStop(QObject *parent=0) : QObject(parent) {}
93 qreal position() const { return m_position; }
94 void setPosition(qreal position) { m_position = position; updateGradient(); }
96 QColor color() const { return m_color; }
97 void setColor(const QColor &color) { m_color = color; updateGradient(); }
100 void updateGradient();
107 class Q_AUTOTEST_EXPORT QDeclarative1Gradient : public QObject
111 Q_PROPERTY(QDeclarativeListProperty<QDeclarative1GradientStop> stops READ stops)
112 Q_CLASSINFO("DefaultProperty", "stops")
115 QDeclarative1Gradient(QObject *parent=0) : QObject(parent), m_gradient(0) {}
116 ~QDeclarative1Gradient() { delete m_gradient; }
118 QDeclarativeListProperty<QDeclarative1GradientStop> stops() { return QDeclarativeListProperty<QDeclarative1GradientStop>(this, m_stops); }
120 const QGradient *gradient() const;
129 QList<QDeclarative1GradientStop *> m_stops;
130 mutable QGradient *m_gradient;
131 friend class QDeclarative1GradientStop;
134 class QDeclarative1RectanglePrivate;
135 class Q_QTQUICK1_EXPORT QDeclarative1Rectangle : public QDeclarativeItem
139 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
140 Q_PROPERTY(QDeclarative1Gradient *gradient READ gradient WRITE setGradient)
141 Q_PROPERTY(QDeclarative1Pen * border READ border CONSTANT)
142 Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
144 QDeclarative1Rectangle(QDeclarativeItem *parent=0);
146 QColor color() const;
147 void setColor(const QColor &);
149 QDeclarative1Pen *border();
151 QDeclarative1Gradient *gradient() const;
152 void setGradient(QDeclarative1Gradient *gradient);
154 qreal radius() const;
155 void setRadius(qreal radius);
157 QRectF boundingRect() const;
159 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
163 void radiusChanged();
169 void generateRoundedRect();
170 void generateBorderedRect();
171 void drawRect(QPainter &painter);
174 Q_DISABLE_COPY(QDeclarative1Rectangle)
175 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Rectangle)
180 QML_DECLARE_TYPE(QDeclarative1Pen)
181 QML_DECLARE_TYPE(QDeclarative1GradientStop)
182 QML_DECLARE_TYPE(QDeclarative1Gradient)
183 QML_DECLARE_TYPE(QDeclarative1Rectangle)
187 #endif // QDECLARATIVERECT_H