Home | History | Annotate | Download | only in dom
      1 /*
      2  * Copyright (C) 2001 Peter Kelly (pmk (at) post.com)
      3  * Copyright (C) 2001 Tobias Anton (anton (at) stud.fbi.fh-darmstadt.de)
      4  * Copyright (C) 2006 Samuel Weinig (sam.weinig (at) gmail.com)
      5  * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Library General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Library General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Library General Public License
     18  * along with this library; see the file COPYING.LIB.  If not, write to
     19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA 02110-1301, USA.
     21  *
     22  */
     23 
     24 #ifndef WheelEvent_h
     25 #define WheelEvent_h
     26 
     27 #include "MouseRelatedEvent.h"
     28 
     29 namespace WebCore {
     30 
     31     // extension: mouse wheel event
     32     class WheelEvent : public MouseRelatedEvent {
     33     public:
     34         enum Granularity { Pixel, Line, Page };
     35 
     36         static PassRefPtr<WheelEvent> create()
     37         {
     38             return adoptRef(new WheelEvent);
     39         }
     40         static PassRefPtr<WheelEvent> create(float wheelTicksX, float wheelTicksY,
     41             float rawDeltaX, float rawDeltaY, Granularity granularity, PassRefPtr<AbstractView> view,
     42             int screenX, int screenY, int pageX, int pageY,
     43             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
     44         {
     45             return adoptRef(new WheelEvent(wheelTicksX, wheelTicksY, rawDeltaX, rawDeltaY,
     46                 granularity, view, screenX, screenY, pageX, pageY,
     47                 ctrlKey, altKey, shiftKey, metaKey));
     48         }
     49 
     50         void initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
     51                             int screenX, int screenY, int pageX, int pageY,
     52                             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
     53 
     54         void initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
     55                                   int screenX, int screenY, int pageX, int pageY,
     56                                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
     57 
     58         int wheelDelta() const { if (m_wheelDeltaY == 0) return m_wheelDeltaX; return m_wheelDeltaY; }
     59         int wheelDeltaX() const { return m_wheelDeltaX; }
     60         int wheelDeltaY() const { return m_wheelDeltaY; }
     61         int rawDeltaX() const { return m_rawDeltaX; }
     62         int rawDeltaY() const { return m_rawDeltaY; }
     63         Granularity granularity() const { return m_granularity; }
     64 
     65         // Needed for Objective-C legacy support
     66         bool isHorizontal() const { return m_wheelDeltaX; }
     67 
     68     private:
     69         WheelEvent();
     70         WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
     71                    Granularity granularity, PassRefPtr<AbstractView>,
     72                    int screenX, int screenY, int pageX, int pageY,
     73                    bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
     74 
     75         virtual bool isWheelEvent() const;
     76 
     77         int m_wheelDeltaX;
     78         int m_wheelDeltaY;
     79 
     80         int m_rawDeltaX;
     81         int m_rawDeltaY;
     82         Granularity m_granularity;
     83     };
     84 
     85 class WheelEventDispatchMediator : public EventDispatchMediator {
     86 public:
     87     WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractView>);
     88 
     89 private:
     90     WheelEvent* event() const;
     91     virtual bool dispatchEvent(EventDispatcher*) const;
     92 };
     93 
     94 } // namespace WebCore
     95 
     96 #endif // WheelEvent_h
     97