initial import
[vuplus_webkit] / Source / WebCore / dom / UIEvent.h
1 /*
2  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3  * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4  * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5  * Copyright (C) 2003, 2004, 2005, 2006, 2008 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 UIEvent_h
25 #define UIEvent_h
26
27 #include "DOMWindow.h"
28 #include "Event.h"
29 #include "EventDispatchMediator.h"
30
31 namespace WebCore {
32
33     typedef DOMWindow AbstractView;
34
35     class UIEvent : public Event {
36     public:
37         static PassRefPtr<UIEvent> create()
38         {
39             return adoptRef(new UIEvent);
40         }
41         static PassRefPtr<UIEvent> create(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView> view, int detail)
42         {
43             return adoptRef(new UIEvent(type, canBubble, cancelable, view, detail));
44         }
45         virtual ~UIEvent();
46
47         void initUIEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, int detail);
48
49         AbstractView* view() const { return m_view.get(); }
50         int detail() const { return m_detail; }
51         
52         virtual bool isUIEvent() const;
53
54         virtual int keyCode() const;
55         virtual int charCode() const;
56
57         virtual int layerX();
58         virtual int layerY();
59
60         virtual int pageX() const;
61         virtual int pageY() const;
62
63         virtual int which() const;
64
65     protected:
66         UIEvent();
67         UIEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, int detail);
68
69     private:
70         RefPtr<AbstractView> m_view;
71         int m_detail;
72     };
73
74     class FocusInEventDispatchMediator : public EventDispatchMediator {
75     public:
76         static PassRefPtr<FocusInEventDispatchMediator> create(PassRefPtr<Event>, PassRefPtr<Node> oldFocusedNode);
77     private:
78         explicit FocusInEventDispatchMediator(PassRefPtr<Event>, PassRefPtr<Node> oldFocusedNode);
79         virtual bool dispatchEvent(EventDispatcher*) const;
80         RefPtr<Node> m_oldFocusedNode;
81     };
82
83     class FocusOutEventDispatchMediator : public EventDispatchMediator {
84     public:
85         static PassRefPtr<FocusOutEventDispatchMediator> create(PassRefPtr<Event>, PassRefPtr<Node> newFocusedNode);
86     private:
87         explicit FocusOutEventDispatchMediator(PassRefPtr<Event>, PassRefPtr<Node> newFocusedNode);
88         virtual bool dispatchEvent(EventDispatcher*) const;
89         RefPtr<Node> m_newFocusedNode;
90     };
91
92 } // namespace WebCore
93
94 #endif // UIEvent_h