webengine/osswebengine/WebCore/platform/PlatformKeyboardEvent.h
changeset 0 dd21522fd290
child 13 10e98eab6f85
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2  * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.  All rights reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions
       
     6  * are met:
       
     7  * 1. Redistributions of source code must retain the above copyright
       
     8  *    notice, this list of conditions and the following disclaimer.
       
     9  * 2. Redistributions in binary form must reproduce the above copyright
       
    10  *    notice, this list of conditions and the following disclaimer in the
       
    11  *    documentation and/or other materials provided with the distribution.
       
    12  *
       
    13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
       
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
       
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
       
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
       
    24  */
       
    25 
       
    26 #ifndef PlatformKeyboardEvent_h
       
    27 #define PlatformKeyboardEvent_h
       
    28 
       
    29 #include "PlatformString.h"
       
    30 #include <wtf/Platform.h>
       
    31 
       
    32 #if PLATFORM(MAC)
       
    33 #include <wtf/RetainPtr.h>
       
    34 #ifdef __OBJC__
       
    35 @class NSEvent;
       
    36 #else
       
    37 class NSEvent;
       
    38 #endif
       
    39 #endif
       
    40 
       
    41 #if PLATFORM(WIN)
       
    42 typedef struct HWND__ *HWND;
       
    43 typedef unsigned WPARAM;
       
    44 typedef long LPARAM;
       
    45 #endif
       
    46 
       
    47 #if PLATFORM(GTK)
       
    48 typedef struct _GdkEventKey GdkEventKey;
       
    49 #endif
       
    50 
       
    51 #if PLATFORM(QT)
       
    52 class QKeyEvent;
       
    53 #elif PLATFORM(SYMBIAN)
       
    54 #include <w32std.h> // enum TEventCode
       
    55 class TKeyEvent;
       
    56 #endif
       
    57 
       
    58 namespace WebCore {
       
    59 
       
    60     class PlatformKeyboardEvent {
       
    61     public:
       
    62         String text() const { return m_text; }
       
    63         String unmodifiedText() const { return m_unmodifiedText; }
       
    64         String keyIdentifier() const { return m_keyIdentifier; }
       
    65         bool isKeyUp() const { return m_isKeyUp; }
       
    66         bool isAutoRepeat() const { return m_autoRepeat; }
       
    67         void setIsAutoRepeat(bool in) { m_autoRepeat = in; }
       
    68         int WindowsKeyCode() const { return m_WindowsKeyCode; }
       
    69         void setWindowsKeyCode(int code) { m_WindowsKeyCode = code; }
       
    70         bool isKeypad() const { return m_isKeypad; }
       
    71         bool shiftKey() const { return m_shiftKey; }
       
    72         bool ctrlKey() const { return m_ctrlKey; }
       
    73         bool altKey() const { return m_altKey; }
       
    74         bool metaKey() const { return m_metaKey; }
       
    75 
       
    76 #if PLATFORM(MAC)
       
    77         PlatformKeyboardEvent(NSEvent*, bool forceAutoRepeat = false);
       
    78         NSEvent* macEvent() const { return m_macEvent.get(); }
       
    79 #endif
       
    80 
       
    81 #if PLATFORM(WIN)
       
    82         PlatformKeyboardEvent(HWND, WPARAM, LPARAM, UChar);
       
    83 #endif
       
    84 
       
    85 #if PLATFORM(GTK)
       
    86         PlatformKeyboardEvent(GdkEventKey*);
       
    87 #endif
       
    88 
       
    89 #if PLATFORM(QT)
       
    90         PlatformKeyboardEvent(QKeyEvent*, bool isKeyUp);
       
    91 #endif
       
    92 
       
    93 #if PLATFORM(SYMBIAN)
       
    94         PlatformKeyboardEvent(TKeyEvent, TEventCode, bool forceAutoRepeat = false );
       
    95         TKeyEvent symbianEvent() const { return m_symbianEvent; }
       
    96 #endif
       
    97     private:
       
    98         String m_text;
       
    99         String m_unmodifiedText;
       
   100         String m_keyIdentifier;
       
   101         bool m_isKeyUp;
       
   102         bool m_autoRepeat;
       
   103         int m_WindowsKeyCode;
       
   104         bool m_isKeypad;
       
   105         bool m_shiftKey;
       
   106         bool m_ctrlKey;
       
   107         bool m_altKey;
       
   108         bool m_metaKey;
       
   109 
       
   110 #if PLATFORM(MAC)
       
   111         RetainPtr<NSEvent> m_macEvent;
       
   112 #endif
       
   113 
       
   114 #if PLATFORM(SYMBIAN)
       
   115         TKeyEvent m_symbianEvent;        
       
   116 #endif
       
   117 
       
   118     };
       
   119 
       
   120 } // namespace WebCore
       
   121 
       
   122 #endif // PlatformKeyboardEvent_h