1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEMOUSEAREA_H
43 #define QDECLARATIVEMOUSEAREA_H
45 #include "qdeclarativeitem.h"
51 QT_MODULE(Declarative)
53 class Q_AUTOTEST_EXPORT QDeclarativeDrag : public QObject
58 Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
59 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
60 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
61 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
62 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
63 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
64 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
65 Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
66 //### consider drag and drop
69 QDeclarativeDrag(QObject *parent=0);
72 QGraphicsObject *target() const;
73 void setTarget(QGraphicsObject *);
76 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
92 bool filterChildren() const;
93 void setFilterChildren(bool);
98 void minimumXChanged();
99 void maximumXChanged();
100 void minimumYChanged();
101 void maximumYChanged();
102 void activeChanged();
103 void filterChildrenChanged();
106 QGraphicsObject *_target;
113 bool _filterChildren: 1;
114 Q_DISABLE_COPY(QDeclarativeDrag)
117 class QDeclarativeMouseEvent;
118 class QDeclarativeMouseAreaPrivate;
119 class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
123 Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePositionChanged)
124 Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePositionChanged)
125 Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
126 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
127 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
128 Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
129 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
130 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
131 Q_PROPERTY(QDeclarativeDrag *drag READ drag CONSTANT) //### add flicking to QDeclarativeDrag or add a QDeclarativeFlick ???
132 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1)
133 Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> forwardTo READ forwardTo);
136 QDeclarativeMouseArea(QDeclarativeItem *parent=0);
137 ~QDeclarativeMouseArea();
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);
156 QDeclarativeDrag *drag();
158 bool preventStealing() const;
159 void setPreventStealing(bool prevent);
161 QDeclarativeListProperty<QGraphicsObject> forwardTo();
164 void hoveredChanged();
165 void pressedChanged();
166 void enabledChanged();
167 void acceptedButtonsChanged();
168 void hoverEnabledChanged();
169 void positionChanged(QDeclarativeMouseEvent *mouse);
170 void mousePositionChanged(QDeclarativeMouseEvent *mouse);
171 Q_REVISION(1) void preventStealingChanged();
173 void pressed(QDeclarativeMouseEvent *mouse);
174 void pressAndHold(QDeclarativeMouseEvent *mouse);
175 void released(QDeclarativeMouseEvent *mouse);
176 void clicked(QDeclarativeMouseEvent *mouse);
177 void doubleClicked(QDeclarativeMouseEvent *mouse);
183 void setHovered(bool);
184 bool setPressed(bool);
186 void mousePressEvent(QGraphicsSceneMouseEvent *event);
187 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
188 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
189 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
190 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
191 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
192 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
193 bool sceneEvent(QEvent *);
194 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
195 bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
196 void timerEvent(QTimerEvent *event);
198 virtual void geometryChanged(const QRectF &newGeometry,
199 const QRectF &oldGeometry);
200 virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
204 void handleRelease();
207 Q_DISABLE_COPY(QDeclarativeMouseArea)
208 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeMouseArea)
213 QML_DECLARE_TYPE(QDeclarativeDrag)
214 QML_DECLARE_TYPE(QDeclarativeMouseArea)
218 #endif // QDECLARATIVEMOUSEAREA_H