1 // Commit: 57676c237992e0aa5a93a4e8fa66b3e7b90c2c90
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 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
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, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
41 ****************************************************************************/
43 #ifndef QSGMOUSEAREA_P_H
44 #define QSGMOUSEAREA_P_H
52 QT_MODULE(Declarative)
54 class Q_AUTOTEST_EXPORT QSGDrag : public QObject
59 Q_PROPERTY(QSGItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
60 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
61 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
62 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
63 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
64 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
65 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
66 Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
67 //### consider drag and drop
70 QSGDrag(QObject *parent=0);
73 QSGItem *target() const;
74 void setTarget(QSGItem *);
77 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
93 bool filterChildren() const;
94 void setFilterChildren(bool);
99 void minimumXChanged();
100 void maximumXChanged();
101 void minimumYChanged();
102 void maximumYChanged();
103 void activeChanged();
104 void filterChildrenChanged();
114 bool _filterChildren: 1;
115 Q_DISABLE_COPY(QSGDrag)
119 class QSGMouseAreaPrivate;
120 class Q_AUTOTEST_EXPORT QSGMouseArea : public QSGItem
124 Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePositionChanged)
125 Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePositionChanged)
126 Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
127 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
128 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
129 Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
130 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
131 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
132 Q_PROPERTY(QSGDrag *drag READ drag CONSTANT) //### add flicking to QSGDrag or add a QDeclarativeFlick ???
133 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
136 QSGMouseArea(QSGItem *parent=0);
139 qreal mouseX() const;
140 qreal mouseY() const;
142 bool isEnabled() const;
143 void setEnabled(bool);
145 bool hovered() const;
146 bool pressed() const;
148 Qt::MouseButtons pressedButtons() const;
150 Qt::MouseButtons acceptedButtons() const;
151 void setAcceptedButtons(Qt::MouseButtons buttons);
153 bool hoverEnabled() const;
154 void setHoverEnabled(bool h);
158 bool preventStealing() const;
159 void setPreventStealing(bool prevent);
162 void hoveredChanged();
163 void pressedChanged();
164 void enabledChanged();
165 void acceptedButtonsChanged();
166 void hoverEnabledChanged();
167 void positionChanged(QSGMouseEvent *mouse);
168 void mousePositionChanged(QSGMouseEvent *mouse);
169 void preventStealingChanged();
171 void pressed(QSGMouseEvent *mouse);
172 void pressAndHold(QSGMouseEvent *mouse);
173 void released(QSGMouseEvent *mouse);
174 void clicked(QSGMouseEvent *mouse);
175 void doubleClicked(QSGMouseEvent *mouse);
181 void setHovered(bool);
182 bool setPressed(bool);
183 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
185 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
186 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
187 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
188 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
189 virtual void mouseUngrabEvent();
190 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
191 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
192 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
193 virtual bool childMouseEventFilter(QSGItem *i, QEvent *e);
194 virtual void timerEvent(QTimerEvent *event);
196 virtual void geometryChanged(const QRectF &newGeometry,
197 const QRectF &oldGeometry);
198 virtual void itemChange(ItemChange change, const ItemChangeData& value);
202 void handleRelease();
205 Q_DISABLE_COPY(QSGMouseArea)
206 Q_DECLARE_PRIVATE(QSGMouseArea)
211 QML_DECLARE_TYPE(QSGDrag)
212 QML_DECLARE_TYPE(QSGMouseArea)
216 #endif // QSGMOUSEAREA_P_H