1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEMOUSEAREA_H
43 #define QDECLARATIVEMOUSEAREA_H
45 #include "qdeclarativeitem.h"
52 class Q_AUTOTEST_EXPORT QDeclarative1Drag : public QObject
57 Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
58 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
59 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
60 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
61 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
62 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
63 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
64 Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
65 //### consider drag and drop
68 QDeclarative1Drag(QObject *parent=0);
71 QGraphicsObject *target() const;
72 void setTarget(QGraphicsObject *);
75 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
91 bool filterChildren() const;
92 void setFilterChildren(bool);
97 void minimumXChanged();
98 void maximumXChanged();
99 void minimumYChanged();
100 void maximumYChanged();
101 void activeChanged();
102 void filterChildrenChanged();
105 QGraphicsObject *_target;
112 bool _filterChildren: 1;
113 Q_DISABLE_COPY(QDeclarative1Drag)
116 class QDeclarative1MouseEvent;
117 class QDeclarative1MouseAreaPrivate;
118 class Q_AUTOTEST_EXPORT QDeclarative1MouseArea : public QDeclarativeItem
122 Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePositionChanged)
123 Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePositionChanged)
124 Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
125 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
126 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
127 Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
128 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
129 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
130 Q_PROPERTY(QDeclarative1Drag *drag READ drag CONSTANT) //### add flicking to QDeclarative1Drag or add a QDeclarative1Flick ???
131 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1)
134 QDeclarative1MouseArea(QDeclarativeItem *parent=0);
135 ~QDeclarative1MouseArea();
137 qreal mouseX() const;
138 qreal mouseY() const;
140 bool isEnabled() const;
141 void setEnabled(bool);
143 bool hovered() const;
144 bool pressed() const;
146 Qt::MouseButtons pressedButtons() const;
148 Qt::MouseButtons acceptedButtons() const;
149 void setAcceptedButtons(Qt::MouseButtons buttons);
151 bool hoverEnabled() const;
152 void setHoverEnabled(bool h);
154 QDeclarative1Drag *drag();
156 bool preventStealing() const;
157 void setPreventStealing(bool prevent);
160 void hoveredChanged();
161 void pressedChanged();
162 void enabledChanged();
163 void acceptedButtonsChanged();
164 void hoverEnabledChanged();
165 void positionChanged(QDeclarative1MouseEvent *mouse);
166 void mousePositionChanged(QDeclarative1MouseEvent *mouse);
167 Q_REVISION(1) void preventStealingChanged();
169 void pressed(QDeclarative1MouseEvent *mouse);
170 void pressAndHold(QDeclarative1MouseEvent *mouse);
171 void released(QDeclarative1MouseEvent *mouse);
172 void clicked(QDeclarative1MouseEvent *mouse);
173 void doubleClicked(QDeclarative1MouseEvent *mouse);
179 void setHovered(bool);
180 bool setPressed(bool);
182 void mousePressEvent(QGraphicsSceneMouseEvent *event);
183 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
184 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
185 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
186 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
187 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
188 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
189 #ifndef QT_NO_CONTEXTMENU
190 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
191 #endif // QT_NO_CONTEXTMENU
192 bool sceneEvent(QEvent *);
193 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
194 bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
195 void timerEvent(QTimerEvent *event);
197 virtual void geometryChanged(const QRectF &newGeometry,
198 const QRectF &oldGeometry);
199 virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
203 void handleRelease();
206 Q_DISABLE_COPY(QDeclarative1MouseArea)
207 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1MouseArea)
212 QML_DECLARE_TYPE(QDeclarative1Drag)
213 QML_DECLARE_TYPE(QDeclarative1MouseArea)
217 #endif // QDECLARATIVEMOUSEAREA_H