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 ** 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)
55 class Q_AUTOTEST_EXPORT QSGDrag : public QObject
60 Q_PROPERTY(QSGItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget)
61 Q_PROPERTY(QSGItem *dropItem READ dropItem NOTIFY dropItemChanged)
62 Q_PROPERTY(QVariant data READ data WRITE setData NOTIFY dataChanged RESET resetData)
63 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
64 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
65 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
66 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
67 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
68 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
69 Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged)
70 Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged)
71 //### consider drag and drop
74 QSGDrag(QObject *parent=0);
77 QSGItem *target() const;
78 void setTarget(QSGItem *);
81 QSGItem *dropItem() const;
82 void setDropItem(QSGItem *item);
84 QSGItem *grabItem() const;
85 void setGrabItem(QSGItem *grabItem);
87 QVariant data() const;
88 void setData(const QVariant &data);
91 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
105 void setActive(bool);
107 bool filterChildren() const;
108 void setFilterChildren(bool);
110 QStringList keys() const;
111 void setKeys(const QStringList &keys);
113 void emitDragged(QSGMouseEvent *event) { emit dragged(event); }
114 void emitDropped(QSGItem *dropItem) { emit dropped(dropItem); }
115 void emitCanceled() { emit canceled(); }
118 void targetChanged();
119 void dropItemChanged();
122 void minimumXChanged();
123 void maximumXChanged();
124 void minimumYChanged();
125 void maximumYChanged();
126 void activeChanged();
127 void filterChildrenChanged();
129 void dragged(QSGMouseEvent *mouse);
130 void dropped(QSGItem *dropItem);
145 bool _filterChildren: 1;
146 Q_DISABLE_COPY(QSGDrag)
149 class QSGMouseAreaPrivate;
150 class Q_AUTOTEST_EXPORT QSGMouseArea : public QSGItem
154 Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePositionChanged)
155 Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePositionChanged)
156 Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged)
157 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
158 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
159 Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
160 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
161 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
162 Q_PROPERTY(QSGDrag *drag READ drag CONSTANT) //### add flicking to QSGDrag or add a QDeclarativeFlick ???
163 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
164 Q_PROPERTY(QDeclarativeListProperty<QSGItem> forwardTo READ forwardTo);
167 QSGMouseArea(QSGItem *parent=0);
170 qreal mouseX() const;
171 qreal mouseY() const;
173 bool isEnabled() const;
174 void setEnabled(bool);
176 bool hovered() const;
177 bool pressed() const;
179 Qt::MouseButtons pressedButtons() const;
181 Qt::MouseButtons acceptedButtons() const;
182 void setAcceptedButtons(Qt::MouseButtons buttons);
184 bool hoverEnabled() const;
185 void setHoverEnabled(bool h);
189 bool preventStealing() const;
190 void setPreventStealing(bool prevent);
192 QDeclarativeListProperty<QSGItem> forwardTo();
195 void hoveredChanged();
196 void pressedChanged();
197 void enabledChanged();
198 void acceptedButtonsChanged();
199 void hoverEnabledChanged();
200 void positionChanged(QSGMouseEvent *mouse);
201 void mousePositionChanged(QSGMouseEvent *mouse);
202 void preventStealingChanged();
204 void pressed(QSGMouseEvent *mouse);
205 void pressAndHold(QSGMouseEvent *mouse);
206 void released(QSGMouseEvent *mouse);
207 void clicked(QSGMouseEvent *mouse);
208 void doubleClicked(QSGMouseEvent *mouse);
214 void setHovered(bool);
215 bool setPressed(bool);
216 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
218 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
219 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
220 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
221 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
222 virtual void mouseUngrabEvent();
223 virtual void hoverEnterEvent(QHoverEvent *event);
224 virtual void hoverMoveEvent(QHoverEvent *event);
225 virtual void hoverLeaveEvent(QHoverEvent *event);
226 virtual bool childMouseEventFilter(QSGItem *i, QEvent *e);
227 virtual void timerEvent(QTimerEvent *event);
229 virtual void geometryChanged(const QRectF &newGeometry,
230 const QRectF &oldGeometry);
231 virtual void itemChange(ItemChange change, const ItemChangeData& value);
235 void handleRelease();
238 Q_DISABLE_COPY(QSGMouseArea)
239 Q_DECLARE_PRIVATE(QSGMouseArea)
244 QML_DECLARE_TYPE(QSGDrag)
245 QML_DECLARE_TYPE(QSGMouseArea)
249 #endif // QSGMOUSEAREA_P_H