• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
3 
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.
8 
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.
13 
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.
18 */
19 
20 #include "config.h"
21 #include "PlatformWheelEvent.h"
22 
23 #include "PlatformMouseEvent.h"
24 #include "Scrollbar.h"
25 
26 #include <qapplication.h>
27 #include <QWheelEvent>
28 
29 namespace WebCore {
30 
31 
PlatformWheelEvent(QWheelEvent * e)32 PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e)
33 #ifdef QT_NO_WHEELEVENT
34 {
35     Q_UNUSED(e);
36 }
37 #else
38     : m_position(e->pos())
39     , m_globalPosition(e->globalPos())
40     , m_granularity(ScrollByPixelWheelEvent)
41     , m_isAccepted(false)
42     , m_shiftKey(e->modifiers() & Qt::ShiftModifier)
43     , m_ctrlKey(e->modifiers() & Qt::ControlModifier)
44     , m_altKey(e->modifiers() & Qt::AltModifier)
45     , m_metaKey(e->modifiers() & Qt::MetaModifier)
46 {
47     if (e->orientation() == Qt::Horizontal) {
48         m_deltaX = (e->delta() / 120);
49         m_deltaY = 0;
50     } else {
51         m_deltaX = 0;
52         m_deltaY = (e->delta() / 120);
53     }
54     m_wheelTicksX = m_deltaX;
55     m_wheelTicksY = m_deltaY;
56 
57     // use the same single scroll step as QTextEdit (in
58     // QTextEditPrivate::init [h,v]bar->setSingleStep )
59     static const float cDefaultQtScrollStep = 20.f;
60     m_deltaX *= QApplication::wheelScrollLines() * cDefaultQtScrollStep;
61     m_deltaY *= QApplication::wheelScrollLines() * cDefaultQtScrollStep;
62 }
63 #endif // QT_NO_WHEELEVENT
64 
65 } // namespace WebCore
66