WheelEvent.h 3.72 KB
Newer Older
weinig's avatar
 
weinig committed
1 2 3 4
/*
 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5
 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2010 Apple Inc. All rights reserved.
weinig's avatar
 
weinig committed
6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
ddkilzer's avatar
ddkilzer committed
19 20
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
weinig's avatar
 
weinig committed
21 22 23 24 25 26 27 28 29 30 31 32 33
 *
 */

#ifndef WheelEvent_h
#define WheelEvent_h

#include "MouseRelatedEvent.h"

namespace WebCore {

    // extension: mouse wheel event
    class WheelEvent : public MouseRelatedEvent {
    public:
34 35
        enum Granularity { Pixel, Line, Page };

darin@apple.com's avatar
darin@apple.com committed
36 37 38 39
        static PassRefPtr<WheelEvent> create()
        {
            return adoptRef(new WheelEvent);
        }
40 41
        static PassRefPtr<WheelEvent> create(float wheelTicksX, float wheelTicksY,
            float rawDeltaX, float rawDeltaY, Granularity granularity, PassRefPtr<AbstractView> view,
darin@apple.com's avatar
darin@apple.com committed
42 43 44
            int screenX, int screenY, int pageX, int pageY,
            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
        {
45 46
            return adoptRef(new WheelEvent(wheelTicksX, wheelTicksY, rawDeltaX, rawDeltaY,
                granularity, view, screenX, screenY, pageX, pageY,
darin@apple.com's avatar
darin@apple.com committed
47 48
                ctrlKey, altKey, shiftKey, metaKey));
        }
darin's avatar
darin committed
49

50
        void initWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
darin's avatar
darin committed
51 52
                            int screenX, int screenY, int pageX, int pageY,
                            bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
53

54 55 56 57
        void initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<AbstractView>,
                                  int screenX, int screenY, int pageX, int pageY,
                                  bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);

58 59 60
        int wheelDelta() const { if (m_wheelDeltaY == 0) return m_wheelDeltaX; return m_wheelDeltaY; }
        int wheelDeltaX() const { return m_wheelDeltaX; }
        int wheelDeltaY() const { return m_wheelDeltaY; }
61 62 63
        int rawDeltaX() const { return m_rawDeltaX; }
        int rawDeltaY() const { return m_rawDeltaY; }
        Granularity granularity() const { return m_granularity; }
weinig's avatar
 
weinig committed
64

65 66 67
        // Needed for Objective-C legacy support
        bool isHorizontal() const { return m_wheelDeltaX; }

weinig's avatar
 
weinig committed
68
    private:
darin@apple.com's avatar
darin@apple.com committed
69
        WheelEvent();
70 71
        WheelEvent(float wheelTicksX, float wheelTicksY, float rawDeltaX, float rawDeltaY,
                   Granularity granularity, PassRefPtr<AbstractView>,
darin@apple.com's avatar
darin@apple.com committed
72 73 74
                   int screenX, int screenY, int pageX, int pageY,
                   bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);

weinig's avatar
 
weinig committed
75
        virtual bool isWheelEvent() const;
76
        
77 78
        int m_wheelDeltaX;
        int m_wheelDeltaY;
79 80 81 82

        int m_rawDeltaX;
        int m_rawDeltaY;
        Granularity m_granularity;
weinig's avatar
 
weinig committed
83 84
    };

85 86 87 88 89 90 91 92 93
class WheelEventDispatchMediator : public EventDispatchMediator {
public:
    WheelEventDispatchMediator(const PlatformWheelEvent&, PassRefPtr<AbstractView>);

private:
    WheelEvent* event() const;
    virtual bool dispatchEvent(EventDispatcher*) const;
};

weinig's avatar
 
weinig committed
94 95 96
} // namespace WebCore

#endif // WheelEvent_h