1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQUICKMOUSEAREA_P_H
43 #define QQUICKMOUSEAREA_P_H
45 #include "qquickitem.h"
47 #include <QtCore/qstringlist.h>
53 class QQuickDragAttached;
54 class QQuickMouseEvent;
55 class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
60 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
61 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
62 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
63 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
64 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
65 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
66 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
67 Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
68 //### consider drag and drop
71 QQuickDrag(QObject *parent=0);
74 QQuickItem *target() const;
75 void setTarget(QQuickItem *target);
78 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
94 bool filterChildren() const;
95 void setFilterChildren(bool);
97 static QQuickDragAttached *qmlAttachedProperties(QObject *obj);
100 void targetChanged();
102 void minimumXChanged();
103 void maximumXChanged();
104 void minimumYChanged();
105 void maximumYChanged();
106 void activeChanged();
107 void filterChildrenChanged();
117 bool _filterChildren: 1;
118 Q_DISABLE_COPY(QQuickDrag)
121 class QQuickMouseAreaPrivate;
122 // used in QtLocation
123 class Q_QUICK_EXPORT QQuickMouseArea : public QQuickItem
127 Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged)
128 Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged)
129 Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
130 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
131 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
132 Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
133 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
134 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
135 Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QDeclarativeFlick ???
136 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
137 Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
140 QQuickMouseArea(QQuickItem *parent=0);
143 qreal mouseX() const;
144 qreal mouseY() const;
146 bool isEnabled() const;
147 void setEnabled(bool);
149 bool hovered() const;
150 bool pressed() const;
152 Qt::MouseButtons pressedButtons() const;
154 Qt::MouseButtons acceptedButtons() const;
155 void setAcceptedButtons(Qt::MouseButtons buttons);
157 bool hoverEnabled() const;
158 void setHoverEnabled(bool h);
162 bool preventStealing() const;
163 void setPreventStealing(bool prevent);
165 bool propagateComposedEvents() const;
166 void setPropagateComposedEvents(bool propagate);
169 void hoveredChanged();
170 void pressedChanged();
171 void enabledChanged();
172 void acceptedButtonsChanged();
173 void hoverEnabledChanged();
174 void positionChanged(QQuickMouseEvent *mouse);
175 void mouseXChanged(QQuickMouseEvent *mouse);
176 void mouseYChanged(QQuickMouseEvent *mouse);
177 void preventStealingChanged();
178 void propagateComposedEventsChanged();
180 void pressed(QQuickMouseEvent *mouse);
181 void pressAndHold(QQuickMouseEvent *mouse);
182 void released(QQuickMouseEvent *mouse);
183 void clicked(QQuickMouseEvent *mouse);
184 void doubleClicked(QQuickMouseEvent *mouse);
190 void setHovered(bool);
191 bool setPressed(bool);
192 bool sendMouseEvent(QMouseEvent *event);
194 virtual void mousePressEvent(QMouseEvent *event);
195 virtual void mouseReleaseEvent(QMouseEvent *event);
196 virtual void mouseDoubleClickEvent(QMouseEvent *event);
197 virtual void mouseMoveEvent(QMouseEvent *event);
198 virtual void mouseUngrabEvent();
199 virtual void hoverEnterEvent(QHoverEvent *event);
200 virtual void hoverMoveEvent(QHoverEvent *event);
201 virtual void hoverLeaveEvent(QHoverEvent *event);
202 virtual bool childMouseEventFilter(QQuickItem *i, QEvent *e);
203 virtual void timerEvent(QTimerEvent *event);
204 virtual void windowDeactivateEvent();
206 virtual void geometryChanged(const QRectF &newGeometry,
207 const QRectF &oldGeometry);
208 virtual void itemChange(ItemChange change, const ItemChangeData& value);
209 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
213 void handleRelease();
217 Q_DISABLE_COPY(QQuickMouseArea)
218 Q_DECLARE_PRIVATE(QQuickMouseArea)
223 QML_DECLARE_TYPE(QQuickDrag)
224 QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)
225 QML_DECLARE_TYPE(QQuickMouseArea)
229 #endif // QQUICKMOUSEAREA_P_H