~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/platform/PlatformWheelEvent.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
 
2
 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
28
28
 
29
29
#include "IntPoint.h"
30
30
 
31
 
#if PLATFORM(MAC)
32
 
#ifdef __OBJC__
33
 
@class NSEvent;
34
 
#else
35
 
class NSEvent;
36
 
#endif
37
 
#endif
38
 
 
39
 
#if PLATFORM(WIN)
40
 
typedef struct HWND__* HWND;
41
 
typedef unsigned WPARAM;
42
 
typedef long LPARAM;
43
 
#endif
44
 
 
45
31
#if PLATFORM(GTK)
46
32
typedef struct _GdkEventScroll GdkEventScroll;
47
33
#endif
49
35
#if PLATFORM(QT)
50
36
QT_BEGIN_NAMESPACE
51
37
class QWheelEvent;
 
38
class QGraphicsSceneWheelEvent;
52
39
QT_END_NAMESPACE
53
40
#endif
54
41
 
 
42
#if PLATFORM(WIN)
 
43
typedef struct HWND__* HWND;
 
44
typedef unsigned WPARAM;
 
45
typedef long LPARAM;
 
46
#endif
 
47
 
55
48
#if PLATFORM(WX)
56
49
class wxMouseEvent;
57
50
class wxPoint;
58
51
#endif
59
52
 
 
53
#if PLATFORM(HAIKU)
 
54
class BMessage;
 
55
#endif
 
56
 
60
57
namespace WebCore {
61
58
 
62
 
    // Wheel events come in three flavors:
63
 
    // The ScrollByPixelWheelEvent is a fine-grained event that specifies the precise number of pixels to scroll.  It is sent by MacBook touchpads on OS X.
64
 
    // For ScrollByPixelWheelEvents, the delta values contain the precise number of pixels to scroll.
65
 
    // The ScrollByLineWheelEvent (the normal wheel event) sends a delta that can be corrected by a line multiplier to determine how many lines to scroll.
66
 
    //      If the platform has configurable line sensitivity (Windows), then the number of lines to scroll is used in order to behave like the platform.
67
 
    //      If the platform does not have configurable line sensitivity, then WebCore's default behavior is used (which scrolls 3 * the wheel line delta).
68
 
    // For ScrollByLineWheelEvents, the delta values represent the number of lines to scroll.
69
 
    // The ScrollByPageWheelEvent indicates that the wheel event should scroll an entire page instead.  In this case WebCore's built in paging behavior is used to page
 
59
    class FloatPoint;
 
60
    class FloatSize;
 
61
 
 
62
    // Wheel events come in two flavors:
 
63
    // The ScrollByPixelWheelEvent is a fine-grained event that specifies the precise number of pixels to scroll.  It is sent directly by MacBook touchpads on OS X,
 
64
    // and synthesized in other cases where platforms generate line-by-line scrolling events.
 
65
    // The ScrollByPageWheelEvent indicates that the wheel event should scroll an entire page.  In this case WebCore's built in paging behavior is used to page
70
66
    // up and down (you get the same behavior as if the user was clicking in a scrollbar track to page up or page down).  Page scrolling only works in the vertical direction.
71
 
    enum PlatformWheelEventGranularity { ScrollByLineWheelEvent, ScrollByPageWheelEvent, ScrollByPixelWheelEvent };
 
67
    enum PlatformWheelEventGranularity { ScrollByPageWheelEvent, ScrollByPixelWheelEvent };
72
68
    
73
 
    // WebCore uses a line multiple of ~3 (40px per line step) when doing arrowing with a scrollbar or line stepping via the arrow keys.  The delta for wheeling is expressed
74
 
    // as a # of actual lines (40 / 3 = 1 wheel line).  We use the horizontalLineMultiplier and verticalLineMultiplier methods to incorporate the line multiplier into the deltas.  On
75
 
    // platforms that do not support wheel sensitivity, we use this hardcoded constant value of 3 to ensure that wheeling by default matches the WebCore multiplier you
76
 
    // get when doing other kinds of line stepping.
77
 
    const int cLineMultiplier = 3;
78
 
 
79
69
    class PlatformWheelEvent {
80
70
    public:
81
71
        const IntPoint& pos() const { return m_position; } // PlatformWindow coordinates.
84
74
        float deltaX() const { return m_deltaX; }
85
75
        float deltaY() const { return m_deltaY; }
86
76
 
 
77
        float wheelTicksX() const { return m_wheelTicksX; }
 
78
        float wheelTicksY() const { return m_wheelTicksY; }
 
79
 
87
80
        PlatformWheelEventGranularity granularity() const { return m_granularity; }
88
81
 
89
82
        bool isAccepted() const { return m_isAccepted; }
100
93
        void accept() { m_isAccepted = true; }
101
94
        void ignore() { m_isAccepted = false; }
102
95
 
103
 
#if PLATFORM(MAC)
104
 
        PlatformWheelEvent(NSEvent*);
105
 
#endif
106
 
#if PLATFORM(WIN)
107
 
        PlatformWheelEvent(HWND, WPARAM, LPARAM, bool isHorizontal);
108
 
#endif
 
96
        void turnVerticalTicksIntoHorizontal()
 
97
        {
 
98
            m_deltaX = m_deltaY;
 
99
            m_deltaY = 0;
 
100
 
 
101
            m_wheelTicksX = m_wheelTicksY;
 
102
            m_wheelTicksY = 0;
 
103
        }
 
104
 
109
105
#if PLATFORM(GTK)
110
106
        PlatformWheelEvent(GdkEventScroll*);
111
107
#endif
 
108
 
 
109
#if PLATFORM(MAC) && defined(__OBJC__)
 
110
        PlatformWheelEvent(NSEvent *, NSView *windowView);
 
111
#endif
 
112
 
112
113
#if PLATFORM(QT)
113
114
        PlatformWheelEvent(QWheelEvent*);
114
 
#endif
 
115
        PlatformWheelEvent(QGraphicsSceneWheelEvent*);
 
116
        void applyDelta(int delta, Qt::Orientation);
 
117
#endif
 
118
 
 
119
#if PLATFORM(WIN)
 
120
        PlatformWheelEvent(HWND, WPARAM, LPARAM, bool isMouseHWheel);
 
121
        PlatformWheelEvent(HWND, const FloatSize& delta, const FloatPoint& location);
 
122
#endif
 
123
 
115
124
#if PLATFORM(WX)
116
125
        PlatformWheelEvent(const wxMouseEvent&, const wxPoint&);
117
126
#endif
118
127
 
 
128
#if PLATFORM(HAIKU)
 
129
        PlatformWheelEvent(BMessage*);
 
130
#endif
 
131
 
119
132
    protected:
120
 
#if !PLATFORM(WIN)
121
 
        int horizontalLineMultiplier() const { return cLineMultiplier; }
122
 
        int verticalLineMultiplier() const { return cLineMultiplier; }
123
 
#else
124
 
        int horizontalLineMultiplier() const;
125
 
        int verticalLineMultiplier() const;
126
 
#endif
127
 
 
128
133
        IntPoint m_position;
129
134
        IntPoint m_globalPosition;
130
135
        float m_deltaX;
131
136
        float m_deltaY;
 
137
        float m_wheelTicksX;
 
138
        float m_wheelTicksY;
132
139
        PlatformWheelEventGranularity m_granularity;
133
140
        bool m_isAccepted;
134
141
        bool m_shiftKey;