1 // Commit: c6e6a35aeb8794d68a3ca0c4e27a3a1181c066b5
2 /****************************************************************************
4 ** Copyright (C) 2011 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 QSGMOUSEAREA_P_H
44 #define QSGMOUSEAREA_P_H
48 #include <QtCore/qstringlist.h>
54 QT_MODULE(Declarative)
56 class QSGDragAttached;
58 class Q_AUTOTEST_EXPORT QSGDrag : public QObject
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
74 QSGDrag(QObject *parent=0);
77 QSGItem *target() const;
78 void setTarget(QSGItem *target);
81 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
97 bool filterChildren() const;
98 void setFilterChildren(bool);
100 static QSGDragAttached *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(QSGDrag)
124 class QSGMouseAreaPrivate;
125 // used in QtLocation
126 class Q_DECLARATIVE_EXPORT QSGMouseArea : public QSGItem
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)
142 QSGMouseArea(QSGItem *parent=0);
145 qreal mouseX() const;
146 qreal mouseY() const;
148 bool isEnabled() const;
149 void setEnabled(bool);
151 bool hovered() const;
152 bool pressed() const;
154 Qt::MouseButtons pressedButtons() const;
156 Qt::MouseButtons acceptedButtons() const;
157 void setAcceptedButtons(Qt::MouseButtons buttons);
159 bool hoverEnabled() const;
160 void setHoverEnabled(bool h);
164 bool preventStealing() const;
165 void setPreventStealing(bool prevent);
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();
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);
188 void setHovered(bool);
189 bool setPressed(bool);
190 bool sendMouseEvent(QMouseEvent *event);
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();
204 virtual void geometryChanged(const QRectF &newGeometry,
205 const QRectF &oldGeometry);
206 virtual void itemChange(ItemChange change, const ItemChangeData& value);
210 void handleRelease();
214 Q_DISABLE_COPY(QSGMouseArea)
215 Q_DECLARE_PRIVATE(QSGMouseArea)
220 QML_DECLARE_TYPE(QSGDrag)
221 QML_DECLARE_TYPEINFO(QSGDrag, QML_HAS_ATTACHED_PROPERTIES)
222 QML_DECLARE_TYPE(QSGMouseArea)
226 #endif // QSGMOUSEAREA_P_H