williamr@4: // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: // All rights reserved. williamr@4: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@4: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: // williamr@4: // Initial Contributors: williamr@4: // Nokia Corporation - initial contribution. williamr@4: // williamr@4: // Contributors: williamr@4: // williamr@4: // Description: williamr@4: // williamr@4: williamr@4: #ifndef POINTEREVENT_H williamr@4: #define POINTEREVENT_H williamr@4: williamr@4: class TAdvancedPointerEvent; williamr@4: williamr@4: /** Pointer event details. williamr@4: williamr@4: The function TWsEvent::Pointer() is used to get this structure for a pointer williamr@4: event. williamr@4: williamr@4: @publishedAll williamr@4: @released */ williamr@4: struct TPointerEvent williamr@4: { williamr@4: /** Pointer event types. williamr@4: williamr@4: Note that the user actions that cause these events will vary according to williamr@4: the type of pointing device used. */ williamr@4: enum TType williamr@4: { williamr@4: /** Button 1 or pen down. */ williamr@4: EButton1Down, williamr@4: /** Button 1 or pen up. */ williamr@4: EButton1Up, williamr@4: /** Button 2 down. williamr@4: williamr@4: This is the middle button of a 3 button mouse. */ williamr@4: EButton2Down, williamr@4: /** Button 2 up. williamr@4: williamr@4: This is the middle button of a 3 button mouse. */ williamr@4: EButton2Up, williamr@4: /** Button 3 down. */ williamr@4: EButton3Down, williamr@4: /** Button 3 up. */ williamr@4: EButton3Up, williamr@4: /** Drag event. williamr@4: williamr@4: These events are only received when button 1 is down. */ williamr@4: EDrag, williamr@4: /** Move event. williamr@4: williamr@4: These events are only received when button 1 is up and the XY input mode is williamr@4: not pen. */ williamr@4: EMove, williamr@4: /** Button repeat event. */ williamr@4: EButtonRepeat, williamr@4: /** Switch on event caused by a screen tap. */ williamr@4: ESwitchOn, williamr@4: /** Out Of Range event caused by 3D pointer leaving the detection volume. williamr@4: It implies that the pointer cannot be tracked any more by device's sensors williamr@4: and that from now the pointer number of this pointer may be used for identifying williamr@4: another physical pointer (for example another finger). williamr@4: As EOutOfRange event is generated when pointer's position is unknown, williamr@4: it contains last known coordinates of the pointer and is delivered to the williamr@4: window based on these coordinates. williamr@4: @see TAdvancedPointerEvent::PointerNumber() williamr@4: @publishedAll williamr@4: @released */ williamr@4: EOutOfRange, williamr@4: /** Caused by a 3D pointer getting close to the screen. williamr@4: It is fired when a pointer's Z coordinate crosses the threshold for EEnterCloseProximity williamr@4: from the OutOfRange state or from the Up/OutOfCloseProximity state. williamr@4: Please refer to the system documentation for an explanation of pointer states. williamr@4: @see RWsSession::SetCloseProximityThresholds williamr@4: @see RWsSession::GetEnterCloseProximityThreshold williamr@4: @publishedAll williamr@4: @released */ williamr@4: EEnterCloseProximity, williamr@4: /** Caused by a 3D pointer moving away from the screen. williamr@4: It is generally fired when a pointer's Z coordinate crosses the threshold for EExitCloseProximity williamr@4: from the Up/InCloseProximity state. williamr@4: Please refer to the system documentation for an explanation of pointer states. williamr@4: @see RWsSession::SetCloseProximityThresholds williamr@4: @see RWsSession::GetExitCloseProximityThreshold williamr@4: @publishedAll williamr@4: @released */ williamr@4: EExitCloseProximity, williamr@4: /** Caused by a 3D pointer pressing the screen. williamr@4: It is generally fired when a pointer's Z coordinate crosses the threshold for EEnterHighPressure williamr@4: from the Down/OutOfHighPressure state. williamr@4: Please refer to the system documentation for an explanation of pointer states. williamr@4: @see RWsSession::SetHighPressureThresholds williamr@4: @see RWsSession::GetEnterHighPressureThreshold williamr@4: @publishedAll williamr@4: @released */ williamr@4: EEnterHighPressure, williamr@4: /** Caused by s 3D pointer pressing the screen with reducing force. williamr@4: It is fired when a pointer's Z coordinate crosses the threshold for EExitHighPressure williamr@4: from the Down/InHighPressure state. williamr@4: Please refer to the system documentation for an explanation of pointer states. williamr@4: @see RWsSession::SetHighPressureThresholds williamr@4: @see RWsSession::GetExitHighPressureThreshold williamr@4: @publishedAll williamr@4: @released */ williamr@4: EExitHighPressure, williamr@4: /** WSERV will never generate TPointerEvent with this type. williamr@4: williamr@4: WARNING: Enum for internal use ONLY. Compatibility is not guaranteed in future releases. */ williamr@4: ENullType = -1 williamr@4: }; williamr@4: williamr@4: inline TPointerEvent(); williamr@4: inline TPointerEvent(const TPointerEvent& aPointerEvent); williamr@4: inline TPointerEvent(TType aType, TUint aModifiers, const TPoint &aPosition, const TPoint &aParentPosition); williamr@4: inline TPointerEvent& operator=(const TPointerEvent& aPointerEvent); williamr@4: williamr@4: inline void Copy(const TPointerEvent& aPointerEvent); williamr@4: inline TBool IsAdvancedPointerEvent() const; williamr@4: inline const TAdvancedPointerEvent* AdvancedPointerEvent() const; williamr@4: /** The type of pointer event. */ williamr@4: TType iType; williamr@4: /** The state of the modifier keys, defined in TEventModifier. */ williamr@4: TUint iModifiers; // State of pointing device and associated buttons williamr@4: /** Co-ordinates of the pointer event relative to the origin of the window it occurred williamr@4: in. williamr@4: williamr@4: Positive co-ordinates indicate a position to the right of and down from williamr@4: the window's origin, negative co-ordinates indicate a position to the left williamr@4: and up. */ williamr@4: TPoint iPosition; williamr@4: /** Co-ordinates of the pointer event relative to the parent window of the window williamr@4: it occurred in. williamr@4: williamr@4: Positive co-ordinates indicate a position to the right of and down from the window's williamr@4: origin, negative co-ordinates indicate a position to the left and up. */ williamr@4: TPoint iParentPosition; williamr@4: }; williamr@4: williamr@4: inline TBool TPointerEvent::IsAdvancedPointerEvent() const williamr@4: /** Check if this pointer event is an instance of TAdvancedPointerEvent williamr@4: containing pointer number, proximity and pressure. williamr@4: williamr@4: @return ETrue if this pointer event is an instance of TAdvancedPointerEvent; williamr@4: EFalse otherwise. williamr@4: @see TPointerEvent::AdvancedPointerEvent() williamr@4: @see RWindowBase::EnableAdvancedPointers() williamr@4: @publishedAll williamr@4: @released */ williamr@4: { williamr@4: return ((iModifiers&EModifierAdvancedPointerEvent)!=0); williamr@4: } williamr@4: williamr@4: /** Default Constructor williamr@4: williamr@4: @publishedAll williamr@4: @released */ williamr@4: inline TPointerEvent::TPointerEvent() {} williamr@4: williamr@4: /** Copy Constructor williamr@4: williamr@4: @param aPointerEvent the pointer event to copy williamr@4: williamr@4: @publishedAll williamr@4: @released */ williamr@4: inline TPointerEvent::TPointerEvent(const TPointerEvent& aPointerEvent) // Copy Constructor williamr@4: { williamr@4: Copy(aPointerEvent); williamr@4: } williamr@4: williamr@4: /* TPointerEvent Constructor williamr@4: williamr@4: @param aType The pointer event type williamr@4: @param aModifiers The event modifiers williamr@4: @param aPosition The pointer position williamr@4: @param aParentPosition The pointer position relative to the parent window williamr@4: */ williamr@4: inline TPointerEvent::TPointerEvent(TType aType, TUint aModifiers, const TPoint &aPosition, const TPoint &aParentPosition) williamr@4: : iType(aType), iModifiers(aModifiers), iPosition(aPosition), iParentPosition(aParentPosition) williamr@4: {} williamr@4: williamr@4: /** Operator= override williamr@4: williamr@4: @param aPointerEvent the pointer event to copy williamr@4: williamr@4: @publishedAll williamr@4: @released */ williamr@4: inline TPointerEvent& TPointerEvent::operator=(const TPointerEvent& aPointerEvent) // Operator = overload williamr@4: { williamr@4: if(this != &aPointerEvent) williamr@4: { williamr@4: Copy(aPointerEvent); williamr@4: } williamr@4: return *this; williamr@4: } williamr@4: williamr@4: /** Copies from a TPointerEvent object williamr@4: williamr@4: @param aPointerEvent the pointer event to copy williamr@4: williamr@4: @publishedAll williamr@4: @released */ williamr@4: inline void TPointerEvent::Copy(const TPointerEvent& aPointerEvent) williamr@4: { williamr@4: iType=aPointerEvent.iType; williamr@4: iModifiers=(aPointerEvent.iModifiers&~EModifierAdvancedPointerEvent); // Clear the advanced pointer flag williamr@4: iPosition=aPointerEvent.iPosition; williamr@4: iParentPosition=aPointerEvent.iParentPosition; williamr@4: } williamr@4: williamr@4: #endif /* POINTEREVENT_H */