Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickmousearea_p.h
1 // Commit: c6e6a35aeb8794d68a3ca0c4e27a3a1181c066b5
2 /****************************************************************************
3 **
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QQUICKMOUSEAREA_P_H
44 #define QQUICKMOUSEAREA_P_H
45
46 #include "qquickitem.h"
47
48 #include <QtCore/qstringlist.h>
49
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54 class QQuickDragAttached;
55 class QQuickMouseEvent;
56 class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
57 {
58     Q_OBJECT
59
60     Q_ENUMS(Axis)
61     Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
62     Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
63     Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
64     Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
65     Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
66     Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
67     Q_PROPERTY(bool active READ active NOTIFY activeChanged)
68     Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
69     //### consider drag and drop
70
71 public:
72     QQuickDrag(QObject *parent=0);
73     ~QQuickDrag();
74
75     QQuickItem *target() const;
76     void setTarget(QQuickItem *target);
77     void resetTarget();
78
79     enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
80     Axis axis() const;
81     void setAxis(Axis);
82
83     qreal xmin() const;
84     void setXmin(qreal);
85     qreal xmax() const;
86     void setXmax(qreal);
87     qreal ymin() const;
88     void setYmin(qreal);
89     qreal ymax() const;
90     void setYmax(qreal);
91
92     bool active() const;
93     void setActive(bool);
94
95     bool filterChildren() const;
96     void setFilterChildren(bool);
97
98     static QQuickDragAttached *qmlAttachedProperties(QObject *obj);
99
100 Q_SIGNALS:
101     void targetChanged();
102     void axisChanged();
103     void minimumXChanged();
104     void maximumXChanged();
105     void minimumYChanged();
106     void maximumYChanged();
107     void activeChanged();
108     void filterChildrenChanged();
109
110 private:
111     QQuickItem *_target;
112     Axis _axis;
113     qreal _xmin;
114     qreal _xmax;
115     qreal _ymin;
116     qreal _ymax;
117     bool _active : 1;
118     bool _filterChildren: 1;
119     Q_DISABLE_COPY(QQuickDrag)
120 };
121
122 class QQuickMouseAreaPrivate;
123 // used in QtLocation
124 class Q_QUICK_EXPORT QQuickMouseArea : public QQuickItem
125 {
126     Q_OBJECT
127
128     Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged)
129     Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged)
130     Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
131     Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
132     Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
133     Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
134     Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
135     Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
136     Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QDeclarativeFlick ???
137     Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
138     Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
139
140 public:
141     QQuickMouseArea(QQuickItem *parent=0);
142     ~QQuickMouseArea();
143
144     qreal mouseX() const;
145     qreal mouseY() const;
146
147     bool isEnabled() const;
148     void setEnabled(bool);
149
150     bool hovered() const;
151     bool pressed() const;
152
153     Qt::MouseButtons pressedButtons() const;
154
155     Qt::MouseButtons acceptedButtons() const;
156     void setAcceptedButtons(Qt::MouseButtons buttons);
157
158     bool hoverEnabled() const;
159     void setHoverEnabled(bool h);
160
161     QQuickDrag *drag();
162
163     bool preventStealing() const;
164     void setPreventStealing(bool prevent);
165
166     bool propagateComposedEvents() const;
167     void setPropagateComposedEvents(bool propagate);
168
169 Q_SIGNALS:
170     void hoveredChanged();
171     void pressedChanged();
172     void enabledChanged();
173     void acceptedButtonsChanged();
174     void hoverEnabledChanged();
175     void positionChanged(QQuickMouseEvent *mouse);
176     void mouseXChanged(QQuickMouseEvent *mouse);
177     void mouseYChanged(QQuickMouseEvent *mouse);
178     void preventStealingChanged();
179     void propagateComposedEventsChanged();
180
181     void pressed(QQuickMouseEvent *mouse);
182     void pressAndHold(QQuickMouseEvent *mouse);
183     void released(QQuickMouseEvent *mouse);
184     void clicked(QQuickMouseEvent *mouse);
185     void doubleClicked(QQuickMouseEvent *mouse);
186     void entered();
187     void exited();
188     void canceled();
189
190 protected:
191     void setHovered(bool);
192     bool setPressed(bool);
193     bool sendMouseEvent(QMouseEvent *event);
194
195     virtual void mousePressEvent(QMouseEvent *event);
196     virtual void mouseReleaseEvent(QMouseEvent *event);
197     virtual void mouseDoubleClickEvent(QMouseEvent *event);
198     virtual void mouseMoveEvent(QMouseEvent *event);
199     virtual void mouseUngrabEvent();
200     virtual void hoverEnterEvent(QHoverEvent *event);
201     virtual void hoverMoveEvent(QHoverEvent *event);
202     virtual void hoverLeaveEvent(QHoverEvent *event);
203     virtual bool childMouseEventFilter(QQuickItem *i, QEvent *e);
204     virtual void timerEvent(QTimerEvent *event);
205     virtual void windowDeactivateEvent();
206
207     virtual void geometryChanged(const QRectF &newGeometry,
208                                  const QRectF &oldGeometry);
209     virtual void itemChange(ItemChange change, const ItemChangeData& value);
210
211 private:
212     void handlePress();
213     void handleRelease();
214     void ungrabMouse();
215
216 private:
217     Q_DISABLE_COPY(QQuickMouseArea)
218     Q_DECLARE_PRIVATE(QQuickMouseArea)
219 };
220
221 QT_END_NAMESPACE
222
223 QML_DECLARE_TYPE(QQuickDrag)
224 QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)
225 QML_DECLARE_TYPE(QQuickMouseArea)
226
227 QT_END_HEADER
228
229 #endif // QQUICKMOUSEAREA_P_H