Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
[qt-netbsd.git] / src / 3rdparty / webkit / WebCore / platform / qt / WheelEventQt.cpp
blob9cc27ab074ac9160fe83852dfef008a76632d7b0
1 /*
2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "config.h"
21 #include "PlatformWheelEvent.h"
23 #include "PlatformMouseEvent.h"
24 #include "Scrollbar.h"
26 #include <qapplication.h>
27 #include <QWheelEvent>
28 #include <QGraphicsSceneWheelEvent>
30 namespace WebCore {
32 void PlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation)
34 if (orientation == Qt::Horizontal) {
35 m_deltaX = (delta / 120.0f);
36 m_deltaY = 0;
37 } else {
38 m_deltaX = 0;
39 m_deltaY = (delta / 120.0f);
42 m_wheelTicksX = m_deltaX;
43 m_wheelTicksY = m_deltaY;
45 // Use the same single scroll step as QTextEdit
46 // (in QTextEditPrivate::init [h,v]bar->setSingleStep)
47 static const float cDefaultQtScrollStep = 20.f;
48 m_deltaX *= QApplication::wheelScrollLines() * cDefaultQtScrollStep;
49 m_deltaY *= QApplication::wheelScrollLines() * cDefaultQtScrollStep;
52 PlatformWheelEvent::PlatformWheelEvent(QGraphicsSceneWheelEvent* e)
53 #ifdef QT_NO_WHEELEVENT
55 Q_UNUSED(e);
57 #else
58 : m_position(e->pos().toPoint())
59 , m_globalPosition(e->screenPos())
60 , m_granularity(ScrollByPixelWheelEvent)
61 , m_isAccepted(false)
62 , m_shiftKey(e->modifiers() & Qt::ShiftModifier)
63 , m_ctrlKey(e->modifiers() & Qt::ControlModifier)
64 , m_altKey(e->modifiers() & Qt::AltModifier)
65 , m_metaKey(e->modifiers() & Qt::MetaModifier)
67 applyDelta(e->delta(), e->orientation());
69 #endif // QT_NO_WHEELEVENT
71 PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e)
72 #ifdef QT_NO_WHEELEVENT
74 Q_UNUSED(e);
76 #else
77 : m_position(e->pos())
78 , m_globalPosition(e->globalPos())
79 , m_granularity(ScrollByPixelWheelEvent)
80 , m_isAccepted(false)
81 , m_shiftKey(e->modifiers() & Qt::ShiftModifier)
82 , m_ctrlKey(e->modifiers() & Qt::ControlModifier)
83 , m_altKey(e->modifiers() & Qt::AltModifier)
84 , m_metaKey(e->modifiers() & Qt::MetaModifier)
86 applyDelta(e->delta(), e->orientation());
88 #endif // QT_NO_WHEELEVENT
90 } // namespace WebCore