1/*
2 *  Copyright (C) 2012 Samsung Electronics
3 *
4 *  This library is free software; you can redistribute it and/or
5 *  modify it under the terms of the GNU Library General Public
6 *  License as published by the Free Software Foundation; either
7 *  version 2 of the License, or (at your option) any later version.
8 *
9 *  This library is distributed in the hope that it will be useful,
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 *  Library General Public License for more details.
13 *
14 *  You should have received a copy of the GNU Library General Public License
15 *  along with this library; see the file COPYING.LIB.  If not, write to
16 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 *  Boston, MA 02110-1301, USA.
18 */
19
20#ifndef DeviceProximityEvent_h
21#define DeviceProximityEvent_h
22
23#if ENABLE(PROXIMITY_EVENTS)
24
25#include "Event.h"
26
27namespace WebCore {
28
29struct DeviceProximityEventInit : public EventInit {
30    DeviceProximityEventInit()
31        : value(std::numeric_limits<double>::infinity())
32        , min(-std::numeric_limits<double>::infinity())
33        , max(std::numeric_limits<double>::infinity())
34    {
35        // Default value of bubbles is true by the Proximity Events spec.
36        // http://www.w3.org/TR/proximity/#deviceproximityevent-interface
37        bubbles = true;
38    };
39
40    double value;
41    double min;
42    double max;
43};
44
45class DeviceProximityEvent : public Event {
46public:
47    ~DeviceProximityEvent() { }
48
49    static PassRef<DeviceProximityEvent> create()
50    {
51        return adoptRef(*new DeviceProximityEvent());
52    }
53
54    static PassRef<DeviceProximityEvent> create(const AtomicString& eventType, const double value, const double min, const double max)
55    {
56        return adoptRef(*new DeviceProximityEvent(eventType, value, min, max));
57    }
58
59    static PassRef<DeviceProximityEvent> create(const AtomicString& type, const DeviceProximityEventInit& initializer)
60    {
61        return adoptRef(*new DeviceProximityEvent(type, initializer));
62    }
63
64    double value() { return m_value; }
65    double min() { return m_min; }
66    double max() { return m_max; }
67
68    virtual EventInterface eventInterface() const { return DeviceProximityEventInterfaceType; }
69
70private:
71    DeviceProximityEvent();
72    DeviceProximityEvent(const AtomicString& eventType, const double value, const double min, const double max);
73    DeviceProximityEvent(const AtomicString& eventType, const DeviceProximityEventInit&);
74
75    double m_value;
76    double m_min;
77    double m_max;
78};
79
80} // namespace WebCore
81
82#endif // DeviceProximityEvent_h
83#endif // PROXIMITY_EVENTS
84