svgtviewer/SvgtViewerPlugin/UIControlSrc/SVGTCustControl.cpp
branchRCL_3
changeset 20 5fd161fa28b6
equal deleted inserted replaced
17:e52958d06c29 20:5fd161fa28b6
       
     1 /*
       
     2 * Copyright (c) 2004,2005 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:  This file implements the SVGT Custom Control which
       
    15 *                is used to display SVGT content
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <aknnotewrappers.h>
       
    23 #include <AknWaitNoteWrapper.h>
       
    24 #include <AknIconUtils.h>
       
    25 #include <aknlayoutscalable_apps.cdl.h>
       
    26 #include <AknsConstants.h>
       
    27 #include <AknsSkinInstance.h>
       
    28 #include <AknsUtils.h>
       
    29 #include <AknWaitDialog.h>
       
    30 #include <bitdev.h>
       
    31 #include <StringLoader.h>
       
    32 #include <DRMHelper.h>
       
    33 #include <eikenv.h> //CEikonEnv
       
    34 #include <e32math.h>
       
    35 #include <uri16.h>
       
    36 #include <ctsydomainpskeys.h> // for call handling
       
    37 #include <data_caging_path_literals.hrh>
       
    38 #include <gdi.h>
       
    39 #include <svgtuicontrol.rsg>
       
    40 #include <svgtuicontrol.mbg>
       
    41 // User Includes
       
    42 #include "SVGTUIControlDbgFlags.hrh"
       
    43 #include "SVGTAppObserver.h"
       
    44 #include "SVGTCustControl.h"
       
    45 #include "SVGTUIDialog.hrh"
       
    46 
       
    47 #include "SvgtController.h"
       
    48 #include "SvgtApplicationExitObserver.h"
       
    49 #include "SvgtEventHandlerAO.h"
       
    50 #include "SvgtEvent.h"
       
    51 #include <svgtfileviewdetails.h>
       
    52 #include <aknnavi.h>
       
    53 #include <aknnavide.h>
       
    54 #include <avkon.mbg>
       
    55 
       
    56 #ifdef RD_SVGT_AUDIO_SUPPORT
       
    57 #include <AknVolumePopup.h>
       
    58 #include<remconinterfaceselector.h>     //for CRemConInterfaceSelector
       
    59 #include<remconcoreapitarget.h>         //for CRemConCoreApiTarget
       
    60 
       
    61 #endif //RD_SVGT_AUDIO_SUPPORT
       
    62 // Constants
       
    63 
       
    64 // Panning Constants
       
    65 // KSccPanNumPixelsX - Amount of Pixels to Pan in X Direction when Pan is
       
    66 //                     performed once.
       
    67 // KSccPanNumPixelsY - Amount of Pixels to Pan in Y Direction when Pan is
       
    68 //                     performed once.
       
    69 const TInt KSccPanNumPixelsX = 30;
       
    70 const TInt KSccPanNumPixelsY = 30;
       
    71 
       
    72 // Pointer Constants
       
    73 // When pointer is moved in a particular direction, the movement also
       
    74 // acceleration. The below constants define the delta for the acceleration.
       
    75 // KSccCursorMinDeltaX - For X Direciton
       
    76 // KSccCursorMinDeltaY - For Y Direciton
       
    77 const TInt KSccCursorMinDeltaX = 5;
       
    78 const TInt KSccCursorMinDeltaY = 5;
       
    79 
       
    80 // Zoom Constants
       
    81 // KSccZoomInFactor - Indicates zoom factor to use while zooming in.
       
    82 //                    This Value should be > 1.0
       
    83 // KSccZoomOutFactor - Indicates zoom factor to use while zooming out.
       
    84 //                     This value should be > 0 and < 1.0
       
    85 const TReal32 KSccZoomInFactor = 2.0; // 2X Zoom In
       
    86 const TReal32 KSccZoomOutFactor = 0.5;// 2X Zoom Out
       
    87 
       
    88 // Key Constants
       
    89 const TInt KSccZoomInKey = ENumberKey5;//'5';
       
    90 const TInt KSccZoomOutKey =ENumberKey0; //'0';
       
    91 
       
    92 // Number of milli seconds per second
       
    93 const TUint32 KSccNumMSecPerSec = 1000;
       
    94 
       
    95 
       
    96 
       
    97 // Time in microsecs after which Pointer Inactivity should be declared
       
    98 const TUint KSccPointerHideTimerStartAfter = 15000000;
       
    99 
       
   100 // Time in microsecs per second
       
   101 const TInt KSccOneSecond = 1000000;
       
   102 
       
   103 // General Constants
       
   104 const TInt KSccConstMinusOne = -1;
       
   105 const TInt KSccConstZero = 0;
       
   106 const TInt KSccConstOne = 1;
       
   107 const TInt KSccConstTwo = 2;
       
   108 
       
   109 // set the name of the multi-bitmap file containing the bitmaps
       
   110 _LIT( KSccIconFile,"Z:SVGTUIControl.mif" );
       
   111 
       
   112 // SMIL Fit Value
       
   113 _LIT( KSccSmilFitValue,"meet" );
       
   114 
       
   115 // Font Ids for use with Engine-Init
       
   116 const TInt KApacFontId = EApacPlain16;
       
   117 const TInt KLatintFontId = ELatinBold12;
       
   118 
       
   119 // Duration const returned by engine when indefinite animations are present
       
   120 const TUint KSccIndefiniteDur = 0xffffffff;
       
   121 
       
   122 
       
   123 // Interval between two consecutive timer ticks in microseconds.
       
   124 const TUint32 KSccProgIndTimerYieldDur = 100000;
       
   125 
       
   126 //constant for converting radians to degrees
       
   127 const TReal32 KDegreesToRadiansFactor = 0.01745329252;
       
   128 
       
   129 // Maximum length of text in a text element
       
   130 const TInt KSccMaxTextLength = 250;
       
   131 const TInt KBackLightTimeInterval = 9;
       
   132 const TInt KMaxEditorTextLength = 5120; 
       
   133 const TInt KEmbededImageTagLength = 5;
       
   134 const TInt KSchemaLength = 4;
       
   135 
       
   136 #ifdef RD_SCALABLE_UI_V2
       
   137 const TInt KInitRepeatInterval = 10000;
       
   138 #endif // RD_SCALABLE_UI_V2
       
   139 
       
   140 // Background colour which is used by engine before rendering as a base colour
       
   141 const TUint32 KSccArgbWhite = 0xffffffff;
       
   142 
       
   143 //TOUCH
       
   144 #ifdef RD_SVGT_AUDIO_SUPPORT
       
   145 const TInt KDefaultVolumeLevel = 3;   
       
   146 const TInt KMinVolume = 0;
       
   147 const TInt KMaxVolume = 10;
       
   148 #endif // RD_SVGT_AUDIO_SUPPORT
       
   149 //TOUCH
       
   150 #ifdef _DEBUG
       
   151 // Backlight Strings
       
   152 _LIT( KSccBacklightOnStr, "Backlight On" );
       
   153 _LIT( KSccBacklightOffStr, "Backlight Off" );
       
   154 #endif
       
   155 
       
   156 //Loading thread name
       
   157 _LIT(KSvgThread,"SvgThread");
       
   158 
       
   159 _LIT(KJpg,   ".jpg" );
       
   160 _LIT(KJpeg,  ".jpeg" );
       
   161 _LIT(KPng,   ".png" );
       
   162 _LIT(KBmp,   ".bmp" );
       
   163 _LIT(KSvg,   ".svg" );
       
   164 _LIT(KSvgz,  ".svgz" );
       
   165 
       
   166 _LIT( KWww, "www" );
       
   167 _LIT( KHttp, "http://");
       
   168 // ============================ MEMBER FUNCTIONS ===============================
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CSVGTCustControl::CSVGTCustControl
       
   172 // C++ default constructor.
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 CSVGTCustControl::CSVGTCustControl(
       
   176     RFile& aFileHandle, // File Handle of SVGT content
       
   177     TBool aProgressiveRendering,
       
   178     TInt aFlag ) :
       
   179     // Animation State
       
   180     iTotalNumerOfAnimation( KSccConstMinusOne ),
       
   181     iAnimationStatus( ESvgNoAnimationsPresent ),
       
   182     iAnimState( ESvgAnimStoppedState ),
       
   183     iContentFileHandle( aFileHandle ),
       
   184     // SVG Engine
       
   185     iIsLoadingDone( EFalse ),
       
   186     iFetchImageError( 0 ),
       
   187     // Control State Variables
       
   188     iZoomLevel( 0 ),
       
   189     iIsLoopOn( EFalse ),
       
   190     iIsFullScreenOn( EFalse ),
       
   191     // Pointer Variables
       
   192     iPointerDx( 0 ),
       
   193     iPointerDy( 0 ),
       
   194     iPointerX( 0 ),
       
   195     iPointerY( 0 ),
       
   196     // Current Match is invalid
       
   197     iIsSearchStrValid( EFalse ),
       
   198     iCurSearchMatchId( 0 ),
       
   199     iNumAnimInProgress( 0 ),
       
   200     iIsPointerDisplayed( ETrue ),                 
       
   201     iFindTextHiColor( KRgbBlack ),               
       
   202     iIgnorePointerKeyEvent( EFalse ),
       
   203     iPointerType( ESvgPointerDefault ),
       
   204     iEnableTextOps( ETrue ),
       
   205     iIsTextEditOn( EFalse ),
       
   206     iIsTextSelectOn(EFalse),
       
   207     iProgressiveRendering(aProgressiveRendering),
       
   208     iDisplayFlags( aFlag ),
       
   209     iEventHandlerAO(NULL),
       
   210     iThreadController(NULL),
       
   211     iIsWaitNoteDisplayed(EFalse),
       
   212 #ifdef RD_SVGT_AUDIO_SUPPORT
       
   213 	iVolumeLevel(KDefaultVolumeLevel),
       
   214 	iPrevVolume(KDefaultVolumeLevel),
       
   215 #endif //RD_SVGT_AUDIO_SUPPORT
       
   216     iIsTextChanged( EFalse ),
       
   217     iViewerCommand(EFalse),
       
   218     iPlayMSKLabel(EFalse),
       
   219     iContextMenuActivated(EFalse),
       
   220     iAElement(EFalse),
       
   221     iScrollKey(EFalse),
       
   222     iPointerDownAnimation(EFalse),
       
   223     iInteractiveElementEnteredCnt(0),
       
   224     iDownKeyOccurred(EFalse),
       
   225     iIsVolumeMuted(EFalse),
       
   226     iIsForeground(ETrue)
       
   227     {
       
   228     }
       
   229 
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CSVGTCustControl::ConstructL
       
   233 // Symbian 2nd phase constructor.
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 void CSVGTCustControl::ConstructL(
       
   237     MSvgtAppObserver* aAppObs, // User Implementation of Mixin
       
   238     MSVGTProgressBarDrawImpl* aPBDrawImpl , // Implementation for rendering
       
   239                                             // progress indicator
       
   240 	MSVGTMSKImpl* aMSKImpl,		//Interface for MSK labelling                                           
       
   241     MSvgtApplicationExitObserver* aExitObserver,
       
   242     const CCoeControl* aParent )
       
   243     {
       
   244     iEngineInitialized = EFalse;
       
   245     // Save the user parameters for later access.
       
   246     iAppObserver = aAppObs;
       
   247     iProgressBarDrawImpl = aPBDrawImpl;
       
   248     iMSKImpl=aMSKImpl;
       
   249     iExitObserver = aExitObserver;
       
   250    
       
   251     TRect lRect;
       
   252     GetNormalScreenLayoutRect( lRect );
       
   253     // Frame buffers creation
       
   254     CreateBitmapsL( lRect.Size() );
       
   255 
       
   256     // Icons(Pointer, Pan Ind) creation
       
   257     CreateIconsL();
       
   258 
       
   259 #ifdef RD_SVGT_AUDIO_SUPPORT
       
   260     iVolumePopup = CAknVolumePopup::NewL(NULL, ETrue);
       
   261     iVolumePopup->SetObserver(this);
       
   262     _LIT( KVolumePopupTitle, "Presentation volume");
       
   263     iVolumePopup->SetTitleTextL(KVolumePopupTitle);
       
   264     iVolumePopup->SetRange( KMinVolume, KMaxVolume);
       
   265     iVolumePopup->SetValue( KDefaultVolumeLevel );
       
   266     
       
   267     
       
   268     // Open a connection to receive Volume Key events.
       
   269     iSelector = CRemConInterfaceSelector::NewL();
       
   270     iInterfaceSelector = CRemConCoreApiTarget::NewL(*iSelector,*this);
       
   271     TRAPD(err, iSelector->OpenTargetL());
       
   272     if(err != KErrNone)
       
   273     {
       
   274 		#ifdef _DEBUG
       
   275 		RDebug::Printf("Leave occured in OpenTargetL. Error code returned %d",err);
       
   276 		#endif
       
   277     }
       
   278     
       
   279 #endif  //RD_SVGT_AUDIO_SUPPORT
       
   280 
       
   281     // DrmHelper to display save related query
       
   282     iSvgDrmHelper = CSVGTDrmHelper::NewL();
       
   283 
       
   284     // Check if it is a preview file
       
   285     iPreviewMode = iSvgDrmHelper->IsPreviewL( iContentFileHandle );
       
   286    
       
   287     // Initialise the SVG engine.
       
   288     InitializeEngineL();
       
   289    
       
   290    
       
   291 //############################################################
       
   292     // Create the timer for Pointer Inactivity
       
   293     if ( iDisplayFlags & ESvgDrawPointer )
       
   294         {
       
   295         iInactivityTimer = CSVGTPointerHideTimer::NewL( this );
       
   296         iInactivityTimer->After( KSccPointerHideTimerStartAfter );
       
   297         }
       
   298 
       
   299     // Create the timer for blinking Pause
       
   300     if ( iDisplayFlags & ESvgDrawPauseIndicator )
       
   301         {
       
   302 
       
   303         iBlinker = CPeriodic::NewL( CTimer::EPriorityStandard );
       
   304         }   
       
   305 
       
   306     // Create the timer for removal of info note
       
   307     if ( iDisplayFlags & ESvgDisplayErrorNotes)
       
   308         {
       
   309         // Create the timer for removal of info note
       
   310         iNoteRemoverTimer = CPeriodic::NewL( CTimer::EPriorityHigh );
       
   311         }
       
   312 
       
   313     if ( iDisplayFlags & ESvgDisplayErrorNotes )
       
   314         {
       
   315         // Create instance of DRM Helper for checking rights for content   
       
   316         iSvgDrmHelper->CheckRightsAmountL( iContentFileHandle );
       
   317         }
       
   318    
       
   319     //Initialize the backlight time to current time
       
   320     iPreviousBackLightTimeStamp.HomeTime();
       
   321     if(iProgressiveRendering)
       
   322         {
       
   323         iEventHandlerAO = CSvgtEventHandlerAO::NewL( aAppObs, this,
       
   324 RThread().Id());
       
   325         
       
   326         iThreadController = CSvgtThreadController::NewL(this);
       
   327         //Separate thread is created to load the content
       
   328         // set up parameters to thread generate thread, leave if fails
       
   329         TInt result = iMainThread.Create( KSvgThread,
       
   330                                       ( TThreadFunction )LoadSvgContent,
       
   331                                       KDefaultStackSize,
       
   332                                       NULL, this, EOwnerProcess );
       
   333         User::LeaveIfError( result );
       
   334         // log on to thread & requests notification of thread completion
       
   335         iThreadController->IssueThreadMonitorRequest( iMainThread );
       
   336 
       
   337         // give thread low priority
       
   338         iMainThread.SetPriority( EPriorityMuchLess );
       
   339         // resume thread (wake it up sometime after this function returns)
       
   340         iMainThread.Resume();
       
   341         }
       
   342     else
       
   343         {
       
   344         // Start displaying wait note
       
   345         LaunchWaitNoteL( R_QTN_SVGT_WAITING_OPENING );
       
   346    
       
   347         // Load the SVGT content
       
   348         LoadContentL( iContentFileHandle );
       
   349 
       
   350         // Dismiss the wait note
       
   351         DismissWaitNote();
       
   352 
       
   353         TInt lLoadErr = DoHandleLoadingThreadError();
       
   354         if ( lLoadErr != KErrNone )
       
   355             {
       
   356             if ( lLoadErr != KErrNoMemory )
       
   357                 {
       
   358                 // All errors other than memory failure related are
       
   359                 // ignored.
       
   360                 lLoadErr = KErrNone;
       
   361                 }
       
   362             User::Leave( lLoadErr );   
       
   363             }
       
   364        
       
   365         // Do the post load functionality
       
   366         DoPostLoadFuncL();   
       
   367         }
       
   368     if ( aParent && (iDisplayFlags & ESvgWindowOwning ))
       
   369         {
       
   370         CreateWindowL( aParent );
       
   371         }
       
   372 //############################################################
       
   373     // Set the windows size
       
   374     SetRect( lRect );
       
   375 
       
   376     // Activate the window, which makes it ready to be drawn
       
   377     ActivateL();   
       
   378     }
       
   379 
       
   380 
       
   381 // -----------------------------------------------------------------------------
       
   382 // CSVGTCustControl::NewL
       
   383 // Factory function for creating CSVGTCustControl objects.
       
   384 // Returns: CSVGTCustControl* ; Pointer to the created object.
       
   385 //          Leaves if error occurs during creation.
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 EXPORT_C CSVGTCustControl* CSVGTCustControl::NewL(
       
   389     RFile& aFileHandle,         // File Handle for the content
       
   390     MSvgtAppObserver* aAppObs,  // User Implementation of Mixin
       
   391     MSVGTProgressBarDrawImpl* aPBDrawImpl , // Implementation for rendering
       
   392                                             // progress indicator
       
   393 	MSVGTMSKImpl* aMSKImpl,		//Interface for MSK labelling                                          
       
   394     MSvgtApplicationExitObserver* aExitObserver,
       
   395     TBool aProgressiveRendering,
       
   396     const CCoeControl* aParent,                                           
       
   397     TInt aDisplayFlag )
       
   398     {
       
   399     CSVGTCustControl* self = CSVGTCustControl::NewLC( aFileHandle,
       
   400                                                       aAppObs,
       
   401                                                       aPBDrawImpl,
       
   402                                                       aMSKImpl,
       
   403                                                       aExitObserver,
       
   404                                                       aProgressiveRendering,
       
   405                                                       aParent,
       
   406                                                       aDisplayFlag );
       
   407     CleanupStack::Pop( self );
       
   408     return self;
       
   409     }
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // CSVGTCustControl::NewLC
       
   413 // Factory function for creating CSVGTCustControl objects.
       
   414 // Returns: CSVGTCustControl* ; Pointer to the created object.
       
   415 //          Leaves if error occurs during creation.
       
   416 // -----------------------------------------------------------------------------
       
   417 //
       
   418 CSVGTCustControl* CSVGTCustControl::NewLC(
       
   419     RFile& aFileHandle,         // File handle for the content
       
   420     MSvgtAppObserver* aAppObs , // User Implementation of Mixin
       
   421     MSVGTProgressBarDrawImpl* aPBDrawImpl , // Implementation for rendering
       
   422                                             // progress indicator
       
   423 	MSVGTMSKImpl* aMSKImpl,		//Interface for MSK labelling                                            
       
   424     MSvgtApplicationExitObserver* aExitObserver,
       
   425     TBool aProgressiveRendering,
       
   426     const CCoeControl* aParent,                                           
       
   427     TInt aDisplayFlag )
       
   428     {
       
   429     CSVGTCustControl* self = new ( ELeave ) CSVGTCustControl( aFileHandle,
       
   430                                                              
       
   431 aProgressiveRendering,
       
   432                                                               aDisplayFlag );
       
   433     CleanupStack::PushL( self );
       
   434     self->ConstructL( aAppObs, aPBDrawImpl ,aMSKImpl, aExitObserver, aParent );
       
   435     return self;
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CSVGTCustControl::~CSVGTCustControl
       
   440 // Destructor
       
   441 // -----------------------------------------------------------------------------
       
   442 //
       
   443 CSVGTCustControl::~CSVGTCustControl()
       
   444     {
       
   445     
       
   446 #ifdef RD_SVGT_AUDIO_SUPPORT
       
   447     // if non volume key is pressed <br>
       
   448     if(iVolumePopup)
       
   449         {
       
   450         iVolumePopup->CloseVolumePopup();
       
   451         delete iVolumePopup;
       
   452         iVolumePopup=NULL;
       
   453         }
       
   454     if(iSelector)
       
   455         {
       
   456         delete iSelector;
       
   457         iInterfaceSelector=NULL;
       
   458         iSelector=NULL; //iSelector has been deleted by "delete iInterfaceSelector"
       
   459         }
       
   460     
       
   461 #endif //RD_SVGT_AUDIO_SUPPORT       
       
   462 
       
   463     if(iProgressiveRendering)
       
   464         {
       
   465         TInt count = 0;
       
   466         if(iSvgModule)
       
   467             {
       
   468             if ( iSvgModule->IsLoading() )
       
   469                 {
       
   470                 iSvgModule->CancelLoad();
       
   471                 do
       
   472                     {
       
   473                     User::After( 10 * 1000 ); // milliseconds
       
   474                     }while ( iSvgModule->IsLoading() && count++ < 100 );
       
   475                 }
       
   476             }
       
   477 
       
   478         if(iThreadController)
       
   479             {
       
   480             iThreadController->StopThreadExecution(iMainThread);
       
   481             }
       
   482        
       
   483         iMainThread.Kill(KErrNone);
       
   484         iMainThread.Close();
       
   485 
       
   486         delete iEventHandlerAO;
       
   487        
       
   488         delete iThreadController;
       
   489         }
       
   490        
       
   491     // Hyperlink Handler
       
   492     if ( iSvgModule )
       
   493         {
       
   494         iSvgModule->RemoveHyperlinkListener( 
       
   495         	static_cast< MSvgHyperlinkListener*> ( this ) );
       
   496         iSvgModule->RemoveListener( static_cast<MSvgLoadingListener*>(this),
       
   497                                                 ESvgLoadingListener);
       
   498         iSvgModule->RemoveListener( static_cast<MSvgLoadingListener*>(this),
       
   499                                                 ESvgHyperlinkListener);
       
   500         iSvgModule->RemoveListener( static_cast<MSvgInteractiveElementListener*>(this), ESvgInteractiveElementListener);
       
   501         }
       
   502          
       
   503     // SVG Engine
       
   504     delete iSvgModule;
       
   505    
       
   506     // Free the icons
       
   507     FreeIcons();
       
   508    
       
   509     // Screen Bitmaps + Masks
       
   510     delete iSVGTBitMap;
       
   511     delete iSVGTBitMapMask;
       
   512    
       
   513     // delete SVG drmHelper
       
   514     delete iSvgDrmHelper;
       
   515 
       
   516    
       
   517    // Delete the arrays
       
   518    iBoundBoxArray.Close();
       
   519    iFoundTextArray.Close();
       
   520    iTextElemIdArray.Close();
       
   521 
       
   522     // Reset App Observer
       
   523     iAppObserver = NULL;
       
   524    
       
   525     // Reset Progress Bar Draw Implementation Callback
       
   526     iProgressBarDrawImpl = NULL;
       
   527     // Current Match is invalid
       
   528     iIsSearchStrValid = EFalse;
       
   529     iCurSearchMatchId = KSccConstZero;
       
   530 
       
   531     // Backlight Timer
       
   532 
       
   533     // Progress Indicator Timer
       
   534     delete iProgressBarTimer;
       
   535         
       
   536     // Pointer Inactivity Hide Timer
       
   537     delete iInactivityTimer;
       
   538 
       
   539     // Pause Blink Timer
       
   540     delete iBlinker;
       
   541    
       
   542     // Framebuffer  Bitmap
       
   543     delete iSVGTFrameBufBitMap;
       
   544    
       
   545     // Framebuffer Bitmap Context
       
   546     delete iSVGTFrameBufContext;
       
   547    
       
   548     // Framebuffer Bitmap Device
       
   549     delete iSVGTFrameBufDevice;
       
   550    
       
   551     // Delete the wait dialog
       
   552     delete iWaitDialog;
       
   553    
       
   554     // Delete the info note
       
   555     delete iInfoNote;
       
   556    
       
   557     // Delete the info note remover timer
       
   558     delete iNoteRemoverTimer;
       
   559    
       
   560     // Close the System RProperty
       
   561     iSystemState.Close(); 
       
   562    
       
   563     // Reset the loading thread error
       
   564     iLoadingThreadError = NULL;
       
   565    
       
   566     // Reset the exit observer
       
   567     iExitObserver = NULL;
       
   568    
       
   569     }
       
   570 
       
   571 // -----------------------------------------------------------------------------
       
   572 // CSVGTCustControl::ProcessViewerCommandL
       
   573 // Process commands for handling SVGT content
       
   574 // -----------------------------------------------------------------------------
       
   575 //
       
   576 void CSVGTCustControl::ProcessViewerCommandL( TInt aCommandId ) // Command ID
       
   577                                                                 // be processed
       
   578     {
       
   579    //Set the flag to indicate that the selection key is for options selection
       
   580     iViewerCommand=ETrue;
       
   581     switch( aCommandId )
       
   582         {
       
   583         case ESvgtDlgSaveCommand:
       
   584             break;
       
   585         case ESvgtDlgZoomInCommand:
       
   586             // Perform Zoom operation
       
   587             iSvgModule->Zoom( KSccZoomInFactor );
       
   588             // Do a Redraw
       
   589             iSvgModule->Redraw();
       
   590             //dummy mouse move
       
   591             iSvgModule->MouseMove( iPointerX, iPointerY );
       
   592             iZoomLevel++;
       
   593             UpdatePointer();
       
   594             break;
       
   595         case ESvgtDlgZoomOutCommand:
       
   596             if ( iZoomLevel > KSccConstZero )
       
   597                 {
       
   598                 iZoomLevel--;
       
   599                 // Perform Zoom operation
       
   600                 iSvgModule->Zoom( KSccZoomOutFactor );
       
   601                 // Do a Redraw
       
   602                 iSvgModule->Redraw();
       
   603                 //dummy mouse move
       
   604                 iSvgModule->MouseMove( iPointerX, iPointerY );
       
   605                 UpdatePointer();
       
   606                 }
       
   607             break;
       
   608         case ESvgtDlgZoomOptimalCommand:
       
   609             if ( iZoomLevel != KSccConstZero )
       
   610                 {
       
   611                 //This is to nullify only the zooming effect
       
   612                 //Other transformations(panning, rotation) won't be restored
       
   613                 TReal reducedFactor = 0.0;
       
   614                 Math::Pow(reducedFactor, KSccZoomOutFactor, iZoomLevel);
       
   615                 iZoomLevel = KSccConstZero;
       
   616                 iSvgModule->Zoom(reducedFactor);
       
   617                 iSvgModule->Redraw();
       
   618                 }
       
   619             break;
       
   620         case ESvgtDlgSelectTextCommand:
       
   621             {
       
   622             if ( iEnableTextOps )
       
   623                 {
       
   624                 HBufC* lStrPtr = HBufC::NewLC( KMaxEditorTextLength ); 
       
   625                 TPtr lPtr = lStrPtr->Des();
       
   626                
       
   627                 if ( iCurrentTextElementId )
       
   628                     {
       
   629                     if ( iIsCurrentTextElement )
       
   630                         {
       
   631                         iSvgModule->GetTextForTextElement(
       
   632                             iCurrentTextElementId,
       
   633                             iIsTextEditOn,
       
   634                             lPtr );
       
   635                         }
       
   636                         else
       
   637                             {
       
   638                             iSvgModule->GetTextForTextAreaElement(
       
   639                                 iCurrentTextElementId,
       
   640                                 iIsTextEditOn,
       
   641                                 lPtr );
       
   642                             }
       
   643                    
       
   644                     DoTextSelectionL( lPtr );
       
   645                     }
       
   646                 CleanupStack::PopAndDestroy( lStrPtr );                   
       
   647                 }
       
   648             }
       
   649             break;
       
   650         case ESvgtDlgEditTextCommand:
       
   651             {
       
   652             if ( iEnableTextOps )
       
   653                 {
       
   654                 if ( iCurrentTextElementId )
       
   655                     {
       
   656                     HBufC* lStrPtr = HBufC::NewLC( KMaxEditorTextLength ); 
       
   657                     TPtr lPtr = lStrPtr->Des();
       
   658 
       
   659                     if ( iIsCurrentTextElement )
       
   660                         {
       
   661                         iSvgModule->GetTextForTextElement(
       
   662                             iCurrentTextElementId,
       
   663                             iIsTextEditOn,
       
   664                             lPtr );
       
   665                         }
       
   666                         else
       
   667                             {
       
   668                             iSvgModule->GetTextForTextAreaElement(
       
   669                                 iCurrentTextElementId,
       
   670                                 iIsTextEditOn,
       
   671                                 lPtr );
       
   672                             }
       
   673                    
       
   674                    
       
   675                     DoTextEditingL( iIsCurrentTextElement,
       
   676                                     iCurrentTextElementId,
       
   677                                     lPtr );
       
   678                     CleanupStack::PopAndDestroy( lStrPtr );                               
       
   679                     }
       
   680                 }
       
   681             }
       
   682             break;
       
   683         case ESvgtDlgPlayCommand:
       
   684             ProcessPlayCmd();
       
   685             break;
       
   686         case ESvgtDlgPauseCommand:
       
   687             ProcessPauseCmd();
       
   688             break;
       
   689         case ESvgtDlgStopCommand:
       
   690             ProcessStopCmd();
       
   691             break;
       
   692 //TOUCH SUPPORT START   
       
   693 #ifdef RD_SVGT_AUDIO_SUPPORT
       
   694         case ESvgtDlgSetVolumeCommand:
       
   695             {
       
   696             // The volume popup will close itself after 1s 
       
   697             // unless another call to ShowVolumePopupL() is made
       
   698             if(iIsVolumeMuted)
       
   699             	{
       
   700             	// Set the volume of pop to zero if muted.
       
   701             	iVolumePopup->SetValue( 0 );
       
   702             	iVolumePopup->ShowVolumePopupL();
       
   703             	}
       
   704             else
       
   705             	{
       
   706             	// If not muted, then show the previous volume
       
   707             	iVolumePopup->SetValue( iPrevVolume );
       
   708             	iVolumePopup->ShowVolumePopupL(); 
       
   709             	}
       
   710             break;
       
   711             }
       
   712 #endif //RD_SVGT_AUDIO_SUPPORT
       
   713 //TOUCH SUPPORT END
       
   714         case ESvgtDlgLoopOnCommand:
       
   715             if ( IsContentFinite() )
       
   716                 {
       
   717                 iIsLoopOn = ETrue;
       
   718                 }
       
   719             break;
       
   720         case ESvgtDlgLoopOffCommand:
       
   721             if ( IsContentFinite() )
       
   722                 {
       
   723                 iIsLoopOn = EFalse;
       
   724                 }
       
   725             break;
       
   726         case ESvgtDlgFindTextCommand:
       
   727             ProcessFindTextCmdL();
       
   728             break;
       
   729         case ESvgtDlgFullScreenCommand: // Fall Through
       
   730         case ESvgtDlgNormalScreenCommand:
       
   731             // No processing here. The Command is processed by the dialog.
       
   732             // Dialog sets the size of the control, because of which
       
   733             // SizeChanged() of control is called. This queries the
       
   734             // layout rectangles and recreates the framebuffer.
       
   735             break;
       
   736         case ESvgtDlgViewDetailsCommand:
       
   737             {
       
   738             CSvgtFileViewDetailsDialog* fileDetailsDialog =
       
   739                 CSvgtFileViewDetailsDialog::NewL();
       
   740             fileDetailsDialog->ExecuteLD( iContentFileHandle );
       
   741 
       
   742             break;
       
   743             }
       
   744         case ESvgtDlgAngle90:
       
   745             {
       
   746             DoRotation( ERotationAngle90 );
       
   747             }
       
   748             break;
       
   749         case ESvgtDlgAngle180:
       
   750             {
       
   751             DoRotation( ERotationAngle180 );
       
   752             }
       
   753             break;
       
   754         case ESvgtDlgAngle270:
       
   755             {
       
   756             DoRotation( ERotationAngle270 );
       
   757             }
       
   758             break;
       
   759         case ESvgtDlgHelpCommand:
       
   760             break;
       
   761         default:
       
   762             break;
       
   763         }
       
   764     if(iMSKImpl && !iPreviewMode)
       
   765     	{
       
   766     	TRAP_IGNORE(SetMSKLabelL());
       
   767     	}
       
   768 }
       
   769 // -----------------------------------------------------------------------------
       
   770 // CSVGTCustControl::GetCurrentZoomLevel
       
   771 // Get function for current zoom level. Zoom level is the number of times the
       
   772 // user has zoomed in.
       
   773 // -----------------------------------------------------------------------------
       
   774 //
       
   775 void CSVGTCustControl::GetCurrentZoomLevel(
       
   776     TInt& aZoomLevel ) const  // Current Zoom Level
       
   777     {
       
   778     aZoomLevel = iZoomLevel;
       
   779     }
       
   780 
       
   781 // -----------------------------------------------------------------------------
       
   782 // CSVGTCustControl::GetCurrentAnimState
       
   783 // Get function for current animation state
       
   784 // -----------------------------------------------------------------------------
       
   785 //
       
   786 void CSVGTCustControl::GetCurrentAnimState(
       
   787     TSvgtViewerAnimStatus& aAnimState )  const // Playing/Paused/Stopped
       
   788     {
       
   789     aAnimState = iAnimState;
       
   790     }
       
   791 
       
   792 // -----------------------------------------------------------------------------
       
   793 // CSVGTCustControl::GetCurrentFullScreenStatus
       
   794 // Get function for current viewing mode.
       
   795 // -----------------------------------------------------------------------------
       
   796 //
       
   797 void CSVGTCustControl::GetCurrentFullScreenStatus(
       
   798     TBool& aIsFullScreenOn )  const //  Full Screen( ETrue )/Normal( EFalse )
       
   799     {
       
   800     aIsFullScreenOn = iIsFullScreenOn;
       
   801     }
       
   802 // -----------------------------------------------------------------------------
       
   803 // CSVGTCustControl::GetCurrentLoopStatus
       
   804 // Get function for current loop mode.
       
   805 // -----------------------------------------------------------------------------
       
   806 //
       
   807 void CSVGTCustControl::GetCurrentLoopStatus(
       
   808     TBool& aIsLoopOn )  const //  Loop On( ETrue )/Loop Off( EFalse )
       
   809     {
       
   810     aIsLoopOn = iIsLoopOn;
       
   811     }
       
   812 
       
   813 // -----------------------------------------------------------------------------
       
   814 // CSVGTCustControl::GetNormalScreenLayoutRect
       
   815 // Gets the normal screen layout rectangle for control from LAF.
       
   816 // -----------------------------------------------------------------------------
       
   817 //
       
   818 void CSVGTCustControl::GetNormalScreenLayoutRect(
       
   819     TRect& aRect )  const // Rectangle specifying extent of control
       
   820     {
       
   821     // Get parent client rect.
       
   822     TRect myRect = iEikonEnv->EikAppUi()->ClientRect();
       
   823    
       
   824     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   825         {
       
   826         TAknLayoutRect lNormalLayoutRect;
       
   827         lNormalLayoutRect.LayoutRect( myRect,
       
   828             AknLayoutScalable_Apps::main_viewer_pane( 0 ) ); // Normal Screen
       
   829         aRect = lNormalLayoutRect.Rect();
       
   830         }
       
   831         else
       
   832             {
       
   833             aRect = myRect;
       
   834             }
       
   835     }
       
   836 
       
   837 // -----------------------------------------------------------------------------
       
   838 // CSVGTCustControl::IsLoopAllowed
       
   839 // Indicates whether the Loop feature is allowed for the Control.
       
   840 // -----------------------------------------------------------------------------
       
   841 //
       
   842 TBool CSVGTCustControl::IsLoopAllowed()  const
       
   843     {
       
   844     return ( IsContentFinite() );
       
   845     }
       
   846 
       
   847 // -----------------------------------------------------------------------------
       
   848 // CSVGTCustControl::IsAnimationPresent
       
   849 //  Finds whether the content has any animations
       
   850 // @return TBool -  ETrue indicates content contains animations,
       
   851 //                  EFalse otherwise
       
   852 // -----------------------------------------------------------------------------
       
   853 //
       
   854 TBool  CSVGTCustControl::IsAnimationPresent() const
       
   855     {
       
   856     return ( iAnimationStatus != ESvgNoAnimationsPresent );
       
   857     }
       
   858 
       
   859 // -----------------------------------------------------------------------------
       
   860 // CSVGTCustControl::IsContentFinite
       
   861 //  Finds whether the content is of finite duration.
       
   862 // @return TBool -  ETrue indicates Finite Duration,
       
   863 //                  EFalse otherwise
       
   864 // -----------------------------------------------------------------------------
       
   865 //
       
   866 TBool  CSVGTCustControl::IsContentFinite() const
       
   867     {
       
   868     // Does it not have any infinite repeat count
       
   869     // animations
       
   870     if ( ( iDuration != 0 ) &&
       
   871         ( iDuration != KSccIndefiniteDur ) )
       
   872         {
       
   873         return ETrue;
       
   874         }
       
   875     // Content contains atlease one infinite animation
       
   876     return EFalse;
       
   877     }
       
   878 
       
   879 // -----------------------------------------------------------------------------
       
   880 // CSVGTCustControl::IsProcessDone
       
   881 // Returns ETrue if loading is done.
       
   882 // -----------------------------------------------------------------------------
       
   883 //
       
   884 TBool CSVGTCustControl::IsProcessDone() const
       
   885     {
       
   886     return iIsLoadingDone;
       
   887     }
       
   888    
       
   889 // -----------------------------------------------------------------------------
       
   890 // CSVGTCustControl::SetCurrentFullScreenStatus
       
   891 // Set function for current viewing mode.
       
   892 // -----------------------------------------------------------------------------
       
   893 //
       
   894 void CSVGTCustControl::SetCurrentFullScreenStatus(
       
   895     TBool aIsFullScreenOn )  //  Full Screen( ETrue )/Normal( EFalse )
       
   896     {
       
   897     iIsFullScreenOn = aIsFullScreenOn;
       
   898     }   
       
   899 // -----------------------------------------------------------------------------
       
   900 // CSVGTCustControl::HandleApplicationForegroundEvent
       
   901 // Does the handling of foreground event occurring.
       
   902 // -----------------------------------------------------------------------------
       
   903 //
       
   904 void CSVGTCustControl::HandleApplicationForegroundEvent( TBool aForeground )
       
   905     { 
       
   906     iIsForeground = aForeground;
       
   907     if ( !aForeground )
       
   908         {
       
   909         // Application going into background, pause presentation.
       
   910         // We need to check first if there are any
       
   911         // animations at all in this presentation and pause
       
   912         // makes sense or not.
       
   913         if ( IsAnimationPresent() && iAnimState == ESvgAnimPlayingState )
       
   914             {
       
   915             TRAPD(errProcessViewerCmd,
       
   916                 ProcessViewerCommandL( ESvgtDlgPauseCommand ));
       
   917            
       
   918             if ( errProcessViewerCmd != KErrNone )
       
   919                 {
       
   920                 // Error occurred , Stop Processing
       
   921                 return;
       
   922                 }
       
   923                
       
   924             if ( iBlinker->IsActive() )               
       
   925                 {
       
   926                 iBlinker->Cancel();
       
   927                 iPauseIconVisible = ETrue;
       
   928                 }
       
   929             }
       
   930         }
       
   931     else
       
   932         {
       
   933         // Application coming into foreground.
       
   934         // May need to start a flashing pause indicator so
       
   935         // that user would come to know presentation is paused.
       
   936         if ( IsAnimationPresent() && iAnimState == ESvgAnimPausedState )
       
   937             {
       
   938             if ( iPauseIconVisible )
       
   939                 {
       
   940                 ShowPauseIcon( ETrue );
       
   941                 }
       
   942             }
       
   943         // Perform a redraw to avoid corrupted bitmap
       
   944         iSvgModule->Redraw();
       
   945         }
       
   946     }
       
   947 
       
   948 // -----------------------------------------------------------------------------
       
   949 // CSVGTCustControl::IsTextSelectOn
       
   950 // Indicates whether the "Select Text" menu item be displayed.
       
   951 // -----------------------------------------------------------------------------
       
   952 //
       
   953 TBool CSVGTCustControl::IsTextSelectOn() const
       
   954     {
       
   955     return ( iIsTextSelectOn );
       
   956     }
       
   957 
       
   958 // -----------------------------------------------------------------------------
       
   959 // CSVGTCustControl::IsTextEditOn
       
   960 // Indicates whether the "Edit Text" menu item be displayed.
       
   961 // -----------------------------------------------------------------------------
       
   962 //
       
   963 TBool CSVGTCustControl::IsTextEditOn() const
       
   964     {
       
   965     return ( iIsTextEditOn );
       
   966     }
       
   967 
       
   968 // -----------------------------------------------------------------------------
       
   969 // CSVGTCustControl::IsTextContentChanged
       
   970 // Indicates whether the text in the content was modified.
       
   971 // -----------------------------------------------------------------------------
       
   972 //
       
   973 TBool CSVGTCustControl::IsTextContentChanged() const
       
   974     {
       
   975     return ( iIsTextChanged );
       
   976     }
       
   977 
       
   978 // -----------------------------------------------------------------------------
       
   979 // CSVGTCustControl::SaveComplete
       
   980 // Used to perform any cleanup once save is complete.
       
   981 // -----------------------------------------------------------------------------
       
   982 //
       
   983 void CSVGTCustControl::SaveComplete( const TInt aError )
       
   984     {
       
   985     if ( !aError )
       
   986         {
       
   987         iIsTextChanged = EFalse;
       
   988        
       
   989         //Upadate the MSK label once saving is done
       
   990         if(iMSKImpl && !iPreviewMode)
       
   991         	{
       
   992         	TRAP_IGNORE(SetMSKLabelL());	
       
   993         	}
       
   994        
       
   995         }
       
   996     }
       
   997    
       
   998 // -----------------------------------------------------------------------------
       
   999 // CSVGTCustControl::UpdateScreen
       
  1000 // Implements MSvgRequestObserver::UpdateScreen.
       
  1001 // -----------------------------------------------------------------------------
       
  1002 //
       
  1003 void CSVGTCustControl::UpdateScreen()
       
  1004     {
       
  1005     if ( IsContentFinite() )
       
  1006         {
       
  1007         ResetBacklightTime();    
       
  1008         }
       
  1009     if ( iSVGTBitMapMask )
       
  1010         {
       
  1011         // Generate the mask for the bitmap
       
  1012         iSvgModule->GenerateMask( iSVGTBitMapMask );
       
  1013         }
       
  1014 	iSvgModule->IsPanPossibleFourWay(iPanLt,iPanRt,iPanUp,iPanDn);
       
  1015        
       
  1016     // Find the new position of bounding boxes if
       
  1017     // Find Text was performed
       
  1018     if ( iIsSearchStrValid )
       
  1019         {
       
  1020         CalcFindTextBBox();
       
  1021         }
       
  1022     if ( iIsLoadingDone )
       
  1023         {
       
  1024         DrawNow();
       
  1025         }   
       
  1026     }
       
  1027 
       
  1028 // -----------------------------------------------------------------------------
       
  1029 // CSVGTCustControl::ScriptCall
       
  1030 // Implements MSvgRequestObserver::ScriptCall.
       
  1031 // -----------------------------------------------------------------------------
       
  1032 //
       
  1033 TBool CSVGTCustControl::ScriptCall( const TDesC& /*aScript*/,
       
  1034                                   CSvgElementImpl* /*aCallerElement*/ )
       
  1035     {
       
  1036     return EFalse;
       
  1037     }
       
  1038 
       
  1039 
       
  1040 // -----------------------------------------------------------------------------
       
  1041 // CSVGTCustControl::FetchImage
       
  1042 // Implements MSvgRequestObserver::FetchImage. It executes asynchronously.
       
  1043 // To fetch the image each time the KErrGeneral should be return.
       
  1044 // -----------------------------------------------------------------------------
       
  1045 //   
       
  1046 TInt  CSVGTCustControl::FetchImage( const TDesC& aUri,
       
  1047              RFs& aSession, RFile& aFileHandle )
       
  1048     {
       
  1049 
       
  1050     TInt ret = 0;
       
  1051 
       
  1052     iImageFileType = ImageFileType(aUri);
       
  1053     if ( iAppObserver )
       
  1054         {
       
  1055         ret = iAppObserver->FetchImage( aUri, aSession, aFileHandle ) ;
       
  1056         }
       
  1057     else
       
  1058         {
       
  1059         return KErrNotFound;
       
  1060         }
       
  1061 
       
  1062     if ( !iFetchImageError )
       
  1063         {
       
  1064         iFetchImageError = ret;
       
  1065         }
       
  1066 
       
  1067     if(iImageFileType == ELocalImageFile)
       
  1068         {
       
  1069         return ret;
       
  1070         }
       
  1071     else
       
  1072         {
       
  1073         return KErrGeneral;
       
  1074         }
       
  1075     }
       
  1076 
       
  1077 TInt CSVGTCustControl::FetchFont( const TDesC& aUri ,
       
  1078                                     RFs& aSession , RFile& aFileHandle )
       
  1079     {
       
  1080     _LIT(KPath, "C:\\data\\images\\");
       
  1081     TBuf<KMaxPath> fileName;
       
  1082     fileName.Copy(KPath);
       
  1083     fileName.Append(aUri);
       
  1084     return aFileHandle.Open( aSession, fileName, EFileShareReadersOnly);
       
  1085     }
       
  1086 	  
       
  1087 // -----------------------------------------------------------------------------
       
  1088 // CSVGTCustControl:: GetSmilFitValue
       
  1089 // Implements the MSvgRequestObserver::GetSmilFitValue.
       
  1090 // -----------------------------------------------------------------------------
       
  1091 //
       
  1092 void CSVGTCustControl::GetSmilFitValue( TDes& aSmilValue )
       
  1093     {
       
  1094     aSmilValue.Copy( KSccSmilFitValue );
       
  1095     }
       
  1096 
       
  1097 // -----------------------------------------------------------------------------
       
  1098 // CSVGTCustControl::UpdatePresentation
       
  1099 // Implements MSvgRequestObserver::UpdatePresentation.
       
  1100 // -----------------------------------------------------------------------------
       
  1101 //
       
  1102 void  CSVGTCustControl::UpdatePresentation( const TInt32&  aNoOfAnimation )
       
  1103     {
       
  1104     if ( iTotalNumerOfAnimation == KSccConstMinusOne )
       
  1105         {
       
  1106         if ( aNoOfAnimation == KSccConstZero )
       
  1107             {
       
  1108             iAnimationStatus = ESvgNoAnimationsPresent;
       
  1109             return;
       
  1110             }
       
  1111         else
       
  1112             {
       
  1113             // First time Update Presentation is called
       
  1114             // and animations are present.
       
  1115             iTotalNumerOfAnimation = aNoOfAnimation;
       
  1116             }
       
  1117         }
       
  1118     else
       
  1119         {
       
  1120         iTotalNumerOfAnimation -= aNoOfAnimation;
       
  1121         }
       
  1122 
       
  1123     if ( iTotalNumerOfAnimation == KSccConstZero )
       
  1124         {
       
  1125         iAnimationStatus = ESvgAllAnimationsComplete;
       
  1126         return;
       
  1127         }
       
  1128 
       
  1129     iAnimationStatus =  ESvgAnimationsNotComplete;
       
  1130     }
       
  1131 
       
  1132 // -----------------------------------------------------------------------------
       
  1133 // CSVGTCustControl::OfferKeyEventL
       
  1134 // Handles Key events by reimplementing CCoeControl::OfferKeyEventL.
       
  1135 // Returns:
       
  1136 //      EKeyWasConsumed: If this control uses this key.
       
  1137 //      EKeyWasNotConsumed: Otherwise.
       
  1138 // -----------------------------------------------------------------------------
       
  1139 //
       
  1140 TKeyResponse CSVGTCustControl::OfferKeyEventL(
       
  1141     const TKeyEvent& aKeyEvent,  // Key Event
       
  1142     TEventCode aType )           // Event Code
       
  1143     {
       
  1144    
       
  1145     TKeyResponse retVal = EKeyWasNotConsumed;
       
  1146     TInt keyScanCode = aKeyEvent.iScanCode;
       
  1147     TInt keyCode = aKeyEvent.iCode;
       
  1148     switch ( aType )
       
  1149         {
       
  1150         case EEventKeyDown:
       
  1151             {
       
  1152             // reset the repeat count
       
  1153             iKeyRepeatCount = 0;
       
  1154             // Reset the select cause
       
  1155             iSelectCause = ESvgInvalidSelectCause;
       
  1156             // UI Spec: Pointer should be displayed when
       
  1157             // Select Key or Pointer is moved
       
  1158             if ( keyScanCode == EStdKeyEnter ||
       
  1159                  keyScanCode == EStdKeyDevice3 ||
       
  1160                  keyScanCode == EStdKeyUpArrow ||
       
  1161                  keyScanCode == EStdKeyDownArrow ||
       
  1162                  keyScanCode == EStdKeyLeftArrow ||
       
  1163                  keyScanCode == EStdKeyRightArrow )
       
  1164                 {
       
  1165                 if ( !iInactivityTimer )
       
  1166                     {
       
  1167                     // Ignore subsequent key events as the pointer should be
       
  1168                     // displayed and no event is to be processed until key
       
  1169                     // up event is received.
       
  1170                     iIgnorePointerKeyEvent = ETrue;
       
  1171                     }
       
  1172                 if( keyScanCode != EStdKeyDevice3 && keyScanCode != EStdKeyEnter && !iIsPointerDisplayed )
       
  1173                 	{
       
  1174                 	iScrollKey=ETrue; //needed to check when the pointer hidden
       
  1175                 	                  // and scroll key is pressed.
       
  1176                    	}
       
  1177                 
       
  1178                
       
  1179                 if( ( keyScanCode == EStdKeyDevice3 || keyScanCode == EStdKeyEnter )&&!iIsPointerDisplayed )
       
  1180                     {
       
  1181                     // Key has been lifted,
       
  1182                     // Reset the Pointer Delta Values
       
  1183                     iPointerDx = KSccConstZero;
       
  1184                     iPointerDy = KSccConstZero;
       
  1185 
       
  1186                     // UI Spec: Pointer should be hidden after 15 sec of
       
  1187                     // user inactivity
       
  1188                     if ( iInactivityTimer )
       
  1189                         {
       
  1190                         // Should not be the case!
       
  1191                         delete iInactivityTimer;
       
  1192                         iInactivityTimer = NULL;
       
  1193                         }
       
  1194                     iInactivityTimer = CSVGTPointerHideTimer::NewL( this );
       
  1195                     iInactivityTimer->After( KSccPointerHideTimerStartAfter );
       
  1196                     }
       
  1197                 if(keyScanCode == EStdKeyDevice3 || keyScanCode == EStdKeyEnter )    
       
  1198                     {
       
  1199                     iDownKeyOccurred = ETrue;
       
  1200                     iSvgModule->MouseDown( iPointerX, iPointerY );    
       
  1201                     }
       
  1202                 SetPointerDisplayStatusAndRedraw( ETrue );
       
  1203                 
       
  1204                 retVal = EKeyWasConsumed;
       
  1205                 }
       
  1206             }
       
  1207             break;
       
  1208         case EEventKeyUp:
       
  1209             {
       
  1210             if ( keyScanCode == EStdKeyEnter ||
       
  1211                  keyScanCode == EStdKeyDevice3 ||
       
  1212                  keyScanCode == EStdKeyUpArrow ||
       
  1213                  keyScanCode == EStdKeyDownArrow ||
       
  1214                  keyScanCode == EStdKeyLeftArrow ||
       
  1215                  keyScanCode == EStdKeyRightArrow )
       
  1216                 {
       
  1217                 // Key has been lifted,
       
  1218                 // Reset the Pointer Delta Values
       
  1219                 iPointerDx = KSccConstZero;
       
  1220                 iPointerDy = KSccConstZero;
       
  1221 
       
  1222                 // UI Spec: Pointer should be hidden after 15 sec of
       
  1223                 // user inactivity
       
  1224                 if ( iInactivityTimer )
       
  1225                     {
       
  1226                     // Should not be the case!
       
  1227                     delete iInactivityTimer;
       
  1228                     iInactivityTimer = NULL;
       
  1229                     }
       
  1230                 iInactivityTimer = CSVGTPointerHideTimer::NewL( this );
       
  1231                 iInactivityTimer->After( KSccPointerHideTimerStartAfter );
       
  1232 
       
  1233                 // Once the pointer is un-hidden, Ignore subsequent key events
       
  1234                 // and no event is to be processed until key up event is received.
       
  1235                 if ( iIgnorePointerKeyEvent )
       
  1236                     {
       
  1237                     iIgnorePointerKeyEvent = EFalse;
       
  1238                     retVal = EKeyWasConsumed;
       
  1239                     TRAP_IGNORE(SetMSKLabelL());
       
  1240                     }
       
  1241                 else
       
  1242                     {
       
  1243                     // Assume key will be consumed
       
  1244                     retVal = EKeyWasConsumed;
       
  1245                    
       
  1246                     if( ( keyScanCode == EStdKeyDevice3 || keyScanCode == EStdKeyEnter )&& iDownKeyOccurred)
       
  1247                         {
       
  1248                         iSvgModule->MouseUp(iPointerX,iPointerY);    
       
  1249                         iDownKeyOccurred= EFalse;
       
  1250                         }
       
  1251                     }
       
  1252                 
       
  1253                 }                           
       
  1254             }
       
  1255             break;
       
  1256         case EEventKey:
       
  1257             {
       
  1258             retVal = EKeyWasConsumed;
       
  1259             iKeyRepeatCount++;
       
  1260 
       
  1261             // Once the pointer is un-hidden, Ignore subsequent joystick 
       
  1262             // key events and no joystick event is to be processed until 
       
  1263             // key up event is received.
       
  1264             switch ( keyCode /*keyScanCode*/ )
       
  1265                 {
       
  1266                 case KSccZoomInKey: // Zoom In Key
       
  1267                     {
       
  1268                     if ( iKeyRepeatCount == 1 )
       
  1269                         {
       
  1270                         ProcessViewerCommandL( ESvgtDlgZoomInCommand );
       
  1271                         }
       
  1272                      
       
  1273                     break;
       
  1274                     }
       
  1275                 case EKeyUpArrow: // Pointer Up
       
  1276                     {
       
  1277                     if ( iIgnorePointerKeyEvent == EFalse)
       
  1278                         {
       
  1279                         iPointerDx = KSccConstZero;
       
  1280                         iPointerDy -= KSccCursorMinDeltaY;
       
  1281                         }
       
  1282                     break;
       
  1283                     }
       
  1284                 case EKeyDownArrow: // Pointer Down
       
  1285                     if ( iIgnorePointerKeyEvent == EFalse)
       
  1286                         {
       
  1287                         iPointerDx = KSccConstZero;
       
  1288                         iPointerDy += KSccCursorMinDeltaY;
       
  1289                         }
       
  1290                     break;
       
  1291                 case EKeyLeftArrow: // Pointer Left
       
  1292                     if ( iIgnorePointerKeyEvent == EFalse)
       
  1293                         {
       
  1294                         iPointerDx -= KSccCursorMinDeltaX;
       
  1295                         iPointerDy = KSccConstZero;
       
  1296                         }
       
  1297                     break;
       
  1298                 case EKeyRightArrow: // Pointer Right
       
  1299                     if ( iIgnorePointerKeyEvent == EFalse)
       
  1300                         {
       
  1301                         iPointerDx += KSccCursorMinDeltaX;
       
  1302                         iPointerDy = KSccConstZero;
       
  1303                         }
       
  1304                         break;
       
  1305                 case ENumberKey1:    //key 1
       
  1306                     DoRotation(ERotationAngle90);
       
  1307                     break;
       
  1308                 case ENumberKey3:    //key 3
       
  1309                     DoRotation(-ERotationAngle90);
       
  1310                     break;
       
  1311                 case ENumberKey7:    //key 7
       
  1312                     DoRotation(ERotationAngle45);
       
  1313                     break;
       
  1314                 case ENumberKey9:    //key 9
       
  1315                     DoRotation(-ERotationAngle45);
       
  1316                     break;
       
  1317                 case KSccZoomOutKey: // Zoom out key
       
  1318                     // Zoom out if "zoom-out" key was pressed once
       
  1319                     {
       
  1320                     if ( iKeyRepeatCount == 1 )
       
  1321                         {
       
  1322                         ProcessViewerCommandL( ESvgtDlgZoomOutCommand );
       
  1323                         }
       
  1324                     else if ( ( iZoomLevel > 0 ) && ( iKeyRepeatCount == 2 ) )
       
  1325                         {
       
  1326                         ProcessViewerCommandL(ESvgtDlgZoomOptimalCommand );
       
  1327                         }                             
       
  1328                     break;    
       
  1329                     }
       
  1330                 default:
       
  1331                     {
       
  1332                     // Unknown Key
       
  1333                     retVal = EKeyWasNotConsumed;
       
  1334                     }
       
  1335                 }
       
  1336             }
       
  1337             break;
       
  1338         default:
       
  1339             {
       
  1340             // Unknown Key
       
  1341             retVal = EKeyWasNotConsumed;
       
  1342             }
       
  1343             break;
       
  1344         }
       
  1345     if ( ( iPointerDx != KSccConstZero ) ||
       
  1346             ( iPointerDy != KSccConstZero ) )
       
  1347         {
       
  1348         UpdatePointer();
       
  1349         }
       
  1350     return retVal;
       
  1351     }
       
  1352 
       
  1353    
       
  1354 // -----------------------------------------------------------------------------
       
  1355 // CSVGTCustControl::HandleResourceChange
       
  1356 // This function is called by the framework when there is a layout switch/skin
       
  1357 // change
       
  1358 // -----------------------------------------------------------------------------
       
  1359 //
       
  1360 void CSVGTCustControl::HandleResourceChange( TInt aType )
       
  1361     {
       
  1362     if ( aType == KAknsMessageSkinChange )
       
  1363         {
       
  1364         // Recreate the icons
       
  1365         TRAPD( err, CreateIconsL() );
       
  1366         if ( err !=  KErrNone )
       
  1367             {
       
  1368             // No Error Handling done here.
       
  1369             }
       
  1370         // Find Text Highlight Colour
       
  1371         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1372        
       
  1373         // Color is not updated if it not found from the skin
       
  1374         AknsUtils::GetCachedColor(skin, iFindTextHiColor,
       
  1375                                   KAknsIIDQsnHighlightColors,
       
  1376                                   EAknsCIQsnHighlightColorsCG2);
       
  1377         SetSize(Rect().Size());                          
       
  1378         }
       
  1379 
       
  1380     CCoeControl::HandleResourceChange( aType );       
       
  1381     }
       
  1382 
       
  1383        
       
  1384 // -----------------------------------------------------------------------------
       
  1385 // CSVGTCustControl::LinkEntered
       
  1386 // Callback Function called by the engine when the pointer enters a hyperlink
       
  1387 // -----------------------------------------------------------------------------
       
  1388 //
       
  1389 
       
  1390 TBool CSVGTCustControl::LinkEntered( const TDesC& aUri)
       
  1391     {
       
  1392    
       
  1393     CXmlElementImpl* ptr=NULL;
       
  1394    
       
  1395     // Get the elementID
       
  1396     ptr=iSvgModule->GetElementById(iSvgModule->SvgDocument(),aUri);
       
  1397 	
       
  1398 	// Check for "a" element or an element which has animation on
       
  1399 	// mousedown/mouseup 
       
  1400 	if(!ptr)
       
  1401 		{
       
  1402 		iAElement=ETrue;
       
  1403 		iPointerType = ESvgPointerHand;
       
  1404 		// Sets the MSK label
       
  1405         if(iMSKImpl && !iPreviewMode )
       
  1406     	    {
       
  1407     	    TRAP_IGNORE(SetMSKLabelL());	
       
  1408     	    }  
       
  1409 		}
       
  1410     
       
  1411     return ETrue;
       
  1412     }
       
  1413 
       
  1414 // -----------------------------------------------------------------------------
       
  1415 // CSVGTCustControl::LinkExited
       
  1416 // Callback Function called by the engine when the pointer exits a hyperlink
       
  1417 // -----------------------------------------------------------------------------
       
  1418 //
       
  1419 
       
  1420 TBool CSVGTCustControl::LinkExited( const TDesC& /*aUri*/ )
       
  1421     {
       
  1422    
       
  1423     iPointerType = ESvgPointerDefault;
       
  1424    
       
  1425     // Reset the flag for a element
       
  1426     iAElement=EFalse;
       
  1427    
       
  1428     //Set the MSK label
       
  1429     if(iMSKImpl && !iPreviewMode)
       
  1430     	{
       
  1431     	TRAP_IGNORE(SetMSKLabelL());	
       
  1432     	}
       
  1433    
       
  1434     return ETrue;
       
  1435     }
       
  1436 // ---------------------------------------------------------------------------
       
  1437 // CSVGTCustControl::LinkActivated
       
  1438 // Callback Function called by the engine when a hyperlink is activated
       
  1439 // ---------------------------------------------------------------------------
       
  1440 //
       
  1441 
       
  1442 TBool CSVGTCustControl::LinkActivated(
       
  1443     const TDesC& aUri )
       
  1444     {
       
  1445     if (iSelectCause != ESvgInvalidSelectCause )
       
  1446         {
       
  1447         // Ignore this callback as it was already processed.
       
  1448         return ETrue;
       
  1449         }
       
  1450     // Set the cause for select operation as Hyperlink so that
       
  1451     // subsequent events trigerred are ignored.
       
  1452     iSelectCause = ESvgHyperLinkSelectCause;
       
  1453    
       
  1454     if( iAppObserver )
       
  1455         {
       
  1456         if( IsThreadRunning() )
       
  1457             {
       
  1458             CSvgtEventLinkActivated* event = new 
       
  1459                 CSvgtEventLinkActivated( aUri );
       
  1460             iEventHandlerAO->AddEventToList( event );
       
  1461             iEventHandlerAO->MakeRequestComplete( KErrNone );
       
  1462             return ETrue;
       
  1463             }
       
  1464         else
       
  1465             {
       
  1466             return iAppObserver->LinkActivated( aUri );    
       
  1467             }
       
  1468         }
       
  1469     else
       
  1470         {
       
  1471         return EFalse;
       
  1472         }
       
  1473     }
       
  1474 
       
  1475 // --------------------------------------------------------------------
       
  1476 // CSVGTCustControl::LinkActivatedWithShow
       
  1477 // Callback Function called by the engine when a hyperlink with show
       
  1478 // attribute is activated
       
  1479 // --------------------------------------------------------------------
       
  1480 //
       
  1481 TBool CSVGTCustControl::LinkActivatedWithShow(
       
  1482     const TDesC& aUri ,
       
  1483     const TDesC& aShow )
       
  1484     {
       
  1485     if (iSelectCause != ESvgInvalidSelectCause )
       
  1486         {
       
  1487         // Ignore this callback as it was already processed.
       
  1488         return ETrue;
       
  1489         }   
       
  1490     // Set the cause for select operation as Hyperlink so that
       
  1491     // subsequent events trigerred are ignored.
       
  1492     iSelectCause = ESvgHyperLinkSelectCause;
       
  1493     if( iAppObserver )
       
  1494         {
       
  1495         if( IsThreadRunning() )
       
  1496             {
       
  1497             CSvgtEventLinkActivatedWithShow* event = 
       
  1498                 new CSvgtEventLinkActivatedWithShow( aUri, aShow );
       
  1499             iEventHandlerAO->AddEventToList( event );
       
  1500             iEventHandlerAO->MakeRequestComplete( KErrNone );
       
  1501            
       
  1502             return ETrue;
       
  1503             }
       
  1504         else
       
  1505             {
       
  1506             return iAppObserver->LinkActivatedWithShow( aUri, aShow );     
       
  1507             }
       
  1508         }
       
  1509     else
       
  1510         {
       
  1511         return EFalse;
       
  1512         }
       
  1513     }
       
  1514 
       
  1515 // -----------------------------------------------------------------------------
       
  1516 // CSVGTCustControl::CreateBitmapsL
       
  1517 // This function is called to create the bitmaps used by the SVG engine
       
  1518 // for rendering.
       
  1519 // -----------------------------------------------------------------------------
       
  1520 //
       
  1521 void CSVGTCustControl::CreateBitmapsL(
       
  1522     const TSize& aBitmapSize ) // Bitmap Size used to render content
       
  1523     {
       
  1524    
       
  1525     if( iSVGTBitMap && (iSVGTBitMap->SizeInPixels() == aBitmapSize))
       
  1526         {
       
  1527         return ;
       
  1528         }
       
  1529    
       
  1530     TDisplayMode dispMode = iEikonEnv->ScreenDevice()->DisplayMode();
       
  1531     TInt errCode = KErrNone;
       
  1532     // Modes currently supported by SVG engine are:
       
  1533     // EGray2, EColor4K, EColor64K, EColor16M, EColor16MU.
       
  1534     switch ( dispMode )
       
  1535         {
       
  1536         case EGray2:
       
  1537         case EColor16M:
       
  1538             {
       
  1539             break;
       
  1540             }
       
  1541         case EColor16MU:
       
  1542             {
       
  1543             break;
       
  1544             }
       
  1545         default:
       
  1546             {
       
  1547             dispMode = EColor64K;
       
  1548             break;
       
  1549             }
       
  1550         }
       
  1551     // Create the bitmaps using local variables and assign
       
  1552     // to member variable if successful
       
  1553     CFbsBitmap* lTempBitmap = new ( ELeave ) CFbsBitmap();
       
  1554    
       
  1555     // Create the bitmap with size and display mode
       
  1556     errCode = lTempBitmap->Create( aBitmapSize, dispMode );
       
  1557     if ( errCode != KErrNone )
       
  1558         {
       
  1559         delete lTempBitmap;
       
  1560         User::Leave( errCode );
       
  1561         }
       
  1562    
       
  1563     // Check and destroy existing bitmap
       
  1564     if ( iSVGTBitMap )
       
  1565         {
       
  1566         delete iSVGTBitMap;
       
  1567         }
       
  1568    
       
  1569     // Assign newly created bitmap   
       
  1570     iSVGTBitMap = lTempBitmap;
       
  1571    
       
  1572     // Create the bitmap mask
       
  1573     lTempBitmap = new ( ELeave ) CFbsBitmap();
       
  1574    
       
  1575     // Create the bitmap with size and display mode
       
  1576     errCode = lTempBitmap->Create( aBitmapSize, EGray256 );
       
  1577     if ( errCode != KErrNone )
       
  1578         {
       
  1579         delete lTempBitmap;
       
  1580         User::Leave( errCode );
       
  1581         }
       
  1582 
       
  1583     // Check and destroy existing bitmap
       
  1584     if ( iSVGTBitMapMask )
       
  1585         {
       
  1586         delete iSVGTBitMapMask;
       
  1587         }
       
  1588    
       
  1589     // Assign newly created bitmap
       
  1590     iSVGTBitMapMask = lTempBitmap;
       
  1591        
       
  1592     // Create the Framebuffer Bitmap
       
  1593     lTempBitmap = new ( ELeave ) CFbsBitmap();
       
  1594    
       
  1595     // Create the bitmap with size and display mode
       
  1596     errCode = lTempBitmap->Create( aBitmapSize, dispMode );
       
  1597     if ( errCode != KErrNone )
       
  1598         {
       
  1599         delete lTempBitmap;
       
  1600         User::Leave( errCode );
       
  1601         }
       
  1602 
       
  1603     // Check and destroy existing bitmap
       
  1604     if ( iSVGTFrameBufBitMap  )
       
  1605         {
       
  1606         delete iSVGTFrameBufBitMap;
       
  1607         }
       
  1608    
       
  1609     // Assign newly created bitmap   
       
  1610     iSVGTFrameBufBitMap = lTempBitmap;
       
  1611        
       
  1612     // Create the Bitmap Device and Contexts, used to reduce the number
       
  1613     // of interactions with the windows server
       
  1614     CFbsBitmapDevice* lTempBitmapDev = CFbsBitmapDevice::NewL(
       
  1615             iSVGTFrameBufBitMap );
       
  1616    
       
  1617     CFbsBitGc* lTempBitmapCtx = NULL;
       
  1618     // Create framebuffer context
       
  1619     errCode = lTempBitmapDev->CreateContext( lTempBitmapCtx );
       
  1620     if ( errCode != KErrNone )
       
  1621         {
       
  1622         delete lTempBitmapDev;
       
  1623         User::Leave( errCode );
       
  1624         }
       
  1625    
       
  1626     // Check and destroy existing bitmap device
       
  1627     if ( iSVGTFrameBufDevice )
       
  1628         {
       
  1629         delete iSVGTFrameBufDevice;
       
  1630         }
       
  1631    
       
  1632     // Check and destroy existing bitmap context
       
  1633     if ( iSVGTFrameBufContext )
       
  1634         {
       
  1635         delete iSVGTFrameBufContext;
       
  1636         }
       
  1637    
       
  1638     // Assign newly created bitmap device
       
  1639     iSVGTFrameBufDevice = lTempBitmapDev;
       
  1640     iSVGTFrameBufContext = lTempBitmapCtx;
       
  1641     }
       
  1642 // -----------------------------------------------------------------------------
       
  1643 // CSVGTCustControl::CreateIconsL
       
  1644 // This function is called to create the icons used by the control.
       
  1645 // -----------------------------------------------------------------------------
       
  1646 //
       
  1647 void CSVGTCustControl::CreateIconsL()
       
  1648     {
       
  1649     // Skin instance
       
  1650     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1651 
       
  1652     // Cleanup the old icons.
       
  1653     FreeIcons();
       
  1654    
       
  1655     // Construct the MBM file name
       
  1656     TParse parse;
       
  1657     parse.Set( KSccIconFile, &KDC_APP_BITMAP_DIR, NULL);
       
  1658     TPtrC iconFile = parse.FullName();
       
  1659 
       
  1660     //Create icon for drawing the pointer
       
  1661     iPointerIcon = AknsUtils::CreateGulIconL(
       
  1662             skin,
       
  1663             KAknsIIDQgnIndiViewerPointer,
       
  1664             iconFile,
       
  1665             EMbmSvgtuicontrolQgn_indi_viewer_pointer,
       
  1666             EMbmSvgtuicontrolQgn_indi_viewer_pointer_mask );
       
  1667 
       
  1668     //Create icon for drawing the hyperlink pointer
       
  1669     iHandIcon = AknsUtils::CreateGulIconL(
       
  1670             skin,
       
  1671             KAknsIIDQgnIndiViewerPointerHand,
       
  1672             iconFile,
       
  1673             EMbmSvgtuicontrolQgn_indi_viewer_pointer_hand,
       
  1674             EMbmSvgtuicontrolQgn_indi_viewer_pointer_hand_mask );
       
  1675 
       
  1676     //Create icon for drawing the hyperlink pointer
       
  1677     iTextIcon = AknsUtils::CreateGulIconL(
       
  1678            skin,
       
  1679             KAknsIIDQgnIndiViewerPointerText,
       
  1680             iconFile,
       
  1681             EMbmSvgtuicontrolQgn_indi_viewer_pointer_text,
       
  1682             EMbmSvgtuicontrolQgn_indi_viewer_pointer_text_mask );
       
  1683 
       
  1684     // Panning Indicators
       
  1685     // Create icon for drawing the Pan Left
       
  1686     iPanIndLeftIcon = AknsUtils::CreateGulIconL(
       
  1687             skin,
       
  1688             KAknsIIDQgnIndiViewerPanningLeft,
       
  1689             iconFile,
       
  1690             EMbmSvgtuicontrolQgn_indi_viewer_panning_left,
       
  1691             EMbmSvgtuicontrolQgn_indi_viewer_panning_left_mask );
       
  1692 
       
  1693     // Create icon for drawing the Pan Right
       
  1694     iPanIndRightIcon = AknsUtils::CreateGulIconL(
       
  1695             skin,
       
  1696             KAknsIIDQgnIndiViewerPanningRight,
       
  1697             iconFile,
       
  1698             EMbmSvgtuicontrolQgn_indi_viewer_panning_right,
       
  1699             EMbmSvgtuicontrolQgn_indi_viewer_panning_right_mask );
       
  1700 
       
  1701     // Create icon for drawing the Pan Up
       
  1702     iPanIndUpIcon = AknsUtils::CreateGulIconL(
       
  1703             skin,
       
  1704             KAknsIIDQgnIndiViewerPanningUp,
       
  1705             iconFile,
       
  1706             EMbmSvgtuicontrolQgn_indi_viewer_panning_up,
       
  1707             EMbmSvgtuicontrolQgn_indi_viewer_panning_up_mask );
       
  1708 
       
  1709     // Create icon for drawing the Pan Down
       
  1710     iPanIndDownIcon = AknsUtils::CreateGulIconL(
       
  1711            skin,
       
  1712            KAknsIIDQgnIndiViewerPanningDown,
       
  1713            iconFile,
       
  1714            EMbmSvgtuicontrolQgn_indi_viewer_panning_down,
       
  1715            EMbmSvgtuicontrolQgn_indi_viewer_panning_down_mask );
       
  1716 
       
  1717     // Create icon for drawing the Pause
       
  1718     iPauseIcon = AknsUtils::CreateGulIconL(
       
  1719            skin,
       
  1720            KAknsIIDQgnIndiCamsPaused,
       
  1721            iconFile,
       
  1722            EMbmSvgtuicontrolQgn_indi_cams_paused,
       
  1723            EMbmSvgtuicontrolQgn_indi_cams_paused_mask );
       
  1724     }
       
  1725 // -----------------------------------------------------------------------------
       
  1726 // CSVGTCustControl::InitializeEngineL
       
  1727 // Initiliazes the interface with the SVG engine.
       
  1728 // -----------------------------------------------------------------------------
       
  1729 //
       
  1730 void CSVGTCustControl::InitializeEngineL()
       
  1731     {
       
  1732     if ( !iSvgModule )
       
  1733         {
       
  1734         TInt fontId = KLatintFontId;
       
  1735    
       
  1736         switch ( AknLayoutUtils::Variant() )
       
  1737             {
       
  1738             case EApacVariant:
       
  1739                 {
       
  1740                 fontId = KApacFontId;
       
  1741                 }
       
  1742                 break;
       
  1743             case EEuropeanVariant:
       
  1744             default:
       
  1745                 break;
       
  1746             }
       
  1747 
       
  1748         const CFont* font = AknLayoutUtils::FontFromId( fontId );
       
  1749         TFontSpec spec = font->FontSpecInTwips();
       
  1750        
       
  1751         iSvgModule = CSvgEngineInterfaceImpl::NewL( iSVGTBitMap,
       
  1752                 this, spec );
       
  1753         iSvgModule->SetBackgroundColor( KSccArgbWhite );
       
  1754         iSvgModule->AddHyperlinkListener( static_cast < MSvgHyperlinkListener* >
       
  1755                                         (this) );
       
  1756         // Register for notification of Animation Start/Stop.
       
  1757         iSvgModule->AddAnimationListener( static_cast < MSvgAnimationListener* >
       
  1758                          ( this ) );
       
  1759         iSvgModule->AddListener(static_cast<MSvgLoadingListener*>(this),
       
  1760             ESvgLoadingListener);
       
  1761         iSvgModule->AddListener(static_cast<MSvgLoadingListener*>(this),
       
  1762             ESvgHyperlinkListener);
       
  1763         iSvgModule->AddListener( static_cast < MSvgInteractiveElementListener* >
       
  1764                     (this), ESvgInteractiveElementListener);
       
  1765 
       
  1766 #ifdef SVGTUICONTROL_DBG_TEXT_EDIT_SELECT_API_ENABLE   
       
  1767         // In DRM protected contents, disable the text operations:
       
  1768         iEnableTextOps = !( iSvgDrmHelper->IsProtected()||iPreviewMode );
       
  1769        
       
  1770         if ( iEnableTextOps )
       
  1771             {
       
  1772             // Add textArea element listener
       
  1773             iSvgModule->AddListener( static_cast<MSvgTextAreaListener *>(this),
       
  1774                                      ESvgTextAreaListener );
       
  1775            
       
  1776             // Add text element listener
       
  1777             iSvgModule->AddListener( static_cast<MSvgTextListener *>(this),
       
  1778                                      ESvgTextListener );
       
  1779             }
       
  1780 #endif // SVGTUICONTROL_DBG_TEXT_EDIT_SELECT_API_ENABLE                           
       
  1781        }
       
  1782 
       
  1783     }
       
  1784 
       
  1785 // -----------------------------------------------------------------------------
       
  1786 // CSVGTCustControl::LoadContentL
       
  1787 // This function uses the SVG Engine to load the SVGT content.
       
  1788 // -----------------------------------------------------------------------------
       
  1789 //
       
  1790 void CSVGTCustControl::LoadContentL(
       
  1791     RFile& aFileHandle )    // Filename of SVGT content
       
  1792     {
       
  1793     // Enable DRM mode of engine
       
  1794     iSvgModule->SetDRMMode( ETrue );
       
  1795    
       
  1796     // Rewind the file
       
  1797     TInt pos = 0;
       
  1798     aFileHandle.Seek( ESeekStart, pos );
       
  1799    
       
  1800     iLoadingThreadError = iSvgModule->Load( aFileHandle );
       
  1801 
       
  1802 #ifdef SVGTUICONTROL_DBG_OPENVG_TESTING_ENABLE   
       
  1803     iSvgModule->CustomOption( ETrue );
       
  1804 #endif // SVGTUICONTROL_DBG_OPENVG_TESTING_ENABLE   
       
  1805     }
       
  1806 
       
  1807 TInt CSVGTCustControl::LoadSvgContent(TAny* aAny)
       
  1808     {
       
  1809     CSVGTCustControl& loader = *( CSVGTCustControl* )aAny;
       
  1810     CTrapCleanup* theTrapCleanup = CTrapCleanup::New();
       
  1811     loader.SetThreadRunning(ETrue);
       
  1812     TRAP_IGNORE( loader.InitSvgContentL() );
       
  1813     delete theTrapCleanup;
       
  1814     return 0;
       
  1815     }
       
  1816 
       
  1817 void CSVGTCustControl::InitSvgContentL()
       
  1818     {
       
  1819     CActiveScheduler* threadScheduler = new (ELeave) CActiveScheduler;
       
  1820     CleanupStack::PushL( threadScheduler );
       
  1821     CActiveScheduler::Install(threadScheduler);
       
  1822 
       
  1823     // Load the SVGT content
       
  1824     LoadContentL( iContentFileHandle );
       
  1825     CleanupStack::PopAndDestroy( threadScheduler );
       
  1826     }
       
  1827 
       
  1828 // -----------------------------------------------------------------------------
       
  1829 // CSVGTCustControl::DisplayInfoNoteL
       
  1830 // This is a utility function for displaying the info notes
       
  1831 // -----------------------------------------------------------------------------
       
  1832 //
       
  1833 void CSVGTCustControl::DisplayInfoNoteL( TInt aResourceId, // Resource Id of
       
  1834                                                            // string
       
  1835                                  TBool aIsWaitingDialog ) // Indicate whether \
       
  1836                                                           // dialog should wait
       
  1837     {
       
  1838     if(iDisplayFlags & ESvgDisplayErrorNotes )
       
  1839         {
       
  1840         // Show information note
       
  1841         HBufC* prompt = iCoeEnv->AllocReadResourceLC( aResourceId );
       
  1842         CAknInformationNote* note = new ( ELeave ) CAknInformationNote(
       
  1843                                                             aIsWaitingDialog );
       
  1844         note->ExecuteLD( *prompt );
       
  1845         CleanupStack::PopAndDestroy( prompt );
       
  1846         }
       
  1847     }
       
  1848 
       
  1849 // -----------------------------------------------------------------------------
       
  1850 // CSVGTCustControl::DoPostLoadFuncL
       
  1851 // This is a utility function for performing post-load functionality
       
  1852 // -----------------------------------------------------------------------------
       
  1853 //
       
  1854 void CSVGTCustControl::DoPostLoadFuncL()
       
  1855     {
       
  1856     if ( iSvgModule )
       
  1857         {
       
  1858 #ifdef RD_SVGT_AUDIO_SUPPORT
       
  1859         SetPresentationVolume( iVolumeLevel );
       
  1860 #endif //RD_SVGT_AUDIO_SUPPORT
       
  1861 
       
  1862         // give thread normal priority
       
  1863         iMainThread.SetPriority( EPriorityNormal );
       
  1864         // Attach to property for call state property
       
  1865         User::LeaveIfError( iSystemState.Attach( KPSUidCtsyCallInformation,
       
  1866                                                  KCTsyCallState ) );
       
  1867         // Attach to property for call type property
       
  1868         User::LeaveIfError( iSystemState.Attach( KPSUidCtsyCallInformation,
       
  1869                                                  KCTsyCallType ) );
       
  1870         // Indicate that the content loading is complete
       
  1871         iIsLoadingDone = ETrue;
       
  1872    
       
  1873         // Store SVG duration
       
  1874         iDuration = iSvgModule->Duration();   
       
  1875 
       
  1876         // Start the rendering process
       
  1877         iAnimState = ESvgAnimPlayingState;
       
  1878         iSvgModule->Start();
       
  1879 		
       
  1880 		//Drawing the MSK label for the first time
       
  1881 		if(iMSKImpl && !iPreviewMode)
       
  1882 			{
       
  1883 			TRAP_IGNORE(SetMSKLabelL());
       
  1884 			}
       
  1885 			
       
  1886         // Check whether the content is finite, inorder to display the
       
  1887         // progress timer
       
  1888         if ( IsContentFinite() )
       
  1889             {
       
  1890             // Start immediately so that the first count is displayed
       
  1891             StartProgIndTimer( 0 );
       
  1892             }
       
  1893 
       
  1894         if ( IsVoiceCallActive() )
       
  1895             {
       
  1896             ProcessPauseCmd();
       
  1897             }
       
  1898         }
       
  1899     }   
       
  1900 
       
  1901 // -----------------------------------------------------------------------------
       
  1902 // CSVGTCustControl::SaveSvgDom
       
  1903 // This function is a helper function to save the modified svg content
       
  1904 // given the file name.
       
  1905 // -----------------------------------------------------------------------------
       
  1906 TInt CSVGTCustControl::SaveSvgDom( const TDesC& aFileName )
       
  1907     {
       
  1908     TInt retVal = KErrNone;
       
  1909     MSvgError* lSvgErr = iSvgModule->SaveSvgDom(
       
  1910         (TInt)iSvgModule->SvgDocument(), aFileName );
       
  1911     if ( ( !lSvgErr ) || ( lSvgErr->HasError() ) )
       
  1912         {
       
  1913         if ( lSvgErr )
       
  1914             {
       
  1915             // Attempt to find the system error code
       
  1916             retVal = lSvgErr->SystemErrorCode();
       
  1917             }
       
  1918             else
       
  1919                 {
       
  1920                 // No free memory available
       
  1921                 retVal = KErrNoMemory;
       
  1922                 }
       
  1923        
       
  1924         // No error code found, indicate general error   
       
  1925         if ( retVal == KErrNone )
       
  1926             {
       
  1927             retVal = KErrGeneral;
       
  1928             }
       
  1929         }
       
  1930     return retVal;
       
  1931     }
       
  1932  // -----------------------------------------------------------------------------
       
  1933 
       
  1934 
       
  1935 //-----------------------------------------------------------------------------    
       
  1936 void CSVGTCustControl::GetViewPort( TInt  getWidth , 
       
  1937                                     TInt  getHeight , 
       
  1938                                     TBool isWidthInPercentage, 
       
  1939                                     TBool isHeightInPercentage, 
       
  1940                                     TInt& setWidth, TInt& setHeight )
       
  1941  {
       
  1942     if(!iSvgModule)
       
  1943     {
       
  1944         return;
       
  1945     }
       
  1946     if(!iSVGTBitMap)
       
  1947     {
       
  1948         return;
       
  1949     }
       
  1950     TSize svgSize = iSvgModule->ContentDimensionsInPercentage();
       
  1951     TInt  per=100;
       
  1952     TSize tempSize = iSvgModule->ContentDimensions();
       
  1953     TInt scrW = iSVGTBitMap->SizeInPixels().iWidth;
       
  1954     TInt scrH = iSVGTBitMap->SizeInPixels().iHeight;
       
  1955     //both not in percentage
       
  1956     if(!isWidthInPercentage && !isHeightInPercentage)
       
  1957     {
       
  1958         setWidth = tempSize.iWidth;
       
  1959         setHeight = tempSize.iHeight;
       
  1960     }
       
  1961     //if width in percentage 
       
  1962     else if(isWidthInPercentage && !isHeightInPercentage)
       
  1963     {
       
  1964         setWidth = svgSize.iWidth * scrW / per;
       
  1965         //if svg had valid height take it else use default
       
  1966         if(tempSize.iHeight)
       
  1967         {
       
  1968          setHeight = getHeight;
       
  1969         }
       
  1970     }
       
  1971     //if height in percentage
       
  1972     else if(!isWidthInPercentage && isHeightInPercentage)
       
  1973     {
       
  1974         setHeight =  svgSize.iHeight * scrH / per;
       
  1975         if(tempSize.iWidth)
       
  1976         {
       
  1977          setWidth = getWidth;
       
  1978         }
       
  1979     }
       
  1980     //if both height and width are in percentage
       
  1981     else
       
  1982     {
       
  1983         setHeight =  svgSize.iHeight * scrH / per;
       
  1984         setWidth = svgSize.iWidth * scrW / per;
       
  1985     }
       
  1986     
       
  1987     //if height is greater than screenHeight
       
  1988     //or if width is greater than screenwidth 
       
  1989     //set the width and height by preserving the aspect ratio
       
  1990     TReal32 sx,sy;
       
  1991 
       
  1992     if(setHeight > scrH || setWidth > scrW)
       
  1993     {
       
  1994         sx = (TReal32) (scrW) / (TReal32) (setWidth);
       
  1995         sy = (TReal32) (scrH) / (TReal32) (setHeight);
       
  1996         if ( sx > sy )
       
  1997         {
       
  1998             sx = sy;
       
  1999         }
       
  2000         else // ( sx < sy )
       
  2001         {
       
  2002             sy = sx;
       
  2003         }
       
  2004         setWidth = sx * setWidth;
       
  2005         setHeight = sy * setHeight;
       
  2006     }
       
  2007     
       
  2008     
       
  2009  }
       
  2010  
       
  2011  
       
  2012 // -----------------------------------------------------------------------------
       
  2013 // CSVGTCustControl::DrawPointer
       
  2014 // This function blits the pointer bitmap on the screen at the current mouse
       
  2015 // co-ordinates which are maintained as data-members of CSVGTCustControl.
       
  2016 // -----------------------------------------------------------------------------
       
  2017 //
       
  2018 
       
  2019 void CSVGTCustControl::DrawPointer() const
       
  2020     {
       
  2021 
       
  2022     iSVGTFrameBufContext->SetPenStyle( CGraphicsContext::ENullPen );
       
  2023     iSVGTFrameBufContext->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2024    
       
  2025    
       
  2026     // Use the aid for the hotspot from the LAF.
       
  2027     // This value is set in the SizeChanged function.
       
  2028     // The hotspot information is used so that the bitmap is drawn in
       
  2029     // correct position with respect to the mouse position.
       
  2030     switch ( iPointerType )
       
  2031         {
       
  2032         case ESvgPointerHand:
       
  2033             {
       
  2034             // Draw the hand icon at the mouse position
       
  2035             TPoint pointerStart( iPointerX - iHandAidRect.Rect().Width(),
       
  2036                                  iPointerY - iHandAidRect.Rect().Height() );
       
  2037             iSVGTFrameBufContext->BitBltMasked( pointerStart,
       
  2038                  iHandIcon->Bitmap(),
       
  2039                  iHandRect.Rect(),
       
  2040                  iHandIcon->Mask(),
       
  2041                  EFalse );
       
  2042             break;
       
  2043             }
       
  2044         case ESvgPointerText:
       
  2045             {
       
  2046             // Draw the hand icon at the mouse position
       
  2047             TPoint pointerStart( iPointerX - iTextAidRect.Rect().Width(),
       
  2048                                  iPointerY - iTextAidRect.Rect().Height() );
       
  2049             iSVGTFrameBufContext->BitBltMasked( pointerStart,
       
  2050                  iTextIcon->Bitmap(),
       
  2051                  iTextRect.Rect(),
       
  2052                  iTextIcon->Mask(),
       
  2053                  EFalse );
       
  2054             break;
       
  2055             }
       
  2056         case ESvgPointerDefault:      // Fall Through
       
  2057         default:                      // Fall Through - Should never be the case
       
  2058             {
       
  2059             // Draw the pointer icon at the mouse position
       
  2060             TPoint pointerStart( iPointerX - iPointerAidRect.Rect().Width(),
       
  2061                                  iPointerY - iPointerAidRect.Rect().Height() );
       
  2062             iSVGTFrameBufContext->BitBltMasked( pointerStart,
       
  2063                 iPointerIcon->Bitmap(),
       
  2064                 iPointerRect.Rect(),
       
  2065                 iPointerIcon->Mask(),
       
  2066                 EFalse );
       
  2067             break;
       
  2068             }
       
  2069         }
       
  2070     }
       
  2071 
       
  2072 // -----------------------------------------------------------------------------
       
  2073 // CSVGTCustControl::UpdatePointer
       
  2074 // Called when pointer needs to be redrawn
       
  2075 // -----------------------------------------------------------------------------
       
  2076 //
       
  2077 void CSVGTCustControl::UpdatePointer()
       
  2078     {
       
  2079     // Get the size of the content
       
  2080     TSize svgSize = iSvgModule->Size();
       
  2081     TInt rgnw = svgSize.iWidth;
       
  2082     TInt rgnh = svgSize.iHeight;
       
  2083 
       
  2084     // This is to store whether the framebuffer changed
       
  2085     TBool lFrameBufChange = EFalse;
       
  2086    
       
  2087     // iPointerDx contains the delta increment in X axis
       
  2088     // Add it to the pointer coordinates
       
  2089     iPointerX += iPointerDx;
       
  2090    
       
  2091     // If pointer coordinate becomes negative then reset it
       
  2092     // and perform panning.
       
  2093     if ( iPointerX < KSccConstZero )
       
  2094         {
       
  2095         iPointerX = KSccConstZero;
       
  2096 		if(iPanLt)
       
  2097 			{
       
  2098 			iSvgModule->Pan( KSccPanNumPixelsX, KSccConstZero );
       
  2099 			}
       
  2100         lFrameBufChange = ETrue;
       
  2101         }
       
  2102    
       
  2103     // If pointer coordinate becomes greater than content size
       
  2104     // then set it back to (content width - 1) and
       
  2105     // perform panning.
       
  2106     if ( rgnw <= iPointerX )
       
  2107         {
       
  2108         iPointerX = rgnw - KSccConstOne;
       
  2109 		if(iPanRt)
       
  2110 			{
       
  2111     	    iSvgModule->Pan( -KSccPanNumPixelsX, KSccConstZero );
       
  2112 			}
       
  2113         lFrameBufChange = ETrue;
       
  2114         }
       
  2115 
       
  2116     // iPointerDy contains the delta increment in Y axis
       
  2117     // Add it to the pointer coordinates.
       
  2118     iPointerY += iPointerDy;
       
  2119 
       
  2120     // If pointer coordinate becomes negative then reset it
       
  2121     // and perform panning.
       
  2122     if ( iPointerY < KSccConstZero )
       
  2123         {
       
  2124         iPointerY = KSccConstZero;
       
  2125 		if(iPanUp)
       
  2126 			{
       
  2127             iSvgModule->Pan( KSccConstZero, KSccPanNumPixelsY );
       
  2128 			}
       
  2129         lFrameBufChange = ETrue;
       
  2130         }
       
  2131 
       
  2132     // If pointer coordinate becomes greater than content size
       
  2133     // then set it back to (content height - 1) and
       
  2134     // perform panning.
       
  2135     if ( iPointerY >= rgnh )
       
  2136         {
       
  2137         iPointerY = rgnh - KSccConstOne;
       
  2138 		if(iPanDn)
       
  2139 		    {
       
  2140 	        iSvgModule->Pan( KSccConstZero, -KSccPanNumPixelsY );
       
  2141 		    }
       
  2142         lFrameBufChange = ETrue;
       
  2143         }
       
  2144    
       
  2145     // If Framebuffer changed, perform an engine redraw and recalculate
       
  2146     // bound box coordinates
       
  2147     if ( lFrameBufChange )
       
  2148         {
       
  2149         iSvgModule->Redraw();
       
  2150         CalcFindTextBBox();       
       
  2151         }
       
  2152    
       
  2153     // Indicate new mouse position to engine
       
  2154     iSvgModule->MouseMove( iPointerX, iPointerY );
       
  2155    
       
  2156     // Perform a redraw to reflect new position of pointer
       
  2157     DrawDeferred();
       
  2158     }
       
  2159 
       
  2160 // -----------------------------------------------------------------------------
       
  2161 // CSVGTCustControl::SetMSKLabel
       
  2162 // This function is called to set the MSK labels under various circumstances.
       
  2163 // -----------------------------------------------------------------------------
       
  2164 //   
       
  2165 void CSVGTCustControl::SetMSKLabelL()
       
  2166 {
       
  2167 	TInt lResourceID=0;
       
  2168 	TInt lCommandID=0;
       
  2169 	if(!iIsPointerDisplayed)
       
  2170 		{
       
  2171 		if (IsAnimationPresent())
       
  2172 			{
       
  2173 			lResourceID=R_SVGT_MSK_LABEL_CONTEXT;
       
  2174 			lCommandID=EAknSoftkeyContextOptions;
       
  2175 			}
       
  2176 		else if ( !IsAnimationPresent() && 
       
  2177 		    (iAppObserver->CanShowSave() || IsTextContentChanged() ) )
       
  2178 			{
       
  2179 			lResourceID=R_SVGT_MSK_LABEL_SAVE;
       
  2180 			lCommandID=EAknSoftkeySave;	
       
  2181 			}
       
  2182 		else
       
  2183 			{	
       
  2184 			lResourceID=R_SVGT_MSK_LABEL_CONTEXT;
       
  2185 			lCommandID=EAknSoftkeyOptions;		
       
  2186 			}
       
  2187 		}
       
  2188 	else
       
  2189 		{
       
  2190 		switch(iPointerType)
       
  2191 			{
       
  2192 			case ESvgPointerHand:
       
  2193 				{
       
  2194 				lCommandID=EAknSoftkeySelect;	
       
  2195 				if(iAElement)
       
  2196 					{
       
  2197 					lResourceID=R_SVGT_MSK_LABEL_OPEN;
       
  2198 					}
       
  2199 				else
       
  2200 					{
       
  2201 					iPlayMSKLabel=ETrue;
       
  2202 					lResourceID=R_SVGT_MSK_LABEL_PLAY;
       
  2203 					}
       
  2204 				}
       
  2205 				break;			
       
  2206 			case ESvgPointerText:
       
  2207 				{
       
  2208 				lCommandID=EAknSoftkeySelect;
       
  2209 				if(IsTextEditOn())
       
  2210 					{
       
  2211 					lResourceID=R_SVGT_MSK_LABEL_EDIT;
       
  2212 					}
       
  2213 				else
       
  2214 					{
       
  2215 					lResourceID=R_SVGT_MSK_LABEL_SELECT;
       
  2216 					}
       
  2217 				}
       
  2218 				break;
       
  2219 			case ESvgPointerDefault:
       
  2220 				{
       
  2221 				if (IsAnimationPresent())
       
  2222 					{
       
  2223 					lResourceID=R_SVGT_MSK_LABEL_CONTEXT;
       
  2224 					lCommandID=EAknSoftkeyContextOptions;
       
  2225 					}
       
  2226 				else if( !IsAnimationPresent() && 
       
  2227 				    ( iAppObserver->CanShowSave() || IsTextContentChanged() ) )
       
  2228 					{
       
  2229 					lResourceID=R_SVGT_MSK_LABEL_SAVE;
       
  2230 					lCommandID=EAknSoftkeySave;	
       
  2231 					}
       
  2232 				else
       
  2233 					{	
       
  2234 					lResourceID=R_SVGT_MSK_LABEL_CONTEXT;
       
  2235 					lCommandID=EAknSoftkeyOptions;		
       
  2236 					}
       
  2237 				}
       
  2238 				break;
       
  2239 			}
       
  2240 		}
       
  2241 	iMSKImpl->RemoveMSKLabel();
       
  2242 	iMSKImpl->DrawMSKLabelL(lResourceID,lCommandID);
       
  2243 }
       
  2244 
       
  2245 // -----------------------------------------------------------------------------
       
  2246 // CSVGTCustControl::GetMSKLabelFlag
       
  2247 // This function is called to get either iPlayMSKLabel or
       
  2248 // iContextMenuActivated flag
       
  2249 // -----------------------------------------------------------------------------
       
  2250 //
       
  2251 TBool CSVGTCustControl::GetMSKLabelFlag(TInt aButtonId) const
       
  2252 {
       
  2253 	if (aButtonId==EAknSoftkeyContextOptions)
       
  2254 		{
       
  2255 		return iContextMenuActivated;	
       
  2256 		}
       
  2257 	else   //Else the case will be for EAknSoftkeySelect for which the
       
  2258            // iPlayMSKLabel has to be returned
       
  2259 		{
       
  2260 		return iPlayMSKLabel;	
       
  2261 		}
       
  2262 }
       
  2263 
       
  2264 // -----------------------------------------------------------------------------
       
  2265 // CSVGTCustControl::SetMSKLabelFlag
       
  2266 // This function is called to set/reset either iPlayMSKLabel or
       
  2267 // iContextMenuActivated flag
       
  2268 // -----------------------------------------------------------------------------
       
  2269 //
       
  2270 void CSVGTCustControl::ChangeMSKLabelFlag(TInt aButtonId)
       
  2271 {
       
  2272 	if (aButtonId==EAknSoftkeyContextOptions)
       
  2273 		{
       
  2274 		iContextMenuActivated = !iContextMenuActivated;
       
  2275 		}
       
  2276 	else //Else the case will be for EAknSoftkeySelect
       
  2277 		{
       
  2278 		iPlayMSKLabel=!iPlayMSKLabel;
       
  2279 		}
       
  2280 }
       
  2281 
       
  2282 // -----------------------------------------------------------------------------
       
  2283 // CSVGTCustControl::SwitchScreenModeL
       
  2284 // This function is called to change the viewing mode to Normal Screen/Full
       
  2285 // Screen.
       
  2286 // -----------------------------------------------------------------------------
       
  2287 //
       
  2288 void CSVGTCustControl::SwitchScreenModeL()
       
  2289     {
       
  2290     // When control mode is being switched, following
       
  2291     // processing needs to happen:
       
  2292     //  a. Save the current framebuffer
       
  2293     //  b. Create the New Framebuffer by calling CreateBitmaps()
       
  2294     //  c. Set the framebuffer to the new framebuffer
       
  2295     //  d. Pause the content if it was paused.
       
  2296     //  e. Also processing in following functions is affected:
       
  2297     //      i. UpdateScreen - This is the callback of the engine to indicate
       
  2298     //         that it has rendered the frame on the bitmap, and is ready to be
       
  2299     //         drawn. Here we need to generate mask with correct bitmap
       
  2300     //      ii. Draw -  This function needs to bitblt the bitmap
       
  2301     //         along with the mask
       
  2302 
       
  2303     if ( iSvgModule )
       
  2304         {
       
  2305         // Create new bitmaps
       
  2306         CreateBitmapsL( Rect().Size() );
       
  2307         iSvgModule->Pause();       
       
  2308         // Change the rendering bitmap to the appropriate Screen Bitmap
       
  2309         iSvgModule->SetFrameBuffer( iSVGTBitMap );  
       
  2310        
       
  2311         // Check if content was playing
       
  2312         if ( iAnimState != ESvgAnimPlayingState )
       
  2313             {
       
  2314             // Stop it, as content is paused
       
  2315             iSvgModule->Pause();
       
  2316             // Redraw the screen, to prevent blank screen from appearing
       
  2317             iSvgModule->Redraw();
       
  2318             }
       
  2319         // Find Text Update
       
  2320         // Get new position of Bounding Boxes
       
  2321         CalcFindTextBBox();
       
  2322         }
       
  2323     }
       
  2324 
       
  2325 // -----------------------------------------------------------------------------
       
  2326 // CSVGTCustControl::CalcFindTextBBox
       
  2327 // This function is called to recalculate the bounding boxes for the find text.
       
  2328 // -----------------------------------------------------------------------------
       
  2329 //
       
  2330 TBool CSVGTCustControl::CalcFindTextBBox()
       
  2331     {
       
  2332 
       
  2333     // Clear the Arrays
       
  2334     iBoundBoxArray.Reset();
       
  2335     iFoundTextArray.Reset();
       
  2336     iTextElemIdArray.Reset();
       
  2337 
       
  2338     // If the Search String is not valid, then
       
  2339     // no need to do anything.
       
  2340     if ( !iIsSearchStrValid )
       
  2341         {
       
  2342         return EFalse;
       
  2343         }
       
  2344        
       
  2345     // Invoke Engine call for searching text.
       
  2346     TBool retVal = iSvgModule->SearchForText(
       
  2347         iLastSearchText,
       
  2348         iBoundBoxArray,
       
  2349         iFoundTextArray,
       
  2350         iTextElemIdArray,
       
  2351         EFalse );
       
  2352    
       
  2353     if ( retVal == EFalse )
       
  2354         {
       
  2355         // Set the search string as invalid
       
  2356         iIsSearchStrValid = EFalse;
       
  2357         // Reset the string
       
  2358       //Himanshu  iLastSearchText.Zero();
       
  2359         }
       
  2360        
       
  2361     return ( retVal );
       
  2362     }
       
  2363 
       
  2364 // -----------------------------------------------------------------------------
       
  2365 // CSVGTCustControl::PanToCurBBox
       
  2366 // This function is called to pan the content inorder that the current
       
  2367 // bounding box is visible.
       
  2368 // -----------------------------------------------------------------------------
       
  2369 //
       
  2370 
       
  2371 void CSVGTCustControl::PanToCurBBox()
       
  2372     {
       
  2373     TPoint lRefPos( Rect().Center() );
       
  2374 
       
  2375     // We need to pan in such a way that the Top Left of the Bounding box
       
  2376     // coincides with the current view's Center
       
  2377     TPoint lPanAmount( lRefPos - FPRCenter(
       
  2378         iBoundBoxArray[ iCurSearchMatchId ] ) );
       
  2379     iSvgModule->Pan( lPanAmount.iX, lPanAmount.iY );
       
  2380     // Do a Redraw
       
  2381     iSvgModule->Redraw();
       
  2382     }
       
  2383 
       
  2384 // -----------------------------------------------------------------------------
       
  2385 // CSVGTCustControl::ProcessFindTextCmd
       
  2386 // This function is called to perform the necessary processing for the find
       
  2387 // text command.
       
  2388 // -----------------------------------------------------------------------------
       
  2389 //
       
  2390 void CSVGTCustControl::ProcessFindTextCmdL()
       
  2391     {
       
  2392     // The Processing involved is
       
  2393     // 1. Query the text to be searched for from the User
       
  2394     // 2. Is the text same as the text input before? (Case Insensitive Match)
       
  2395     // 3. If Yes, then
       
  2396     //      Perform "Find Next" functionality
       
  2397     //          a. If the bounding box is not in view then
       
  2398     //                 move to the same bound box
       
  2399     //             Else,
       
  2400     //                 Cycle through the list of bound-boxes by incrementing
       
  2401     //                 with wrap around the iCurSearchMatchId while the text
       
  2402     //                 is not visible
       
  2403     //    else // New text entered
       
  2404     //      Perform "Find First" Functionality
       
  2405     //          If no Match is found then,
       
  2406     //                 Display an "Text not found" info note
       
  2407     //                 Reset the Last Searched Text
       
  2408     //                 return to caller
       
  2409     //             Else,
       
  2410     //                 Find the List of Bound Boxes
       
  2411     //                 Set the Current Match as the Index Zero of the BBox Array
       
  2412     // 4. If the current bound box is not in view
       
  2413     //      Pan to the Bound Box
       
  2414     //      Recalculate the Bound Box Co-ordinates
       
  2415     // 5. Move the mouse to the center of the bound box
       
  2416     // 6. Return to caller.
       
  2417 
       
  2418     TBuf<KFindTextQueryMaxLen> lText( iLastSearchText );
       
  2419     // Query the text to be searched for from the User
       
  2420     CAknTextQueryDialog* dlg = new ( ELeave ) CAknTextQueryDialog(
       
  2421         iLastSearchText );
       
  2422     if( dlg->ExecuteLD( R_FIND_TEXT_QUERY_DIALOG ) )
       
  2423         {
       
  2424         // User entered text
       
  2425         if ( lText.CompareF( iLastSearchText ) == 0 && 
       
  2426             iIsSearchStrValid==1 ) // Case insensitive comparison
       
  2427             {
       
  2428             // Searching for same text = Find Next
       
  2429             // If current bound box is not in view and is visible, then
       
  2430             //      move to the same bound box
       
  2431             // else  ; Bound Box is in view or is Not Visible
       
  2432             //      find next visible box with wraparound.
       
  2433             TBool lIsBoxInView = FPRIntersects( 
       
  2434                 iBoundBoxArray[ iCurSearchMatchId ] ,
       
  2435                 Rect() );
       
  2436             if ( lIsBoxInView  ||
       
  2437                     ( !iSvgModule->IsElementVisible(
       
  2438                       iTextElemIdArray[ iCurSearchMatchId ] ) ) )
       
  2439                 {
       
  2440                 // Store the current match Index so that the end of the list
       
  2441                 // can be identified.
       
  2442                 TInt lastSearchMatchId = iCurSearchMatchId;
       
  2443                 // Increment iIsCurMatchId to point to next matching text
       
  2444                 iCurSearchMatchId = ( iCurSearchMatchId + KSccConstOne ) %
       
  2445                     ( iBoundBoxArray.Count() );
       
  2446                 while ( ( iCurSearchMatchId != lastSearchMatchId ) &&
       
  2447                             ( !iSvgModule->IsElementVisible(
       
  2448                                iTextElemIdArray[ iCurSearchMatchId ] ) ) )
       
  2449                     {
       
  2450                     // Increment iIsCurMatchId to point to next matching text
       
  2451                     iCurSearchMatchId = ( iCurSearchMatchId + KSccConstOne ) %
       
  2452                         ( iBoundBoxArray.Count() );
       
  2453                     }
       
  2454                     if( iCurSearchMatchId == lastSearchMatchId ||
       
  2455                         (iCurSearchMatchId==0 )   )
       
  2456                     {
       
  2457                     ProcessNoTextFoundL();
       
  2458                     return;
       
  2459                     }
       
  2460                 }
       
  2461             }
       
  2462         else
       
  2463             {
       
  2464             // New Search String
       
  2465             iCurSearchMatchId = KSccConstZero;
       
  2466             iIsSearchStrValid = ETrue;
       
  2467 
       
  2468             if ( !CalcFindTextBBox() )
       
  2469                 {
       
  2470                 ProcessNoTextFoundL();
       
  2471                 return;
       
  2472                 }
       
  2473                 else
       
  2474                     {
       
  2475                     // Match Found,
       
  2476                     // Find the first box in the list that is visible
       
  2477                     if ( !iSvgModule->IsElementVisible(
       
  2478                         iTextElemIdArray[ iCurSearchMatchId ] ) )
       
  2479                         {
       
  2480                         // Store the current match Index so that the end of the
       
  2481                         // list can be identified.
       
  2482                         TInt lastSearchMatchId = iCurSearchMatchId;
       
  2483                         // Increment iIsCurMatchId to point to next matching
       
  2484                         // text
       
  2485                         iCurSearchMatchId = ( iCurSearchMatchId +
       
  2486                                 KSccConstOne ) % ( iBoundBoxArray.Count() );
       
  2487                         while ( ( iCurSearchMatchId != lastSearchMatchId ) &&
       
  2488                                     ( !iSvgModule->IsElementVisible(
       
  2489                                      iTextElemIdArray[ iCurSearchMatchId ] ) ) )
       
  2490                             {
       
  2491                             // Increment iIsCurMatchId to point to next
       
  2492                             // matching text
       
  2493                             iCurSearchMatchId = ( iCurSearchMatchId +
       
  2494                                     KSccConstOne ) % ( iBoundBoxArray.Count() );
       
  2495                             }
       
  2496                         if ( iCurSearchMatchId == lastSearchMatchId )
       
  2497                             {
       
  2498                             ProcessNoTextFoundL();
       
  2499                             return;
       
  2500                             }
       
  2501                         }
       
  2502                     }
       
  2503             }
       
  2504 
       
  2505         // To determine if a bounding-box is in view:
       
  2506         //   Take the intersection ( TRect::Intersects ) of the
       
  2507         //   Cust Control's rect and the bounding-box. If Intersects()
       
  2508         //   returns true, bounding-box is in view
       
  2509         TRect myRect= Rect();
       
  2510         TBool lIsBoxInView = FPRIntersects( iBoundBoxArray[ iCurSearchMatchId ],
       
  2511             myRect );
       
  2512        
       
  2513         if ( !lIsBoxInView )
       
  2514             {
       
  2515             // Box is not in view
       
  2516 
       
  2517             // Pan Content to bring the text in view
       
  2518             PanToCurBBox();
       
  2519 
       
  2520             // Get new position of Bounding Boxes
       
  2521             CalcFindTextBBox();
       
  2522             }
       
  2523 
       
  2524         // Make the mouse visible
       
  2525         SetPointerDisplayStatusAndRedraw( ETrue );
       
  2526         // Move Mouse over to the centre of the Bound Box
       
  2527         TPoint lMousePos =
       
  2528             FPRCenter( iBoundBoxArray[ iCurSearchMatchId ] );
       
  2529         iPointerX = lMousePos.iX;
       
  2530         iPointerY = lMousePos.iY;
       
  2531 
       
  2532         UpdatePointer();
       
  2533         }
       
  2534     }
       
  2535 
       
  2536 // -----------------------------------------------------------------------------
       
  2537 // CSVGTCustControl::DrawFindTextBBox
       
  2538 //  Draws the Bounding Box for the current match in the SVGT content.
       
  2539 // -----------------------------------------------------------------------------
       
  2540 //
       
  2541 void CSVGTCustControl::DrawFindTextBBox(
       
  2542     const TRect& aRect ) const // Rectangle which needs to be redrawn
       
  2543     {
       
  2544     // Is there any text to highlight?
       
  2545     if ( iIsSearchStrValid )
       
  2546         {
       
  2547         // To determine if a bounding-box can be drawn:
       
  2548         //  Need to check whether it is in view && It is visible
       
  2549         //
       
  2550         //  Check whether it is in view:
       
  2551         //   Take the intersection ( TRect::Intersects ) of the CoeControl-rect
       
  2552         //   and the bounding-box.if Intersects() returns true,
       
  2553         //   bounding-box is in view
       
  2554         //  Check whether it is visible:
       
  2555         //   Call Engine API to check whether the text elem is visible.
       
  2556 
       
  2557         TBool lCanDrawBox = ( FPRIntersects(
       
  2558             iBoundBoxArray[ iCurSearchMatchId ], aRect ) &&
       
  2559             iSvgModule->IsElementVisible( iTextElemIdArray[
       
  2560                 iCurSearchMatchId ] ) );
       
  2561 
       
  2562         if ( lCanDrawBox )
       
  2563             {
       
  2564             // Set the Draw Mode to XOR
       
  2565             iSVGTFrameBufContext->SetDrawMode( CGraphicsContext::EDrawModeXOR );
       
  2566            
       
  2567             // Set the Brush Style to No Fill
       
  2568             iSVGTFrameBufContext->SetBrushStyle(
       
  2569                 CGraphicsContext::ESolidBrush );
       
  2570            
       
  2571             // Set the Pen Style to Solid and color to one obtd from LAF
       
  2572             iSVGTFrameBufContext->SetPenStyle( CGraphicsContext::ESolidPen );
       
  2573             iSVGTFrameBufContext->SetPenColor( iFindTextHiColor );
       
  2574            
       
  2575             // Set the line thickness
       
  2576             iSVGTFrameBufContext->SetPenSize( TSize( KSccConstTwo,
       
  2577                         KSccConstTwo ) );
       
  2578            
       
  2579             // Set the brush to White so that when the color is XORed with it
       
  2580             // it is displayed in its complementary colours.
       
  2581             iSVGTFrameBufContext->SetBrushColor( KRgbWhite );
       
  2582             // Form the clipping rectangle so that text beyound the
       
  2583             // framebuffer is not displayed
       
  2584             TRect lClipRect( TPoint( 0,0 ), iSvgModule->Size() );
       
  2585            
       
  2586             iSVGTFrameBufContext->SetClippingRect( lClipRect);
       
  2587             CArrayFix<TPoint>* lArray = NULL;
       
  2588             TRAPD( err,
       
  2589                 FPR2PointArrayL( iBoundBoxArray[ iCurSearchMatchId ], 
       
  2590                 lArray ) );
       
  2591             if ( err != KErrNone )
       
  2592                 {
       
  2593                 delete lArray;
       
  2594                 return;
       
  2595                 }
       
  2596                
       
  2597             iSVGTFrameBufContext->DrawPolygon(
       
  2598                 lArray );
       
  2599            
       
  2600             delete lArray;
       
  2601             lArray = NULL;
       
  2602            
       
  2603             // Reset the graphic context parameters so that subsequent
       
  2604             // Draw() functions are not affected.
       
  2605             iSVGTFrameBufContext->Reset();
       
  2606             }
       
  2607         }
       
  2608     }
       
  2609 
       
  2610 // -----------------------------------------------------------------------------
       
  2611 // CSVGTCustControl::ProcessNoTextFoundL
       
  2612 //  This function is called to perform the necessary procesing when
       
  2613 //  text being searched using Find Text command is not found.
       
  2614 // -----------------------------------------------------------------------------
       
  2615 //
       
  2616 void CSVGTCustControl::ProcessNoTextFoundL()
       
  2617     {
       
  2618     // Set the search string as invalid
       
  2619     iIsSearchStrValid = EFalse;
       
  2620     // Reset the string
       
  2621    //Himanshu iLastSearchText.Zero();
       
  2622    
       
  2623     // No match found, display an information note
       
  2624     TInt resourceId;
       
  2625 
       
  2626     resourceId = R_SVGT_TEXT_NOT_FOUND;
       
  2627     // Read from Resource
       
  2628     HBufC* prompt = iCoeEnv->AllocReadResourceLC(
       
  2629         resourceId );
       
  2630    
       
  2631     // Start a timer to delete the note after 3 seconds.
       
  2632     if (!iNoteRemoverTimer->IsActive())
       
  2633         {
       
  2634         iNoteRemoverTimer->Start( KSccOneSecond * 3, KSccOneSecond * 3,
       
  2635                 TCallBack( RemoveInfoNote, this ) );
       
  2636         }
       
  2637     // Create and display the note
       
  2638     iInfoNote = new ( ELeave ) CAknInformationNote(
       
  2639             ETrue ); // ETrue - Waiting Dialog
       
  2640     iInfoNote->ExecuteLD( *prompt );
       
  2641    
       
  2642     // Reset the pointer
       
  2643     iInfoNote = NULL;
       
  2644            
       
  2645     CleanupStack::PopAndDestroy( prompt );
       
  2646 
       
  2647     // Do a deferred draw in order to refresh the highlight
       
  2648     DrawDeferred();
       
  2649     }
       
  2650 
       
  2651 // -----------------------------------------------------------------------------
       
  2652 // CSVGTCustControl::DrawPanInd
       
  2653 //  Draws the Panning indicators for the SVGT content.
       
  2654 // -----------------------------------------------------------------------------
       
  2655 //
       
  2656 void CSVGTCustControl::DrawPanInd() const
       
  2657     {
       
  2658     // Get current Control Rectangle
       
  2659     TRect myRect = Rect();
       
  2660     // Set the Brush Style and Pen Style to NULL type
       
  2661     // so that the background of bitmap is correctly blitted.
       
  2662     iSVGTFrameBufContext->SetPenStyle( CGraphicsContext::ENullPen );
       
  2663     iSVGTFrameBufContext->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2664 
       
  2665     if ( iSvgModule )
       
  2666         {
       
  2667         // Pan Left?
       
  2668         if ( iPanLt )
       
  2669             {
       
  2670             // Draw the indicator                   
       
  2671             iSVGTFrameBufContext->BitBltMasked( iPanIndLeftRect.Rect().iTl,
       
  2672                 iPanIndLeftIcon->Bitmap(),
       
  2673                 myRect,
       
  2674                 iPanIndLeftIcon->Mask(),
       
  2675                 EFalse );                              
       
  2676                    
       
  2677             }
       
  2678 
       
  2679         // Pan Right?
       
  2680         if ( iPanRt )
       
  2681             {
       
  2682             // Draw the indicator
       
  2683             iSVGTFrameBufContext->BitBltMasked( iPanIndRightRect.Rect().iTl,
       
  2684                 iPanIndRightIcon->Bitmap(),
       
  2685                 myRect,
       
  2686                 iPanIndRightIcon->Mask(),
       
  2687                 EFalse );                              
       
  2688             }
       
  2689 
       
  2690         // Pan Up?
       
  2691         if ( iPanUp )
       
  2692             {
       
  2693             // Draw the indicator
       
  2694             iSVGTFrameBufContext->BitBltMasked( iPanIndUpRect.Rect().iTl,
       
  2695                 iPanIndUpIcon->Bitmap(),
       
  2696                 myRect,
       
  2697                 iPanIndUpIcon->Mask(),
       
  2698                 EFalse );                              
       
  2699             }
       
  2700 
       
  2701         // Pan Down?
       
  2702         if ( iPanDn )
       
  2703             {
       
  2704             // Draw the indicator
       
  2705             iSVGTFrameBufContext->BitBltMasked( iPanIndDownRect.Rect().iTl,
       
  2706                 iPanIndDownIcon->Bitmap(),
       
  2707                 myRect,
       
  2708                 iPanIndDownIcon->Mask(),
       
  2709                 EFalse );
       
  2710             }
       
  2711         }
       
  2712    }
       
  2713 
       
  2714 // -----------------------------------------------------------------------------
       
  2715 // CSVGTCustControl::CountAnimStarted
       
  2716 //  Counts the number of animations started in the SVGT content.
       
  2717 // -----------------------------------------------------------------------------
       
  2718 //
       
  2719 void CSVGTCustControl::CountAnimStarted()
       
  2720     {
       
  2721     iNumAnimInProgress++;
       
  2722 #ifdef _DEBUG
       
  2723     iDbgNumAnimStarted++;
       
  2724 #endif       
       
  2725     }
       
  2726 
       
  2727 // -----------------------------------------------------------------------------
       
  2728 // CSVGTCustControl::CountAnimPaused
       
  2729 //  Counts the number of animations paused in the SVGT content.
       
  2730 // -----------------------------------------------------------------------------
       
  2731 //
       
  2732 void CSVGTCustControl::CountAnimPaused()
       
  2733     {
       
  2734     // Pause is for the whole content, rather than per animation.
       
  2735     // Do not reset the count of animations in progress. Once the
       
  2736     // animation is resumed it would receive as many AnimStopped()(as in
       
  2737     // iNumAnimInProgress) as the animation progresses towards completion.
       
  2738 #ifdef _DEBUG
       
  2739     iDbgNumAnimPaused++;
       
  2740 #endif       
       
  2741     }
       
  2742    
       
  2743 // -----------------------------------------------------------------------------
       
  2744 // CSVGTCustControl::CountAnimStopped
       
  2745 //  Counts the number of animations stopped in the SVGT content.
       
  2746 // -----------------------------------------------------------------------------
       
  2747 //
       
  2748 void CSVGTCustControl::CountAnimStopped()
       
  2749     {
       
  2750     iNumAnimInProgress--;
       
  2751 #ifdef _DEBUG
       
  2752     iDbgNumAnimStopped++;
       
  2753 #endif           
       
  2754     }   
       
  2755 
       
  2756 // -----------------------------------------------------------------------------
       
  2757 // CSVGTCustControl::IsAnimFirst
       
  2758 //  Function indicates whether the animation currently in progress is first one.
       
  2759 // @return TBool - ETrue - First one
       
  2760 //                 EFalse Otherwise.
       
  2761 // -----------------------------------------------------------------------------
       
  2762 //
       
  2763 TBool CSVGTCustControl::IsAnimFirst() const
       
  2764     {
       
  2765     return( iNumAnimInProgress == 0 );
       
  2766     }
       
  2767 
       
  2768 // -----------------------------------------------------------------------------
       
  2769 // CSVGTCustControl::IsAnimLast
       
  2770 //  Function indicates whether the animation currently in progress is the last
       
  2771 //  one.
       
  2772 // @return TBool - ETrue - Last one
       
  2773 //                 EFalse Otherwise.
       
  2774 // -----------------------------------------------------------------------------
       
  2775 //
       
  2776 TBool CSVGTCustControl::IsAnimLast() const
       
  2777     {
       
  2778     return( iNumAnimInProgress == 0 );
       
  2779     }   
       
  2780 
       
  2781 
       
  2782 // -----------------------------------------------------------------------------
       
  2783 // CSVGTCustControl::SetPointerDisplayStatusAndRedraw
       
  2784 // Function sets the Pointer display status and redraws the whole control
       
  2785 // inorder to update display status. Called when Pointer Hide Timer times out.
       
  2786 // -----------------------------------------------------------------------------
       
  2787 //
       
  2788 void CSVGTCustControl::SetPointerDisplayStatusAndRedraw(
       
  2789     TBool aIsPointerDisplayed )
       
  2790     {
       
  2791     if ( iIsPointerDisplayed != aIsPointerDisplayed )
       
  2792         {
       
  2793         iIsPointerDisplayed = aIsPointerDisplayed;   
       
  2794         //Set the MSK label
       
  2795         if(iMSKImpl &&  iScrollKey && !iPreviewMode )
       
  2796         	{
       
  2797         	iScrollKey=EFalse;
       
  2798         	TRAP_IGNORE(SetMSKLabelL());
       
  2799         	}
       
  2800         DrawDeferred();
       
  2801         }
       
  2802     }
       
  2803 
       
  2804 // -----------------------------------------------------------------------------
       
  2805 // CSVGTCustControl::ShowPauseIcon()
       
  2806 // This function updates the pause indicator display in the main pane
       
  2807 // -----------------------------------------------------------------------------
       
  2808 //
       
  2809 void CSVGTCustControl::ShowPauseIcon(
       
  2810     TBool aPauseIconVisible ) // ETrue - Start Pause Blink
       
  2811     {
       
  2812     if ( iDisplayFlags & ESvgDrawPauseIndicator )
       
  2813         {       
       
  2814         if (aPauseIconVisible && !iBlinker->IsActive())
       
  2815             {
       
  2816             iBlinker->Start( KSccOneSecond/2, KSccOneSecond/2,
       
  2817                     TCallBack( BlinkPauseIcon, this ) );
       
  2818             }
       
  2819         if (!aPauseIconVisible && iBlinker->IsActive())
       
  2820             {
       
  2821             iBlinker->Cancel();
       
  2822             }
       
  2823         iPauseIconVisible = aPauseIconVisible;
       
  2824         }
       
  2825     }
       
  2826 
       
  2827 // -----------------------------------------------------------------------------
       
  2828 // CSVGTCustControl::BlinkPauseIcon
       
  2829 // Callback function of blink timer
       
  2830 // -----------------------------------------------------------------------------
       
  2831 //
       
  2832 TInt CSVGTCustControl::BlinkPauseIcon( TAny* aPtr )
       
  2833     {
       
  2834     if ( aPtr )
       
  2835         {
       
  2836         static_cast< CSVGTCustControl* >( aPtr )->DoBlinkPauseIcon();
       
  2837         }
       
  2838     return KErrNone;       
       
  2839     }
       
  2840 
       
  2841 // -----------------------------------------------------------------------------
       
  2842 // CSVGTCustControl::DoBlinkPauseIcon
       
  2843 // Function which does the actual work of toggling pause indicator
       
  2844 // -----------------------------------------------------------------------------
       
  2845 //
       
  2846 void CSVGTCustControl::DoBlinkPauseIcon()
       
  2847     {
       
  2848     iPauseIconVisible = !iPauseIconVisible;
       
  2849     DrawDeferred();
       
  2850     }
       
  2851 
       
  2852 // -----------------------------------------------------------------------------
       
  2853 // CSVGTCustControl::FreeIcons
       
  2854 // Function which frees the icons created by CreateIcons
       
  2855 // -----------------------------------------------------------------------------
       
  2856 //
       
  2857 void CSVGTCustControl::FreeIcons()
       
  2858     {
       
  2859     // Pointer Icons - owned
       
  2860     delete iPointerIcon;
       
  2861     iPointerIcon = NULL;
       
  2862    
       
  2863     delete iHandIcon;
       
  2864     iHandIcon = NULL;
       
  2865    
       
  2866     delete iTextIcon;
       
  2867     iTextIcon = NULL;
       
  2868    
       
  2869     // Panning Indicator Icons - owned
       
  2870     delete iPanIndLeftIcon;
       
  2871     iPanIndLeftIcon = NULL;
       
  2872    
       
  2873     delete iPanIndRightIcon;
       
  2874     iPanIndRightIcon = NULL;
       
  2875    
       
  2876     delete iPanIndUpIcon;
       
  2877     iPanIndUpIcon = NULL;
       
  2878    
       
  2879     delete iPanIndDownIcon;
       
  2880     iPanIndDownIcon = NULL;
       
  2881    
       
  2882     // Pause Indicator Icons - owned
       
  2883     delete iPauseIcon;
       
  2884     iPauseIcon = NULL;
       
  2885     }
       
  2886 
       
  2887 // ----------------------------------------------------------------------------
       
  2888 // CSVGTCustControl::LaunchWaitNoteL
       
  2889 // Helper function for launching wait note.
       
  2890 // ----------------------------------------------------------------------------
       
  2891 //
       
  2892 void CSVGTCustControl::LaunchWaitNoteL(
       
  2893     TInt aResourceId ) // Resource ID indicating
       
  2894                        // string to be displayed
       
  2895                        // while waiting.
       
  2896     {
       
  2897     if ( iDisplayFlags & ESvgDisplayWaitNote )
       
  2898         {
       
  2899         if( iWaitDialog )
       
  2900             {
       
  2901             delete iWaitDialog;
       
  2902             iWaitDialog = NULL;
       
  2903             }
       
  2904 
       
  2905         iWaitDialog = new( ELeave ) CAknWaitDialog(
       
  2906                                     reinterpret_cast<CEikDialog**>( 
       
  2907                                     &iWaitDialog ),
       
  2908                                     ETrue /* No visibility delay =
       
  2909                                              Display Wait note immediately */ );
       
  2910 
       
  2911         iWaitDialog->PrepareLC( R_SVGT_WAIT_NOTE );
       
  2912 
       
  2913         HBufC* lNoteTextPtr = StringLoader::LoadLC( aResourceId );
       
  2914         iWaitDialog->SetTextL( *lNoteTextPtr );
       
  2915         CleanupStack::PopAndDestroy( lNoteTextPtr );
       
  2916 
       
  2917         // Launch dialog
       
  2918         iWaitDialog->RunLD();
       
  2919         }
       
  2920     }
       
  2921 
       
  2922 // ----------------------------------------------------------------------------
       
  2923 // CSVGTCustControl::DismissWaitNote
       
  2924 // Helper function for dismissing wait note.
       
  2925 // ----------------------------------------------------------------------------
       
  2926 //
       
  2927 void CSVGTCustControl::DismissWaitNote()
       
  2928     {
       
  2929     if ( iDisplayFlags & ESvgDisplayWaitNote )
       
  2930         {
       
  2931         if( iWaitDialog )
       
  2932             {
       
  2933             TRAPD( err, iWaitDialog->ProcessFinishedL() );
       
  2934             if( err )
       
  2935                 {
       
  2936                 delete iWaitDialog;
       
  2937                 iWaitDialog = NULL;
       
  2938                 }
       
  2939             }
       
  2940         }
       
  2941     }
       
  2942 
       
  2943 // ----------------------------------------------------------------------------
       
  2944 // CSVGTCustControl::StartProgIndTimer
       
  2945 // Helper function for starting the progress indicator timer.
       
  2946 // ----------------------------------------------------------------------------
       
  2947 //
       
  2948 void CSVGTCustControl::StartProgIndTimer( TInt aAfter ) // Time period in
       
  2949                                                         // micro-seconds after
       
  2950                                                         // after which timer
       
  2951                                                         // expires
       
  2952     {
       
  2953     // Stop the progress indicator timer if exists
       
  2954     StopProgIndTimer();
       
  2955        
       
  2956     TRAPD(err, iProgressBarTimer =
       
  2957                    CSVGTProgressBarTimer::NewL( this,
       
  2958                    iDisplayFlags & ESvgUseBackLight ) );           
       
  2959    
       
  2960     if ( err == KErrNone )
       
  2961         {
       
  2962         // Expire after aAfter microseconds.
       
  2963         iProgressBarTimer->After( aAfter );
       
  2964         }       
       
  2965     }                                            
       
  2966 
       
  2967 // ----------------------------------------------------------------------------
       
  2968 // CSVGTCustControl::StopProgIndTimer
       
  2969 // Helper function for stopping the progress indicator timer.
       
  2970 // ----------------------------------------------------------------------------
       
  2971 //
       
  2972 void CSVGTCustControl::StopProgIndTimer()
       
  2973     {
       
  2974     // Delete the Progress Bar timer
       
  2975     if ( iProgressBarTimer )
       
  2976         {
       
  2977         delete iProgressBarTimer;
       
  2978         iProgressBarTimer = NULL;
       
  2979         }
       
  2980     }
       
  2981 
       
  2982 // -----------------------------------------------------------------------------
       
  2983 // CSVGTCustControl::ProcessPlayCmd
       
  2984 // This function is called to perform the necessary processing for the Play
       
  2985 // command.
       
  2986 // -----------------------------------------------------------------------------
       
  2987 //
       
  2988 void CSVGTCustControl::ProcessPlayCmd()
       
  2989     {
       
  2990     // Play Command is applicable only if animations are present
       
  2991     if ( IsAnimationPresent() )
       
  2992         {
       
  2993         if ( iAnimState != ESvgAnimPlayingState )
       
  2994             {
       
  2995             // Start the backlight timer if the content is of finite duration
       
  2996             if ( IsContentFinite() )
       
  2997                 {
       
  2998                 if ( ( iDisplayFlags & ESvgUseBackLight ) )
       
  2999                     {
       
  3000 #ifdef _DEBUG                    
       
  3001                     iEikonEnv->InfoMsg( KSccBacklightOnStr );   
       
  3002 #endif 
       
  3003 /*
       
  3004                     TRAPD( err, iBacklightTimer = CSVGTBacklightTimer::NewL() );
       
  3005                     if ( err == KErrNone )
       
  3006                         {
       
  3007                         iBacklightTimer->After( KSccBacklightTimerStartAfter ); 
       
  3008                         }           
       
  3009 */                       
       
  3010                     }
       
  3011                 }
       
  3012 
       
  3013             // Start the Progress Ind Timer if the content is of finite duration
       
  3014             if ( IsContentFinite() )
       
  3015                 {
       
  3016                 // Start immediately so that current count is updated.
       
  3017                 StartProgIndTimer( 0 );
       
  3018                 }
       
  3019            
       
  3020             if ( iAnimState == ESvgAnimStoppedState )
       
  3021                 {
       
  3022                 // Rewind the content
       
  3023                 iSvgModule->Replay();
       
  3024                 }
       
  3025             else
       
  3026                 {
       
  3027                 // Resume playback of the content
       
  3028                 iSvgModule->Resume();
       
  3029                 }
       
  3030             // Set the state variable to indicate content is playing        
       
  3031             iAnimState = ESvgAnimPlayingState;
       
  3032            
       
  3033             // Hide the display of Pause content
       
  3034             ShowPauseIcon( EFalse );
       
  3035             }
       
  3036         }
       
  3037     }
       
  3038    
       
  3039 // -----------------------------------------------------------------------------
       
  3040 // CSVGTCustControl::ProcessPauseCmd
       
  3041 // This function is called to perform the necessary processing for the Pause
       
  3042 // command.
       
  3043 // -----------------------------------------------------------------------------
       
  3044 //
       
  3045 void CSVGTCustControl::ProcessPauseCmd()
       
  3046     {
       
  3047     // Pause Command is applicable only if animations are present
       
  3048     if ( IsAnimationPresent() )
       
  3049         {
       
  3050         if ( iAnimState == ESvgAnimPlayingState )
       
  3051             {
       
  3052             if ( IsContentFinite() )
       
  3053                 {
       
  3054                 // Stop the progress Bar timer
       
  3055                 StopProgIndTimer();
       
  3056                 }
       
  3057             // Set the state variable.
       
  3058             iAnimState = ESvgAnimPausedState;
       
  3059             // Pause the content
       
  3060             iSvgModule->Pause();
       
  3061             // Show the pause indicator
       
  3062             ShowPauseIcon( ETrue );
       
  3063             }
       
  3064         }
       
  3065     }
       
  3066    
       
  3067 // -----------------------------------------------------------------------------
       
  3068 // CSVGTCustControl::ProcessStopCmd
       
  3069 // This function is called to perform the necessary processing for the Stop
       
  3070 // command.
       
  3071 // -----------------------------------------------------------------------------
       
  3072 //
       
  3073 void CSVGTCustControl::ProcessStopCmd()
       
  3074     {
       
  3075     // Stop Command is applicable only if animations are present
       
  3076     if ( IsAnimationPresent() )
       
  3077         {
       
  3078         if ( IsContentFinite() )
       
  3079             {
       
  3080             // Stop the progress Bar timer
       
  3081             StopProgIndTimer();
       
  3082             }
       
  3083         // Stop playing the content
       
  3084         // Do a pause so that the content is not rewound.
       
  3085         iSvgModule->Stop();
       
  3086        
       
  3087         // Reset the state variables
       
  3088         iAnimState = ESvgAnimStoppedState;
       
  3089         iProgIndTimeElap = 0;
       
  3090        
       
  3091         // Reset the number of animations in progress.
       
  3092         iNumAnimInProgress = 0;
       
  3093        
       
  3094         // Stop the display of the Pause indicator
       
  3095         ShowPauseIcon( EFalse );
       
  3096        
       
  3097         // Redraw the screen - so that pause icon is cleaned up
       
  3098         DrawDeferred();
       
  3099         }
       
  3100     }       
       
  3101 // -----------------------------------------------------------------------------
       
  3102 // CSVGTCustControl::IsVoiceCallActive 
       
  3103 // -----------------------------------------------------------------------------
       
  3104 //
       
  3105 TBool CSVGTCustControl::IsVoiceCallActive()
       
  3106     {
       
  3107     TBool call;
       
  3108     TInt type = 0; 
       
  3109     // Check whether a call is a voice call
       
  3110     TInt error = iSystemState.Get( KPSUidCtsyCallInformation,
       
  3111                                    KCTsyCallType, type );
       
  3112     if ( !error && type == EPSCTsyCallTypeCSVoice )
       
  3113         {
       
  3114         call = ETrue;
       
  3115         }
       
  3116     else
       
  3117         {
       
  3118         call = EFalse;
       
  3119         }
       
  3120          
       
  3121     TInt state = 0;
       
  3122     // Check whether the voice call is active
       
  3123     error = iSystemState.Get( KPSUidCtsyCallInformation, 
       
  3124              KCTsyCallState, state );
       
  3125     if ( call && !error && state == EPSCTsyCallStateConnected )
       
  3126         {
       
  3127         return ETrue;
       
  3128         }
       
  3129     else
       
  3130         {       
       
  3131         return EFalse;
       
  3132         }   
       
  3133     }
       
  3134 
       
  3135 // -----------------------------------------------------------------------------
       
  3136 // CSVGTCustControl::RemoveInfoNote
       
  3137 // This function is called by the periodic timer to remove the info note that
       
  3138 // is not removed because of starvation.
       
  3139 // -----------------------------------------------------------------------------
       
  3140 //
       
  3141 TInt CSVGTCustControl::RemoveInfoNote( TAny* aPtr )
       
  3142     {
       
  3143     CSVGTCustControl* thisPtr = static_cast< CSVGTCustControl* >( aPtr );
       
  3144     if ( thisPtr && thisPtr->iInfoNote )
       
  3145         {
       
  3146         delete thisPtr->iInfoNote;
       
  3147         thisPtr->iInfoNote = NULL;
       
  3148         }
       
  3149     if ( thisPtr )       
       
  3150         {
       
  3151         if ( thisPtr->iNoteRemoverTimer->IsActive() )
       
  3152             {
       
  3153             thisPtr->iNoteRemoverTimer->Cancel();
       
  3154             }
       
  3155         }
       
  3156     return KErrNone;
       
  3157     }
       
  3158 
       
  3159 // -----------------------------------------------------------------------------
       
  3160 // CSVGTCustControl::DoRotation()
       
  3161 // This function rotates the presentation in clockwise direction with given
       
  3162 // angle about bitmap center
       
  3163 // -----------------------------------------------------------------------------
       
  3164 //
       
  3165 void CSVGTCustControl::DoRotation( const TInt aAngle )
       
  3166     {
       
  3167     const TInt xCenter = iSVGTBitMap->SizeInPixels().iWidth / 2; 
       
  3168     const TInt yCenter = iSVGTBitMap->SizeInPixels().iHeight / 2;
       
  3169     const TReal32 angleInRadians = KDegreesToRadiansFactor * TReal32( aAngle );
       
  3170     iSvgModule->Rotate( angleInRadians, xCenter, yCenter );
       
  3171     // Do a Redraw
       
  3172     iSvgModule->Redraw();
       
  3173     UpdatePointer();
       
  3174     }
       
  3175 
       
  3176 #ifdef SVGTUICONTROL_DBG_TEXT_EDIT_SELECT_API_ENABLE   
       
  3177 // -----------------------------------------------------------------------------
       
  3178 // CSVGTCustControl::DoTextSelectionL()
       
  3179 // This function displays the existing text in the text/textArea in a
       
  3180 // read-only dialog so that the user can copy text into system clipboard
       
  3181 // from it.
       
  3182 // -----------------------------------------------------------------------------
       
  3183 //
       
  3184 void CSVGTCustControl::DoTextSelectionL(
       
  3185     TDes& aText // Text Content descriptor
       
  3186     ) const
       
  3187     {
       
  3188     CAknTextQueryDialog* dlgPtr = CAknTextQueryDialog::NewL( aText );
       
  3189     dlgPtr->ExecuteLD( R_SVGT_TEXT_SELECTION_DIALOG );
       
  3190     }
       
  3191 
       
  3192 // -----------------------------------------------------------------------------
       
  3193 // CSVGTCustControl::DoTextEditingL()
       
  3194 // This function displays the existing text in the text/textArea element which
       
  3195 // is editable and returns the modified text in the same descriptor.
       
  3196 // -----------------------------------------------------------------------------
       
  3197 //
       
  3198 void CSVGTCustControl::DoTextEditingL(
       
  3199     TBool aIsTextElement, // Bool indicating whether element is text/textArea
       
  3200     TInt aElemHandle, // Element handle from engine
       
  3201     TDes& aText ) // Text Content descriptor
       
  3202     {
       
  3203     const TChar KOpeningBraces ='<';
       
  3204     const TChar KClosingBraces ='>';
       
  3205     TBool lTextQueryDone = EFalse;
       
  3206 
       
  3207     while ( !lTextQueryDone )
       
  3208         {
       
  3209         CAknTextQueryDialog* dlgPtr = CAknTextQueryDialog::NewL( aText );
       
  3210         dlgPtr->SetPredictiveTextInputPermitted( ETrue );
       
  3211         TInt retVal = dlgPtr->ExecuteLD( R_SVGT_EDIT_TEXT_QUERY_DIALOG );
       
  3212         if (retVal)
       
  3213             {
       
  3214             if ( !iIsTextChanged )
       
  3215                 {
       
  3216                 // Set iIsTextChanged to indicate that text content is
       
  3217                 // changed and changes need to be saved
       
  3218                 iIsTextChanged = ETrue;
       
  3219                 }
       
  3220            
       
  3221             if( aText.Locate( KOpeningBraces ) != KErrNotFound ||
       
  3222                     aText.Locate( KClosingBraces ) != KErrNotFound )
       
  3223                 {
       
  3224                 // display a error not with the msg that the text area
       
  3225                 // cant contain < or > since it will fuddle up the xml parsing
       
  3226                 DisplayInfoNoteL(R_SVGT_BRACES_FOUND_IN_TEXTAREA, ETrue );
       
  3227                 }
       
  3228                 else
       
  3229                     {
       
  3230                     // User entered valid text, go out of loop
       
  3231                     lTextQueryDone = ETrue;
       
  3232                     }
       
  3233             }
       
  3234             else
       
  3235                 {
       
  3236                 // User pressed cancel, no need to change the text
       
  3237                 // return back to caller
       
  3238                 return;
       
  3239                 }
       
  3240         }
       
  3241 
       
  3242     if ( aIsTextElement )
       
  3243         {
       
  3244         // Update the text element in the engine
       
  3245         iSvgModule->SetTextForTextElement( aElemHandle, aText );
       
  3246         }
       
  3247         else
       
  3248             {
       
  3249             // Update the textArea element in the engine
       
  3250             iSvgModule->SetTextForTextAreaElement( aElemHandle, aText );
       
  3251             }
       
  3252     // Redraw the screen to reflect the new changes
       
  3253     iSvgModule->Redraw();
       
  3254            
       
  3255 
       
  3256     }
       
  3257 #endif // SVGTUICONTROL_DBG_TEXT_EDIT_SELECT_API_ENABLE 
       
  3258 
       
  3259 // -----------------------------------------------------------------------------
       
  3260 // CSVGTCustControl::FPRCenter()
       
  3261 // This function calculates the center of the four point rectangle
       
  3262 // -----------------------------------------------------------------------------
       
  3263 //
       
  3264 TPoint CSVGTCustControl::FPRCenter(
       
  3265     const MRect* aBBoxRect    // Four point rect
       
  3266     ) const
       
  3267     {
       
  3268     TPoint pt1( 0, 0 ), pt2( 0, 0 ), pt3( 0, 0 ), pt4( 0, 0 );
       
  3269     TPoint lCentre;
       
  3270 
       
  3271     if ( aBBoxRect )
       
  3272         {
       
  3273         aBBoxRect->GetPoints( pt1, pt2, pt3, pt4 );
       
  3274         // Center of the rectangle is the center of the diagonal as
       
  3275         // diagonals are congruent in a rectangle
       
  3276         lCentre = TPoint( ( pt1.iX + pt3.iX ) / 2, ( pt1.iY + pt3.iY )/2 );
       
  3277         }
       
  3278     return lCentre;
       
  3279     }
       
  3280 
       
  3281 // -----------------------------------------------------------------------------
       
  3282 // CSVGTCustControl::FPRIntersects()
       
  3283 // This function calculates whether the FPR intersects with the rectangle
       
  3284 // -----------------------------------------------------------------------------
       
  3285 TBool CSVGTCustControl::FPRIntersects(
       
  3286     const MRect* aBBoxRect,   // Four point rect
       
  3287     const TRect& aRect        // Rectangle
       
  3288     ) const
       
  3289     {
       
  3290     TPoint pt1( 0, 0 ), pt2( 0, 0 ), pt3( 0, 0 ), pt4( 0, 0 );
       
  3291     if ( aBBoxRect )
       
  3292         {
       
  3293         aBBoxRect->GetPoints( pt1, pt2, pt3, pt4 );   
       
  3294         // TODO: Need to use clipping algorithm here - to check whether line is
       
  3295         // within rectangle.
       
  3296         TInt32 maxx,maxy,minx,miny;
       
  3297         
       
  3298         maxx = pt1.iX;
       
  3299         if(pt2.iX > maxx)
       
  3300         	maxx = pt2.iX;
       
  3301         if(pt3.iX > maxx)
       
  3302         	maxx = pt3.iX;
       
  3303         if(pt4.iX > maxx)
       
  3304         	maxx = pt4.iX;
       
  3305         
       
  3306         maxy = pt1.iY;
       
  3307         if(pt2.iY > maxy)
       
  3308         	maxy = pt2.iY;
       
  3309         if(pt3.iY > maxy)
       
  3310         	maxy = pt3.iY;
       
  3311         if(pt4.iY > maxy)
       
  3312         	maxy = pt4.iY;
       
  3313         
       
  3314         minx = pt1.iX;
       
  3315         if(pt2.iX < minx)
       
  3316         	minx = pt2.iX;
       
  3317         if(pt3.iX < minx)
       
  3318         	minx = pt3.iX;
       
  3319         if(pt4.iX < minx)
       
  3320         	minx = pt4.iX;
       
  3321         
       
  3322         miny = pt1.iY;
       
  3323         if(pt2.iY < miny)
       
  3324         	miny = pt2.iY;
       
  3325         if(pt3.iY < miny)
       
  3326         	miny = pt3.iY;
       
  3327         if(pt4.iY < miny)
       
  3328         	miny = pt4.iY;
       
  3329         
       
  3330 
       
  3331         TPoint topleft(aRect.iTl);
       
  3332         TPoint bottomright(aRect.iBr);
       
  3333 
       
  3334 	    if ( ( bottomright.iX < minx ) || ( maxx < topleft.iX ) ||
       
  3335          	 ( bottomright.iY  < miny) || ( maxy < topleft.iY ) )
       
  3336         {
       
  3337         return EFalse;
       
  3338         }
       
  3339         
       
  3340         return ETrue;
       
  3341         }
       
  3342     return EFalse;   
       
  3343     }
       
  3344 // -----------------------------------------------------------------------------
       
  3345 // CSVGTCustControl::FPR2PointArrayL()
       
  3346 // This function converts a Four Point Rect into an array of points
       
  3347 // -----------------------------------------------------------------------------
       
  3348 void CSVGTCustControl::FPR2PointArrayL(
       
  3349     const MRect* aBBoxRect,         // Four Point Rect
       
  3350     CArrayFix<TPoint>*& aArrayPtr   // Array of Points
       
  3351     )  const
       
  3352     {
       
  3353     aArrayPtr = new (ELeave) CArrayFixFlat<TPoint> ( 4 );
       
  3354     CleanupStack::PushL( aArrayPtr );
       
  3355     TPoint pt1( 0, 0 ), pt2( 0, 0 ), pt3( 0, 0 ), pt4( 0, 0 );
       
  3356    
       
  3357     if ( aBBoxRect )
       
  3358         {
       
  3359         aBBoxRect->GetPoints( pt1, pt2, pt3, pt4 );
       
  3360         }
       
  3361     aArrayPtr->AppendL( pt1 );
       
  3362     aArrayPtr->AppendL( pt2 );
       
  3363     aArrayPtr->AppendL( pt4 );
       
  3364     aArrayPtr->AppendL( pt3 );   
       
  3365    
       
  3366     CleanupStack::Pop( aArrayPtr ); // Ownership transferred to caller
       
  3367     }
       
  3368 
       
  3369 // -----------------------------------------------------------------------------
       
  3370 // CSVGTCustControl::Draw
       
  3371 // Reimplements CCoeControl::Draw to draw this control's view to the screen
       
  3372 // -----------------------------------------------------------------------------
       
  3373 //
       
  3374 void CSVGTCustControl::Draw(
       
  3375     const TRect& aRect ) const
       
  3376     {
       
  3377     iSVGTFrameBufContext->Clear();
       
  3378    
       
  3379     if ( iSVGTBitMap && iSVGTBitMapMask )
       
  3380         {
       
  3381         iSVGTFrameBufContext->BitBltMasked( iViewerPaneRect.Rect().iTl,
       
  3382                                             iSVGTBitMap,
       
  3383                                             iViewerPaneRect.Rect(),
       
  3384                                             iSVGTBitMapMask,
       
  3385                                             ETrue );
       
  3386         }
       
  3387    
       
  3388     // Draw the bounding box
       
  3389     DrawFindTextBBox( aRect );
       
  3390 
       
  3391     if ( iDisplayFlags & ESvgDrawPanIndicator )
       
  3392         {
       
  3393         // Draw Panning Indicator
       
  3394         DrawPanInd();
       
  3395         }
       
  3396    
       
  3397     // draw paused icon
       
  3398     if ( iPauseIconVisible )
       
  3399         {
       
  3400         iSVGTFrameBufContext->BitBltMasked( iPauseRect.Rect().iTl,
       
  3401             iPauseIcon->Bitmap(),
       
  3402             Rect(),
       
  3403             iPauseIcon->Mask(),
       
  3404             EFalse ); 
       
  3405         }
       
  3406 
       
  3407     
       
  3408     // Draw Pointer
       
  3409     if ( iIsPointerDisplayed && iDisplayFlags & ESvgDrawPointer )
       
  3410         {
       
  3411         DrawPointer();   
       
  3412         }
       
  3413 
       
  3414     // Get the standard graphics context
       
  3415     CWindowGc& gc = SystemGc();
       
  3416     // Blit our framebuffer bitmap to the System GC   
       
  3417     gc.BitBlt( iViewerPaneRect.Rect().iTl, iSVGTFrameBufBitMap );
       
  3418     }
       
  3419 
       
  3420 // -----------------------------------------------------------------------------
       
  3421 // CSVGTCustControl::ConstructFromResourceL
       
  3422 // Since this control is to be displayed in a dialog, this function is
       
  3423 // reimplented from CCoeControl::ConstructFromResourceL inorder to read
       
  3424 // resource values from resource file.
       
  3425 // -----------------------------------------------------------------------------
       
  3426 //
       
  3427 void CSVGTCustControl::ConstructFromResourceL(
       
  3428     TResourceReader& /*aReader*/) // Resource Reader
       
  3429     {
       
  3430     }
       
  3431 
       
  3432 // -----------------------------------------------------------------------------
       
  3433 // CSVGTCustControl::SizeChanged
       
  3434 // Handles resizing of control reimplementing CCoeControl::SizeChanged.
       
  3435 // -----------------------------------------------------------------------------
       
  3436 //
       
  3437 void CSVGTCustControl::SizeChanged()
       
  3438     {
       
  3439     TRect myRect = Rect();
       
  3440    
       
  3441    // Commented this section because,Indicators were not displaying in
       
  3442    // case of theme change
       
  3443    // if ( myRect == iCurrentLayout )
       
  3444    //    {
       
  3445    // Layout has not changed, do nothing
       
  3446    // return;
       
  3447    // } 
       
  3448    // 
       
  3449        
       
  3450     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
  3451         {
       
  3452         TInt lVariety = 0; // Normal Screen
       
  3453         if ( iIsFullScreenOn )
       
  3454             {
       
  3455             lVariety = 1; // Full Screen
       
  3456             }
       
  3457        
       
  3458         // Main Viewer Pane
       
  3459         iViewerPaneRect.LayoutRect( myRect,
       
  3460             AknLayoutScalable_Apps::main_viewer_pane( lVariety ) );
       
  3461        
       
  3462         // Panning Indicators
       
  3463         iPanIndLeftRect.LayoutRect( myRect,
       
  3464             AknLayoutScalable_Apps::main_viewer_pane_g3( lVariety ) );
       
  3465         iPanIndRightRect.LayoutRect( myRect,
       
  3466             AknLayoutScalable_Apps::main_viewer_pane_g4( lVariety ) );
       
  3467         iPanIndUpRect.LayoutRect( myRect,
       
  3468             AknLayoutScalable_Apps::main_viewer_pane_g1( lVariety ) );
       
  3469         iPanIndDownRect.LayoutRect( myRect,
       
  3470             AknLayoutScalable_Apps::main_viewer_pane_g2( lVariety ) );
       
  3471       // Panning Indicators Rectangle for Touch Area
       
  3472       	iPanIndLeftAidRect.LayoutRect( myRect,
       
  3473             AknLayoutScalable_Apps::aid_main_viewer_pane_g3( lVariety ) );
       
  3474         iPanIndRightAidRect.LayoutRect( myRect,
       
  3475             AknLayoutScalable_Apps::aid_main_viewer_pane_g4( lVariety ) );
       
  3476         iPanIndUpAidRect.LayoutRect( myRect,
       
  3477             AknLayoutScalable_Apps::aid_main_viewer_pane_g1( lVariety ) );
       
  3478         iPanIndDownAidRect.LayoutRect( myRect,
       
  3479             AknLayoutScalable_Apps::aid_main_viewer_pane_g2( lVariety ) );
       
  3480        
       
  3481         // Pointers
       
  3482         iPointerRect.LayoutRect( myRect,
       
  3483             AknLayoutScalable_Apps::main_viewer_pane_g5( lVariety ) );
       
  3484         iHandRect.LayoutRect( myRect,
       
  3485             AknLayoutScalable_Apps::main_viewer_pane_g7( lVariety ) );
       
  3486         iTextRect.LayoutRect( myRect,
       
  3487             AknLayoutScalable_Apps::main_viewer_pane_g7( lVariety ) );
       
  3488        
       
  3489         // Pause Indicator
       
  3490         iPauseRect.LayoutRect( myRect,
       
  3491             AknLayoutScalable_Apps::main_viewer_pane_g8( lVariety ) );
       
  3492 
       
  3493         // Aid for display of pointer
       
  3494         // In order to draw the cursor in the correct location on
       
  3495         // the screen, the viewer needs to know the offsetX and offSetY
       
  3496         // of the cursor hotspot in the icon bitmap.
       
  3497         // Because of Scalable UI the size of the icons can be changed
       
  3498         // and this would result in the change of these co-ordinates.
       
  3499         // he viewer needs to get this information from the LAF
       
  3500         // so that viewer can draw the cursor in the correct position
       
  3501         // on the screen.
       
  3502        
       
  3503         iPointerAidRect.LayoutRect( myRect,
       
  3504             AknLayoutScalable_Apps::aid_hotspot_pointer_arrow_pane() );
       
  3505         iHandAidRect.LayoutRect( myRect,
       
  3506             AknLayoutScalable_Apps::aid_hotspot_pointer_hand_pane() );
       
  3507         iTextAidRect.LayoutRect( myRect,
       
  3508             AknLayoutScalable_Apps::aid_hotspot_pointer_text2_pane() );
       
  3509         }
       
  3510         else
       
  3511             {
       
  3512             // Hardcode the values for normal resolution (172x208)
       
  3513            
       
  3514             iViewerPaneRect.LayoutRect( myRect,
       
  3515                 0, 0, 0, 0, 0, myRect.Width(), myRect.Height() );
       
  3516                
       
  3517             iPanIndLeftRect.LayoutRect( myRect,
       
  3518                     0, 0, ( myRect.Height() / KSccConstTwo ) - 8, 0, 0, 6, 15 );
       
  3519             iPanIndRightRect.LayoutRect( myRect,
       
  3520                     0, ( myRect.Width() - 6 ),
       
  3521                     (myRect.Height() / KSccConstTwo ) - 8, 0, 0, 6, 15 );
       
  3522             iPanIndUpRect.LayoutRect( myRect,
       
  3523                     0, ( ( myRect.Width() / KSccConstTwo ) - 8 ),  0, 0, 0,
       
  3524                     15, 6 );
       
  3525             iPanIndDownRect.LayoutRect( myRect,
       
  3526                     0, ( ( myRect.Width() / KSccConstTwo ) - 8 ), 
       
  3527                     myRect.Height() - 6, 0, 0, 15, 6 );
       
  3528 
       
  3529             iPointerRect.LayoutRect( myRect,
       
  3530                     0, 0, 0, 0, 0, 18, 24 );
       
  3531             iHandRect.LayoutRect( myRect,
       
  3532                     0, 0, 0, 0, 0, 18, 24 );
       
  3533             iTextRect.LayoutRect( myRect,
       
  3534                     0, 0, 0, 0, 0, 18, 24 );
       
  3535 
       
  3536            
       
  3537             iPauseRect.LayoutRect(myRect,
       
  3538                     0, 0, 0, 0, 0, 13, 13 );
       
  3539            
       
  3540             iPointerAidRect.LayoutRect( myRect,
       
  3541                     0, 0, 0, 0, 0, 0, 0 );
       
  3542             iHandAidRect.LayoutRect( myRect,
       
  3543                     0, 0, 0, 0, 0, 0, 0 );                   
       
  3544             iTextAidRect.LayoutRect( myRect,
       
  3545                     0, 0, 0, 0, 0, 0, 0 );                   
       
  3546             }
       
  3547    
       
  3548     // Set the size of the bitmaps
       
  3549     // No Error Handling for SetSize
       
  3550     // Pointers
       
  3551     AknIconUtils::SetSize( iPointerIcon->Bitmap(), iPointerRect.Rect().Size() );
       
  3552     AknIconUtils::SetSize( iHandIcon->Bitmap(), iHandRect.Rect().Size() );
       
  3553     AknIconUtils::SetSize( iTextIcon->Bitmap(), iTextRect.Rect().Size() );
       
  3554 
       
  3555     // Panning Indicators
       
  3556 
       
  3557     // Left Ind
       
  3558     AknIconUtils::SetSize( iPanIndLeftIcon->Bitmap(),
       
  3559             iPanIndLeftRect.Rect().Size() );
       
  3560 
       
  3561     // Right Ind
       
  3562     AknIconUtils::SetSize( iPanIndRightIcon->Bitmap(),
       
  3563             iPanIndRightRect.Rect().Size() );
       
  3564    
       
  3565     // Up Ind
       
  3566     AknIconUtils::SetSize( iPanIndUpIcon->Bitmap(),
       
  3567             iPanIndUpRect.Rect().Size() );
       
  3568 
       
  3569     // Down Ind
       
  3570     AknIconUtils::SetSize( iPanIndDownIcon->Bitmap(),
       
  3571             iPanIndDownRect.Rect().Size() );
       
  3572 
       
  3573     // Pause Ind
       
  3574     AknIconUtils::SetSize( iPauseIcon->Bitmap(),
       
  3575             iPauseRect.Rect().Size() );
       
  3576 
       
  3577     // Recreate the framebuffer.
       
  3578     TRAPD( errSwitchMode, SwitchScreenModeL() );
       
  3579     if ( errSwitchMode != KErrNone )
       
  3580         {
       
  3581         // Let environment handle error
       
  3582         iCoeEnv->HandleError( errSwitchMode );
       
  3583         }
       
  3584    
       
  3585     // Dummy mouse-move to the engine
       
  3586     iSvgModule->MouseMove( iPointerX, iPointerY );                   
       
  3587    
       
  3588     // Save current layout so that we know if the Layout changed.
       
  3589     iCurrentLayout = myRect;
       
  3590     }
       
  3591 
       
  3592 
       
  3593 // -----------------------------------------------------------------------------
       
  3594 // CSVGTCustControl::AnimationStarted
       
  3595 // Handles callback notification from SVG engine indicating Animation Started.
       
  3596 // Reimplements MSvgAnimationListener::AnimationStarted.
       
  3597 // -----------------------------------------------------------------------------
       
  3598 //
       
  3599 TBool CSVGTCustControl::AnimationStarted( TBool aIsAnimationIndefinite )
       
  3600     {
       
  3601     // If the content contains any infinite animations - then the
       
  3602     // backlight behaves normally.
       
  3603     if ( !IsContentFinite() )
       
  3604         {
       
  3605         return ETrue;
       
  3606         }
       
  3607        
       
  3608     if ( aIsAnimationIndefinite )
       
  3609         {
       
  3610 #ifdef _DEBUG
       
  3611         iEikonEnv->InfoMsg( KSccBacklightOffStr );   
       
  3612 #endif 
       
  3613        
       
  3614         }
       
  3615         else
       
  3616             {
       
  3617             if ( IsAnimFirst() )
       
  3618                 {               
       
  3619 #ifdef _DEBUG                    
       
  3620                 iEikonEnv->InfoMsg( KSccBacklightOnStr );   
       
  3621 #endif 
       
  3622                 if ( ( iDisplayFlags & ESvgUseBackLight ) )
       
  3623                     {
       
  3624                         
       
  3625                     }
       
  3626                 }
       
  3627             CountAnimStarted();
       
  3628             }
       
  3629     return ETrue;
       
  3630     }
       
  3631 
       
  3632 // -----------------------------------------------------------------------------
       
  3633 // CSVGTCustControl::AnimationEnded
       
  3634 // Handles callback notification from SVG engine indicating Animation Ended.
       
  3635 // Reimplements MSvgAnimationListener::AnimationEnded.
       
  3636 // -----------------------------------------------------------------------------
       
  3637 //
       
  3638 TBool CSVGTCustControl::AnimationEnded()
       
  3639     {
       
  3640     // If the content contains any infinite animations - then the
       
  3641     // backlight behaves normally.
       
  3642     if ( !IsContentFinite() )
       
  3643         {
       
  3644         return ETrue;
       
  3645         }
       
  3646    
       
  3647     CountAnimStopped();
       
  3648     if ( IsAnimLast() )
       
  3649         {
       
  3650 #ifdef _DEBUG
       
  3651         iEikonEnv->InfoMsg( KSccBacklightOffStr );   
       
  3652 #endif 
       
  3653         // All animations have ended
       
  3654        
       
  3655         }
       
  3656     return ETrue;
       
  3657     }
       
  3658 
       
  3659 // -----------------------------------------------------------------------------
       
  3660 // CSVGTCustControl::AnimationPaused
       
  3661 // Handles callback notification from SVG engine indicating Animation Paused.
       
  3662 // Reimplements MSvgAnimationListener::AnimationPaused.
       
  3663 // -----------------------------------------------------------------------------
       
  3664 //
       
  3665 TBool CSVGTCustControl::AnimationPaused()
       
  3666     {
       
  3667     // If the content contains any infinite animations - then the
       
  3668     // backlight behaves normally.
       
  3669     if ( !IsContentFinite() )
       
  3670         {
       
  3671         return ETrue;
       
  3672         }
       
  3673    
       
  3674 #ifdef _DEBUG
       
  3675     iEikonEnv->InfoMsg( KSccBacklightOffStr );   
       
  3676 #endif 
       
  3677     // Animation is paused,
       
  3678     CountAnimPaused();
       
  3679 
       
  3680     return ETrue;
       
  3681     }
       
  3682 
       
  3683 // -----------------------------------------------------------------------------
       
  3684 // CSVGTCustControl::UpdateProgressBar
       
  3685 // This function updates the progress bar in the navi pane. It is called back
       
  3686 // by the progress bar timer.
       
  3687 // -----------------------------------------------------------------------------
       
  3688 //
       
  3689 void CSVGTCustControl::UpdateProgressBar()
       
  3690     {
       
  3691     
       
  3692     TReal lSecElapsedRounded = 0.0;
       
  3693     TReal lSecElapsedReal    = 0.0;
       
  3694     TReal lTotalTimeReal     = 0.0;
       
  3695     TReal lTotalTimeRounded  = 0.0;
       
  3696     TUint32 lTimeElapsed     = 0;
       
  3697         
       
  3698     lSecElapsedReal = (TReal)iSvgModule->MediaTime() 
       
  3699             / KSccNumMSecPerSec;
       
  3700             
       
  3701     lTotalTimeReal = (TReal)iDuration / KSccNumMSecPerSec;      
       
  3702         if ( iProgressBarDrawImpl )
       
  3703             {
       
  3704             
       
  3705         
       
  3706            // Round off the Elapsed time inorder to display time accurately.
       
  3707            Math::Round( lSecElapsedRounded, lSecElapsedReal, 0 );
       
  3708         
       
  3709            // Round off the Total time inorder to display time accurately.
       
  3710            Math::Round( lTotalTimeRounded, lTotalTimeReal, 0 );
       
  3711 
       
  3712            lTimeElapsed = lSecElapsedRounded;
       
  3713            TRAPD( err, iProgressBarDrawImpl->DrawProgressBarL( lTimeElapsed, 
       
  3714            lTotalTimeRounded ) );
       
  3715            if ( err != KErrNone )
       
  3716               {
       
  3717               // Error Case, Nothing is done now.
       
  3718                }    
       
  3719             
       
  3720       
       
  3721            // Stop the Progress Bar timer
       
  3722            StopProgIndTimer();
       
  3723            iProgIndTimeElap = lSecElapsedReal ;
       
  3724    
       
  3725             }
       
  3726             
       
  3727         // Check whether end of animation is reached.
       
  3728         // 01-Feb-2008 Fix for TSW Id "CGSR-7B6DFW"
       
  3729         // Earlier this check was happening only if iProgressBarDrawImpl is there
       
  3730         // for screen saver iProgressBarDrawImpl is not there but still the animation
       
  3731         // should work for the duration set for ScreenSaver
       
  3732         
       
  3733      if ( lSecElapsedReal >= (TReal)iDuration / KSccNumMSecPerSec )
       
  3734         {
       
  3735         TInt err = 0;
       
  3736         // Reset the state variables
       
  3737         iProgIndTimeElap = 0;
       
  3738         
       
  3739         // Stop the animation and rewind.
       
  3740         TRAP(err, ProcessViewerCommandL( ESvgtDlgStopCommand ) );
       
  3741         if ( err != KErrNone )
       
  3742             {
       
  3743             // Error Case, Nothing is done now.               
       
  3744             }
       
  3745         // If loop is on then replay the content.
       
  3746         if ( !iIsLoopOn )
       
  3747             {
       
  3748             // Animation is done, no need to continue progress bar.
       
  3749             return;
       
  3750             }
       
  3751             else
       
  3752                 {
       
  3753                 // Loop option enabled. Replay content.
       
  3754                 TRAP( err, ProcessViewerCommandL( ESvgtDlgPlayCommand ));
       
  3755                 if ( err != KErrNone )
       
  3756                     {
       
  3757                     // Error Case, Nothing is done now.
       
  3758                     }
       
  3759                 return;
       
  3760                 }
       
  3761         }        
       
  3762             
       
  3763             
       
  3764             
       
  3765             
       
  3766     // Restart the timer
       
  3767     StartProgIndTimer( KSccProgIndTimerYieldDur ); 
       
  3768     }   
       
  3769 
       
  3770 
       
  3771 
       
  3772 // -----------------------------------------------------------------------------
       
  3773 // CSVGTCustControl::PointerInactivityTimeout()
       
  3774 // This function updates the pointer display status in the navi pane.
       
  3775 // It is called back by the pointer hide timer.
       
  3776 // -----------------------------------------------------------------------------
       
  3777 //
       
  3778 void CSVGTCustControl::PointerInactivityTimeout()
       
  3779     {
       
  3780     // UI Spec: Hide Pointer as time of inactivity has passed
       
  3781     SetPointerDisplayStatusAndRedraw( EFalse );
       
  3782    
       
  3783     //Set the MSK label
       
  3784     if(iMSKImpl && !iPreviewMode )
       
  3785     	{
       
  3786     	TRAP_IGNORE(SetMSKLabelL());
       
  3787     	}
       
  3788    		
       
  3789     // Delete the inactivity timer
       
  3790     delete iInactivityTimer;
       
  3791     iInactivityTimer = NULL;
       
  3792     }
       
  3793 
       
  3794 #ifdef SVGTUICONTROL_DBG_TEXT_EDIT_SELECT_API_ENABLE
       
  3795 // -----------------------------------------------------------------------------
       
  3796 // CSVGTCustControl::TextAreaEntered()
       
  3797 // This callback is called to notify when a pointer enters a textbox element.
       
  3798 // -----------------------------------------------------------------------------
       
  3799 //
       
  3800 TBool CSVGTCustControl::TextAreaEntered( TInt aTextAreaHandle )
       
  3801     {
       
  3802     // Save the current element handle
       
  3803     iCurrentTextElementId = aTextAreaHandle;
       
  3804    
       
  3805     // Indicate that it is a text area element
       
  3806     iIsCurrentTextElement = EFalse;
       
  3807    
       
  3808     // check if there is a 'a' element or interactive element
       
  3809     // within which text is present
       
  3810     
       
  3811     if(iAElement || iPointerDownAnimation)
       
  3812     	{
       
  3813     	iPointerType=ESvgPointerHand;	
       
  3814     	}
       
  3815     else
       
  3816     	{
       
  3817     	// Text symbol to indicate user can perform some action by clicking
       
  3818     	iPointerType = ESvgPointerText;
       
  3819     	}
       
  3820     // Remember that textArea element is entered, so that
       
  3821     // subsequent text element notifications are ignored
       
  3822     iTextAreaEntered = ETrue;
       
  3823    
       
  3824     // Enable Select Menu Option
       
  3825     iIsTextSelectOn = ETrue;
       
  3826     HBufC* lStrPtr = HBufC::New( KSccMaxTextLength );
       
  3827     if ( !lStrPtr )
       
  3828         {
       
  3829         // Error while allocation, no memory
       
  3830         iCoeEnv->HandleError( KErrNoMemory );
       
  3831         return ETrue;
       
  3832         }
       
  3833     TPtr lPtr = lStrPtr->Des();
       
  3834    
       
  3835     // Check whether the Text is editable
       
  3836     iSvgModule->GetTextForTextAreaElement( aTextAreaHandle,
       
  3837         iIsTextEditOn,
       
  3838         lPtr );   
       
  3839 
       
  3840     delete lStrPtr;
       
  3841    
       
  3842     //Display MSK label Select/Edit
       
  3843     if(iMSKImpl && !iPreviewMode)
       
  3844     	{
       
  3845     	TRAP_IGNORE(SetMSKLabelL());	
       
  3846     	}
       
  3847    	
       
  3848     return ETrue;
       
  3849     }
       
  3850 
       
  3851 // -----------------------------------------------------------------------------
       
  3852 // CSVGTCustControl::TextAreaExited()
       
  3853 // This callback is called to notify when a pointer exits a textbox element.
       
  3854 // -----------------------------------------------------------------------------
       
  3855 //
       
  3856 TBool CSVGTCustControl::TextAreaExited( TInt /* aTextAreaHandle */)
       
  3857     {
       
  3858     // Reset the current element handle
       
  3859     iCurrentTextElementId = 0;
       
  3860    
       
  3861     // Reset the element flag to text element
       
  3862     iIsCurrentTextElement = ETrue;
       
  3863    
       
  3864     // check if there is a 'a' element or interactive element
       
  3865     // within which text is present
       
  3866     if(iAElement || iPointerDownAnimation)
       
  3867     	{
       
  3868     	iPointerType=ESvgPointerHand;	
       
  3869     	}
       
  3870     else
       
  3871     	{
       
  3872     	// Reset the pointer to default pointer
       
  3873     	iPointerType = ESvgPointerDefault;   
       
  3874     	}
       
  3875     // Remember that textArea element is exitted
       
  3876     iTextAreaEntered = EFalse;
       
  3877 
       
  3878     // Disable the Select and Edit menu option
       
  3879     iIsTextSelectOn = EFalse;
       
  3880     iIsTextEditOn = EFalse;
       
  3881     //Set the MSK label
       
  3882     if(iMSKImpl && !iPreviewMode)
       
  3883     	{
       
  3884     	TRAP_IGNORE(SetMSKLabelL());	
       
  3885     	}
       
  3886    
       
  3887     return ETrue;
       
  3888     }
       
  3889 
       
  3890 // -----------------------------------------------------------------------------
       
  3891 // CSVGTCustControl::TextAreaActivated()
       
  3892 // This callback is called to notify that a text element has been activated.
       
  3893 // -----------------------------------------------------------------------------
       
  3894 //
       
  3895 TBool CSVGTCustControl::TextAreaActivated( TInt aTextAreaHandle )
       
  3896     {
       
  3897     if (iSelectCause != ESvgInvalidSelectCause )
       
  3898         {
       
  3899         // Ignore this callback as it was already processed.
       
  3900         return ETrue;
       
  3901         }
       
  3902     // Set the cause for select operation as text area so that
       
  3903     // subsequent events trigerred are ignored.
       
  3904     iSelectCause = ESvgTextAreaSelectCause;
       
  3905 
       
  3906     HBufC* lStrPtr = HBufC::New( KMaxEditorTextLength );         
       
  3907     if ( !lStrPtr )
       
  3908         {
       
  3909         // Error while allocation, no memory
       
  3910         iCoeEnv->HandleError( KErrNoMemory );
       
  3911         return ETrue;
       
  3912         }
       
  3913     TPtr lPtr = lStrPtr->Des();
       
  3914    
       
  3915     // Check whether the Text is editable
       
  3916     iSvgModule->GetTextForTextAreaElement( aTextAreaHandle,
       
  3917         iIsTextEditOn,
       
  3918         lPtr );
       
  3919        
       
  3920     if ( iIsTextEditOn && !iSvgModule->IsLoading() )
       
  3921         {
       
  3922         TRAPD( err, DoTextEditingL(
       
  3923                         EFalse,              // Text Area Element
       
  3924                         aTextAreaHandle,     // Element Handle
       
  3925                         lPtr ) );            // buffer pointer
       
  3926         if ( err != KErrNone )
       
  3927             {
       
  3928             // No error handling done.
       
  3929             }
       
  3930                        
       
  3931         }
       
  3932         else
       
  3933             {
       
  3934             TRAPD( err,
       
  3935                 DoTextSelectionL( lPtr );
       
  3936                 );
       
  3937             if ( err != KErrNone )
       
  3938                 {
       
  3939                 // No error handling done.
       
  3940                 }
       
  3941             }
       
  3942    
       
  3943     delete lStrPtr;       
       
  3944     return ETrue;
       
  3945     }
       
  3946    
       
  3947 // -----------------------------------------------------------------------------
       
  3948 // CSVGTCustControl::TextEntered()
       
  3949 // This callback is called to notify that a text element has been entered.
       
  3950 // -----------------------------------------------------------------------------
       
  3951 //
       
  3952 TBool CSVGTCustControl::TextEntered( TInt aTextHandle )
       
  3953     {
       
  3954     if ( iTextAreaEntered )
       
  3955         {
       
  3956         // Ignore all text element notifications when cursor is
       
  3957         // within a textArea element
       
  3958         return ETrue;
       
  3959         }
       
  3960        
       
  3961     // Save the current element handle
       
  3962     iCurrentTextElementId = aTextHandle;
       
  3963    
       
  3964     // Set the flag to indicate element type is text element
       
  3965     iIsCurrentTextElement = ETrue;
       
  3966    
       
  3967     // check if there is a 'a' element or interactive element
       
  3968     // within which text is present
       
  3969     
       
  3970     if(iAElement || iPointerDownAnimation)
       
  3971     	{
       
  3972     	iPointerType=ESvgPointerHand;	
       
  3973     	}
       
  3974     else
       
  3975     	{
       
  3976     	// Text symbol to indicate user can perform some action by clicking
       
  3977     	iPointerType = ESvgPointerText;
       
  3978     	}
       
  3979     // Enable Select Menu Option
       
  3980     iIsTextSelectOn = ETrue;
       
  3981 
       
  3982     HBufC* lStrPtr = HBufC::New( KSccMaxTextLength );
       
  3983    
       
  3984     if ( !lStrPtr )
       
  3985         {
       
  3986         // Error while allocation, no memory
       
  3987         iCoeEnv->HandleError( KErrNoMemory );
       
  3988         return ETrue;
       
  3989         }
       
  3990    
       
  3991     TPtr lPtr = lStrPtr->Des();
       
  3992    
       
  3993     // Check whether the Text is editable
       
  3994     iSvgModule->GetTextForTextElement( aTextHandle,
       
  3995         iIsTextEditOn,
       
  3996         lPtr );
       
  3997    
       
  3998     delete lStrPtr;
       
  3999      // Display MSK label Select/Edit
       
  4000     if(iMSKImpl && !iPreviewMode)
       
  4001     	{
       
  4002     	TRAP_IGNORE(SetMSKLabelL());	
       
  4003     	}
       
  4004     return ETrue;
       
  4005     }
       
  4006 
       
  4007 // -----------------------------------------------------------------------------
       
  4008 // CSVGTCustControl::TextExited()
       
  4009 // This callback is called to notify that a text element has been exited.
       
  4010 // -----------------------------------------------------------------------------
       
  4011 //
       
  4012 TBool CSVGTCustControl::TextExited( TInt /* aTextHandle */ )
       
  4013     {
       
  4014     if ( iTextAreaEntered )
       
  4015         {
       
  4016         // Ignore all text element notifications when cursor is
       
  4017         // within a textArea element
       
  4018         return ETrue;
       
  4019         }
       
  4020            
       
  4021     // Reset the current element handle
       
  4022     iCurrentTextElementId = 0;
       
  4023     
       
  4024     // check if there is a 'a' element or interactive element
       
  4025     // within which text is present
       
  4026     if(iAElement || iPointerDownAnimation)
       
  4027     	{
       
  4028     	iPointerType=ESvgPointerHand;	
       
  4029     	}
       
  4030     else
       
  4031     	{
       
  4032     	// Reset the pointer to default
       
  4033     	iPointerType = ESvgPointerDefault;
       
  4034     	}
       
  4035     // Disable the Select and Edit menu option
       
  4036     iIsTextSelectOn = EFalse;
       
  4037     iIsTextEditOn = EFalse;
       
  4038    
       
  4039     //Set the MSK label
       
  4040     if(iMSKImpl && !iPreviewMode)
       
  4041     	{
       
  4042     	TRAP_IGNORE(SetMSKLabelL());	
       
  4043     	}
       
  4044        	
       
  4045     return ETrue;
       
  4046     }
       
  4047 
       
  4048 // -----------------------------------------------------------------------------
       
  4049 // CSVGTCustControl::TextActivated()
       
  4050 // This callback is called to notify that a text element has been activated.
       
  4051 // -----------------------------------------------------------------------------
       
  4052 //
       
  4053 TBool CSVGTCustControl::TextActivated( TInt aTextHandle )
       
  4054     {
       
  4055     if (iSelectCause != ESvgInvalidSelectCause )
       
  4056         {
       
  4057         // Ignore this callback as it was already processed.
       
  4058         return ETrue;
       
  4059         }
       
  4060     // Set the cause for select operation as text so that
       
  4061     // subsequent events trigerred are ignored.
       
  4062     iSelectCause = ESvgTextSelectCause;
       
  4063     HBufC* lStrPtr = HBufC::New( KMaxEditorTextLength );         
       
  4064     if ( !lStrPtr )
       
  4065         {
       
  4066         // Error while allocation, no memory
       
  4067         iCoeEnv->HandleError( KErrNoMemory );
       
  4068         return ETrue;
       
  4069         }
       
  4070     TPtr lPtr = lStrPtr->Des();
       
  4071 
       
  4072     // Check whether the Text is editable
       
  4073     iSvgModule->GetTextForTextElement( aTextHandle,
       
  4074         iIsTextEditOn,
       
  4075         lPtr );
       
  4076 
       
  4077     if ( iIsTextEditOn && !iSvgModule->IsLoading())
       
  4078         {
       
  4079         TRAPD( err,
       
  4080             DoTextEditingL( ETrue,             // Text Element
       
  4081                             aTextHandle ,      // Element Handle
       
  4082                             lPtr );            // Buffer Pointer
       
  4083             );
       
  4084         if ( err != KErrNone )
       
  4085             {
       
  4086             // No Error handling done.
       
  4087             }
       
  4088         }
       
  4089         else
       
  4090             {
       
  4091             TRAPD( err,
       
  4092                 DoTextSelectionL( lPtr );
       
  4093                 );
       
  4094             if ( err != KErrNone )
       
  4095                 {
       
  4096                 // No Error handling done.
       
  4097                 }
       
  4098             }
       
  4099     delete lStrPtr;
       
  4100     return ETrue;
       
  4101     }
       
  4102    
       
  4103 #endif // SVGTUICONTROL_DBG_TEXT_EDIT_SELECT_API_ENABLE   
       
  4104 
       
  4105 // -----------------------------------------------------------------------------
       
  4106 // CSVGTCustControl::InteractiveElementEntered()
       
  4107 // This callback is called to notify that an interactive element has been entered.
       
  4108 // -----------------------------------------------------------------------------
       
  4109 //
       
  4110 TBool CSVGTCustControl::InteractiveElementEntered(TPtrC /*aElementIdPtr*/, TUint16 aInteractonTypeList )
       
  4111     {
       
  4112   
       
  4113     if( (aInteractonTypeList & ESvgInteractiveEventClick )||
       
  4114         (aInteractonTypeList & ESvgInteractiveEventMousedown ) ||
       
  4115         (aInteractonTypeList & ESvgInteractiveEventMouseup ) )
       
  4116         {
       
  4117         
       
  4118         iPointerType = ESvgPointerHand;
       
  4119         
       
  4120         // Increment the count maintained for overlapping interactive elements
       
  4121         // with pointer-down events so that the iPointertype is set properly
       
  4122         iInteractiveElementEnteredCnt++;    
       
  4123         
       
  4124         // Need to set flag so that when the element is within 
       
  4125         // textarea or text
       
  4126         iPointerDownAnimation=ETrue;
       
  4127             
       
  4128         // Sets the MSK label
       
  4129         if(iMSKImpl && !iPreviewMode)
       
  4130     	    {
       
  4131     	    TRAP_IGNORE(SetMSKLabelL());	
       
  4132     	    }
       
  4133         }
       
  4134     return ETrue;
       
  4135     }
       
  4136 // -----------------------------------------------------------------------------
       
  4137 // CSVGTCustControl::InteractiveElementExited()
       
  4138 // This callback is called to notify that an interactive element has been exited.
       
  4139 // -----------------------------------------------------------------------------
       
  4140 //
       
  4141 TBool CSVGTCustControl::InteractiveElementExited(TPtrC /*aElementIdPtr*/)
       
  4142     {
       
  4143     
       
  4144     // The count of interactive elements with pointer down events registered
       
  4145     // is decremented 
       
  4146     if(iPointerDownAnimation)
       
  4147         {
       
  4148         iInteractiveElementEnteredCnt--;    
       
  4149         }
       
  4150     
       
  4151     
       
  4152     if(!iInteractiveElementEnteredCnt)
       
  4153         {
       
  4154         iPointerType = ESvgPointerDefault;
       
  4155         
       
  4156         iPointerDownAnimation=EFalse;
       
  4157         //Set the MSK label
       
  4158         if(iMSKImpl && !iPreviewMode)
       
  4159     	    {    	
       
  4160     	    TRAP_IGNORE(SetMSKLabelL());	
       
  4161     	    }
       
  4162         }
       
  4163        
       
  4164     return ETrue;
       
  4165     }
       
  4166 // -----------------------------------------------------------------------------
       
  4167 // CSVGTCustControl::ReportAllElements
       
  4168 // Implements MSvgLoadingListener::ReportAllElements.
       
  4169 // -----------------------------------------------------------------------------
       
  4170 //
       
  4171 TBool CSVGTCustControl::ReportAllElements()
       
  4172     {
       
  4173     return ETrue;
       
  4174     }
       
  4175 
       
  4176 // -----------------------------------------------------------------------------
       
  4177 // CSVGTCustControl::WillAssignImageData
       
  4178 // Implements MSvgLoadingListener::WillAssignImageData.
       
  4179 // -----------------------------------------------------------------------------
       
  4180 //
       
  4181 TBool CSVGTCustControl::WillAssignImageData()
       
  4182     {
       
  4183     // Return ETrue to indicate that AssignImageData will be used to
       
  4184     // asynchronously load the image in the engine
       
  4185     if(iProgressiveRendering)
       
  4186     	{
       
  4187     	return ETrue;
       
  4188     	}
       
  4189     else
       
  4190     	{
       
  4191     	return EFalse;
       
  4192     	}
       
  4193 	}
       
  4194 
       
  4195 // -----------------------------------------------------------------------------
       
  4196 // CSVGTCustControl::ImageDataReference
       
  4197 // Implements MSvgLoadingListener::ImageDataReference.
       
  4198 // -----------------------------------------------------------------------------
       
  4199 //
       
  4200 void CSVGTCustControl::ImageDataReference( const TDesC& aUri )
       
  4201     {
       
  4202     CSvgtEvent* event = NULL;
       
  4203     if ( aUri.Length() > KEmbededImageTagLength &&
       
  4204         aUri.Left(KEmbededImageTagLength) == KDataTagName )
       
  4205         {
       
  4206         event = new CSvgtEventEmbededImage(aUri);
       
  4207         }
       
  4208     else
       
  4209         {
       
  4210         event = new CSvgtEventFetchImage(aUri);
       
  4211         }
       
  4212     if ( iEventHandlerAO )
       
  4213         {
       
  4214         iEventHandlerAO->AddEventToList( event );       
       
  4215         iEventHandlerAO->MakeRequestComplete( KErrNone );
       
  4216         }  
       
  4217     }
       
  4218 // -----------------------------------------------------------------------------
       
  4219 // CSVGTCustControl::ReportAllElements
       
  4220 // Implements MSvgLoadingListener::DocumentStart.
       
  4221 // -----------------------------------------------------------------------------
       
  4222 //
       
  4223 TBool CSVGTCustControl::DocumentStart()
       
  4224     {
       
  4225     return EFalse;
       
  4226     }
       
  4227    
       
  4228 // -----------------------------------------------------------------------------
       
  4229 // CSVGTCustControl::DocumentEnd
       
  4230 // Implements MSvgLoadingListener::DocumentEnd.
       
  4231 // -----------------------------------------------------------------------------
       
  4232 //
       
  4233 TBool CSVGTCustControl::DocumentEnd()
       
  4234     {
       
  4235     if(iProgressiveRendering)
       
  4236         {
       
  4237         iEventHandlerAO->SetDocumentComplete();
       
  4238         iEventHandlerAO->AddRedrawEventToList( ETrue );
       
  4239         iEventHandlerAO->MakeRequestComplete( KErrNone );
       
  4240         }
       
  4241     return EFalse;
       
  4242     }
       
  4243    
       
  4244 // -----------------------------------------------------------------------------
       
  4245 // CSVGTCustControl::ElementStart
       
  4246 // Implements MSvgLoadingListener::ElementStart.
       
  4247 // -----------------------------------------------------------------------------
       
  4248 //
       
  4249 TBool CSVGTCustControl::ElementStart( const TDesC& aTagName,
       
  4250                     MSvgAttributeList& /*aAttributeList*/)
       
  4251     {
       
  4252     if ( iProgressiveRendering && aTagName == KSvgTagName && iEngineInitialized
       
  4253                                                                  == EFalse )
       
  4254         {
       
  4255         iEngineInitialized = ETrue;
       
  4256         iSvgModule->AddListener( static_cast < MSvgViewPortListener*>(this), ESvgViewPortListener );
       
  4257         iSvgModule->InitializeEngine( NULL, EFalse);
       
  4258         }
       
  4259     else if ( iProgressiveRendering )
       
  4260         {
       
  4261 //        iEventHandlerAO->RequestRedraw();
       
  4262 //        User::After( 10 * 1000 );
       
  4263         }
       
  4264     return EFalse;
       
  4265     }
       
  4266 
       
  4267 // -----------------------------------------------------------------------------
       
  4268 // CSVGTCustControl::ElementEnd
       
  4269 // Implements MSvgLoadingListener::ElementEnd.
       
  4270 // -----------------------------------------------------------------------------
       
  4271 //
       
  4272 TBool CSVGTCustControl::ElementEnd( const TDesC& /* aTagName */)
       
  4273     {
       
  4274     if(iProgressiveRendering)
       
  4275         {
       
  4276         iEventHandlerAO->AddRedrawEventToList();
       
  4277         iEventHandlerAO->MakeRequestComplete( KErrNone );
       
  4278         }
       
  4279     return EFalse;
       
  4280     }
       
  4281 
       
  4282 // -----------------------------------------------------------------------------
       
  4283 // CSVGTCustControl::ExternalDataRequested
       
  4284 // Implements MSvgLoadingListener::ExternalDataRequested.
       
  4285 // -----------------------------------------------------------------------------
       
  4286 //
       
  4287 TBool CSVGTCustControl::ExternalDataRequested( const TDesC& /* aUri */)
       
  4288     {
       
  4289     return EFalse;
       
  4290     }
       
  4291 
       
  4292 // -----------------------------------------------------------------------------
       
  4293 // CSVGTCustControl::ExternalDataReceived
       
  4294 // Implements MSvgLoadingListener::ExternalDataReceived.
       
  4295 // -----------------------------------------------------------------------------
       
  4296 //
       
  4297 TBool CSVGTCustControl::ExternalDataReceived( const TDesC& /* aUri */)
       
  4298     {
       
  4299     return EFalse;
       
  4300     }
       
  4301 
       
  4302 // -----------------------------------------------------------------------------
       
  4303 // CSVGTCustControl::ExternalDataRequestFailed
       
  4304 // Implements MSvgLoadingListener::ExternalDataRequestFailed.
       
  4305 // -----------------------------------------------------------------------------
       
  4306 //
       
  4307 TBool CSVGTCustControl::ExternalDataRequestFailed( const TDesC& /* aUri */)
       
  4308     {   
       
  4309     return EFalse;
       
  4310     }
       
  4311 
       
  4312 // -----------------------------------------------------------------------------
       
  4313 // CSVGTCustControl::UnsupportedElement
       
  4314 // Implements MSvgLoadingListener::UnsupportedElement.
       
  4315 // -----------------------------------------------------------------------------
       
  4316 //
       
  4317 TBool CSVGTCustControl::UnsupportedElement( const TDesC& /* aTagName */,
       
  4318                     MSvgAttributeList& /* aAttributeList*/ )
       
  4319     {
       
  4320     return EFalse;
       
  4321     }
       
  4322 void CSVGTCustControl::ImagesLoaded(TInt aError)
       
  4323     {
       
  4324     if(aError != KErrNone)
       
  4325         {
       
  4326         if(!iIsWaitNoteDisplayed)
       
  4327             {
       
  4328             iIsWaitNoteDisplayed = ETrue;
       
  4329             TRAP_IGNORE( DisplayInfoNoteL( R_SVGT_FILE_NOT_COMPLETE, ETrue ) );
       
  4330             }
       
  4331         }
       
  4332     }
       
  4333 
       
  4334 void CSVGTCustControl::DoExitFromDialogL()
       
  4335     {
       
  4336     if ( iExitObserver )
       
  4337         {
       
  4338         iExitObserver->HandleApplicationExitL(EEikCmdExit);
       
  4339         }
       
  4340     }
       
  4341    
       
  4342 void CSVGTCustControl::AssignImageData( const TDesC& aUri, HBufC8* aData )
       
  4343     {
       
  4344     if(aData)
       
  4345         {
       
  4346         iSvgModule->AssignImageData(aUri, aData);
       
  4347         // Do a redraw to reflect the image loaded
       
  4348         iSvgModule->Redraw();
       
  4349         }
       
  4350     else
       
  4351         {
       
  4352         // Show information note
       
  4353         if(!iIsWaitNoteDisplayed)
       
  4354             {
       
  4355             iIsWaitNoteDisplayed = ETrue;
       
  4356             TRAP_IGNORE( DisplayInfoNoteL( R_SVGT_FILE_NOT_COMPLETE, ETrue ) );
       
  4357             }
       
  4358         }
       
  4359     }
       
  4360 TInt CSVGTCustControl::DoHandleLoadingThreadError()
       
  4361     {
       
  4362     TInt lErrCode = KErrNone;
       
  4363     // An error note "Unable to open file" for eg. should be displayed
       
  4364     // in the following conditions
       
  4365     //  a. Error Object contains NULL. This means possible out of memory
       
  4366     //     when create error object.
       
  4367     //  b. Error Object has an error which is not a warning - This
       
  4368     //     indicates unrecoverable error in parsing -
       
  4369     //     invalid/corrupted content
       
  4370     if ( (! iLoadingThreadError ) || ( iLoadingThreadError &&
       
  4371                                        iLoadingThreadError->HasError() &&
       
  4372                                        !iLoadingThreadError->IsWarning() ) )
       
  4373         {
       
  4374         TRAP_IGNORE( DisplayInfoNoteL( R_SVGT_FILE_OPEN_FAILURE, ETrue ) );
       
  4375    
       
  4376         // Exiting from the dialog   
       
  4377         if ( iLoadingThreadError )
       
  4378             {
       
  4379             lErrCode = iLoadingThreadError->SystemErrorCode();
       
  4380             if ( lErrCode == KErrNone )
       
  4381                 {
       
  4382                 lErrCode = KErrGeneral;
       
  4383                 }
       
  4384             }
       
  4385         else
       
  4386             {
       
  4387             lErrCode = KErrNoMemory;
       
  4388             }
       
  4389         }
       
  4390 
       
  4391     if ( lErrCode == KErrNone )
       
  4392         {
       
  4393 // Placed into the DoPostLoadFuncL
       
  4394         }
       
  4395 
       
  4396     return lErrCode;
       
  4397     }
       
  4398    
       
  4399 CSVGTCustControl::TFileType
       
  4400         CSVGTCustControl::ImageFileType( const TDesC& aUri ) const
       
  4401     {
       
  4402 
       
  4403     TUriParser UriParser;
       
  4404    
       
  4405     TBuf<KMaxFileName> localUri;
       
  4406     // url starts with www so append http://
       
  4407     if ( !aUri.Left( KSchemaLength ).Compare( KWww ) )    
       
  4408         {
       
  4409         localUri.Append( KHttp );
       
  4410         localUri.Append( aUri );
       
  4411         if ( UriParser.Parse( localUri ) )
       
  4412             {
       
  4413             return ( EInvalidFilePath );
       
  4414             }
       
  4415         }
       
  4416     else
       
  4417         {
       
  4418         if ( UriParser.Parse( aUri ) )
       
  4419             {
       
  4420             return ( EInvalidFilePath );
       
  4421             }
       
  4422         }
       
  4423    
       
  4424     if ( UriParser.IsPresent( EUriHost ) )
       
  4425         {
       
  4426         // Extract the Path, filename and extension from the uri
       
  4427         TFileName filename = UriParser.Extract( EUriPath );
       
  4428         TParsePtrC fileParser( filename );
       
  4429    
       
  4430         if ( fileParser.NamePresent() && fileParser.ExtPresent() )
       
  4431             {                       
       
  4432             if ( fileParser.Ext().Compare( KJpg ) == 0  || 
       
  4433                  fileParser.Ext().Compare( KJpeg ) == 0 ||
       
  4434                  fileParser.Ext().Compare( KBmp ) == 0  ||
       
  4435                  fileParser.Ext().Compare( KPng ) == 0  ||
       
  4436                  fileParser.Ext().Compare( KSvg ) == 0  ||
       
  4437                  fileParser.Ext().Compare( KSvgz ) == 0 )
       
  4438                 {
       
  4439                 // file name and ext present and
       
  4440                 // it is amy of the supported image types
       
  4441                 return ERemoteImageFile;        
       
  4442                 }
       
  4443             else
       
  4444                 {
       
  4445                 //file Extension present but not a supported image ext,
       
  4446                 //may be some html file
       
  4447                 return ENotAnImageFile;
       
  4448                 }
       
  4449             }
       
  4450         else
       
  4451             {
       
  4452             //Should be a domain name so return ENotAnImageFile
       
  4453             return ENotAnImageFile;
       
  4454             }
       
  4455         }
       
  4456     else
       
  4457         {    
       
  4458         return ELocalImageFile;
       
  4459         }                       
       
  4460     }
       
  4461 
       
  4462 /**
       
  4463 * CSVGTCustControl::ResetBacklightTime
       
  4464 * Resets the backlight time for finite content
       
  4465 */
       
  4466 void CSVGTCustControl::ResetBacklightTime()
       
  4467     {
       
  4468     TTimeIntervalSeconds secondCount;
       
  4469     TTime currTime;
       
  4470     currTime.HomeTime();
       
  4471     currTime.SecondsFrom(iPreviousBackLightTimeStamp, secondCount);
       
  4472    
       
  4473     if ( iDisplayFlags & ESvgUseBackLight )
       
  4474         {
       
  4475         if(secondCount.Int() >= KBackLightTimeInterval)
       
  4476            {
       
  4477            User::ResetInactivityTime();
       
  4478            iPreviousBackLightTimeStamp = currTime;
       
  4479            }       
       
  4480         }
       
  4481     }
       
  4482 
       
  4483 void CSVGTCustControl::StopEventHandler()
       
  4484     {
       
  4485     if ( iEventHandlerAO )
       
  4486         {
       
  4487         iEventHandlerAO->Cancel();
       
  4488         }
       
  4489     }
       
  4490 
       
  4491 void CSVGTCustControl::SetThreadRunning(TBool aIsRunning)
       
  4492     {
       
  4493     iIsThreadRunning = aIsRunning;
       
  4494     }
       
  4495 
       
  4496 TBool CSVGTCustControl::IsThreadRunning() const
       
  4497     {
       
  4498     return iIsThreadRunning;
       
  4499     }
       
  4500 
       
  4501 void CSVGTCustControl::PerformEngineRedraw()   
       
  4502     {
       
  4503     iSvgModule->Redraw();
       
  4504     }
       
  4505 
       
  4506 //TOUCH SUPPORT START   
       
  4507 #ifdef RD_SCALABLE_UI_V2
       
  4508 void CSVGTCustControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  4509 	{
       
  4510 	if(aPointerEvent.iType == TPointerEvent::EButton1Down)
       
  4511 		{
       
  4512         if(iPntrObserver && iPntrObserver->HandleCustControlPointerEventL(aPointerEvent))
       
  4513             return;
       
  4514 
       
  4515         // Reset the select cause
       
  4516         iSelectCause = ESvgInvalidSelectCause;
       
  4517 
       
  4518 		TIndicatorType indicatorType =
       
  4519             ActiveIndicator(aPointerEvent.iPosition);
       
  4520 		if (indicatorType != ENoIndicator)
       
  4521 		    {
       
  4522 		    if(indicatorType == EPauseIndicator)
       
  4523                 {
       
  4524                 ProcessPlayCmd();
       
  4525                 }
       
  4526             else
       
  4527                 {
       
  4528         	    PanPresentation( indicatorType );
       
  4529                 }
       
  4530 		    }
       
  4531     
       
  4532             // Get the size of the content
       
  4533     	TSize svgSize = iSvgModule->Size();
       
  4534     	TInt rgnw = svgSize.iWidth;
       
  4535     	TInt rgnh = svgSize.iHeight;     
       
  4536         if ( aPointerEvent.iPosition.iX >= rgnw || aPointerEvent.iPosition.iY >= rgnh  )
       
  4537         	return;  
       
  4538         iPointerX = aPointerEvent.iPosition.iX;
       
  4539         iPointerY = aPointerEvent.iPosition.iY;
       
  4540         iSvgModule->MouseDown( iPointerX, iPointerY );       
       
  4541 
       
  4542         SetPointerDisplayStatusAndRedraw(ETrue);
       
  4543         UpdatePointer();
       
  4544 
       
  4545 		Window().RequestPointerRepeatEvent(KInitRepeatInterval, ActiveIndicatorRect(indicatorType));
       
  4546 		}
       
  4547 	else if(aPointerEvent.iType == TPointerEvent::EButtonRepeat)
       
  4548 		{
       
  4549         UpdatePointer();
       
  4550 		TIndicatorType indicatorType =
       
  4551             ActiveIndicator(aPointerEvent.iPosition);
       
  4552 		PanPresentation( indicatorType );
       
  4553 		Window().RequestPointerRepeatEvent(KInitRepeatInterval, ActiveIndicatorRect(indicatorType));
       
  4554 		}
       
  4555 	else if(aPointerEvent.iType == TPointerEvent::EButton1Up)
       
  4556 		{
       
  4557 		Window().CancelPointerRepeatEventRequest();
       
  4558         // UI Spec: Pointer should be hidden after 15 sec of
       
  4559         // user inactivity
       
  4560         if ( iInactivityTimer )
       
  4561             {
       
  4562             // Should not be the case!
       
  4563             delete iInactivityTimer;
       
  4564             iInactivityTimer = NULL;
       
  4565             }
       
  4566         iInactivityTimer = CSVGTPointerHideTimer::NewL( this );
       
  4567         iInactivityTimer->After( KSccPointerHideTimerStartAfter );
       
  4568 
       
  4569 		TIndicatorType indicatorType =
       
  4570             ActiveIndicator(aPointerEvent.iPosition);
       
  4571 		if (indicatorType == ENoIndicator)
       
  4572 		    {
       
  4573             iSvgModule->MouseUp( iPointerX, iPointerY );
       
  4574 		    }
       
  4575 		}
       
  4576 	else if(aPointerEvent.iType == TPointerEvent::EDrag)
       
  4577 	    {
       
  4578 	       // Get the size of the content
       
  4579     	TSize svgSize = iSvgModule->Size();
       
  4580     	TInt rgnw = svgSize.iWidth;
       
  4581     	TInt rgnh = svgSize.iHeight;     
       
  4582         if ( aPointerEvent.iPosition.iX >= rgnw || aPointerEvent.iPosition.iY >= rgnh  )
       
  4583         	return;
       
  4584         iPointerX = aPointerEvent.iPosition.iX;
       
  4585         iPointerY = aPointerEvent.iPosition.iY;
       
  4586 
       
  4587         iSvgModule->MouseMove( iPointerX, iPointerY );
       
  4588         SetPointerDisplayStatusAndRedraw(ETrue);
       
  4589         UpdatePointer();
       
  4590 	    }
       
  4591 	}
       
  4592 
       
  4593 void CSVGTCustControl::SetContainerWindowL(const CCoeControl &aContainer)
       
  4594     {
       
  4595     CCoeControl::SetContainerWindowL(aContainer);
       
  4596     EnableDragEvents();
       
  4597     }
       
  4598     
       
  4599 void CSVGTCustControl::PanPresentation( 
       
  4600     const CSVGTCustControl::TIndicatorType aIndicatorType )
       
  4601     {
       
  4602 	switch( aIndicatorType )
       
  4603 	    {
       
  4604 	    case ELeftIndicator:
       
  4605 	        {
       
  4606 			iSvgModule->Pan( KSccPanNumPixelsX, KSccConstZero );
       
  4607 			break;
       
  4608 	        }
       
  4609 	    case ERightIndicator:
       
  4610 	        {
       
  4611 			iSvgModule->Pan( -KSccPanNumPixelsX, KSccConstZero );
       
  4612 			break;
       
  4613 	        }
       
  4614 	    case EUpIndicator:
       
  4615 	        {
       
  4616 			iSvgModule->Pan( KSccConstZero, KSccPanNumPixelsY );
       
  4617 			break;
       
  4618 	        }
       
  4619 	    case EDownIndicator:
       
  4620 	        {
       
  4621 			iSvgModule->Pan( KSccConstZero, -KSccPanNumPixelsY );
       
  4622 			break;
       
  4623 	        }
       
  4624 	    }
       
  4625 	    iSvgModule->Redraw();
       
  4626 	    DrawDeferred();
       
  4627 	}
       
  4628 
       
  4629 CSVGTCustControl::TIndicatorType CSVGTCustControl::ActiveIndicator(
       
  4630     const TPoint aPosition ) const
       
  4631 	{
       
  4632 	TIndicatorType indicatorType = ENoIndicator;
       
  4633 	
       
  4634     if( iPanIndLeftAidRect.Rect().Contains( aPosition ) && iPanLt)
       
  4635 		{
       
  4636 		indicatorType = ELeftIndicator;
       
  4637 		}
       
  4638     else if( iPanIndRightAidRect.Rect().Contains( aPosition ) && iPanRt)
       
  4639 		{
       
  4640 		indicatorType = ERightIndicator;
       
  4641 		}
       
  4642     else if( iPanIndUpAidRect.Rect().Contains( aPosition ) && iPanUp)
       
  4643 		{
       
  4644 		indicatorType = EUpIndicator;
       
  4645 		}
       
  4646     else if( iPanIndDownAidRect.Rect().Contains( aPosition ) && iPanDn)
       
  4647 		{
       
  4648 		indicatorType = EDownIndicator;
       
  4649 		}
       
  4650 	
       
  4651 	return indicatorType ;
       
  4652 	}
       
  4653 
       
  4654 TRect CSVGTCustControl::ActiveIndicatorRect( TIndicatorType aIndicator) const
       
  4655     {
       
  4656     TRect indicatorRect(0,0,0,0);
       
  4657     
       
  4658     switch(aIndicator)
       
  4659         {
       
  4660         case ELeftIndicator:
       
  4661             {
       
  4662     		indicatorRect = iPanIndLeftAidRect.Rect();
       
  4663             }
       
  4664             break;
       
  4665         case ERightIndicator:
       
  4666             {
       
  4667     		indicatorRect = iPanIndRightAidRect.Rect();
       
  4668             }
       
  4669             break;
       
  4670         case EUpIndicator:
       
  4671             {
       
  4672     		indicatorRect = iPanIndUpAidRect.Rect();
       
  4673             }
       
  4674             break;
       
  4675         case EDownIndicator:
       
  4676             {
       
  4677     		indicatorRect = iPanIndDownAidRect.Rect();
       
  4678             }
       
  4679             break;
       
  4680         }
       
  4681 
       
  4682 	return indicatorRect;	
       
  4683     }	
       
  4684 
       
  4685 #endif //RD_SCALABLE_UI_V2
       
  4686 
       
  4687 #ifdef RD_SVGT_AUDIO_SUPPORT
       
  4688 void CSVGTCustControl::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
       
  4689     {
       
  4690     if((aControl == iVolumePopup) && ( aEventType == MCoeControlObserver::EEventStateChanged))
       
  4691         {
       
  4692 #ifdef _DEBUG
       
  4693         TName msg;
       
  4694         msg.Format(_L("Volume level: %d"), iVolumePopup->Value());
       
  4695         iEikonEnv->InfoMsgWithAlignment(TGulAlignment(EHCenterVCenter), msg);
       
  4696 #endif  
       
  4697 		// Save the current volume as previous volume before setting
       
  4698         // new volume level
       
  4699         iPrevVolume=iVolumeLevel;    
       
  4700         iVolumeLevel = iVolumePopup->Value();
       
  4701         SetPresentationVolume( iVolumeLevel );
       
  4702         }
       
  4703     }
       
  4704     
       
  4705 void CSVGTCustControl::SetPresentationVolume( TInt aVolumeLevel )
       
  4706     {
       
  4707     TInt volumeInPercent = aVolumeLevel * 10;
       
  4708 
       
  4709     if(volumeInPercent)
       
  4710         {
       
  4711         
       
  4712         iSvgModule->SetAudioVolume(volumeInPercent);
       
  4713         if(iIsVolumeMuted)
       
  4714             {
       
  4715             iIsVolumeMuted = EFalse;
       
  4716             if(iAudioMuteListener)
       
  4717                 {
       
  4718                 iAudioMuteListener->VolumeMuted(EFalse);    
       
  4719                 }
       
  4720             
       
  4721             }
       
  4722         }
       
  4723         
       
  4724     else
       
  4725         {
       
  4726         iSvgModule->MuteAudioVolume();
       
  4727         if(!iIsVolumeMuted)
       
  4728             {
       
  4729             iIsVolumeMuted = ETrue;
       
  4730             if(iAudioMuteListener)
       
  4731                 {
       
  4732                 iAudioMuteListener->VolumeMuted(ETrue);    
       
  4733                 }
       
  4734             
       
  4735             }
       
  4736         
       
  4737         }
       
  4738         
       
  4739     }
       
  4740 
       
  4741 TInt CSVGTCustControl::PresentationVolume() const
       
  4742     {
       
  4743     return iVolumeLevel;
       
  4744     }
       
  4745     
       
  4746 void CSVGTCustControl::MrccatoCommand(TRemConCoreApiOperationId aOperationId, 
       
  4747                              TRemConCoreApiButtonAction aButtonAct )
       
  4748     {
       
  4749     switch(aOperationId)
       
  4750         {
       
  4751         case ERemConCoreApiVolumeUp:
       
  4752             {
       
  4753             switch (aButtonAct)
       
  4754                 {
       
  4755                 case ERemConCoreApiButtonPress:
       
  4756                     {
       
  4757                     break;
       
  4758                     }
       
  4759                 case ERemConCoreApiButtonRelease:
       
  4760                     {
       
  4761                     break;
       
  4762                     }
       
  4763                 case ERemConCoreApiButtonClick:
       
  4764                     {
       
  4765                     FilterAndSendCommand(EStdKeyIncVolume);
       
  4766                     break;
       
  4767                     }
       
  4768                 default:
       
  4769                     {
       
  4770                     break;
       
  4771                     }
       
  4772                 }
       
  4773             break;
       
  4774             }
       
  4775         case ERemConCoreApiVolumeDown:
       
  4776             {
       
  4777             switch (aButtonAct)
       
  4778                 {
       
  4779                 case ERemConCoreApiButtonPress:
       
  4780                     {
       
  4781                     break;
       
  4782                     }
       
  4783                 case ERemConCoreApiButtonRelease:
       
  4784                     {
       
  4785                     break;
       
  4786                     }
       
  4787                 case ERemConCoreApiButtonClick:
       
  4788                     {
       
  4789                     FilterAndSendCommand(EStdKeyDecVolume);
       
  4790                     break;
       
  4791                     }
       
  4792                 default:
       
  4793                     {
       
  4794                     break;
       
  4795                     }
       
  4796                 }
       
  4797             break;
       
  4798             }
       
  4799         default:
       
  4800             {
       
  4801             break;
       
  4802             }
       
  4803         }        
       
  4804     }
       
  4805 
       
  4806 void CSVGTCustControl::FilterAndSendCommand(TInt aCommandId)
       
  4807     {    
       
  4808     TInt currentVolume = iVolumeLevel;
       
  4809     
       
  4810     if(!iIsForeground)
       
  4811         {
       
  4812         return;
       
  4813         }
       
  4814         
       
  4815     switch(aCommandId)
       
  4816         {
       
  4817         case EStdKeyIncVolume:
       
  4818             currentVolume=(currentVolume< KMaxVolume)? ++currentVolume : KMaxVolume;
       
  4819             break;
       
  4820         case EStdKeyDecVolume:
       
  4821             currentVolume=(currentVolume> KMinVolume)? --currentVolume : KMinVolume;
       
  4822             break;  
       
  4823         default:
       
  4824             break;      
       
  4825         }
       
  4826          
       
  4827     iVolumePopup->SetValue( currentVolume );
       
  4828     TRAP_IGNORE(iVolumePopup->ShowVolumePopupL());
       
  4829     iVolumePopup->DrawNow();
       
  4830 
       
  4831     TRAP_IGNORE(HandleControlEventL( iVolumePopup, MCoeControlObserver::EEventStateChanged ));    
       
  4832 }
       
  4833 
       
  4834 EXPORT_C void CSVGTCustControl::AddListener(MSvgCustControlListener *aListener, TCustControlListener aType)
       
  4835     {
       
  4836     if(aType == EAudioListener)
       
  4837         {
       
  4838         iAudioMuteListener = (MSvgAudioMuteListener *)aListener;    
       
  4839         }
       
  4840     
       
  4841     }
       
  4842 TInt CSVGTCustControl::GetPrevVolume() const
       
  4843     {
       
  4844     return iPrevVolume;
       
  4845     } 
       
  4846 #endif  //RD_SVGT_AUDIO_SUPPORT
       
  4847 
       
  4848 //TOUCH SUPPORT END
       
  4849 
       
  4850 // End of File