2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef PlatformWheelEvent_h
27 #define PlatformWheelEvent_h
31 #import <GraphicsServices/GSEvent.h>
37 typedef struct HWND__
* HWND
;
38 typedef unsigned WPARAM
;
43 typedef struct _GdkEventScroll GdkEventScroll
;
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
};
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;
76 class PlatformWheelEvent
{
78 const IntPoint
& pos() const { return m_position
; } // PlatformWindow coordinates.
79 const IntPoint
& globalPos() const { return m_globalPosition
; } // Screen coordinates.
81 float deltaX() const { return m_deltaX
; }
82 float deltaY() const { return m_deltaY
; }
84 PlatformWheelEventGranularity
granularity() const { return m_granularity
; }
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
; }
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(); }
97 void accept() { m_isAccepted
= true; }
98 void ignore() { m_isAccepted
= false; }
101 PlatformWheelEvent(GSEventRef
);
104 PlatformWheelEvent(HWND
, WPARAM
, LPARAM
, bool isHorizontal
);
107 PlatformWheelEvent(GdkEventScroll
*);
110 PlatformWheelEvent(QWheelEvent
*);
113 PlatformWheelEvent(const wxMouseEvent
&, const wxPoint
&);
118 int horizontalLineMultiplier() const { return cLineMultiplier
; }
119 int verticalLineMultiplier() const { return cLineMultiplier
; }
121 int horizontalLineMultiplier() const;
122 int verticalLineMultiplier() const;
126 IntPoint m_globalPosition
;
129 PlatformWheelEventGranularity m_granularity
;
137 } // namespace WebCore
139 #endif // PlatformWheelEvent_h