source: trunk/src/declarative/graphicsitems/qdeclarativemousearea_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 7.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the QtDeclarative module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
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.
23**
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.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDECLARATIVEMOUSEAREA_H
43#define QDECLARATIVEMOUSEAREA_H
44
45#include "qdeclarativeitem.h"
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Declarative)
52
53class Q_AUTOTEST_EXPORT QDeclarativeDrag : public QObject
54{
55 Q_OBJECT
56
57 Q_ENUMS(Axis)
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
67
68public:
69 QDeclarativeDrag(QObject *parent=0);
70 ~QDeclarativeDrag();
71
72 QGraphicsObject *target() const;
73 void setTarget(QGraphicsObject *);
74 void resetTarget();
75
76 enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
77 Axis axis() const;
78 void setAxis(Axis);
79
80 qreal xmin() const;
81 void setXmin(qreal);
82 qreal xmax() const;
83 void setXmax(qreal);
84 qreal ymin() const;
85 void setYmin(qreal);
86 qreal ymax() const;
87 void setYmax(qreal);
88
89 bool active() const;
90 void setActive(bool);
91
92 bool filterChildren() const;
93 void setFilterChildren(bool);
94
95Q_SIGNALS:
96 void targetChanged();
97 void axisChanged();
98 void minimumXChanged();
99 void maximumXChanged();
100 void minimumYChanged();
101 void maximumYChanged();
102 void activeChanged();
103 void filterChildrenChanged();
104
105private:
106 QGraphicsObject *_target;
107 Axis _axis;
108 qreal _xmin;
109 qreal _xmax;
110 qreal _ymin;
111 qreal _ymax;
112 bool _active : 1;
113 bool _filterChildren: 1;
114 Q_DISABLE_COPY(QDeclarativeDrag)
115};
116
117class QDeclarativeMouseEvent;
118class QDeclarativeMouseAreaPrivate;
119class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
120{
121 Q_OBJECT
122
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
133public:
134 QDeclarativeMouseArea(QDeclarativeItem *parent=0);
135 ~QDeclarativeMouseArea();
136
137 qreal mouseX() const;
138 qreal mouseY() const;
139
140 bool isEnabled() const;
141 void setEnabled(bool);
142
143 bool hovered() const;
144 bool pressed() const;
145
146 Qt::MouseButtons pressedButtons() const;
147
148 Qt::MouseButtons acceptedButtons() const;
149 void setAcceptedButtons(Qt::MouseButtons buttons);
150
151 bool hoverEnabled() const;
152 void setHoverEnabled(bool h);
153
154 QDeclarativeDrag *drag();
155
156Q_SIGNALS:
157 void hoveredChanged();
158 void pressedChanged();
159 void enabledChanged();
160 void acceptedButtonsChanged();
161 void hoverEnabledChanged();
162 void positionChanged(QDeclarativeMouseEvent *mouse);
163 void mousePositionChanged(QDeclarativeMouseEvent *mouse);
164
165 void pressed(QDeclarativeMouseEvent *mouse);
166 void pressAndHold(QDeclarativeMouseEvent *mouse);
167 void released(QDeclarativeMouseEvent *mouse);
168 void clicked(QDeclarativeMouseEvent *mouse);
169 void doubleClicked(QDeclarativeMouseEvent *mouse);
170 void entered();
171 void exited();
172 void canceled();
173
174protected:
175 void setHovered(bool);
176 bool setPressed(bool);
177
178 void mousePressEvent(QGraphicsSceneMouseEvent *event);
179 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
180 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
181 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
182 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
183 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
184 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
185 bool sceneEvent(QEvent *);
186 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
187 bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
188 void timerEvent(QTimerEvent *event);
189
190 virtual void geometryChanged(const QRectF &newGeometry,
191 const QRectF &oldGeometry);
192 virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
193
194private:
195 void handlePress();
196 void handleRelease();
197
198private:
199 Q_DISABLE_COPY(QDeclarativeMouseArea)
200 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeMouseArea)
201};
202
203QT_END_NAMESPACE
204
205QML_DECLARE_TYPE(QDeclarativeDrag)
206QML_DECLARE_TYPE(QDeclarativeMouseArea)
207
208QT_END_HEADER
209
210#endif // QDECLARATIVEMOUSEAREA_H
Note: See TracBrowser for help on using the repository browser.