uiacceltk/hitchcock/Client/src/alfevent.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Event class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfevent.h"
       
    21 #include "alf/alfvisual.h"
       
    22 #include <alf/alfscrollerevent.h>
       
    23 
       
    24 #include <uiacceltk/HuiUtil.h>
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // Constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 TAlfEvent::TAlfEvent(CAlfDisplay& aDisplay, TType aType)
       
    33         : iDisplay(&aDisplay),
       
    34           iCode( EEventNull ),
       
    35           iParam(KErrNotFound),
       
    36           iType(aType),
       
    37           iVisual( NULL )
       
    38           
       
    39     {
       
    40     }
       
    41     
       
    42 // ---------------------------------------------------------------------------
       
    43 // Constructor
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 EXPORT_C TAlfEvent::TAlfEvent(TInt aCustomParam)
       
    47         : iDisplay(NULL),
       
    48           iCode( EEventNull ),
       
    49           iParam(aCustomParam),
       
    50           iCustomEventData(0),
       
    51           iType(ETypeCustom),
       
    52           iVisual( NULL )
       
    53     {
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // Constructor
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 EXPORT_C TAlfEvent::TAlfEvent(TInt aCustomParam, TInt aCustomEventData)
       
    61         : iDisplay(NULL),
       
    62           iCode( EEventNull ),
       
    63           iParam(aCustomParam),
       
    64           iCustomEventData(aCustomEventData),
       
    65           iType(ETypeCustom),
       
    66           iVisual( NULL )
       
    67     {
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // Constructor
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C TAlfEvent::TAlfEvent( 
       
    75     CAlfDisplay& aDisplay, 
       
    76     const TAlfScrollerEvent& aEvent )
       
    77         : iDisplay(&aDisplay),
       
    78           iCode( EEventNull ),
       
    79           iScrollerEvent(aEvent),
       
    80           iParam(0),
       
    81           iCustomEventData(0),
       
    82           iType(ETypeScroller),
       
    83           iVisual( NULL )
       
    84     {
       
    85     }
       
    86 
       
    87    
       
    88 // ---------------------------------------------------------------------------
       
    89 // Constructor
       
    90 // ---------------------------------------------------------------------------
       
    91 // 
       
    92 EXPORT_C TAlfEvent::TAlfEvent(
       
    93     CAlfDisplay& aDisplay, const TKeyEvent& aKeyEvent, TEventCode aType)
       
    94         : iDisplay(&aDisplay),
       
    95           iCode(aType),
       
    96           iKeyEvent(aKeyEvent),
       
    97           iParam(KErrNotFound),
       
    98           iType(ETypeKey),
       
    99           iVisual( NULL )
       
   100     {
       
   101     }
       
   102   
       
   103 // ---------------------------------------------------------------------------
       
   104 // Constructor
       
   105 // ---------------------------------------------------------------------------
       
   106 //  
       
   107 EXPORT_C TAlfEvent::TAlfEvent( CAlfDisplay& aDisplay, 
       
   108                       const TPointerEvent& aPointerEvent )
       
   109         : iDisplay(&aDisplay),
       
   110           iCode( EEventNull ),
       
   111           /*iPointerEvent(*aPointerEvent.AdvancedPointerEvent()),*/
       
   112           iParam( KErrNotFound ),
       
   113           iType(ETypePointer),
       
   114           iVisual( NULL )
       
   115     {
       
   116      if ( aPointerEvent.iModifiers &EModifierAdvancedPointerEvent )
       
   117          {
       
   118          iPointerEvent = *aPointerEvent.AdvancedPointerEvent();
       
   119          }
       
   120      else
       
   121          {
       
   122          iPointerEvent.iType=aPointerEvent.iType;       
       
   123          iPointerEvent.iPosition=aPointerEvent.iPosition;
       
   124          iPointerEvent.iParentPosition=aPointerEvent.iParentPosition;
       
   125          }
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // Is pointer event?
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 EXPORT_C TBool TAlfEvent::IsPointerEvent() const
       
   133     {
       
   134     return iType == ETypePointer;
       
   135     }
       
   136    
       
   137 // ---------------------------------------------------------------------------
       
   138 // Returns pointer event
       
   139 // ---------------------------------------------------------------------------
       
   140 // 
       
   141 EXPORT_C const TPointerEvent& TAlfEvent::PointerEvent() const
       
   142     {
       
   143     __ASSERT_ALWAYS( IsPointerEvent(), USER_INVARIANT() );
       
   144     return iPointerEvent;
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // Returns event type.
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 EXPORT_C TAlfEvent::TType TAlfEvent::Type() const
       
   152     {
       
   153     return iType;    
       
   154     }
       
   155     
       
   156 // ---------------------------------------------------------------------------
       
   157 // Is custom event?
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C TBool TAlfEvent::IsCustomEvent() const
       
   161     {
       
   162     return iType == ETypeCustom;        
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // Is it a scroller input event?
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C TBool TAlfEvent::IsScrollerEvent() const
       
   170     {
       
   171     return iType == ETypeScroller; 
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // Returns scroller event
       
   176 // ---------------------------------------------------------------------------
       
   177 // 
       
   178 EXPORT_C TAlfScrollerEvent TAlfEvent::ScrollerEvent() const
       
   179     {
       
   180     __ASSERT_ALWAYS( IsScrollerEvent(), USER_INVARIANT() );
       
   181     TAlfScrollerEvent scrollerEvent = iScrollerEvent;
       
   182     return scrollerEvent;
       
   183     }
       
   184     
       
   185 // ---------------------------------------------------------------------------
       
   186 // Is key event?
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C TBool TAlfEvent::IsKeyEvent() const
       
   190     {
       
   191     return iType == ETypeKey;
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // Return key event code.
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 EXPORT_C const TEventCode& TAlfEvent::Code() const
       
   199     {
       
   200     __ASSERT_ALWAYS( IsKeyEvent(), USER_INVARIANT() );
       
   201     return iCode;
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // Return key event.
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 EXPORT_C const TKeyEvent& TAlfEvent::KeyEvent() const
       
   209     {
       
   210     __ASSERT_ALWAYS( IsKeyEvent(), USER_INVARIANT() );
       
   211     return iKeyEvent;
       
   212     }
       
   213     
       
   214 // ---------------------------------------------------------------------------
       
   215 // Return custom event parameter
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C TInt TAlfEvent::CustomParameter() const
       
   219     {
       
   220     __ASSERT_ALWAYS( IsCustomEvent(), USER_INVARIANT() );
       
   221     return iParam;
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // Return custom event data
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 EXPORT_C TInt TAlfEvent::CustomEventData() const
       
   229     {
       
   230     __ASSERT_ALWAYS( IsCustomEvent(), USER_INVARIANT() );
       
   231     return iCustomEventData;
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // Sets display
       
   236 // ---------------------------------------------------------------------------
       
   237 //    
       
   238 void TAlfEvent::SetDisplay( CAlfDisplay* aDisplay )
       
   239     {
       
   240     iDisplay = aDisplay;
       
   241     }
       
   242     
       
   243 // ---------------------------------------------------------------------------
       
   244 // Returns display or NULL
       
   245 // ---------------------------------------------------------------------------
       
   246 //    
       
   247 EXPORT_C CAlfDisplay* TAlfEvent::Display( ) const
       
   248     {
       
   249     return iDisplay;
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------------------------
       
   253 // Check if the event is pointer down event.
       
   254 // ---------------------------------------------------------------------------
       
   255 // 
       
   256 EXPORT_C TBool TAlfEvent::PointerDown() const
       
   257     {
       
   258     return iType == ETypePointer &&
       
   259            iPointerEvent.iType == TPointerEvent::EButton1Down;
       
   260     }
       
   261 
       
   262 // ---------------------------------------------------------------------------
       
   263 // Check if the event is pointer up event.
       
   264 // ---------------------------------------------------------------------------
       
   265 //     
       
   266 EXPORT_C TBool TAlfEvent::PointerUp() const
       
   267     {
       
   268     return iType == ETypePointer &&
       
   269            iPointerEvent.iType == TPointerEvent::EButton1Up;
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------------------------
       
   273 // Check if the event is long pointer event.
       
   274 // ---------------------------------------------------------------------------
       
   275 //     
       
   276 EXPORT_C TBool TAlfEvent::PointerLongTap() const
       
   277     {
       
   278     return iType == ETypePointer &&
       
   279            iPointerEvent.iType == TPointerEvent::EButtonRepeat;
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------------------------
       
   283 // Sets the associated visual
       
   284 // ---------------------------------------------------------------------------
       
   285 //     
       
   286 EXPORT_C void TAlfEvent::SetVisual(CAlfVisual* aVisual)
       
   287     {
       
   288     iVisual = aVisual;
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // Returns the visual
       
   293 // ---------------------------------------------------------------------------
       
   294 //     
       
   295 EXPORT_C CAlfVisual* TAlfEvent::Visual() const
       
   296     {
       
   297     return iVisual;
       
   298     }
       
   299     
       
   300