windowing/windowserver/inc/pointerevent.h
changeset 0 5d03bc08d59c
child 80 823021ef148e
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef POINTEREVENT_H
       
    17 #define POINTEREVENT_H
       
    18 
       
    19 class TAdvancedPointerEvent;
       
    20 
       
    21 /** Pointer event details.
       
    22 
       
    23 The function TWsEvent::Pointer() is used to get this structure for a pointer
       
    24 event.
       
    25 
       
    26 @publishedAll
       
    27 @released */
       
    28 struct TPointerEvent
       
    29 	{
       
    30 	/** Pointer event types.
       
    31 	
       
    32 	Note that the user actions that cause these events will vary according to
       
    33 	the type of pointing device used. */
       
    34 	enum TType
       
    35 		{
       
    36 		/** Button 1 or pen down. */
       
    37 		EButton1Down,
       
    38 		/** Button 1 or pen up. */
       
    39 		EButton1Up,
       
    40 		/** Button 2 down.
       
    41 
       
    42 		This is the middle button of a 3 button mouse. */
       
    43 		EButton2Down,
       
    44 		/** Button 2 up.
       
    45 
       
    46 		This is the middle button of a 3 button mouse. */
       
    47 		EButton2Up,
       
    48 		/** Button 3 down. */
       
    49 		EButton3Down,
       
    50 		/** Button 3 up. */
       
    51 		EButton3Up,
       
    52 		/** Drag event.
       
    53 
       
    54 		These events are only received when button 1 is down. */
       
    55 		EDrag,
       
    56 		/** Move event.
       
    57 
       
    58 		These events are only received when button 1 is up and the XY input mode is
       
    59 		not pen. */
       
    60 		EMove,
       
    61 		/** Button repeat event. */
       
    62 		EButtonRepeat,
       
    63 		/** Switch on event caused by a screen tap. */
       
    64 		ESwitchOn,
       
    65 		/** Out Of Range event caused by 3D pointer leaving the detection volume.
       
    66 		It implies that the pointer cannot be tracked any more by device's sensors
       
    67 		and that from now the pointer number of this pointer may be used for identifying
       
    68 		another physical pointer (for example another finger).
       
    69 		As EOutOfRange event is generated when pointer's position is unknown,
       
    70 		it contains last known coordinates of the pointer and is delivered to the
       
    71 		window based on these coordinates.
       
    72 		@see TAdvancedPointerEvent::PointerNumber()
       
    73  		@publishedAll
       
    74  		@released */
       
    75 		EOutOfRange,
       
    76 		/**	Caused by a 3D pointer getting close to the screen. 
       
    77 		It is fired when a pointer's Z coordinate crosses the threshold for EEnterCloseProximity 
       
    78 		from the OutOfRange state or from the Up/OutOfCloseProximity state.
       
    79 		Please refer to the system documentation for an explanation of pointer states.  
       
    80 		@see RWsSession::SetCloseProximityThresholds
       
    81 		@see RWsSession::GetEnterCloseProximityThreshold 
       
    82  		@publishedAll
       
    83  		@released */
       
    84 		EEnterCloseProximity,
       
    85 		/**	Caused by a 3D pointer moving away from the screen. 
       
    86 		It is generally fired when a pointer's Z coordinate crosses the threshold for EExitCloseProximity 
       
    87 		from the Up/InCloseProximity state.
       
    88 		Please refer to the system documentation for an explanation of pointer states.  
       
    89 		@see RWsSession::SetCloseProximityThresholds
       
    90 		@see RWsSession::GetExitCloseProximityThreshold 
       
    91  		@publishedAll
       
    92  		@released */
       
    93 		EExitCloseProximity,
       
    94 		/**	Caused by a 3D pointer pressing the screen. 
       
    95 		It is generally fired when a pointer's Z coordinate crosses the threshold for EEnterHighPressure 
       
    96 		from the Down/OutOfHighPressure state.
       
    97 		Please refer to the system documentation for an explanation of pointer states.  
       
    98 		@see RWsSession::SetHighPressureThresholds
       
    99 		@see RWsSession::GetEnterHighPressureThreshold 
       
   100  		@publishedAll
       
   101  		@released */
       
   102 		EEnterHighPressure,
       
   103 		/**	Caused by s 3D pointer pressing the screen with reducing force. 
       
   104 		It is fired when a pointer's Z coordinate crosses the threshold for EExitHighPressure 
       
   105 		from the Down/InHighPressure state.
       
   106 		Please refer to the system documentation for an explanation of pointer states.  
       
   107 		@see RWsSession::SetHighPressureThresholds
       
   108 		@see RWsSession::GetExitHighPressureThreshold 
       
   109  		@publishedAll
       
   110  		@released */
       
   111 		EExitHighPressure,
       
   112 		/** WSERV will never generate TPointerEvent with this type.
       
   113 		    
       
   114 		    WARNING: Enum for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   115 		ENullType = -1
       
   116 		};
       
   117 
       
   118 	inline TPointerEvent();
       
   119 	inline TPointerEvent(const TPointerEvent& aPointerEvent);
       
   120 	inline TPointerEvent(TType aType, TUint aModifiers, const TPoint &aPosition, const TPoint &aParentPosition);	
       
   121 	inline TPointerEvent& operator=(const TPointerEvent& aPointerEvent);
       
   122 	
       
   123 	inline void Copy(const TPointerEvent& aPointerEvent);
       
   124 	inline TBool IsAdvancedPointerEvent() const;
       
   125 	inline const TAdvancedPointerEvent* AdvancedPointerEvent() const;
       
   126 	/** The type of pointer event. */
       
   127 	TType iType;
       
   128 	/** The state of the modifier keys, defined in TEventModifier. */
       
   129 	TUint iModifiers;	// State of pointing device and associated buttons
       
   130 	/** Co-ordinates of the pointer event relative to the origin of the window it occurred
       
   131 	in.
       
   132 
       
   133 	Positive co-ordinates indicate a position to the right of and down from
       
   134 	the window's origin, negative co-ordinates indicate a position to the left
       
   135 	and up. */
       
   136 	TPoint iPosition;
       
   137 	/** Co-ordinates of the pointer event relative to the parent window of the window
       
   138 	it occurred in.
       
   139 
       
   140 	Positive co-ordinates indicate a position to the right of and down from the window's
       
   141 	origin, negative co-ordinates indicate a position to the left and up. */
       
   142 	TPoint iParentPosition;
       
   143 	};
       
   144 
       
   145 inline TBool TPointerEvent::IsAdvancedPointerEvent() const
       
   146 /** Check if this pointer event is an instance of TAdvancedPointerEvent
       
   147     containing pointer number, proximity and pressure.
       
   148     
       
   149     @return ETrue if this pointer event is an instance of TAdvancedPointerEvent;
       
   150             EFalse otherwise.
       
   151     @see TPointerEvent::AdvancedPointerEvent()
       
   152     @see RWindowBase::EnableAdvancedPointers()
       
   153  	@publishedAll
       
   154  	@released */
       
   155 	{
       
   156 	return ((iModifiers&EModifierAdvancedPointerEvent)!=0);
       
   157 	}
       
   158 
       
   159 /** Default Constructor
       
   160 
       
   161  	@publishedAll
       
   162  	@released */
       
   163 inline TPointerEvent::TPointerEvent() {}
       
   164 
       
   165 /** Copy Constructor
       
   166 
       
   167 	@param aPointerEvent the pointer event to copy
       
   168 
       
   169  	@publishedAll
       
   170  	@released */
       
   171 inline TPointerEvent::TPointerEvent(const TPointerEvent& aPointerEvent) // Copy Constructor
       
   172 	{
       
   173 	Copy(aPointerEvent);
       
   174 	}
       
   175 
       
   176 /* TPointerEvent Constructor
       
   177 
       
   178 	@param aType The pointer event type
       
   179 	@param aModifiers The event modifiers
       
   180 	@param aPosition The pointer position
       
   181 	@param aParentPosition The pointer position relative to the parent window
       
   182 */
       
   183 inline TPointerEvent::TPointerEvent(TType aType, TUint aModifiers, const TPoint &aPosition, const TPoint &aParentPosition)
       
   184 : iType(aType), iModifiers(aModifiers), iPosition(aPosition), iParentPosition(aParentPosition)  
       
   185 	{}
       
   186 
       
   187 /** Operator= override
       
   188 
       
   189 	@param aPointerEvent the pointer event to copy
       
   190 
       
   191  	@publishedAll
       
   192  	@released */
       
   193 inline TPointerEvent& TPointerEvent::operator=(const TPointerEvent& aPointerEvent) // Operator = overload
       
   194 	{
       
   195 	if(this != &aPointerEvent)
       
   196 		{
       
   197 		Copy(aPointerEvent);
       
   198 		}
       
   199 	return *this;
       
   200 	}
       
   201 
       
   202 /** Copies from a TPointerEvent object
       
   203 
       
   204 	@param aPointerEvent the pointer event to copy
       
   205 
       
   206  	@publishedAll
       
   207  	@released */
       
   208 inline void TPointerEvent::Copy(const TPointerEvent& aPointerEvent)
       
   209 	{
       
   210 	iType=aPointerEvent.iType;
       
   211 	iModifiers=(aPointerEvent.iModifiers&~EModifierAdvancedPointerEvent); // Clear the advanced pointer flag
       
   212 	iPosition=aPointerEvent.iPosition;
       
   213 	iParentPosition=aPointerEvent.iParentPosition;
       
   214 	}
       
   215 
       
   216 #endif /* POINTEREVENT_H */