Initial import from qtquick2.
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsgpainteditem.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 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
15 ** this package.
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, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QSGPAINTEDITEM_P_H
44 #define QSGPAINTEDITEM_P_H
45
46 #include <qsgitem.h>
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52 class QSGPaintedItemPrivate;
53 class Q_DECLARATIVE_EXPORT QSGPaintedItem : public QSGItem
54 {
55     Q_OBJECT
56     Q_ENUMS(RenderTarget)
57
58     Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged)
59     Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
60     Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize)
61     Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache)
62     Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged)
63     Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
64 public:
65     QSGPaintedItem(QSGItem *parent = 0);
66     virtual ~QSGPaintedItem();
67
68     enum RenderTarget {
69         Image,
70         FramebufferObject
71     };
72
73     void update(const QRect &rect = QRect());
74
75     bool opaquePainting() const;
76     void setOpaquePainting(bool opaque);
77
78     QSize contentsSize() const;
79     void setContentsSize(const QSize &);
80     void resetContentsSize();
81
82     qreal contentsScale() const;
83     void setContentsScale(qreal);
84
85     int pixelCacheSize() const;
86     void setPixelCacheSize(int pixels);
87
88     bool smoothCache() const;
89     void setSmoothCache(bool on);
90
91     QColor fillColor() const;
92     void setFillColor(const QColor&);
93
94     RenderTarget renderTarget() const;
95     void setRenderTarget(RenderTarget target);
96
97     virtual void paint(QPainter *painter) = 0;
98
99 Q_SIGNALS:
100     void fillColorChanged();
101     void contentsSizeChanged();
102     void contentsScaleChanged();
103     void renderTargetChanged();
104
105 protected:
106     QSGPaintedItem(QSGPaintedItemPrivate &dd, QSGItem *parent = 0);
107     virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
108     virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
109
110 private:
111     Q_DISABLE_COPY(QSGPaintedItem);
112     Q_DECLARE_PRIVATE(QSGPaintedItem);
113 };
114
115 QT_END_NAMESPACE
116
117 QT_END_HEADER
118
119 #endif // QSGPAINTEDITEM_P_H