source: trunk/src/gui/statemachine/qmouseeventtransition.cpp@ 605

Last change on this file since 605 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui 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 [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "qmouseeventtransition.h"
43
44#ifndef QT_NO_STATEMACHINE
45
46#include "qbasicmouseeventtransition_p.h"
47#include <QtCore/qstatemachine.h>
48#include <QtGui/qpainterpath.h>
49#include <private/qeventtransition_p.h>
50
51QT_BEGIN_NAMESPACE
52
53/*!
54 \class QMouseEventTransition
55
56 \brief The QMouseEventTransition class provides a transition for mouse events.
57
58 \since 4.6
59 \ingroup statemachine
60
61 QMouseEventTransition is part of \l{The State Machine Framework}.
62
63 \sa QState::addTransition()
64*/
65
66/*!
67 \property QMouseEventTransition::button
68
69 \brief the button that this mouse event transition is associated with
70*/
71
72/*!
73 \property QMouseEventTransition::modifierMask
74
75 \brief the keyboard modifier mask that this mouse event transition checks for
76*/
77
78class QMouseEventTransitionPrivate : public QEventTransitionPrivate
79{
80 Q_DECLARE_PUBLIC(QMouseEventTransition)
81public:
82 QMouseEventTransitionPrivate();
83
84 QBasicMouseEventTransition *transition;
85};
86
87QMouseEventTransitionPrivate::QMouseEventTransitionPrivate()
88{
89}
90
91/*!
92 Constructs a new mouse event transition with the given \a sourceState.
93*/
94QMouseEventTransition::QMouseEventTransition(QState *sourceState)
95 : QEventTransition(*new QMouseEventTransitionPrivate, sourceState)
96{
97 Q_D(QMouseEventTransition);
98 d->transition = new QBasicMouseEventTransition();
99}
100
101/*!
102 Constructs a new mouse event transition for events of the given \a type for
103 the given \a object, with the given \a button and \a sourceState.
104*/
105QMouseEventTransition::QMouseEventTransition(QObject *object, QEvent::Type type,
106 Qt::MouseButton button,
107 QState *sourceState)
108 : QEventTransition(*new QMouseEventTransitionPrivate, object, type, sourceState)
109{
110 Q_D(QMouseEventTransition);
111 d->transition = new QBasicMouseEventTransition(type, button);
112}
113
114/*!
115 Destroys this mouse event transition.
116*/
117QMouseEventTransition::~QMouseEventTransition()
118{
119 Q_D(QMouseEventTransition);
120 delete d->transition;
121}
122
123/*!
124 Returns the button that this mouse event transition checks for.
125*/
126Qt::MouseButton QMouseEventTransition::button() const
127{
128 Q_D(const QMouseEventTransition);
129 return d->transition->button();
130}
131
132/*!
133 Sets the \a button that this mouse event transition will check for.
134*/
135void QMouseEventTransition::setButton(Qt::MouseButton button)
136{
137 Q_D(QMouseEventTransition);
138 d->transition->setButton(button);
139}
140
141/*!
142 Returns the keyboard modifier mask that this mouse event transition checks
143 for.
144*/
145Qt::KeyboardModifiers QMouseEventTransition::modifierMask() const
146{
147 Q_D(const QMouseEventTransition);
148 return d->transition->modifierMask();
149}
150
151/*!
152 Sets the keyboard modifier mask that this mouse event transition will
153 check for to \a modifierMask.
154*/
155void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
156{
157 Q_D(QMouseEventTransition);
158 d->transition->setModifierMask(modifierMask);
159}
160
161/*!
162 Returns the hit test path for this mouse event transition.
163*/
164QPainterPath QMouseEventTransition::hitTestPath() const
165{
166 Q_D(const QMouseEventTransition);
167 return d->transition->hitTestPath();
168}
169
170/*!
171 Sets the hit test path for this mouse event transition to \a path.
172 If a valid path has been set, the transition will only trigger if the mouse
173 event position (QMouseEvent::pos()) is inside the path.
174
175 \sa QPainterPath::contains()
176*/
177void QMouseEventTransition::setHitTestPath(const QPainterPath &path)
178{
179 Q_D(QMouseEventTransition);
180 d->transition->setHitTestPath(path);
181}
182
183/*!
184 \reimp
185*/
186bool QMouseEventTransition::eventTest(QEvent *event)
187{
188 Q_D(const QMouseEventTransition);
189 if (!QEventTransition::eventTest(event))
190 return false;
191 QStateMachine::WrappedEvent *we = static_cast<QStateMachine::WrappedEvent*>(event);
192 d->transition->setEventType(we->event()->type());
193 return QAbstractTransitionPrivate::get(d->transition)->callEventTest(we->event());
194}
195
196/*!
197 \reimp
198*/
199void QMouseEventTransition::onTransition(QEvent *event)
200{
201 QEventTransition::onTransition(event);
202}
203
204QT_END_NAMESPACE
205
206#endif //QT_NO_STATEMACHINE
Note: See TracBrowser for help on using the repository browser.