~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/dom/KeyboardEvent.h

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, 2007 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., 59 Temple Place - Suite 330,
 
20
 * Boston, MA 02111-1307, USA.
 
21
 *
 
22
 */
 
23
 
 
24
#ifndef KeyboardEvent_h
 
25
#define KeyboardEvent_h
 
26
 
 
27
#include "UIEventWithKeyState.h"
 
28
#include <wtf/Vector.h>
 
29
 
 
30
namespace WebCore {
 
31
 
 
32
    class PlatformKeyboardEvent;
 
33
 
 
34
#if PLATFORM(MAC)
 
35
    struct KeypressCommand {
 
36
        Vector<String> commandNames;
 
37
        String text;
 
38
        
 
39
        bool isEmpty() const { return text.isEmpty() && commandNames.isEmpty(); }
 
40
    };
 
41
#endif
 
42
    
 
43
    // Introduced in DOM Level 3
 
44
    class KeyboardEvent : public UIEventWithKeyState {
 
45
    public:
 
46
        enum KeyLocationCode {
 
47
            DOM_KEY_LOCATION_STANDARD      = 0x00,
 
48
            DOM_KEY_LOCATION_LEFT          = 0x01,
 
49
            DOM_KEY_LOCATION_RIGHT         = 0x02,
 
50
            DOM_KEY_LOCATION_NUMPAD        = 0x03
 
51
        };
 
52
        
 
53
        KeyboardEvent();
 
54
        KeyboardEvent(const PlatformKeyboardEvent&, AbstractView*);
 
55
        KeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*,
 
56
                      const String& keyIdentifier, unsigned keyLocation,
 
57
                      bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey);
 
58
        virtual ~KeyboardEvent();
 
59
    
 
60
        void initKeyboardEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView*,
 
61
                               const String& keyIdentifier, unsigned keyLocation,
 
62
                               bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey = false);
 
63
    
 
64
        String keyIdentifier() const { return m_keyIdentifier; }
 
65
        unsigned keyLocation() const { return m_keyLocation; }
 
66
 
 
67
        bool getModifierState(const String& keyIdentifier) const;
 
68
 
 
69
        bool altGraphKey() const { return m_altGraphKey; }
 
70
    
 
71
        const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent; }
 
72
 
 
73
        int keyCode() const; // key code for keydown and keyup, character for other events
 
74
        int charCode() const;
 
75
    
 
76
        virtual bool isKeyboardEvent() const;
 
77
        virtual int which() const;
 
78
 
 
79
#if PLATFORM(MAC)
 
80
        // We only have this need to store keypress command info on the Mac.
 
81
        KeypressCommand keypressCommand() { return m_keypressCommand; }
 
82
        void setKeypressCommand(const KeypressCommand& command) { m_keypressCommand = command; }        
 
83
#endif
 
84
 
 
85
    private:
 
86
        PlatformKeyboardEvent* m_keyEvent;
 
87
        String m_keyIdentifier;
 
88
        unsigned m_keyLocation;
 
89
        bool m_altGraphKey : 1;
 
90
 
 
91
#if PLATFORM(MAC)        
 
92
        KeypressCommand m_keypressCommand;
 
93
#endif
 
94
    };
 
95
 
 
96
    KeyboardEvent* findKeyboardEvent(Event*);
 
97
 
 
98
} // namespace WebCore
 
99
 
 
100
#endif // KeyboardEvent_h