1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
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.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef QQUICKMOUSEAREA_P_H
43 #define QQUICKMOUSEAREA_P_H
45 #include "qquickitem.h"
46 #include <private/qtquickglobal_p.h>
47 #include <QtCore/qstringlist.h>
53 class QQuickMouseEvent;
55 #ifndef QT_NO_DRAGANDDROP
57 class QQuickDragAttached;
58 class Q_AUTOTEST_EXPORT QQuickDrag : public QObject
63 Q_PROPERTY(QQuickItem *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
74 QQuickDrag(QObject *parent=0);
77 QQuickItem *target() const;
78 void setTarget(QQuickItem *target);
81 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
97 bool filterChildren() const;
98 void setFilterChildren(bool);
100 static QQuickDragAttached *qmlAttachedProperties(QObject *obj);
103 void targetChanged();
105 void minimumXChanged();
106 void maximumXChanged();
107 void minimumYChanged();
108 void maximumYChanged();
109 void activeChanged();
110 void filterChildrenChanged();
120 bool _filterChildren: 1;
121 Q_DISABLE_COPY(QQuickDrag)
124 #endif // QT_NO_DRAGANDDROP
126 class QQuickMouseAreaPrivate;
127 class QQuickWheelEvent;
128 // used in QtLocation
129 class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
133 Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged)
134 Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged)
135 Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
136 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
137 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
138 Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedButtonsChanged)
139 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
140 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
141 #ifndef QT_NO_DRAGANDDROP
142 Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QQuickFlick ???
144 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
145 Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
147 Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET unsetCursor NOTIFY cursorShapeChanged)
151 QQuickMouseArea(QQuickItem *parent=0);
154 qreal mouseX() const;
155 qreal mouseY() const;
157 bool isEnabled() const;
158 void setEnabled(bool);
160 bool hovered() const;
161 bool pressed() const;
163 Qt::MouseButtons pressedButtons() const;
165 Qt::MouseButtons acceptedButtons() const;
166 void setAcceptedButtons(Qt::MouseButtons buttons);
168 bool hoverEnabled() const;
169 void setHoverEnabled(bool h);
171 #ifndef QT_NO_DRAGANDDROP
175 bool preventStealing() const;
176 void setPreventStealing(bool prevent);
178 bool propagateComposedEvents() const;
179 void setPropagateComposedEvents(bool propagate);
182 Qt::CursorShape cursorShape() const;
183 void setCursorShape(Qt::CursorShape shape);
187 void hoveredChanged();
188 void pressedChanged();
189 void enabledChanged();
190 void pressedButtonsChanged();
191 void acceptedButtonsChanged();
192 void hoverEnabledChanged();
194 void cursorShapeChanged();
196 void positionChanged(QQuickMouseEvent *mouse);
197 void mouseXChanged(QQuickMouseEvent *mouse);
198 void mouseYChanged(QQuickMouseEvent *mouse);
199 void preventStealingChanged();
200 void propagateComposedEventsChanged();
202 void pressed(QQuickMouseEvent *mouse);
203 void pressAndHold(QQuickMouseEvent *mouse);
204 void released(QQuickMouseEvent *mouse);
205 void clicked(QQuickMouseEvent *mouse);
206 void doubleClicked(QQuickMouseEvent *mouse);
207 void wheel(QQuickWheelEvent *wheel);
213 void setHovered(bool);
214 bool setPressed(Qt::MouseButton button, bool);
215 bool sendMouseEvent(QMouseEvent *event);
217 virtual void mousePressEvent(QMouseEvent *event);
218 virtual void mouseReleaseEvent(QMouseEvent *event);
219 virtual void mouseDoubleClickEvent(QMouseEvent *event);
220 virtual void mouseMoveEvent(QMouseEvent *event);
221 virtual void mouseUngrabEvent();
222 virtual void hoverEnterEvent(QHoverEvent *event);
223 virtual void hoverMoveEvent(QHoverEvent *event);
224 virtual void hoverLeaveEvent(QHoverEvent *event);
225 virtual void wheelEvent(QWheelEvent *event);
226 virtual bool childMouseEventFilter(QQuickItem *i, QEvent *e);
227 virtual void timerEvent(QTimerEvent *event);
228 virtual void windowDeactivateEvent();
230 virtual void geometryChanged(const QRectF &newGeometry,
231 const QRectF &oldGeometry);
232 virtual void itemChange(ItemChange change, const ItemChangeData& value);
233 virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
237 void handleRelease();
241 Q_DISABLE_COPY(QQuickMouseArea)
242 Q_DECLARE_PRIVATE(QQuickMouseArea)
247 #ifndef QT_NO_DRAGANDDROP
248 QML_DECLARE_TYPE(QQuickDrag)
249 QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES)
251 QML_DECLARE_TYPE(QQuickMouseArea)
255 #endif // QQUICKMOUSEAREA_P_H