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 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEMOUSEAREA_H
43 #define QDECLARATIVEMOUSEAREA_H
45 #include "qdeclarativeitem.h"
51 QT_MODULE(Declarative)
53 class Q_AUTOTEST_EXPORT QDeclarative1Drag : 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 QDeclarative1Drag(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(QDeclarative1Drag)
117 class QDeclarative1MouseEvent;
118 class QDeclarative1MouseAreaPrivate;
119 class Q_AUTOTEST_EXPORT QDeclarative1MouseArea : 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(QDeclarative1Drag *drag READ drag CONSTANT) //### add flicking to QDeclarative1Drag or add a QDeclarative1Flick ???
132 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1)
135 QDeclarative1MouseArea(QDeclarativeItem *parent=0);
136 ~QDeclarative1MouseArea();
138 qreal mouseX() const;
139 qreal mouseY() const;
141 bool isEnabled() const;
142 void setEnabled(bool);
144 bool hovered() const;
145 bool pressed() const;
147 Qt::MouseButtons pressedButtons() const;
149 Qt::MouseButtons acceptedButtons() const;
150 void setAcceptedButtons(Qt::MouseButtons buttons);
152 bool hoverEnabled() const;
153 void setHoverEnabled(bool h);
155 QDeclarative1Drag *drag();
157 bool preventStealing() const;
158 void setPreventStealing(bool prevent);
161 void hoveredChanged();
162 void pressedChanged();
163 void enabledChanged();
164 void acceptedButtonsChanged();
165 void hoverEnabledChanged();
166 void positionChanged(QDeclarative1MouseEvent *mouse);
167 void mousePositionChanged(QDeclarative1MouseEvent *mouse);
168 Q_REVISION(1) void preventStealingChanged();
170 void pressed(QDeclarative1MouseEvent *mouse);
171 void pressAndHold(QDeclarative1MouseEvent *mouse);
172 void released(QDeclarative1MouseEvent *mouse);
173 void clicked(QDeclarative1MouseEvent *mouse);
174 void doubleClicked(QDeclarative1MouseEvent *mouse);
180 void setHovered(bool);
181 bool setPressed(bool);
183 void mousePressEvent(QGraphicsSceneMouseEvent *event);
184 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
185 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
186 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
187 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
188 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
189 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
190 #ifndef QT_NO_CONTEXTMENU
191 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
192 #endif // QT_NO_CONTEXTMENU
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(QDeclarative1MouseArea)
208 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1MouseArea)
213 QML_DECLARE_TYPE(QDeclarative1Drag)
214 QML_DECLARE_TYPE(QDeclarative1MouseArea)
218 #endif // QDECLARATIVEMOUSEAREA_H