Fix test fails related to QTBUG-22237
[profile/ivi/qtdeclarative.git] / src / declarative / items / qquickrectangle_p.h
1 // Commit: ac5c099cc3c5b8c7eec7a49fdeb8a21037230350
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 **
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this
15 ** file. Please review the following information to ensure the GNU Lesser
16 ** General Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** GNU General Public License Usage
24 ** Alternatively, this file may be used under the terms of the GNU General
25 ** Public License version 3.0 as published by the Free Software Foundation
26 ** and appearing in the file LICENSE.GPL included in the packaging of this
27 ** file. Please review the following information to ensure the GNU General
28 ** Public License version 3.0 requirements will be met:
29 ** http://www.gnu.org/copyleft/gpl.html.
30 **
31 ** Other Usage
32 ** Alternatively, this file may be used in accordance with the terms and
33 ** conditions contained in a signed written agreement between you and Nokia.
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QQUICKRECTANGLE_P_H
44 #define QQUICKRECTANGLE_P_H
45
46 #include "qquickitem.h"
47
48 #include <QtGui/qbrush.h>
49
50 #include <private/qdeclarativeglobal_p.h>
51
52 QT_BEGIN_HEADER
53
54 QT_BEGIN_NAMESPACE
55
56 QT_MODULE(Declarative)
57 class Q_DECLARATIVE_PRIVATE_EXPORT QQuickPen : public QObject
58 {
59     Q_OBJECT
60
61     Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY penChanged)
62     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged)
63     Q_PROPERTY(bool aligned READ aligned WRITE setAligned NOTIFY penChanged)
64 public:
65     QQuickPen(QObject *parent=0);
66
67     qreal width() const;
68     void setWidth(qreal w);
69
70     QColor color() const;
71     void setColor(const QColor &c);
72
73     bool aligned() const;
74     void setAligned(bool aligned);
75
76     bool isValid() const;
77
78 Q_SIGNALS:
79     void penChanged();
80
81 private:
82     qreal m_width;
83     QColor m_color;
84     bool m_aligned : 1;
85     bool m_valid : 1;
86 };
87
88 class Q_AUTOTEST_EXPORT QQuickGradientStop : public QObject
89 {
90     Q_OBJECT
91
92     Q_PROPERTY(qreal position READ position WRITE setPosition)
93     Q_PROPERTY(QColor color READ color WRITE setColor)
94
95 public:
96     QQuickGradientStop(QObject *parent=0);
97
98     qreal position() const;
99     void setPosition(qreal position);
100
101     QColor color() const;
102     void setColor(const QColor &color);
103
104 private:
105     void updateGradient();
106
107 private:
108     qreal m_position;
109     QColor m_color;
110 };
111
112 class Q_AUTOTEST_EXPORT QQuickGradient : public QObject
113 {
114     Q_OBJECT
115
116     Q_PROPERTY(QDeclarativeListProperty<QQuickGradientStop> stops READ stops)
117     Q_CLASSINFO("DefaultProperty", "stops")
118
119 public:
120     QQuickGradient(QObject *parent=0);
121     ~QQuickGradient();
122
123     QDeclarativeListProperty<QQuickGradientStop> stops();
124
125     const QGradient *gradient() const;
126
127 Q_SIGNALS:
128     void updated();
129
130 private:
131     void doUpdate();
132
133 private:
134     QList<QQuickGradientStop *> m_stops;
135     mutable QGradient *m_gradient;
136     friend class QQuickRectangle;
137     friend class QQuickGradientStop;
138 };
139
140 class QQuickRectanglePrivate;
141 class Q_DECLARATIVE_PRIVATE_EXPORT QQuickRectangle : public QQuickItem
142 {
143     Q_OBJECT
144
145     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
146     Q_PROPERTY(QQuickGradient *gradient READ gradient WRITE setGradient)
147     Q_PROPERTY(QQuickPen * border READ border CONSTANT)
148     Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
149 public:
150     QQuickRectangle(QQuickItem *parent=0);
151
152     QColor color() const;
153     void setColor(const QColor &);
154
155     QQuickPen *border();
156
157     QQuickGradient *gradient() const;
158     void setGradient(QQuickGradient *gradient);
159
160     qreal radius() const;
161     void setRadius(qreal radius);
162
163     virtual QRectF boundingRect() const;
164
165 Q_SIGNALS:
166     void colorChanged();
167     void radiusChanged();
168
169 protected:
170     virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
171
172 private Q_SLOTS:
173     void doUpdate();
174
175 private:
176     Q_DISABLE_COPY(QQuickRectangle)
177     Q_DECLARE_PRIVATE(QQuickRectangle)
178 };
179
180 QT_END_NAMESPACE
181
182 QML_DECLARE_TYPE(QQuickPen)
183 QML_DECLARE_TYPE(QQuickGradientStop)
184 QML_DECLARE_TYPE(QQuickGradient)
185 QML_DECLARE_TYPE(QQuickRectangle)
186
187 QT_END_HEADER
188
189 #endif // QQUICKRECTANGLE_P_H