OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 QT_END_NAMESPACE | 52 QT_END_NAMESPACE |
53 #endif | 53 #endif |
54 | 54 |
55 #if PLATFORM(WX) | 55 #if PLATFORM(WX) |
56 class wxMouseEvent; | 56 class wxMouseEvent; |
57 class wxPoint; | 57 class wxPoint; |
58 #endif | 58 #endif |
59 | 59 |
60 namespace WebCore { | 60 namespace WebCore { |
61 | 61 |
62 // Wheel events come in three flavors: | 62 // Wheel events come in two flavors: |
63 // The ScrollByPixelWheelEvent is a fine-grained event that specifies the pr
ecise number of pixels to scroll. It is sent by MacBook touchpads on OS X. | 63 // The ScrollByPixelWheelEvent is a fine-grained event that specifies the pr
ecise number of pixels to scroll. It is sent directly by MacBook touchpads on O
S X, |
64 // For ScrollByPixelWheelEvents, the delta values contain the precise number
of pixels to scroll. | 64 // and synthesized in other cases where platforms generate line-by-line scro
lling events. |
65 // The ScrollByLineWheelEvent (the normal wheel event) sends a delta that ca
n be corrected by a line multiplier to determine how many lines to scroll. | 65 // The ScrollByPageWheelEvent indicates that the wheel event should scroll a
n entire page. In this case WebCore's built in paging behavior is used to page |
66 // If the platform has configurable line sensitivity (Windows), then th
e 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 We
bCore's default behavior is used (which scrolls 3 * the wheel line delta). | |
68 // For ScrollByLineWheelEvents, the delta values represent the number of lin
es to scroll. | |
69 // The ScrollByPageWheelEvent indicates that the wheel event should scroll a
n entire page instead. In this case WebCore's built in paging behavior is used
to page | |
70 // up and down (you get the same behavior as if the user was clicking in a s
crollbar track to page up or page down). Page scrolling only works in the verti
cal direction. | 66 // up and down (you get the same behavior as if the user was clicking in a s
crollbar track to page up or page down). Page scrolling only works in the verti
cal direction. |
71 enum PlatformWheelEventGranularity { ScrollByLineWheelEvent, ScrollByPageWhe
elEvent, ScrollByPixelWheelEvent }; | 67 enum PlatformWheelEventGranularity { ScrollByPageWheelEvent, ScrollByPixelWh
eelEvent }; |
72 | 68 |
73 // WebCore uses a line multiple of ~3 (40px per line step) when doing arrowi
ng 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 horizontalLin
eMultiplier and verticalLineMultiplier methods to incorporate the line multiplie
r into the deltas. On | |
75 // platforms that do not support wheel sensitivity, we use this hardcoded co
nstant value of 3 to ensure that wheeling by default matches the WebCore multipl
ier you | |
76 // get when doing other kinds of line stepping. | |
77 const int cLineMultiplier = 3; | |
78 | |
79 class PlatformWheelEvent { | 69 class PlatformWheelEvent { |
80 public: | 70 public: |
81 const IntPoint& pos() const { return m_position; } // PlatformWindow coo
rdinates. | 71 const IntPoint& pos() const { return m_position; } // PlatformWindow coo
rdinates. |
82 const IntPoint& globalPos() const { return m_globalPosition; } // Screen
coordinates. | 72 const IntPoint& globalPos() const { return m_globalPosition; } // Screen
coordinates. |
83 | 73 |
84 float deltaX() const { return m_deltaX; } | 74 float deltaX() const { return m_deltaX; } |
85 float deltaY() const { return m_deltaY; } | 75 float deltaY() const { return m_deltaY; } |
86 | 76 |
87 PlatformWheelEventGranularity granularity() const { return m_granularity
; } | 77 PlatformWheelEventGranularity granularity() const { return m_granularity
; } |
88 | 78 |
(...skipping 21 matching lines...) Expand all Loading... |
110 PlatformWheelEvent(GdkEventScroll*); | 100 PlatformWheelEvent(GdkEventScroll*); |
111 #endif | 101 #endif |
112 #if PLATFORM(QT) | 102 #if PLATFORM(QT) |
113 PlatformWheelEvent(QWheelEvent*); | 103 PlatformWheelEvent(QWheelEvent*); |
114 #endif | 104 #endif |
115 #if PLATFORM(WX) | 105 #if PLATFORM(WX) |
116 PlatformWheelEvent(const wxMouseEvent&, const wxPoint&); | 106 PlatformWheelEvent(const wxMouseEvent&, const wxPoint&); |
117 #endif | 107 #endif |
118 | 108 |
119 protected: | 109 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 IntPoint m_position; | 110 IntPoint m_position; |
129 IntPoint m_globalPosition; | 111 IntPoint m_globalPosition; |
130 float m_deltaX; | 112 float m_deltaX; |
131 float m_deltaY; | 113 float m_deltaY; |
132 PlatformWheelEventGranularity m_granularity; | 114 PlatformWheelEventGranularity m_granularity; |
133 bool m_isAccepted; | 115 bool m_isAccepted; |
134 bool m_shiftKey; | 116 bool m_shiftKey; |
135 bool m_ctrlKey; | 117 bool m_ctrlKey; |
136 bool m_altKey; | 118 bool m_altKey; |
137 bool m_metaKey; | 119 bool m_metaKey; |
138 }; | 120 }; |
139 | 121 |
140 } // namespace WebCore | 122 } // namespace WebCore |
141 | 123 |
142 #endif // PlatformWheelEvent_h | 124 #endif // PlatformWheelEvent_h |
OLD | NEW |