1/* 2 * Copyright (C) 2009 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26// FIXME: Rename this file to WebEventIOS.mm after we upstream the iOS port and remove the PLATFORM(IOS)-guard. 27#ifndef WebEventIOS_h 28#define WebEventIOS_h 29 30#import <CoreGraphics/CoreGraphics.h> 31#import <Foundation/Foundation.h> 32 33#if TARGET_OS_IPHONE 34 35typedef enum { 36 WebEventMouseDown, 37 WebEventMouseUp, 38 WebEventMouseMoved, 39 40 WebEventScrollWheel, 41 42 WebEventKeyDown, 43 WebEventKeyUp, 44 45 WebEventTouchBegin, 46 WebEventTouchChange, 47 WebEventTouchEnd, 48 WebEventTouchCancel 49} WebEventType; 50 51typedef enum { 52 WebEventTouchPhaseBegan, 53 WebEventTouchPhaseMoved, 54 WebEventTouchPhaseStationary, 55 WebEventTouchPhaseEnded, 56 WebEventTouchPhaseCancelled 57} WebEventTouchPhaseType; 58 59// These enum values are copied directly from GSEvent for compatibility. 60typedef enum { 61 WebEventFlagMaskAlphaShift = 0x00010000, 62 WebEventFlagMaskShift = 0x00020000, 63 WebEventFlagMaskControl = 0x00040000, 64 WebEventFlagMaskAlternate = 0x00080000, 65 WebEventFlagMaskCommand = 0x00100000, 66} WebEventFlagValues; 67typedef unsigned WebEventFlags; 68 69// These enum values are copied directly from GSEvent for compatibility. 70typedef enum { 71 WebEventCharacterSetASCII = 0, 72 WebEventCharacterSetSymbol = 1, 73 WebEventCharacterSetDingbats = 2, 74 WebEventCharacterSetUnicode = 253, 75 WebEventCharacterSetFunctionKeys = 254, 76} WebEventCharacterSet; 77 78@interface WebEvent : NSObject { 79@private 80 WebEventType _type; 81 CFTimeInterval _timestamp; 82 83 CGPoint _locationInWindow; 84 85 NSString *_characters; 86 NSString *_charactersIgnoringModifiers; 87 WebEventFlags _modifierFlags; 88 BOOL _keyRepeating; 89 BOOL _popupVariant; // FIXME: to be removed 90 NSUInteger _keyboardFlags; 91 uint16_t _keyCode; 92 BOOL _tabKey; 93 WebEventCharacterSet _characterSet; 94 95 float _deltaX; 96 float _deltaY; 97 98 unsigned _touchCount; 99 NSArray *_touchLocations; 100 NSArray *_touchIdentifiers; 101 NSArray *_touchPhases; 102 103 BOOL _isGesture; 104 float _gestureScale; 105 float _gestureRotation; 106 107 BOOL _wasHandled; 108} 109 110- (WebEvent *)initWithMouseEventType:(WebEventType)type 111 timeStamp:(CFTimeInterval)timeStamp 112 location:(CGPoint)point; 113 114- (WebEvent *)initWithScrollWheelEventWithTimeStamp:(CFTimeInterval)timeStamp 115 location:(CGPoint)point 116 deltaX:(float)deltaX 117 deltaY:(float)deltaY; 118 119- (WebEvent *)initWithTouchEventType:(WebEventType)type 120 timeStamp:(CFTimeInterval)timeStamp 121 location:(CGPoint)point 122 modifiers:(WebEventFlags)modifiers 123 touchCount:(unsigned)touchCount 124 touchLocations:(NSArray *)touchLocations 125 touchIdentifiers:(NSArray *)touchIdentifiers 126 touchPhases:(NSArray *)touchPhases isGesture:(BOOL)isGesture 127 gestureScale:(float)gestureScale 128 gestureRotation:(float)gestureRotation; 129 130// FIXME: this is deprecated. It will be removed when UIKit adopts the new one below. 131- (WebEvent *)initWithKeyEventType:(WebEventType)type 132 timeStamp:(CFTimeInterval)timeStamp 133 characters:(NSString *)characters 134 charactersIgnoringModifiers:(NSString *)charactersIgnoringModifiers 135 modifiers:(WebEventFlags)modifiers 136 isRepeating:(BOOL)repeating 137 isPopupVariant:(BOOL)popupVariant 138 keyCode:(uint16_t)keyCode 139 isTabKey:(BOOL)tabKey 140 characterSet:(WebEventCharacterSet)characterSet; 141 142- (WebEvent *)initWithKeyEventType:(WebEventType)type 143 timeStamp:(CFTimeInterval)timeStamp 144 characters:(NSString *)characters 145 charactersIgnoringModifiers:(NSString *)charactersIgnoringModifiers 146 modifiers:(WebEventFlags)modifiers 147 isRepeating:(BOOL)repeating 148 withFlags:(NSUInteger)flags 149 keyCode:(uint16_t)keyCode 150 isTabKey:(BOOL)tabKey 151 characterSet:(WebEventCharacterSet)characterSet; 152 153@property(nonatomic, readonly) WebEventType type; 154@property(nonatomic, readonly) CFTimeInterval timestamp; 155 156// Mouse 157@property(nonatomic, readonly) CGPoint locationInWindow; 158 159// Keyboard 160@property(nonatomic, readonly, retain) NSString *characters; 161@property(nonatomic, readonly, retain) NSString *charactersIgnoringModifiers; 162@property(nonatomic, readonly) WebEventFlags modifierFlags; 163@property(nonatomic, readonly, getter = isKeyRepeating) BOOL keyRepeating; 164 165// FIXME: this is deprecated. It will be removed when UIKit adopts the new initWithKeyEventType. 166@property(nonatomic, readonly, getter = isPopupVariant) BOOL popupVariant; 167@property(nonatomic, readonly) NSUInteger keyboardFlags; 168@property(nonatomic, readonly) uint16_t keyCode; 169@property(nonatomic, readonly, getter = isTabKey) BOOL tabKey; 170@property(nonatomic, readonly) WebEventCharacterSet characterSet; 171 172// Scroll Wheel 173@property(nonatomic, readonly) float deltaX; 174@property(nonatomic, readonly) float deltaY; 175 176// Touch 177@property(nonatomic, readonly) unsigned touchCount; 178@property(nonatomic, readonly, retain) NSArray *touchLocations; 179@property(nonatomic, readonly, retain) NSArray *touchIdentifiers; 180@property(nonatomic, readonly, retain) NSArray *touchPhases; 181 182// Gesture 183@property(nonatomic, readonly) BOOL isGesture; 184@property(nonatomic, readonly) float gestureScale; 185@property(nonatomic, readonly) float gestureRotation; 186 187@property(nonatomic) BOOL wasHandled; 188 189@end 190 191@interface WebIOSEvent : WebEvent 192@end 193 194#endif // TARGET_OS_IPHONE 195#endif // WebEventIOS_h 196