Qt 4.8
qdeclarativerectangle_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 <private/qdeclarativeglobal_p.h>
50 
52 
54 
55 QT_MODULE(Declarative)
57 {
58  Q_OBJECT
59 
60  int width;
62 public:
63  QDeclarativePen(QObject *parent=0)
64  : QObject(parent), _width(1), _color("#000000"), _valid(false)
65  {}
66 
67  int width() const { return _width; }
68  void setWidth(int w);
69 
70  QColor color() const { return _color; }
71  void setColor(const QColor &c);
72 
73  bool isValid() { return _valid; }
74 
75 Q_SIGNALS:
76  void penChanged();
77 
78 private:
79  int _width;
81  bool _valid;
82 };
83 
85 {
86  Q_OBJECT
87 
90 
91 public:
92  QDeclarativeGradientStop(QObject *parent=0) : QObject(parent) {}
93 
94  qreal position() const { return m_position; }
95  void setPosition(qreal position) { m_position = position; updateGradient(); }
96 
97  QColor color() const { return m_color; }
98  void setColor(const QColor &color) { m_color = color; updateGradient(); }
99 
100 private:
101  void updateGradient();
102 
103 private:
106 };
107 
109 {
110  Q_OBJECT
111 
113  Q_CLASSINFO("DefaultProperty", "stops")
114 
115 public:
116  QDeclarativeGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {}
117  ~QDeclarativeGradient() { delete m_gradient; }
118 
120 
121  const QGradient *gradient() const;
122 
123 Q_SIGNALS:
124  void updated();
125 
126 private:
127  void doUpdate();
128 
129 private:
133 };
134 
137 {
138  Q_OBJECT
139 
143  qreal radius;
144 public:
146 
147  QColor color() const;
148  void setColor(const QColor &);
149 
150  QDeclarativePen *border();
151 
152  QDeclarativeGradient *gradient() const;
153  void setGradient(QDeclarativeGradient *gradient);
154 
155  qreal radius() const;
156  void setRadius(qreal radius);
157 
158  QRectF boundingRect() const;
159 
160  void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
161 
162 Q_SIGNALS:
163  void colorChanged();
164  void radiusChanged();
165 
166 private Q_SLOTS:
167  void doUpdate();
168 
169 private:
170  void generateRoundedRect();
171  void generateBorderedRect();
172  void drawRect(QPainter &painter);
173 
174 private:
177 };
178 
180 
185 
187 
188 #endif // QDECLARATIVERECT_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void setPosition(qreal position)
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
Definition: qobjectdefs.h:78
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
QDeclarativeGradient * gradient
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QDeclarativePen *qreal radius
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QDeclarativeItem class provides the most basic of all visual items in QML.
static const char * data(const QByteArray &arr)
#define Q_DECLARATIVE_PRIVATE_EXPORT
#define Q_OBJECT
Definition: qobjectdefs.h:157
QDeclarativeGradientStop(QObject *parent=0)
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
QDeclarativePen(QObject *parent=0)
void setColor(const QColor &color)
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
QList< QDeclarativeGradientStop * > m_stops
QDeclarativeListProperty< QDeclarativeGradientStop > stops
The QDeclarativePen class provides a pen used for drawing rectangle borders on a QDeclarativeView.
#define class
QDeclarativeListProperty< QDeclarativeGradientStop > stops()
#define QT_END_HEADER
Definition: qglobal.h:137
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
Definition: qstyleoption.h:867
The QList class is a template class that provides lists.
Definition: qdatastream.h:62