Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativerectangle_p.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 QtDeclarative 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 QDECLARATIVERECT_H
43 #define QDECLARATIVERECT_H
44
45 #include "qdeclarativeitem.h"
46
47 #include <QtGui/qbrush.h>
48
49 #include <QtDeclarative/private/qdeclarativeglobal_p.h>
50
51 QT_BEGIN_HEADER
52
53 QT_BEGIN_NAMESPACE
54
55 class Q_QTQUICK1_EXPORT QDeclarative1Pen : public QObject
56 {
57     Q_OBJECT
58
59     Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged)
60     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
61 public:
62     QDeclarative1Pen(QObject *parent=0)
63         : QObject(parent), _width(1), _color("#000000"), _valid(false)
64     {}
65
66     int width() const { return _width; }
67     void setWidth(int w);
68
69     QColor color() const { return _color; }
70     void setColor(const QColor &c);
71
72     bool isValid() { return _valid; }
73
74 Q_SIGNALS:
75     void penChanged();
76
77 private:
78     int _width;
79     QColor _color;
80     bool _valid;
81 };
82
83 class Q_AUTOTEST_EXPORT QDeclarative1GradientStop : public QObject
84 {
85     Q_OBJECT
86
87     Q_PROPERTY(qreal position READ position WRITE setPosition)
88     Q_PROPERTY(QColor color READ color WRITE setColor)
89
90 public:
91     QDeclarative1GradientStop(QObject *parent=0) : QObject(parent) {}
92
93     qreal position() const { return m_position; }
94     void setPosition(qreal position) { m_position = position; updateGradient(); }
95
96     QColor color() const { return m_color; }
97     void setColor(const QColor &color) { m_color = color; updateGradient(); }
98
99 private:
100     void updateGradient();
101
102 private:
103     qreal m_position;
104     QColor m_color;
105 };
106
107 class Q_AUTOTEST_EXPORT QDeclarative1Gradient : public QObject
108 {
109     Q_OBJECT
110
111     Q_PROPERTY(QDeclarativeListProperty<QDeclarative1GradientStop> stops READ stops)
112     Q_CLASSINFO("DefaultProperty", "stops")
113
114 public:
115     QDeclarative1Gradient(QObject *parent=0) : QObject(parent), m_gradient(0) {}
116     ~QDeclarative1Gradient() { delete m_gradient; }
117
118     QDeclarativeListProperty<QDeclarative1GradientStop> stops() { return QDeclarativeListProperty<QDeclarative1GradientStop>(this, m_stops); }
119
120     const QGradient *gradient() const;
121
122 Q_SIGNALS:
123     void updated();
124
125 private:
126     void doUpdate();
127
128 private:
129     QList<QDeclarative1GradientStop *> m_stops;
130     mutable QGradient *m_gradient;
131     friend class QDeclarative1GradientStop;
132 };
133
134 class QDeclarative1RectanglePrivate;
135 class Q_QTQUICK1_EXPORT QDeclarative1Rectangle : public QDeclarativeItem
136 {
137     Q_OBJECT
138
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)
143 public:
144     QDeclarative1Rectangle(QDeclarativeItem *parent=0);
145
146     QColor color() const;
147     void setColor(const QColor &);
148
149     QDeclarative1Pen *border();
150
151     QDeclarative1Gradient *gradient() const;
152     void setGradient(QDeclarative1Gradient *gradient);
153
154     qreal radius() const;
155     void setRadius(qreal radius);
156
157     QRectF boundingRect() const;
158
159     void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
160
161 Q_SIGNALS:
162     void colorChanged();
163     void radiusChanged();
164
165 private Q_SLOTS:
166     void doUpdate();
167
168 private:
169     void generateRoundedRect();
170     void generateBorderedRect();
171     void drawRect(QPainter &painter);
172
173 private:
174     Q_DISABLE_COPY(QDeclarative1Rectangle)
175     Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Rectangle)
176 };
177
178 QT_END_NAMESPACE
179
180 QML_DECLARE_TYPE(QDeclarative1Pen)
181 QML_DECLARE_TYPE(QDeclarative1GradientStop)
182 QML_DECLARE_TYPE(QDeclarative1Gradient)
183 QML_DECLARE_TYPE(QDeclarative1Rectangle)
184
185 QT_END_HEADER
186
187 #endif // QDECLARATIVERECT_H