photosgallery/viewframework/views/zoomview/src/glxzoomeventhandler.cpp
changeset 0 4e91876724a2
child 3 9a9c174934f5
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Implementation of Zoom Event Handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Avkon 
       
    20 #include <eikon.hrh>
       
    21 
       
    22 // Antariksh
       
    23 #include <alf/alfutil.h>                    // AlfUtil
       
    24 #include <mul/mulevent.h>                   //  For Slider events
       
    25 
       
    26 //Photos Headers
       
    27 #include <glxtracer.h>                      //  For Tracer
       
    28 #include <glxlog.h>                         //  For Log
       
    29 
       
    30 #include <mglxuicommandhandler.h>           //  For MGlxUiCommandHandler
       
    31 #include <glxzoomeventhandler.h>
       
    32 #include <glxzoommathsengine.h>
       
    33 #include <glxzoomcontrol.h>
       
    34 #include <glxzoomeventhandler.h>
       
    35 
       
    36 
       
    37 // LOCAL CONSTANTS AND MACROS
       
    38 const TInt KTimerLengthInMicroseconds   = 100000    ;
       
    39 const TInt KGlxScreenTimeout            = 2000000	;      // 2 seconds timer for UI On/Off
       
    40 
       
    41 const TInt KGlxAnimationTimeDrag        = 30        ;
       
    42 const TInt KGlxAnimationTimekeyPan      = 50	    ;
       
    43 
       
    44 const TInt KGlxZoomPanInc               = 5         ; // Min number of pixels panned in one keypress. This value is incremented exponentially by multiples of iPanFactor 
       
    45 
       
    46 // Anime Speed changes in inverse proportion to KGlxAnimeFrameInmS. 
       
    47 // Steps increase with KGlxAnimeFrameCount.
       
    48 // Total time taken = (KGlxAnimeFrameInmS * KGlxAnimeFrameCount)microseconds.
       
    49 const TInt KGlxAnimeFrameInmS           = 10000     ;
       
    50 const TInt KGlxAnimeFrameCount          = 10        ;                 
       
    51 
       
    52 const TInt KGlxPanInertiaFrameInmS      = 20000     ;
       
    53 
       
    54 using namespace GestureHelper;
       
    55 
       
    56 // ============================ CGlxZoomPanEventHandler===============================
       
    57 // ============================ MEMBER FUNCTIONS ===============================
       
    58 
       
    59 //----------------------------------------------------------------------------------
       
    60 // NewL
       
    61 //----------------------------------------------------------------------------------
       
    62 //
       
    63 CGlxZoomPanEventHandler* CGlxZoomPanEventHandler::NewL(MGlxZoomEventHandlers& aZoomEventHandler)
       
    64     {
       
    65     TRACER("CGlxZoomPanEventHandler::NewL");
       
    66     CGlxZoomPanEventHandler* self = new (ELeave) CGlxZoomPanEventHandler(aZoomEventHandler);
       
    67     CleanupStack::PushL(self);
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop(self);
       
    70     return self;
       
    71     }
       
    72 
       
    73 //----------------------------------------------------------------------------------
       
    74 // CGlxZoomPanEventHandler constructor
       
    75 //----------------------------------------------------------------------------------
       
    76 //
       
    77 CGlxZoomPanEventHandler::CGlxZoomPanEventHandler(MGlxZoomEventHandlers& aZoomEventHandler):
       
    78         iZoomEventHandler(aZoomEventHandler)
       
    79     {
       
    80     TRACER("CGlxZoomPanEventHandler::CGlxZoomPanEventHandler()");
       
    81     // No Implementation
       
    82     }
       
    83 
       
    84 //----------------------------------------------------------------------------------
       
    85 // CGlxZoomPanEventHandlerDestructor
       
    86 //----------------------------------------------------------------------------------
       
    87 //
       
    88 CGlxZoomPanEventHandler::~CGlxZoomPanEventHandler()
       
    89     {
       
    90     TRACER("CGlxZoomPanEventHandler::~CGlxZoomPanEventHandler()");
       
    91     if(iZoomPanTimer)
       
    92     	{
       
    93         CancelZoomPanTimer();
       
    94         delete iZoomPanTimer;
       
    95         iZoomPanTimer = NULL;
       
    96         }
       
    97     if (iUiTimer)
       
    98         {
       
    99         CancelUITimer();
       
   100         delete iUiTimer;
       
   101         iUiTimer = NULL;
       
   102   		}
       
   103     if(iZoomAnimationTimer)
       
   104         {
       
   105         CancelAnimationTimer();
       
   106         delete iZoomAnimationTimer;
       
   107         iZoomAnimationTimer = NULL;
       
   108         }
       
   109    
       
   110     }
       
   111 
       
   112 //----------------------------------------------------------------------------------
       
   113 // CGlxZoomPanEventHandler Constructl
       
   114 //----------------------------------------------------------------------------------
       
   115 //
       
   116 void CGlxZoomPanEventHandler::ConstructL()
       
   117     {
       
   118     TRACER("CGlxZoomPanEventHandler::ConstructL()");
       
   119     if(!iUiTimer)
       
   120         {
       
   121         iUiTimer = CPeriodic::NewL(EPriorityNormal);
       
   122         }
       
   123     if(!iZoomPanTimer)
       
   124         {
       
   125         iZoomPanTimer = CPeriodic::NewL(EPriorityNormal);
       
   126         }
       
   127     if(!iZoomAnimationTimer)
       
   128         {
       
   129         iZoomAnimationTimer = CPeriodic::NewL(EPriorityNormal);
       
   130         }
       
   131     }
       
   132 
       
   133 //----------------------------------------------------------------------------------
       
   134 // CGlxZoomPanEventHandler SetupAnimatedZoom
       
   135 //----------------------------------------------------------------------------------
       
   136 //
       
   137 // Todo: Combine logics of setting up animated zoom and pan.
       
   138 void CGlxZoomPanEventHandler::SetupAnimatedZoom(TZoomMode aZoomMode, TPoint* aZoomFocus)
       
   139     {
       
   140     TRACER("CGlxZoomPanEventHandler::SetupAnimatedZoom");
       
   141     
       
   142     iTargetAnimatedZoomRatio = (iMaxZoomRatio + iMinZoomRatio)/2 ;
       
   143     
       
   144     CancelAnimationTimer();
       
   145     
       
   146     //ToDo: Verify this with images slightly smaller or slightly larger than fullscreen size. 
       
   147     if (EZoomIn == aZoomMode)
       
   148         {
       
   149         // the '1+' is to take care of the situation when there the rest of the equation returns something betn 0 and 1
       
   150         iZoomPerInterval = 1 + (iTargetAnimatedZoomRatio - iZoomRatio)/KGlxAnimeFrameCount ; 
       
   151         }
       
   152     else
       
   153         {
       
   154         iZoomPerInterval = 1 + (iZoomRatio - iMinZoomRatio)/KGlxAnimeFrameCount;
       
   155         }
       
   156     
       
   157     
       
   158     if (1 < iZoomPerInterval)
       
   159         {
       
   160         iIsZoomingInAnimatedState = ETrue;
       
   161         
       
   162         switch(aZoomMode)
       
   163             {
       
   164             case EZoomIn:
       
   165                 iAnimatedZoomMode = EAnimationModeZoomIn;
       
   166                 break;
       
   167             case EZoomOut:
       
   168                 iAnimatedZoomMode = EAnimationModeZoomOut;
       
   169                 break;
       
   170             }
       
   171 
       
   172         iZoomAnimationTimer->Start( 0,  
       
   173                 KGlxAnimeFrameInmS, 
       
   174                 TCallBack( ActivationIntervalElapsed,(TAny*)this) );
       
   175         }
       
   176     else
       
   177         // Cant zoom in/out at less than 1 percent. so directly jump to the target zoom ratio.
       
   178         // This happens in cases where there is not much difference between the source and target zoom levels
       
   179         {
       
   180         TInt targetZoomRatio = 0;  
       
   181         if (EZoomIn == aZoomMode)
       
   182             {
       
   183             targetZoomRatio = iTargetAnimatedZoomRatio ;
       
   184             }
       
   185         else
       
   186             {
       
   187             targetZoomRatio = iMinZoomRatio ;
       
   188             }
       
   189         Zoom(targetZoomRatio, 0) ;
       
   190         }
       
   191     }
       
   192 
       
   193 //----------------------------------------------------------------------------------
       
   194 // CGlxZoomPanEventHandler ActivationIntervalElapsed
       
   195 //----------------------------------------------------------------------------------
       
   196 //
       
   197 TInt CGlxZoomPanEventHandler::ActivationIntervalElapsed(TAny* aPtr)
       
   198     {
       
   199     TRACER("CGlxZoomPanEventHandler::ActivationIntervalElapsed");
       
   200 
       
   201     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
       
   202     
       
   203     self->NextStepAnimatedZoom();
       
   204     return 0;
       
   205     }
       
   206 
       
   207 //----------------------------------------------------------------------------------
       
   208 // CGlxZoomPanEventHandler NextStepAmimatedZoom
       
   209 //----------------------------------------------------------------------------------
       
   210 //
       
   211 void CGlxZoomPanEventHandler::NextStepAnimatedZoom()
       
   212     {
       
   213     TRACER("CGlxZoomPanEventHandler::NextStepAmimatedZoom");
       
   214     
       
   215     TInt targetZoomLevel = 0 ;
       
   216     
       
   217     if (EAnimationModeZoomIn == iAnimatedZoomMode)
       
   218         {
       
   219         targetZoomLevel = iZoomRatio + iZoomPerInterval;
       
   220         }
       
   221     else
       
   222         {
       
   223         targetZoomLevel = iZoomRatio - iZoomPerInterval;
       
   224         }
       
   225             
       
   226     Zoom(targetZoomLevel, 0, EZoomIn, &iZoomFocus );
       
   227 
       
   228     // The boundary conditions. 
       
   229     if ( (( targetZoomLevel >= iTargetAnimatedZoomRatio ) && (EAnimationModeZoomIn == iAnimatedZoomMode ) ) 
       
   230             || ((targetZoomLevel <= iMinZoomRatio) && (EAnimationModeZoomOut == iAnimatedZoomMode)))
       
   231         {
       
   232         iIsZoomingInAnimatedState = EFalse;
       
   233         CancelAnimationTimer();
       
   234         TSize screensize = iMathsEngine.ScreenSize();
       
   235         iZoomFocus = TPoint(screensize.iWidth>>1,screensize.iHeight>>1) ;
       
   236         }
       
   237     }
       
   238 
       
   239 
       
   240 //----------------------------------------------------------------------------------
       
   241 // StartZoomTimer:Starts the Zoom timer for continous zoom
       
   242 //----------------------------------------------------------------------------------
       
   243 //
       
   244 void CGlxZoomPanEventHandler::StartZoomTimer()
       
   245     {
       
   246     TRACER("CGlxZoomPanEventHandler::StartZoomTimer");
       
   247 
       
   248     if (iZoomPanTimer->IsActive())
       
   249         {
       
   250         iZoomPanTimer->Cancel();
       
   251         }
       
   252     iZoomPanTimer->Start( KTimerLengthInMicroseconds,  
       
   253             KTimerLengthInMicroseconds, 
       
   254             TCallBack( ZoomIntervalExpired,(TAny*)this) );
       
   255     }
       
   256 
       
   257 //----------------------------------------------------------------------------------
       
   258 // StartPanTimer:Starts the Pan timer for continous Panning
       
   259 //----------------------------------------------------------------------------------
       
   260 //
       
   261 void CGlxZoomPanEventHandler::StartPanTimer()
       
   262     {
       
   263     TRACER("CGlxZoomPanEventHandler::StartPanTimer ");
       
   264 
       
   265     //After Panning in one direction for a long time by holding the key and 
       
   266     //then if panning is started in another direction,the panning will be done in more pixels.
       
   267     iPanTime.HomeTime();
       
   268     
       
   269     GLX_LOG_INFO("CGlxZoomPanEventHandler::StartPanTimer: Cancelling timers ");
       
   270 
       
   271     if (iZoomPanTimer->IsActive())
       
   272         {
       
   273         iZoomPanTimer->Cancel();
       
   274         }
       
   275     iZoomPanTimer->Start( 0,  
       
   276             KTimerLengthInMicroseconds, 
       
   277             TCallBack( PanIntervalExpired,(TAny*)this) );
       
   278 
       
   279     }
       
   280     
       
   281 //----------------------------------------------------------------------------------
       
   282 // CancelZoomPanTimer: Cancels the Zoom timer for continous zoom
       
   283 //----------------------------------------------------------------------------------
       
   284 //
       
   285 void CGlxZoomPanEventHandler::CancelZoomPanTimer()
       
   286     {
       
   287     TRACER("CGlxZoomPanEventHandler::CancelZoomPanTimer ");
       
   288     
       
   289     if (iZoomPanTimer->IsActive())
       
   290         {
       
   291         iZoomPanTimer->Cancel();
       
   292         }
       
   293     }
       
   294 
       
   295 //----------------------------------------------------------------------------------
       
   296 // CancelUITimer
       
   297 //----------------------------------------------------------------------------------
       
   298 //
       
   299 void CGlxZoomPanEventHandler::CancelUITimer()
       
   300     {
       
   301     TRACER("CGlxZoomPanEventHandler::CancelUITimer ");
       
   302     
       
   303     if (iUiTimer->IsActive())
       
   304         {
       
   305         iUiTimer->Cancel();
       
   306         }
       
   307     }
       
   308 
       
   309 //----------------------------------------------------------------------------------
       
   310 // CancelUITimer
       
   311 //----------------------------------------------------------------------------------
       
   312 //
       
   313 void CGlxZoomPanEventHandler::CancelAnimationTimer()
       
   314     {
       
   315     TRACER("CGlxZoomPanEventHandler::CancelAnimationTimer ");
       
   316     
       
   317     // This will set the timer to false if it is being used for zoom. For Pan
       
   318     // this flag is immaterial
       
   319     iIsZoomingInAnimatedState = EFalse;
       
   320     if (iZoomAnimationTimer->IsActive())
       
   321         {
       
   322         iZoomAnimationTimer->Cancel();
       
   323         }
       
   324     }
       
   325 
       
   326 //----------------------------------------------------------------------------------
       
   327 // StartUITimer
       
   328 //----------------------------------------------------------------------------------
       
   329 //
       
   330 void CGlxZoomPanEventHandler::StartUITimer(TTimeIntervalMicroSeconds32 aDelay,
       
   331         TTimeIntervalMicroSeconds32 anInterval,
       
   332         TCallBack aCallBack)
       
   333     {
       
   334     TRACER("CGlxZoomPanEventHandler::StartUITimer ");
       
   335     
       
   336     if (iUiTimer->IsActive())
       
   337         {
       
   338         iUiTimer->Cancel();
       
   339         }
       
   340     iUiTimer->Start(aDelay,anInterval,aCallBack);
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // HandlekeyEvents:This function handles the key Events.
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 TBool CGlxZoomPanEventHandler::HandlekeyEvents(const TAlfEvent &aEvent)
       
   348     {
       
   349     TRACER("CGlxZoomControl::HandlekeyEvents()");
       
   350     GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlekeyEvents. Scancode = %d   ", aEvent.KeyEvent().iScanCode);
       
   351 
       
   352     TBool consumed = EFalse;
       
   353     
       
   354     if (!iIsZoomingInAnimatedState)
       
   355         {
       
   356         switch (aEvent.KeyEvent().iScanCode)
       
   357             {
       
   358             case EStdKeyDevice10: //Listen to EStdKeyDevice10 as EKeyLeftUpArrow key is mapped to TKeyCode::EKeyDevice10 for which TStdScancode is EStdKeyDevice10
       
   359             case EKeyLeftUpArrow :
       
   360             case EStdKeyDevice13: //Listen to EStdKeyDevice13 as EKeyLeftDownArrow key is mapped to TKeyCode::EKeyDevice13 for which TStdScancode is EStdKeyDevice13    
       
   361             case EKeyLeftDownArrow :
       
   362             case EStdKeyDevice11://Listen to EStdKeyDevice11 as EKeyRightUpArrow key is mapped to TKeyCode::EKeyDevice11 for which TStdScancode is EStdKeyDevice11            
       
   363             case EKeyRightUpArrow :
       
   364             case EStdKeyDevice12: //Listen to EStdKeyDevice12 as EKeyRightDownArrow key is mapped to TKeyCode::EKeyDevice12 for which TStdScancode is EStdKeyDevice12
       
   365             case EKeyRightDownArrow :
       
   366             case EStdKeyLeftArrow :
       
   367             case EStdKeyRightArrow :
       
   368 			case EStdKeyUpArrow :
       
   369 			case EStdKeyDownArrow :
       
   370                 {
       
   371                 HandlePanKey(aEvent);
       
   372                 consumed = ETrue;
       
   373                 }
       
   374                 break;
       
   375             case EStdKeyDevice0:
       
   376             case EStdKeyDevice1:                
       
   377             case EStdKeyDevice3:
       
   378                 {
       
   379                 //Center button/MSK changes the UI State
       
   380                 if (aEvent.Code() == EEventKeyDown)
       
   381                     {
       
   382                     if (EUiOff == iZoomUiState )
       
   383                         {
       
   384                         ShowScreenFurniture(KGlxScreenTimeout);
       
   385                         }
       
   386                     else
       
   387                         {
       
   388                         HideScreenFurniture();
       
   389                         }
       
   390                     }
       
   391                 consumed = ETrue;
       
   392                 }
       
   393                 break;
       
   394     
       
   395             //Listen EStdKeyApplicationC as EKeyZoomIn key is mapped to TKeyCode:: EKeyApplicationC for which TStdScancode is EStdKeyApplicatoinC
       
   396             case EStdKeyApplicationC :
       
   397                 {
       
   398                 HandleZoomStripeAction(EZoomIn ,aEvent.Code()) ;
       
   399                 consumed = ETrue;
       
   400                 break ;
       
   401                 }
       
   402             //Listen EStdKeyApplicationD as EKeyZoomOut key is mapped to TKeyCode:: EKeyApplicationD for which TStdScancode is EStdKeyApplicatoinD
       
   403             case EStdKeyApplicationD :
       
   404                 {
       
   405                 HandleZoomStripeAction(EZoomOut,aEvent.Code());
       
   406                 consumed = ETrue;
       
   407                 break ;
       
   408                 }
       
   409             case EStdKeyIncVolume :
       
   410             case EKeyZoomIn :
       
   411             case EStdKeyNkpAsterisk :
       
   412                 {
       
   413                 GLX_LOG_INFO1("CGlxZoomControl::HandlekeyEvents VLUP=%d", aEvent.KeyEvent().iScanCode );
       
   414                 if (iZoomActivated)
       
   415                     {
       
   416                     HandleZoomKey(EZoomIn, aEvent.Code());
       
   417                     }
       
   418                 consumed = ETrue;
       
   419                 break;
       
   420                 }
       
   421             case EStdKeyDecVolume :
       
   422             case EKeyZoomOut :
       
   423             case EStdKeyHash :
       
   424                 {
       
   425                 GLX_LOG_INFO1("CGlxZoomControl::HandlekeyEvents VLUP_D=%d", aEvent.KeyEvent().iScanCode );    
       
   426                 HandleZoomKey(EZoomOut, aEvent.Code());
       
   427                 consumed = ETrue;
       
   428                 break;
       
   429                 }    
       
   430             default:
       
   431                 break;
       
   432             }
       
   433         }
       
   434 
       
   435     return consumed;
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // HandleZoomKey:Starts the Timer for contionous zoom
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 void CGlxZoomPanEventHandler::HandleZoomKey(TZoomMode aZoomMode ,const TEventCode aEventCode )
       
   443     {
       
   444     TRACER("CGlxZoomControl::HandleZoomKey ");
       
   445     
       
   446     if ( EEventKeyDown == aEventCode )
       
   447         {
       
   448         CancelUITimer();
       
   449         iZoomEventHandler.HandleShowUi(ETrue);
       
   450         iZoomMode = aZoomMode ;
       
   451         StartZoomTimer();
       
   452         }
       
   453     else if ( EEventKeyUp == aEventCode )
       
   454         {
       
   455         CancelZoomPanTimer();
       
   456         StartUITimer(KGlxScreenTimeout,KGlxScreenTimeout,TCallBack( 
       
   457                 UiTimeOut,this )) ;
       
   458         }
       
   459     }
       
   460 
       
   461 // -----------------------------------------------------------------------------
       
   462 // HandleZoomStripeAction:Zooms the image on zoom stripe action.
       
   463 // -----------------------------------------------------------------------------
       
   464 //
       
   465 void CGlxZoomPanEventHandler::HandleZoomStripeAction(TZoomMode aZoomMode ,
       
   466         TEventCode aEventCode)
       
   467     {
       
   468     TRACER("CGlxZoomControl::HandleZoomStripeAction ");
       
   469     if ( iZoomActivated )
       
   470         {
       
   471         switch(aEventCode)
       
   472             {
       
   473             case EEventKey :
       
   474                 {
       
   475                 iZoomMode = aZoomMode ;
       
   476                 Zoom(0, 0, aZoomMode) ;
       
   477 
       
   478                 ShowScreenFurniture(KGlxScreenTimeout);
       
   479                 break ;
       
   480                 }
       
   481             default :
       
   482             break ;
       
   483             }
       
   484         }
       
   485     }
       
   486 
       
   487 
       
   488 // -----------------------------------------------------------------------------
       
   489 // SetupPanOperation: start the pan operation for Key based pan. 
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 void CGlxZoomPanEventHandler::SetupPanOperation(TPoint& aPanDirection)
       
   493     {
       
   494     TRACER("CGlxZoomPanEventHandler::SetupPanOperation ");
       
   495     
       
   496     iPanDirection = TPoint(aPanDirection);
       
   497     if(EUiOn == iZoomUiState )
       
   498         {
       
   499         HideScreenFurniture();
       
   500         }
       
   501     
       
   502     StartPanTimer();
       
   503     
       
   504     iMathsEngine.SetupPanOperation();
       
   505     }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // HandlePanKey :handles the keys related to pan and starts the pan Timer
       
   509 // -----------------------------------------------------------------------------
       
   510 //
       
   511 TBool CGlxZoomPanEventHandler::HandlePanKey( const TAlfEvent &aEvent )
       
   512     {
       
   513     TRACER("CGlxZoomPanEventHandler::HandlePanKey ");
       
   514     
       
   515     TSize imageVirtualSize   = iMathsEngine.ImageVirtualSize();
       
   516     TSize screenSize         = iMathsEngine.ScreenSize();
       
   517     TBool safeToPan          = EFalse ;
       
   518     TPoint panDirection(0,0);
       
   519     TBool handled = EFalse;
       
   520 
       
   521     if ( aEvent.Code() == EEventKeyDown )
       
   522         {
       
   523         //if height and/or width of the zoomed image is greater than the screen height and screen width ,
       
   524         //then this paning should be posssible 
       
   525         switch(aEvent.KeyEvent().iScanCode )
       
   526             {
       
   527             case EStdKeyDevice10:
       
   528             case EKeyLeftUpArrow:
       
   529                 {
       
   530                 if ((imageVirtualSize.iHeight>screenSize.iHeight)
       
   531                         &&(imageVirtualSize.iWidth > screenSize.iWidth))
       
   532                     {
       
   533                     safeToPan = ETrue;
       
   534                     panDirection = TPoint(-KGlxZoomPanInc, -KGlxZoomPanInc);
       
   535                     }
       
   536                 }
       
   537                 break;    
       
   538             case EStdKeyDevice11:
       
   539             case EKeyRightUpArrow:
       
   540                 {
       
   541                 if ((imageVirtualSize.iHeight>screenSize.iHeight)
       
   542                         &&(imageVirtualSize.iWidth > screenSize.iWidth))
       
   543                     {
       
   544                     safeToPan = ETrue;
       
   545                     panDirection = TPoint(KGlxZoomPanInc, -KGlxZoomPanInc);
       
   546                     }
       
   547                 }
       
   548                 break;    
       
   549             case EStdKeyDevice12:
       
   550             case EKeyLeftDownArrow:
       
   551                 {
       
   552                 if ((imageVirtualSize.iHeight>screenSize.iHeight)
       
   553                         &&(imageVirtualSize.iWidth > screenSize.iWidth))
       
   554                     {
       
   555                     safeToPan = ETrue;
       
   556                     panDirection = TPoint(-KGlxZoomPanInc, KGlxZoomPanInc);
       
   557                     }
       
   558                 }
       
   559                 break;    
       
   560             case EStdKeyDevice13:
       
   561             case EKeyRightDownArrow:
       
   562                 {
       
   563                 if ((imageVirtualSize.iHeight>screenSize.iHeight)
       
   564                         &&(imageVirtualSize.iWidth > screenSize.iWidth))
       
   565                     {
       
   566                     safeToPan = ETrue;
       
   567                     panDirection = TPoint(KGlxZoomPanInc, KGlxZoomPanInc);
       
   568                     }
       
   569                 }
       
   570                 break;    
       
   571             case EStdKeyUpArrow:
       
   572                 {
       
   573                 if( (imageVirtualSize.iHeight ) > screenSize.iHeight )
       
   574                     {
       
   575                     safeToPan = ETrue;
       
   576                     panDirection = TPoint(0, -KGlxZoomPanInc);
       
   577                     }
       
   578                 }
       
   579                 break;      
       
   580             case EStdKeyDownArrow:
       
   581                 {
       
   582                 if( (imageVirtualSize.iHeight ) > screenSize.iHeight )
       
   583                     {
       
   584                     safeToPan = ETrue;
       
   585                     panDirection = TPoint(0, KGlxZoomPanInc);
       
   586                     }
       
   587                 }
       
   588                 break;      
       
   589             case EStdKeyLeftArrow:
       
   590                 {
       
   591                 if( (imageVirtualSize.iWidth ) > screenSize.iWidth )
       
   592                     {
       
   593                     safeToPan = ETrue;
       
   594                     panDirection = TPoint(-KGlxZoomPanInc, 0);
       
   595                     }
       
   596                 }
       
   597                 break;      
       
   598             case EStdKeyRightArrow:
       
   599                 {
       
   600                 if ((imageVirtualSize.iWidth ) > screenSize.iWidth )
       
   601                     {
       
   602                     safeToPan = ETrue;
       
   603                     panDirection = TPoint(KGlxZoomPanInc, 0);
       
   604                     }
       
   605                 }
       
   606                 break;        
       
   607             default:
       
   608                 break;
       
   609             }
       
   610         if (safeToPan)
       
   611             {
       
   612             SetupPanOperation(panDirection);
       
   613             handled = ETrue;
       
   614             }
       
   615         }
       
   616     else if ( aEvent.Code() == EEventKeyUp)
       
   617         {
       
   618         // destroy the Pan infrastructure
       
   619         // Reset the PanDirection and cancel the pan timers.
       
   620         CancelZoomPanTimer();
       
   621         iPanDirection = TPoint(0, 0);
       
   622         handled = ETrue;
       
   623         }
       
   624     return handled;
       
   625     }
       
   626 
       
   627 
       
   628 // -----------------------------------------------------------------------------
       
   629 // HandleDragEvent
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 void CGlxZoomPanEventHandler::HandleDragEvent(const GestureHelper::MGestureEvent& aEvent )
       
   633     {
       
   634     TRACER("CGlxZoomControl::HandleDragEvent (GestureHelper::MGestureEvent&)");
       
   635     
       
   636 
       
   637     // Ignore events when we are animating in Zoom
       
   638     if (iIsZoomingInAnimatedState)
       
   639         {
       
   640         return;
       
   641         }
       
   642     
       
   643     TPoint startPos = aEvent.StartPos(); 
       
   644     TPoint currPos  = aEvent.CurrentPos();
       
   645 
       
   646     
       
   647     // This means a new gesture has just started.
       
   648     if (startPos != iPreviousDragStartPosition)
       
   649         {
       
   650         iPreviousPointerPosition = startPos;
       
   651         }
       
   652     
       
   653     TPoint offset((iPreviousPointerPosition.iX - currPos.iX) , (iPreviousPointerPosition.iY - currPos.iY));
       
   654     
       
   655     HideScreenFurniture();
       
   656 
       
   657     TPoint topLeftCorner(0,0);    
       
   658     iMathsEngine.Pan(offset, topLeftCorner, EGlxPanIncrementUniform);
       
   659     
       
   660 
       
   661     iZoomEventHandler.HandleViewPortParametersChanged(topLeftCorner, KGlxAnimationTimeDrag);
       
   662     
       
   663     iPreviousPointerPosition = currPos ;
       
   664     iPreviousDragStartPosition = startPos;
       
   665     }
       
   666 
       
   667 // -----------------------------------------------------------------------------
       
   668 // HandleGestureReleased
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 void CGlxZoomPanEventHandler::HandleGestureReleased(const GestureHelper::MGestureEvent& aEvent )
       
   672     {
       
   673     TRACER("CGlxZoomPanEventHandler::HandleGestureReleasedEvent(const GestureHelper::MGestureEvent& )");
       
   674     
       
   675     if ( /*(EGestureUnknown  == iPreviousGestureCode)
       
   676           ||*/(EGestureSwipeLeft  == iPreviousGestureCode)
       
   677           ||(EGestureSwipeRight == iPreviousGestureCode)
       
   678           ||(EGestureSwipeUp    == iPreviousGestureCode)
       
   679           ||(EGestureSwipeDown  == iPreviousGestureCode))
       
   680         {
       
   681         SetupAnimatedPan();
       
   682         }
       
   683     }
       
   684 
       
   685 void CGlxZoomPanEventHandler::SetupAnimatedPan()
       
   686     {
       
   687     TRACER("CGlxZoomPanEventHandler::SetupAnimatedPan");
       
   688 
       
   689     CancelAnimationTimer();
       
   690     
       
   691     iZoomAnimationTimer->Start( KGlxPanInertiaFrameInmS,  
       
   692             KGlxPanInertiaFrameInmS, 
       
   693             TCallBack( PanInertiaFrameElapsed,(TAny*)this) );
       
   694     
       
   695     }
       
   696 
       
   697 
       
   698 TInt CGlxZoomPanEventHandler::PanInertiaFrameElapsed(TAny* aPtr)
       
   699     {
       
   700     TRACER("CGlxZoomPanEventHandler::PanInertiaFrameElapsed");
       
   701 
       
   702     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
       
   703     
       
   704     self->NextStepInerticPan();
       
   705     return 0;
       
   706 
       
   707     }
       
   708 
       
   709 
       
   710 void CGlxZoomPanEventHandler::NextStepInerticPan()
       
   711     {
       
   712     TRACER("CGlxZoomPanEventHandler::NextStepInerticPan");
       
   713     
       
   714     TPoint inertiaOffset = iMathsEngine.LastPanOffset();
       
   715     
       
   716     if ( (10 >= Abs(inertiaOffset.iX )) && (10 >= Abs(inertiaOffset.iY) ))
       
   717         {
       
   718         CancelAnimationTimer();
       
   719         }
       
   720     else
       
   721         {
       
   722         TPoint topLeftCorner(0,0);    
       
   723         TBool thresholdReached = EFalse; 
       
   724         iMathsEngine.Pan(inertiaOffset, topLeftCorner, EGlxPanIncrementInertic, &thresholdReached);
       
   725         
       
   726         iZoomEventHandler.HandleViewPortParametersChanged(topLeftCorner, KGlxAnimationTimeDrag);
       
   727         
       
   728         // we dont want to continue animated PAN if we have reached one end of the image.
       
   729         if (thresholdReached)
       
   730             {
       
   731             CancelAnimationTimer();
       
   732             }
       
   733         }
       
   734     }
       
   735 
       
   736 void CGlxZoomPanEventHandler::SetPreviousEventCode(const TGestureCode aCode )
       
   737     {
       
   738     TRACER("CGlxZoomPanEventHandler::SetPreviousEventCode(const TGestureCode aCode )");
       
   739     
       
   740     iPreviousGestureCode = aCode;
       
   741     }
       
   742 
       
   743 // -----------------------------------------------------------------------------
       
   744 // HandlePinchEvent
       
   745 // -----------------------------------------------------------------------------
       
   746 //
       
   747 void CGlxZoomPanEventHandler::HandlePinchEventL(const GestureHelper::MGestureEvent& aEvent )
       
   748     {
       
   749     TRACER("CGlxZoomControl::HandlePinchEvent(GestureHelper::MGestureEvent&)");
       
   750 
       
   751     // Ignore events when we are animating in Zoom
       
   752     if (iIsZoomingInAnimatedState)
       
   753         {
       
   754         return;
       
   755         }
       
   756     
       
   757     TPoint pinchFocus       = aEvent.PinchCentrePoint();
       
   758     TInt pinchPercentage    = aEvent.PinchPercent();  // Wrong convention in variable nomenclature but better than ratioInPercentOfChangeInPinchDistance which is incidentally correct 
       
   759 
       
   760     // pinchPercentage == 100 => No change in finger distance => No Zoom. 
       
   761     // A negative Pinch percentage signifies an error in calculations. So NOT handling these
       
   762     if ( (pinchPercentage != 100)
       
   763             && (pinchPercentage > 0) )
       
   764         {
       
   765         Zoom(0, pinchPercentage, EZoomIn, &pinchFocus);
       
   766         }
       
   767     
       
   768     HideScreenFurniture();
       
   769     }
       
   770 
       
   771 // -----------------------------------------------------------------------------
       
   772 // HandleDoubleTap
       
   773 // -----------------------------------------------------------------------------
       
   774 //
       
   775 void CGlxZoomPanEventHandler::HandleDoubleTap(const GestureHelper::MGestureEvent& aEvent )
       
   776     {
       
   777     TRACER("CGlxZoomControl::HandleDoubleTap(GestureHelper::MGestureEvent&)");
       
   778 
       
   779     // Ignore events when we are animating in Zoom
       
   780     if (iIsZoomingInAnimatedState)
       
   781         {
       
   782         return;
       
   783         }
       
   784     
       
   785     SetupAnimatedZoom(EZoomOut);
       
   786     }
       
   787 
       
   788 // -----------------------------------------------------------------------------
       
   789 // HandleSingleTap
       
   790 // -----------------------------------------------------------------------------
       
   791 //
       
   792 void CGlxZoomPanEventHandler::HandleSingleTap(const GestureHelper::MGestureEvent& aEvent )
       
   793     {
       
   794     TRACER("CGlxZoomControl::HandleSingleTap(GestureHelper::MGestureEvent&)");
       
   795 
       
   796     // Ignore events when we are animating in Zoom
       
   797     if (iIsZoomingInAnimatedState)
       
   798         {
       
   799         return;
       
   800         }
       
   801     
       
   802     ShowScreenFurniture(KGlxScreenTimeout);
       
   803     }
       
   804 
       
   805 // ---------------------------------------------------------------------------
       
   806 // UiTimeOut: Hides the screen furniture once the Timeout happens
       
   807 // ---------------------------------------------------------------------------
       
   808 //  
       
   809 TInt CGlxZoomPanEventHandler::UiTimeOut(TAny* aSelf)
       
   810     {
       
   811     TRACER("CGlxZoomControl::UiTimeOut");
       
   812     if(aSelf)
       
   813         {
       
   814         CGlxZoomPanEventHandler* self = static_cast <CGlxZoomPanEventHandler*> (aSelf);
       
   815         //retreive the UI state.
       
   816         if(EUiOn == self->iZoomUiState)
       
   817             {
       
   818             self->HideScreenFurniture();
       
   819             }
       
   820         }
       
   821     return KErrNone;
       
   822     }
       
   823 
       
   824 // ---------------------------------------------------------------------------
       
   825 // ZoomOutTimerL
       
   826 // ---------------------------------------------------------------------------
       
   827 //  
       
   828 TInt CGlxZoomPanEventHandler::ZoomOutTimerL(TAny* aSelf)
       
   829     {
       
   830     TRACER("CGlxZoomControl::ZoomOutTimerL");
       
   831     if(aSelf)
       
   832         {
       
   833         CGlxZoomPanEventHandler* self = static_cast <CGlxZoomPanEventHandler*> (aSelf);
       
   834         self->CallZoomOutL();
       
   835         }
       
   836     return KErrNone;
       
   837     }
       
   838 
       
   839 // ---------------------------------------------------------------------------
       
   840 // CallZoomOutL
       
   841 // ---------------------------------------------------------------------------
       
   842 //  
       
   843 void CGlxZoomPanEventHandler::CallZoomOutL()
       
   844     {
       
   845     TRACER("CGlxZoomPanEventHandler::CallZoomOutL()");
       
   846     iZoomEventHandler.HandleZoomOutL(KGlxZoomOutCommand);
       
   847     }
       
   848 
       
   849 //----------------------------------------------------------------------------------
       
   850 // ZoomTimerCallback:Callback function for the Zoom timer
       
   851 //----------------------------------------------------------------------------------
       
   852 //
       
   853 TInt CGlxZoomPanEventHandler::ZoomIntervalExpired(TAny* aPtr)
       
   854     {
       
   855     TRACER("CGlxZoomControl::ZoomIntervalExpired ");
       
   856     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
       
   857     self->DoZoom();
       
   858     return 0; // Timer has finished
       
   859     }
       
   860 
       
   861 //----------------------------------------------------------------------------------
       
   862 // PanIntervalExpired:Callback function for the pan timer
       
   863 //----------------------------------------------------------------------------------
       
   864 //
       
   865 TInt CGlxZoomPanEventHandler::PanIntervalExpired(TAny* aPtr)
       
   866     {
       
   867     TRACER("CGlxZoomPanEventHandler::PanIntervalExpired ");
       
   868     GLX_LOG_INFO("PanIntervalExpired ");
       
   869     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
       
   870     self->DoPan();
       
   871     return 0; // Timer has finished
       
   872     }
       
   873 
       
   874 //----------------------------------------------------------------------------------
       
   875 // DoZoom:calls zooming function and updates the slider value 
       
   876 //----------------------------------------------------------------------------------
       
   877 //    
       
   878 void CGlxZoomPanEventHandler::DoZoom()
       
   879     {
       
   880     TRACER("CGlxZoomPanEventHandler::DoZoom ");
       
   881     Zoom(0, 0, iZoomMode);
       
   882     }
       
   883 
       
   884 
       
   885 //----------------------------------------------------------------------------------
       
   886 // DoPan:calls Panning function.
       
   887 //----------------------------------------------------------------------------------
       
   888 //    
       
   889 void CGlxZoomPanEventHandler::DoPan()
       
   890     {
       
   891     TRACER("CGlxZoomPanEventHandler::DoPan ");
       
   892 
       
   893     TBool atPanThreshold = EFalse;
       
   894     TPoint topLeftCorner;
       
   895     iMathsEngine.Pan(iPanDirection, topLeftCorner, EGlxPanIncrementExponential,  &atPanThreshold);
       
   896     
       
   897     iZoomEventHandler.HandleViewPortParametersChanged(topLeftCorner, KGlxAnimationTimekeyPan);
       
   898     
       
   899     if ( atPanThreshold )
       
   900         {
       
   901         CancelZoomPanTimer();
       
   902         }
       
   903     
       
   904     iMathsEngine.UpdatePanFactor(iPanTime);
       
   905     }
       
   906 
       
   907 
       
   908 //----------------------------------------------------------------------------------
       
   909 // OrientationChanged 
       
   910 //----------------------------------------------------------------------------------
       
   911 //    
       
   912 void CGlxZoomPanEventHandler::OrientationChanged(const TRect& aNewScreenRect)
       
   913     {
       
   914     TRACER("CGlxZoomPanEventHandler::OrientationChanged ");
       
   915     
       
   916     Zoom(0, 0, iZoomMode) ;
       
   917 
       
   918     iMathsEngine.OrientationChanged(aNewScreenRect);
       
   919     }
       
   920 
       
   921 // -----------------------------------------------------------------------------
       
   922 // ShowSlider
       
   923 // -----------------------------------------------------------------------------
       
   924 //
       
   925 void CGlxZoomPanEventHandler::ShowScreenFurniture(TTimeIntervalMicroSeconds32 aTimeout)
       
   926     {
       
   927     TRACER("CGlxZoomPanEventHandler::ShowScreenFurniture()");
       
   928 
       
   929     iZoomEventHandler.HandleShowUi(ETrue);
       
   930     
       
   931     if (aTimeout.Int())
       
   932         {
       
   933         StartUITimer(aTimeout,aTimeout,TCallBack( UiTimeOut,this ));
       
   934         }
       
   935     }
       
   936 
       
   937 
       
   938 // -----------------------------------------------------------------------------
       
   939 // HideScreenFurniture
       
   940 // -----------------------------------------------------------------------------
       
   941 //
       
   942 void CGlxZoomPanEventHandler::HideScreenFurniture()
       
   943     {
       
   944     TRACER("CGlxZoomPanEventHandler::HideScreenFurniture()");
       
   945 
       
   946     iZoomEventHandler.HandleShowUi(EFalse);
       
   947     CancelUITimer();
       
   948     }
       
   949 
       
   950 
       
   951 // -----------------------------------------------------------------------------
       
   952 // ActivateZoom
       
   953 // -----------------------------------------------------------------------------
       
   954 //
       
   955 void CGlxZoomPanEventHandler::ActivateZoom(TInt /*aInitialZoomRatio*/, 
       
   956         TSize aImageSize, 
       
   957         TZoomStartMode aStartMode, 
       
   958         TInt aMinSliderRange, 
       
   959         TInt aMaxSliderRange,
       
   960         TSize& aOriginalDimensions, 
       
   961         TPoint* aZoomFocus)
       
   962     {
       
   963     TRACER("CGlxZoomPanEventHandler::ActivateZoom");
       
   964     
       
   965     TPoint center(aImageSize.iWidth/2 ,aImageSize.iHeight/2 );
       
   966     TSize  imageSize(aImageSize.iWidth, aImageSize.iHeight);
       
   967 
       
   968     TSize  screenSize = TSize(AlfUtil::ScreenSize());
       
   969     
       
   970     GLX_LOG_INFO2("ActivateZoom : Center = [%d,%d],   ", 
       
   971             TInt(center.iX), 
       
   972             TInt(center.iY)  
       
   973               );
       
   974     
       
   975     // A zoom ratio is calculated by multiplying the the new virtual size with 100 and dividing it with the original size. 
       
   976     // this division using integers might cause truncation. The +1 is added to make sure that every such truncation 
       
   977     // is pegged to the next higher integer than the next lower, thus ensuring that the zoom ratio in the zoom mode will always
       
   978     // be greater than that in the full screen mode.
       
   979     //
       
   980     // The only other solution is to introduce a real number for this calculation. But do we really need such a deep level of accuracy?
       
   981     iMinZoomRatio = iZoomRatio = aMinSliderRange + 1;
       
   982     iMaxZoomRatio = aMaxSliderRange   ;
       
   983 
       
   984     iMathsEngine.Initialize(center,
       
   985             screenSize,
       
   986             imageSize,
       
   987             aOriginalDimensions,
       
   988             iZoomRatio
       
   989             );
       
   990     
       
   991     //initially show the slider,so set the state to slider visible
       
   992     TPoint   viewPortTopLeft(0,0);
       
   993     TSize    viewPortDimension(0,0);
       
   994     iZoomMode = EZoomIn;
       
   995 
       
   996     switch(aStartMode)
       
   997         {
       
   998         case EZoomStartKey :
       
   999             {
       
  1000             StartZoomTimer();            
       
  1001             }
       
  1002             break;
       
  1003         case EZoomStartDoubleTap :
       
  1004             {
       
  1005             if (!iIsZoomingInAnimatedState)
       
  1006                 {
       
  1007                 if (aZoomFocus)
       
  1008                     {
       
  1009                     iZoomFocus.iX = aZoomFocus->iX ;
       
  1010                     iZoomFocus.iY = aZoomFocus->iY ;
       
  1011                     }
       
  1012                 SetupAnimatedZoom(EZoomIn, &iZoomFocus);
       
  1013                 }
       
  1014             }
       
  1015             break;
       
  1016         case EZoomStartPinch:
       
  1017             {
       
  1018             iZoomRatio = iMathsEngine.Zoom(EZoomIn, aMinSliderRange,  
       
  1019                     viewPortTopLeft, viewPortDimension);
       
  1020 
       
  1021             iZoomEventHandler.HandleViewPortParametersChanged(viewPortTopLeft , 0, 
       
  1022                     &viewPortDimension, iZoomRatio);
       
  1023             iZoomEventHandler.HandleShowUi(EFalse);
       
  1024             }
       
  1025             break;
       
  1026         case EZoomStartSlider :
       
  1027             break;
       
  1028         default:
       
  1029             break;
       
  1030         }
       
  1031     
       
  1032     }
       
  1033 
       
  1034 // -----------------------------------------------------------------------------
       
  1035 // DeactivateZoom
       
  1036 // -----------------------------------------------------------------------------
       
  1037 //
       
  1038 void CGlxZoomPanEventHandler::DeactivateZoom()
       
  1039     {
       
  1040     TRACER("CGlxZoomPanEventHandler::DeactivateZoom()");
       
  1041     
       
  1042     iZoomMode = EZoomOut;
       
  1043     iIsZoomingInAnimatedState = EFalse ;
       
  1044     CancelZoomPanTimer();
       
  1045     CancelUITimer();
       
  1046     CancelAnimationTimer();
       
  1047     }
       
  1048 
       
  1049 // -----------------------------------------------------------------------------
       
  1050 // HandleEvent
       
  1051 // -----------------------------------------------------------------------------
       
  1052 //
       
  1053 // Todo: Combine both these HandleEvents
       
  1054 TBool CGlxZoomPanEventHandler::HandleEvent( const TAlfEvent& aEvent )
       
  1055     {
       
  1056     TRACER("CGlxZoomControl::HandleEvent()");
       
  1057     
       
  1058     TBool eventHandledState = EFalse;
       
  1059     
       
  1060     if (iZoomActivated)
       
  1061         {
       
  1062         if(!aEvent.IsCustomEvent())
       
  1063             {
       
  1064             eventHandledState = EFalse;
       
  1065             }
       
  1066         else
       
  1067             {
       
  1068             GLX_LOG_INFO("CGlxZoomPanEventHandler::HandleEvent: Custom Event.");
       
  1069             TInt EventID = aEvent.CustomParameter();
       
  1070 
       
  1071             switch(EventID)
       
  1072                 {
       
  1073                 case ETypePrimaryValueChange:
       
  1074                     {
       
  1075                     GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent: ETypePrimaryValueChange."  );
       
  1076 
       
  1077                     MulSliderPos* dataPtr = (MulSliderPos*)(aEvent.CustomEventData());  
       
  1078                     TInt currentSliderValue = dataPtr->mCurrentValue;
       
  1079 
       
  1080                     // is current value within accetable ranges.
       
  1081                     if ( currentSliderValue > iMinZoomRatio 
       
  1082                             &&  currentSliderValue <= iMaxZoomRatio )
       
  1083                         {
       
  1084                         Zoom(currentSliderValue, 0, EZoomIn);
       
  1085                         }
       
  1086                     else if (currentSliderValue <= iMinZoomRatio)
       
  1087                         {
       
  1088                         CallZoomOutL();
       
  1089                         }
       
  1090                     eventHandledState = ETrue;
       
  1091                     }
       
  1092                     break;
       
  1093 
       
  1094                 case ECustomEventIconClick :
       
  1095                      {
       
  1096                      //The Slider is held by user,so cancel the UI Timer
       
  1097                      //When the slider is held ,the screen furniture shouldn't disappear
       
  1098                      GLX_LOG_INFO( " CGlxZoomControl::offerEvent,ECustomEventIconClick");
       
  1099                      CancelUITimer();    
       
  1100                      eventHandledState = ETrue;           
       
  1101                      }
       
  1102                      break;
       
  1103 
       
  1104                 case ECustomEventIconRelease:
       
  1105                      {
       
  1106                      //The slider is not held, by the user,start the ui timer to hide the screen furniture
       
  1107                      GLX_LOG_INFO( " CGlxZoomControl::offerEvent,ECustomEventIconRelease");
       
  1108                      StartUITimer(KGlxScreenTimeout, KGlxScreenTimeout, TCallBack( UiTimeOut,this ) );
       
  1109                      eventHandledState = ETrue;
       
  1110                      }
       
  1111                      break;
       
  1112 
       
  1113                 default:
       
  1114                     {
       
  1115                     GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent default");
       
  1116                     eventHandledState = EFalse;
       
  1117                     break;
       
  1118                     }
       
  1119                 }
       
  1120             }
       
  1121         }
       
  1122     return eventHandledState ;    
       
  1123     }
       
  1124 
       
  1125 // -----------------------------------------------------------------------------
       
  1126 // HandleEvent
       
  1127 // -----------------------------------------------------------------------------
       
  1128 //
       
  1129 TBool CGlxZoomPanEventHandler::HandleEventL(const TAlfEvent &aEvent)
       
  1130     {
       
  1131     TRACER("CGlxZoomControl::HandleEventL()");
       
  1132     
       
  1133     TBool consumed = EFalse;
       
  1134 
       
  1135     if (iZoomActivated)
       
  1136         {
       
  1137         if (aEvent.IsKeyEvent() )
       
  1138             {
       
  1139             GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent KeyEvent");
       
  1140             consumed = HandlekeyEvents(aEvent);
       
  1141             }
       
  1142         else if(aEvent.IsPointerEvent() )
       
  1143             {
       
  1144             GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent PointerEvent ");
       
  1145             consumed = iZoomEventHandler.HandlePointerEventsL(aEvent);
       
  1146             }
       
  1147         }
       
  1148     return consumed;
       
  1149     }
       
  1150 
       
  1151 
       
  1152 // -----------------------------------------------------------------------------
       
  1153 // Zoom
       
  1154 // -----------------------------------------------------------------------------
       
  1155 //
       
  1156 
       
  1157 
       
  1158 void CGlxZoomPanEventHandler::Zoom(TInt aExpectedZoomLevel, TInt aRelativeZoomFactor, TZoomMode aZoomMode, TPoint* aZoomFocus)
       
  1159     {
       
  1160     TRACER("CGlxZoomControl::ZoomL( )");
       
  1161     
       
  1162     TPoint          viewPortTopLeft(0,0);
       
  1163     TSize           viewPortDimension(0,0);
       
  1164     TBool           atZoomThreshold = EFalse;
       
  1165     
       
  1166     iZoomRatio = iMathsEngine.Zoom(aZoomMode, 
       
  1167             aExpectedZoomLevel, 
       
  1168             viewPortTopLeft, 
       
  1169             viewPortDimension, 
       
  1170             &atZoomThreshold,
       
  1171             aZoomFocus, 
       
  1172             aRelativeZoomFactor);
       
  1173     
       
  1174     iZoomEventHandler.HandleViewPortParametersChanged(viewPortTopLeft, 0, 
       
  1175             &viewPortDimension, iZoomRatio);
       
  1176     
       
  1177     if( atZoomThreshold )
       
  1178         {
       
  1179         CancelZoomPanTimer();
       
  1180         if (iZoomRatio <= iMinZoomRatio)
       
  1181             {
       
  1182             CallZoomOutL();
       
  1183             }
       
  1184         }
       
  1185     }
       
  1186 
       
  1187 // -----------------------------------------------------------------------------
       
  1188 // ZoomIsActivated
       
  1189 // -----------------------------------------------------------------------------
       
  1190 //
       
  1191 void CGlxZoomPanEventHandler::SetZoomActivated(TBool aIsActivated)
       
  1192     {
       
  1193     TRACER("CGlxZoomPanEventHandler::ZoomIsActivated");
       
  1194     iZoomActivated = aIsActivated;
       
  1195     }
       
  1196 
       
  1197 // -----------------------------------------------------------------------------
       
  1198 // SetZoomUiState
       
  1199 // -----------------------------------------------------------------------------
       
  1200 //
       
  1201 void CGlxZoomPanEventHandler::SetZoomUiState(TUiState aZoomUiState)
       
  1202     {
       
  1203     TRACER("CGlxZoomPanEventHandler::ZoomIsActivated");
       
  1204     iZoomUiState = aZoomUiState;
       
  1205     GLX_LOG_INFO1("CGlxZoomPanEventHandler::SetZoomUiState :=%d",iZoomUiState);
       
  1206     }
       
  1207 
       
  1208 // -----------------------------------------------------------------------------
       
  1209 // ZoomUiState
       
  1210 // -----------------------------------------------------------------------------
       
  1211 //
       
  1212 TUiState CGlxZoomPanEventHandler::ZoomUiState()
       
  1213     {
       
  1214     TRACER("CGlxZoomPanEventHandler::ZoomUiState");
       
  1215     return iZoomUiState ;
       
  1216     }
       
  1217 
       
  1218 // -----------------------------------------------------------------------------
       
  1219 // HandleMultiTouchReleased
       
  1220 // -----------------------------------------------------------------------------
       
  1221 //
       
  1222 void CGlxZoomPanEventHandler::HandleMultiTouchReleased()
       
  1223     {
       
  1224     TRACER("CGlxZoomPanEventHandler::HandleMultiTouchReleased");
       
  1225 
       
  1226 //    ShowScreenFurniture(KGlxScreenTimeout);
       
  1227     }