Fix test fails related to QTBUG-22237
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsgmousearea_p.h
1 // Commit: c6e6a35aeb8794d68a3ca0c4e27a3a1181c066b5
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 QSGMOUSEAREA_P_H
44 #define QSGMOUSEAREA_P_H
45
46 #include "qsgitem.h"
47
48 #include <QtCore/qstringlist.h>
49
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54 QT_MODULE(Declarative)
55
56 class QSGDragAttached;
57 class QSGMouseEvent;
58 class Q_AUTOTEST_EXPORT QSGDrag : public QObject
59 {
60     Q_OBJECT
61
62     Q_ENUMS(Axis)
63     Q_PROPERTY(QSGItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
64     Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
65     Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
66     Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
67     Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
68     Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
69     Q_PROPERTY(bool active READ active NOTIFY activeChanged)
70     Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
71     //### consider drag and drop
72
73 public:
74     QSGDrag(QObject *parent=0);
75     ~QSGDrag();
76
77     QSGItem *target() const;
78     void setTarget(QSGItem *target);
79     void resetTarget();
80
81     enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
82     Axis axis() const;
83     void setAxis(Axis);
84
85     qreal xmin() const;
86     void setXmin(qreal);
87     qreal xmax() const;
88     void setXmax(qreal);
89     qreal ymin() const;
90     void setYmin(qreal);
91     qreal ymax() const;
92     void setYmax(qreal);
93
94     bool active() const;
95     void setActive(bool);
96
97     bool filterChildren() const;
98     void setFilterChildren(bool);
99
100     static QSGDragAttached *qmlAttachedProperties(QObject *obj);
101
102 Q_SIGNALS:
103     void targetChanged();
104     void axisChanged();
105     void minimumXChanged();
106     void maximumXChanged();
107     void minimumYChanged();
108     void maximumYChanged();
109     void activeChanged();
110     void filterChildrenChanged();
111
112 private:
113     QSGItem *_target;
114     Axis _axis;
115     qreal _xmin;
116     qreal _xmax;
117     qreal _ymin;
118     qreal _ymax;
119     bool _active : 1;
120     bool _filterChildren: 1;
121     Q_DISABLE_COPY(QSGDrag)
122 };
123
124 class QSGMouseAreaPrivate;
125 // used in QtLocation
126 class Q_DECLARATIVE_EXPORT QSGMouseArea : public QSGItem
127 {
128     Q_OBJECT
129
130     Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged)
131     Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged)
132     Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
133     Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
134     Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
135     Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
136     Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
137     Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
138     Q_PROPERTY(QSGDrag *drag READ drag CONSTANT) //### add flicking to QSGDrag or add a QDeclarativeFlick ???
139     Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
140
141 public:
142     QSGMouseArea(QSGItem *parent=0);
143     ~QSGMouseArea();
144
145     qreal mouseX() const;
146     qreal mouseY() const;
147
148     bool isEnabled() const;
149     void setEnabled(bool);
150
151     bool hovered() const;
152     bool pressed() const;
153
154     Qt::MouseButtons pressedButtons() const;
155
156     Qt::MouseButtons acceptedButtons() const;
157     void setAcceptedButtons(Qt::MouseButtons buttons);
158
159     bool hoverEnabled() const;
160     void setHoverEnabled(bool h);
161
162     QSGDrag *drag();
163
164     bool preventStealing() const;
165     void setPreventStealing(bool prevent);
166
167 Q_SIGNALS:
168     void hoveredChanged();
169     void pressedChanged();
170     void enabledChanged();
171     void acceptedButtonsChanged();
172     void hoverEnabledChanged();
173     void positionChanged(QSGMouseEvent *mouse);
174     void mouseXChanged(QSGMouseEvent *mouse);
175     void mouseYChanged(QSGMouseEvent *mouse);
176     void preventStealingChanged();
177
178     void pressed(QSGMouseEvent *mouse);
179     void pressAndHold(QSGMouseEvent *mouse);
180     void released(QSGMouseEvent *mouse);
181     void clicked(QSGMouseEvent *mouse);
182     void doubleClicked(QSGMouseEvent *mouse);
183     void entered();
184     void exited();
185     void canceled();
186
187 protected:
188     void setHovered(bool);
189     bool setPressed(bool);
190     bool sendMouseEvent(QMouseEvent *event);
191
192     virtual void mousePressEvent(QMouseEvent *event);
193     virtual void mouseReleaseEvent(QMouseEvent *event);
194     virtual void mouseDoubleClickEvent(QMouseEvent *event);
195     virtual void mouseMoveEvent(QMouseEvent *event);
196     virtual void mouseUngrabEvent();
197     virtual void hoverEnterEvent(QHoverEvent *event);
198     virtual void hoverMoveEvent(QHoverEvent *event);
199     virtual void hoverLeaveEvent(QHoverEvent *event);
200     virtual bool childMouseEventFilter(QSGItem *i, QEvent *e);
201     virtual void timerEvent(QTimerEvent *event);
202     virtual void windowDeactivateEvent();
203
204     virtual void geometryChanged(const QRectF &newGeometry,
205                                  const QRectF &oldGeometry);
206     virtual void itemChange(ItemChange change, const ItemChangeData& value);
207
208 private:
209     void handlePress();
210     void handleRelease();
211     void ungrabMouse();
212
213 private:
214     Q_DISABLE_COPY(QSGMouseArea)
215     Q_DECLARE_PRIVATE(QSGMouseArea)
216 };
217
218 QT_END_NAMESPACE
219
220 QML_DECLARE_TYPE(QSGDrag)
221 QML_DECLARE_TYPEINFO(QSGDrag, QML_HAS_ATTACHED_PROPERTIES)
222 QML_DECLARE_TYPE(QSGMouseArea)
223
224 QT_END_HEADER
225
226 #endif // QSGMOUSEAREA_P_H