]> git.saurik.com Git - iphone-api.git/blame - WebCore/PlatformWheelEvent.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / PlatformWheelEvent.h
CommitLineData
a90939db
JF
1/*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef PlatformWheelEvent_h
27#define PlatformWheelEvent_h
28
29#include "IntPoint.h"
30
31#import <GraphicsServices/GSEvent.h>
32
33#if PLATFORM(MAC)
34#endif
35
36#if PLATFORM(WIN)
37typedef struct HWND__* HWND;
38typedef unsigned WPARAM;
39typedef long LPARAM;
40#endif
41
42#if PLATFORM(GTK)
43typedef struct _GdkEventScroll GdkEventScroll;
44#endif
45
46#if PLATFORM(QT)
47QT_BEGIN_NAMESPACE
48class QWheelEvent;
49QT_END_NAMESPACE
50#endif
51
52#if PLATFORM(WX)
53class wxMouseEvent;
54class wxPoint;
55#endif
56
57namespace WebCore {
58
59 // Wheel events come in three flavors:
60 // 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.
61 // For ScrollByPixelWheelEvents, the delta values contain the precise number of pixels to scroll.
62 // The ScrollByLineWheelEvent (the normal wheel event) sends a delta that can be corrected by a line multiplier to determine how many lines to scroll.
63 // If the platform has configurable line sensitivity (Windows), then the number of lines to scroll is used in order to behave like the platform.
64 // If the platform does not have configurable line sensitivity, then WebCore's default behavior is used (which scrolls 3 * the wheel line delta).
65 // For ScrollByLineWheelEvents, the delta values represent the number of lines to scroll.
66 // 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
67 // 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.
68 enum PlatformWheelEventGranularity { ScrollByLineWheelEvent, ScrollByPageWheelEvent, ScrollByPixelWheelEvent };
69
70 // 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
71 // 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
72 // 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
73 // get when doing other kinds of line stepping.
74 const int cLineMultiplier = 3;
75
76 class PlatformWheelEvent {
77 public:
78 const IntPoint& pos() const { return m_position; } // PlatformWindow coordinates.
79 const IntPoint& globalPos() const { return m_globalPosition; } // Screen coordinates.
80
81 float deltaX() const { return m_deltaX; }
82 float deltaY() const { return m_deltaY; }
83
84 PlatformWheelEventGranularity granularity() const { return m_granularity; }
85
86 bool isAccepted() const { return m_isAccepted; }
87 bool shiftKey() const { return m_shiftKey; }
88 bool ctrlKey() const { return m_ctrlKey; }
89 bool altKey() const { return m_altKey; }
90 bool metaKey() const { return m_metaKey; }
91
92 int x() const { return m_position.x(); } // PlatformWindow coordinates.
93 int y() const { return m_position.y(); }
94 int globalX() const { return m_globalPosition.x(); } // Screen coordinates.
95 int globalY() const { return m_globalPosition.y(); }
96
97 void accept() { m_isAccepted = true; }
98 void ignore() { m_isAccepted = false; }
99
100#if PLATFORM(MAC)
101 PlatformWheelEvent(GSEventRef);
102#endif
103#if PLATFORM(WIN)
104 PlatformWheelEvent(HWND, WPARAM, LPARAM, bool isHorizontal);
105#endif
106#if PLATFORM(GTK)
107 PlatformWheelEvent(GdkEventScroll*);
108#endif
109#if PLATFORM(QT)
110 PlatformWheelEvent(QWheelEvent*);
111#endif
112#if PLATFORM(WX)
113 PlatformWheelEvent(const wxMouseEvent&, const wxPoint&);
114#endif
115
116 protected:
117#if !PLATFORM(WIN)
118 int horizontalLineMultiplier() const { return cLineMultiplier; }
119 int verticalLineMultiplier() const { return cLineMultiplier; }
120#else
121 int horizontalLineMultiplier() const;
122 int verticalLineMultiplier() const;
123#endif
124
125 IntPoint m_position;
126 IntPoint m_globalPosition;
127 float m_deltaX;
128 float m_deltaY;
129 PlatformWheelEventGranularity m_granularity;
130 bool m_isAccepted;
131 bool m_shiftKey;
132 bool m_ctrlKey;
133 bool m_altKey;
134 bool m_metaKey;
135 };
136
137} // namespace WebCore
138
139#endif // PlatformWheelEvent_h