1 // Commit: c6e6a35aeb8794d68a3ca0c4e27a3a1181c066b5
2 /****************************************************************************
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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.
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.
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.
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.
41 ****************************************************************************/
43 #ifndef QQUICKMOUSEAREA_P_H
44 #define QQUICKMOUSEAREA_P_H
46 #include "qquickitem.h"
48 #include <QtCore/qstringlist.h>
54 class QQuickDragAttached;
55 class QQuickMouseEvent;
56 class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
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
72 QQuickDrag(QObject *parent=0);
75 QQuickItem *target() const;
76 void setTarget(QQuickItem *target);
79 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
95 bool filterChildren() const;
96 void setFilterChildren(bool);
98 static QQuickDragAttached *qmlAttachedProperties(QObject *obj);
101 void targetChanged();
103 void minimumXChanged();
104 void maximumXChanged();
105 void minimumYChanged();
106 void maximumYChanged();
107 void activeChanged();
108 void filterChildrenChanged();
118 bool _filterChildren: 1;
119 Q_DISABLE_COPY(QQuickDrag)
122 class QQuickMouseAreaPrivate;
123 // used in QtLocation
124 class Q_QUICK_EXPORT QQuickMouseArea : public QQuickItem
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)
141 QQuickMouseArea(QQuickItem *parent=0);
144 qreal mouseX() const;
145 qreal mouseY() const;
147 bool isEnabled() const;
148 void setEnabled(bool);
150 bool hovered() const;
151 bool pressed() const;
153 Qt::MouseButtons pressedButtons() const;
155 Qt::MouseButtons acceptedButtons() const;
156 void setAcceptedButtons(Qt::MouseButtons buttons);
158 bool hoverEnabled() const;
159 void setHoverEnabled(bool h);
163 bool preventStealing() const;
164 void setPreventStealing(bool prevent);
166 bool propagateComposedEvents() const;
167 void setPropagateComposedEvents(bool propagate);
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();
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);
191 void setHovered(bool);
192 bool setPressed(bool);
193 bool sendMouseEvent(QMouseEvent *event);
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();
207 virtual void geometryChanged(const QRectF &newGeometry,
208 const QRectF &oldGeometry);
209 virtual void itemChange(ItemChange change, const ItemChangeData& value);
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