camerauis/cameraapp/generic/src/CamNaviProgressBarModel.cpp
changeset 0 1ddebce53859
child 16 d486e5e3cc9a
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Control for displaying elapse/remaining record time
       
    15 *                in Navi Pane
       
    16 *
       
    17 *  Copyright (c) 2007-2008 Nokia.  All rights reserved.
       
    18 *  This material, including documentation and any related computer
       
    19 *  programs, is protected by copyright controlled by Nokia.  All
       
    20 *  rights are reserved.  Copying, including reproducing, storing,
       
    21 *  adapting or translating, any or all of this material requires the
       
    22 *  prior written consent of Nokia.  This material also contains
       
    23 *  confidential information which may not be disclosed to others
       
    24 *  without the prior written consent of Nokia.
       
    25 
       
    26 *
       
    27 *
       
    28 */
       
    29 
       
    30 
       
    31 // INCLUDE FILES
       
    32 #include <eiklabel.h>
       
    33 #include <eikenv.h>
       
    34 #include <eikapp.h>		// For CEikApplication
       
    35 #include <AknsUtils.h>
       
    36 #include <AknsDrawUtils.h>
       
    37 #include <aknconsts.h>
       
    38 #include <StringLoader.h> // StringLoader
       
    39 #include <e32base.h>
       
    40 #include <barsread.h>    // TResourceReader
       
    41 #include <AknBidiTextUtils.h>
       
    42 #include <cameraapp.mbg>
       
    43 #include <AknLayoutFont.h>
       
    44 #include <aknlayoutscalable_apps.cdl.h>
       
    45 #include <aknlayoutscalable_avkon.cdl.h>
       
    46 #include <layoutmetadata.cdl.h>
       
    47 #include <cameraapp.rsg>
       
    48 #include <vgacamsettings.rsg>
       
    49 #include <avkon.mbg>
       
    50 
       
    51 #include "CamNaviProgressBarModel.h"
       
    52 #include "CamAppUi.h"
       
    53 #include "CamLogger.h"
       
    54 #include "CamUtility.h"
       
    55 #include "CamDecorator.h"
       
    56 #include "CamObserverHandler.h"
       
    57 #include "camcameraevents.h"
       
    58 #include "camcameracontrollertypes.h"
       
    59 #include "camtextitem.h"
       
    60 #include "OstTraceDefinitions.h"
       
    61 #ifdef OST_TRACE_COMPILER_IN_USE
       
    62 #include "CamNaviProgressBarModelTraces.h"
       
    63 #endif
       
    64 
       
    65 
       
    66 // CONSTANTS
       
    67 const TInt  KFlashInterval       = 200000;
       
    68 const TUint KCameraEventInterest = ECamCameraEventClassVideoTimes;
       
    69 
       
    70 // ========================= MEMBER FUNCTIONS ================================
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CCamNaviProgressBarModel::NewL
       
    74 // Factory construction function
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 CCamNaviProgressBarModel* CCamNaviProgressBarModel::NewL( CCamAppController& aController )
       
    78     {
       
    79     CCamNaviProgressBarModel* self = new( ELeave ) CCamNaviProgressBarModel( aController );
       
    80     CleanupStack::PushL( self );
       
    81     self->ConstructL();
       
    82     CleanupStack::Pop( self );
       
    83     return self;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CCamNaviProgressBarModel::~CCamNaviProgressBarModel
       
    88 // Destructor
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 CCamNaviProgressBarModel::~CCamNaviProgressBarModel()
       
    92   {
       
    93   PRINT( _L("Camera => ~CCamNaviProgressBarModel") );
       
    94 
       
    95   delete iElapsedTimeTextItem;
       
    96   delete iRemainingTimeTextItem;
       
    97 
       
    98   UnloadResourceData();
       
    99 
       
   100   iController.RemoveControllerObserver( this );
       
   101   iController.RemoveCameraObserver( this );
       
   102   
       
   103   delete iTimeFormat;
       
   104   delete iObserverHandler;
       
   105   
       
   106   if ( iFlashingTimer && iFlashingTimer->IsActive() )
       
   107     {
       
   108     iFlashingTimer->Cancel();
       
   109     }
       
   110   delete iFlashingTimer;
       
   111   PRINT( _L("Camera <= ~CCamNaviProgressBarModel") );
       
   112   }
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CCamNaviProgressBarModel::CCamNaviProgressBarModel
       
   116 // C++ constructor
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 CCamNaviProgressBarModel::CCamNaviProgressBarModel(
       
   120     CCamAppController& aController )
       
   121 : iController( aController )
       
   122     {
       
   123     }
       
   124     
       
   125 // ---------------------------------------------------------
       
   126 // CCamNaviProgressBarModel::DrawProgressBar
       
   127 // Draw Navi-progress
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 void 
       
   131 CCamNaviProgressBarModel::DrawProgressBar(       CBitmapContext& aGc, 
       
   132                                            const CCoeControl*    aControl ) const
       
   133 	{
       
   134 	DrawProgBar( aGc, aControl );
       
   135 	}
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CCamNaviProgressBarModel::ConstructL
       
   139 // Symbian OS 2nd phase constructor
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CCamNaviProgressBarModel::ConstructL()
       
   143     {
       
   144     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMNAVIPROGRESSBARMODEL_CONSTRUCTL, "e_CCamNaviProgressBarModel_ConstructL 1" );
       
   145     iController.AddControllerObserverL( this ); 
       
   146     iController.AddCameraObserverL( this, KCameraEventInterest ); 
       
   147 
       
   148     LoadResourceDataL();
       
   149 
       
   150     iObserverHandler = CCamObserverHandler::NewL();
       
   151 
       
   152     iFlashingTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   153     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMNAVIPROGRESSBARMODEL_CONSTRUCTL, "e_CCamNaviProgressBarModel_ConstructL 0" );
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CCamNaviProgressBarModel::LoadResourceDataL()
       
   158 // Reads in all information needed from resources
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 void CCamNaviProgressBarModel::LoadResourceDataL()
       
   162     {
       
   163     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMNAVIPROGRESSBARMODEL_LOADRESOURCEDATAL, "e_CCamNaviProgressBarModel_LoadResourceDataL 1" );
       
   164     // Create component bitmaps
       
   165     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   166 
       
   167     TFileName resFileName;
       
   168     CamUtility::ResourceFileName( resFileName );
       
   169     TPtrC resname = resFileName;
       
   170 
       
   171     AknsUtils::CreateIconL(
       
   172         skin,
       
   173         KAknsIIDQgnGrafMup2BarProgress,
       
   174         iProgressBarBitmap,
       
   175         iProgressBarMask,
       
   176         resname, 
       
   177         EMbmCameraappQgn_graf_mup2_bar_progress,
       
   178         EMbmCameraappQgn_graf_mup2_bar_progress_mask );
       
   179 
       
   180     AknsUtils::CreateIconL(
       
   181         skin,
       
   182         KAknsIIDQgnGrafMup2BarFrame,
       
   183         iProgressBarFrame, 
       
   184         resname, 
       
   185         EMbmCameraappQgn_graf_mup2_bar_frame );
       
   186 
       
   187     delete iElapsedTimeTextItem;
       
   188     iElapsedTimeTextItem = NULL;
       
   189     CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );  
       
   190     iElapsedTimeTextItem = CCamTextItem::NewL();
       
   191 
       
   192     delete iRemainingTimeTextItem;
       
   193     iRemainingTimeTextItem = NULL;
       
   194     iRemainingTimeTextItem = CCamTextItem::NewL();
       
   195 
       
   196     iCamOrientation = appUi->CamOrientation();
       
   197 
       
   198     if ( CamUtility::IsNhdDevice() )
       
   199         {
       
   200         TouchLayoutL();
       
   201         }
       
   202     else
       
   203         {
       
   204         if ( ECamOrientationPortrait == appUi->CamOrientation() )
       
   205             {
       
   206             NonTouchLayoutSecondaryL();
       
   207             }
       
   208         else
       
   209             {
       
   210             NonTouchLayoutL();
       
   211             }
       
   212         }
       
   213 
       
   214     // Read the time format resource
       
   215     // We have to free the memory first if it has been
       
   216     // allocated already
       
   217     if ( iTimeFormat )
       
   218     	{
       
   219     	delete iTimeFormat;
       
   220     	iTimeFormat = NULL;
       
   221     	}
       
   222     if ( ECamOrientationPortrait == appUi->CamOrientation() )
       
   223     	{
       
   224     	iTimeFormat = CEikonEnv::Static()->AllocReadResourceL( R_QTN_TIME_DURAT_MIN_SEC_WITH_ZERO );
       
   225     	}
       
   226     else 
       
   227     	{
       
   228     	iTimeFormat = CEikonEnv::Static()->AllocReadResourceL( R_QTN_TIME_DURAT_LONG );
       
   229     	}
       
   230 
       
   231     TBool progressBarVisible = ETrue;
       
   232 
       
   233     if ( progressBarVisible )
       
   234         {
       
   235         iDecorator = CCamDecorator::NewL( iController, 
       
   236                 ROID(R_CAM_VIDEO_CAP_LIMIT_RECORDING_ICON_ID), this );
       
   237         }
       
   238     else
       
   239         {
       
   240         iDecorator = CCamDecorator::NewL( iController, 
       
   241                 ROID(R_CAM_VIDEO_CAP_UNLIMIT_RECORDING_ICON_ID), this );
       
   242         }
       
   243     
       
   244     AknIconUtils::SetSize(
       
   245         iProgressBarBitmap,
       
   246         iProgressBarRect.Rect().Size(),
       
   247         EAspectRatioNotPreserved );
       
   248 
       
   249     // Progress bar area background
       
   250     AknIconUtils::SetSize(
       
   251         iProgressBarFrame,
       
   252         iProgressBarRect.Rect().Size(),
       
   253         EAspectRatioNotPreserved);
       
   254 
       
   255     // Create component bitmaps
       
   256     TSize size;    
       
   257     if ( CamUtility::IsNhdDevice() )
       
   258         {
       
   259         size =  iProgressIconRect.Rect().Size();
       
   260         }
       
   261     else
       
   262         {
       
   263         size =  iVidStorageIconRect.Rect().Size();
       
   264         }
       
   265     TCamOrientation orientation = appUi->CamOrientation();
       
   266     AknIconUtils::CreateIconL( iPhoneIcon, 
       
   267                                iPhoneIconMask, 
       
   268                                resname, 
       
   269                                EMbmCameraappQgn_indi_cam4_memory_phone, 
       
   270                                EMbmCameraappQgn_indi_cam4_memory_phone_mask );
       
   271     AknIconUtils::SetSize( iPhoneIcon, size );
       
   272 
       
   273     AknIconUtils::CreateIconL( iMMCIcon, 
       
   274                                iMMCIconMask, 
       
   275                                resname, 
       
   276                                EMbmCameraappQgn_indi_cam4_memory_mmc, 
       
   277                                EMbmCameraappQgn_indi_cam4_memory_mmc_mask );
       
   278     AknIconUtils::SetSize( iMMCIcon, size );
       
   279 
       
   280     AknIconUtils::CreateIconL( iMassStorageIcon, 
       
   281                                iMassStorageIconMask, 
       
   282                                resname, 
       
   283                                EMbmCameraappQgn_indi_cam4_memory_mass,  
       
   284                                EMbmCameraappQgn_indi_cam4_memory_mass_mask );
       
   285 
       
   286                                
       
   287     AknIconUtils::SetSize( iMassStorageIcon, size );
       
   288     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMNAVIPROGRESSBARMODEL_LOADRESOURCEDATAL, "e_CCamNaviProgressBarModel_LoadResourceDataL 0" );
       
   289     }
       
   290     
       
   291 // -----------------------------------------------------------------------------
       
   292 // CCamNaviProgressBarModel::UnloadResourceData()
       
   293 // Frees all dynamic resources allocated in LoadResourceDataL
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 void CCamNaviProgressBarModel::UnloadResourceData()
       
   297     {
       
   298     delete iDecorator;
       
   299     iDecorator = NULL;
       
   300     
       
   301     delete iPhoneIcon;
       
   302     iPhoneIcon = NULL;
       
   303     delete iPhoneIconMask;
       
   304     iPhoneIconMask = NULL;
       
   305     delete iMMCIcon;
       
   306     iMMCIcon = NULL;
       
   307     delete iMMCIconMask;
       
   308     iMMCIconMask = NULL;
       
   309     delete iMassStorageIcon;
       
   310     iMassStorageIcon = NULL;
       
   311     delete iMassStorageIconMask;
       
   312     iMassStorageIconMask = NULL;
       
   313     delete iProgressBarBitmap;
       
   314     iProgressBarBitmap = NULL;
       
   315     delete iProgressBarMask;
       
   316     iProgressBarMask = NULL;
       
   317     delete iProgressBarFrame;
       
   318     iProgressBarFrame = NULL;
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CCamNaviProgressBarModel::ReloadResourceDataL()
       
   323 // Refreshes all resource-based information stored in the class
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CCamNaviProgressBarModel::ReloadResourceDataL()
       
   327     {
       
   328     UnloadResourceData();
       
   329     LoadResourceDataL();
       
   330     }
       
   331 
       
   332 // ---------------------------------------------------------
       
   333 // CCamNaviProgressBarModel::DrawProgBar
       
   334 // Draw the control
       
   335 // ---------------------------------------------------------
       
   336 //
       
   337 void 
       
   338 CCamNaviProgressBarModel::DrawProgBar(       CBitmapContext& aGc, 
       
   339                                        const CCoeControl*    /*aControl*/ ) const
       
   340     {
       
   341     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   342 
       
   343     iDecorator->Draw( aGc, iExtent );
       
   344 
       
   345     CFbsBitmap* icon = NULL;
       
   346     CFbsBitmap* mask = NULL;
       
   347     if ( iStorageLocation == ECamMediaStoragePhone )
       
   348         {
       
   349         icon = iPhoneIcon;
       
   350         mask = iPhoneIconMask;
       
   351         }
       
   352     else if ( iStorageLocation == ECamMediaStorageMassStorage )
       
   353         {
       
   354         icon = iMassStorageIcon;
       
   355         mask = iMassStorageIconMask;
       
   356         }
       
   357     else
       
   358         {
       
   359         icon = iMMCIcon;
       
   360         mask = iMMCIconMask;
       
   361         }
       
   362 
       
   363     DrawElapsedTimeText( aGc );
       
   364     DrawRemainingTimeText( aGc, skin );
       
   365     if ( CamUtility::IsNhdDevice() )
       
   366         {
       
   367         aGc.BitBltMasked( iProgressIconRect.Rect().iTl,
       
   368             icon, icon->SizeInPixels(), mask, ETrue );
       
   369         }
       
   370     else
       
   371         {
       
   372         aGc.BitBltMasked( iVidStorageIconRect.Rect().iTl,
       
   373             icon, icon->SizeInPixels(), mask, ETrue );
       
   374         }
       
   375     
       
   376     DrawProgressBar( aGc );
       
   377     }
       
   378 
       
   379 // ---------------------------------------------------------
       
   380 // CCamNaviProgressBarModel::HandleControllerEventL
       
   381 // Handle an event from CCamAppController.
       
   382 // ---------------------------------------------------------
       
   383 //
       
   384 void CCamNaviProgressBarModel::HandleControllerEventL(
       
   385     TCamControllerEvent aEvent, TInt /* aError */ )
       
   386     {
       
   387     PRINT( _L("Camera => CCamNaviProgressBarModel::HandleControllerEventL"))
       
   388 
       
   389     switch( aEvent )
       
   390       {
       
   391       // ---------------------------------------------------
       
   392       /* Get it from CCameraController now.
       
   393       // if this is a record counter update event
       
   394       case ECamEventCounterUpdated:
       
   395         {
       
   396         PRINT( _L("Camera => CCamNaviProgressBarModel::HandleControllerEventL update"))
       
   397         iRecordTimeElapsed   = iController.RecordTimeElapsed();
       
   398         iRecordTimeRemaining = iController.RecordTimeRemaining();
       
   399         FormatTimeL();
       
   400         BroadcastEvent( ECamObserverEventNaviModelUpdated );
       
   401 
       
   402         // See if we need to start blinking the elapsed time      
       
   403         TTime time( iRecordTimeElapsed.Int64() );
       
   404         TDateTime recordTime = time.DateTime();
       
   405 
       
   406         if ( recordTime.Minute() != 0  && 
       
   407             recordTime.Second() == 0 &&
       
   408             !iFlashingTimer->IsActive() )
       
   409             {
       
   410             iFlashingTimer->Start( KFlashInterval,
       
   411                                    KFlashInterval,
       
   412                                    TCallBack( FlashCallBack, this ) );  
       
   413             }
       
   414         break;
       
   415         }
       
   416       */
       
   417       // ---------------------------------------------------
       
   418       case ECamEventEngineStateChanged:
       
   419         {
       
   420 // <CAMERAAPP_CAPI_V2_MIGRATION/>
       
   421 //        if ( iController.EngineState() == ECamEngineVideoCapturePrepared )
       
   422         if ( ECamCameraPreparedVideo == iController.CameraState() )
       
   423           {
       
   424           iRecordTimeRemaining = iController.RecordTimeRemaining();
       
   425           FormatTimeL();
       
   426           BroadcastEvent( ECamObserverEventNaviModelUpdated );
       
   427           }
       
   428         else
       
   429           {
       
   430           // empty statement to remove Lint error
       
   431           }
       
   432         break;
       
   433         }
       
   434       // ---------------------------------------------------
       
   435       case ECamEventOperationStateChanged:
       
   436         {
       
   437         if ( ECamControllerVideo == iController.CurrentMode()
       
   438           && ECamCapturing       == iController.CurrentOperation() )
       
   439           {
       
   440           // get the current media storage
       
   441           iStorageLocation = static_cast< TCamMediaStorage > 
       
   442               ( iController.IntegerSettingValue( ECamSettingItemVideoMediaStorage ) );
       
   443           }
       
   444         else
       
   445           {
       
   446           // empty statement to remove Lint error
       
   447           }
       
   448         break;
       
   449         }
       
   450       // ---------------------------------------------------
       
   451       case ECamEventRecordComplete:
       
   452         {
       
   453         // reset elapsed recording time
       
   454         iController.RecordTimeElapsed( iRecordTimeElapsed );
       
   455         iRecordTimeElapsed = static_cast<TInt64>(0);
       
   456         iFlashingTimer->Cancel();
       
   457         iFlash = EFalse;
       
   458         break;
       
   459         }
       
   460       // ---------------------------------------------------
       
   461       default:
       
   462         {
       
   463     		break;
       
   464         }
       
   465       // ---------------------------------------------------
       
   466       }
       
   467     PRINT( _L("Camera <= CCamNaviProgressBarModel::HandleControllerEventL"))
       
   468     }
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // HandleCameraEventL
       
   472 //
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 void 
       
   476 CCamNaviProgressBarModel
       
   477 ::HandleCameraEventL( TInt              /*aStatus*/, 
       
   478                       TCamCameraEventId aEventId, 
       
   479                       TAny*             aEventData /*= NULL*/ )
       
   480   {
       
   481   PRINT( _L("Camera => CCamNaviProgressBarModel::HandleCameraEventL") );
       
   482   switch( aEventId )
       
   483     {
       
   484     // ---------------------------------------------------
       
   485     case ECamCameraEventVideoTimes:
       
   486       {
       
   487       TCamVideoRecordingTimes* times = 
       
   488         static_cast<TCamVideoRecordingTimes*>( aEventData );
       
   489       if( times )
       
   490         {
       
   491         iRecordTimeElapsed   = times->iTimeElapsed;
       
   492         iRecordTimeRemaining = times->iTimeRemaining;
       
   493         
       
   494         // If the time we have is greater than the maximum allowed, return the
       
   495         // maximum
       
   496         TTimeIntervalMicroSeconds maxRecordingLength( static_cast<TInt64>(KMaxRecordingLength) );        
       
   497         
       
   498         if( iRecordTimeRemaining > maxRecordingLength )
       
   499           {
       
   500           iRecordTimeRemaining = maxRecordingLength;  
       
   501           }
       
   502         
       
   503         FormatTimeL();
       
   504         BroadcastEvent( ECamObserverEventNaviModelUpdated );
       
   505   
       
   506         // See if we need to start blinking the elapsed time      
       
   507         TTime time( iRecordTimeElapsed.Int64() );
       
   508         TDateTime recordTime = time.DateTime();
       
   509   
       
   510         if (  recordTime.Minute() != 0  
       
   511           &&  recordTime.Second() == 0 
       
   512           &&  !iFlashingTimer->IsActive() )
       
   513           {
       
   514           iFlashingTimer->Start( KFlashInterval,
       
   515                                  KFlashInterval,
       
   516                                  TCallBack( FlashCallBack, this ) );  
       
   517           }
       
   518         }
       
   519       break;
       
   520       }
       
   521     // ---------------------------------------------------
       
   522     default:
       
   523       break;
       
   524     // ---------------------------------------------------
       
   525     }
       
   526   PRINT( _L("Camera <= CCamNaviProgressBarModel::HandleCameraEventL") );
       
   527   }
       
   528 
       
   529 
       
   530 // -----------------------------------------------------------------------------
       
   531 // CCamNaviProgressBarModel::FormatTimeL 
       
   532 // Formats the elapsed/remaining record time 
       
   533 // -----------------------------------------------------------------------------
       
   534 //
       
   535 void CCamNaviProgressBarModel::FormatTimeL()
       
   536     {
       
   537     TTime time( iRecordTimeElapsed.Int64() );
       
   538     time.FormatL( iElapsedTimeText, *iTimeFormat );
       
   539 
       
   540     time = iRecordTimeRemaining.Int64();
       
   541     time.FormatL( iRemainingTimeText, *iTimeFormat );
       
   542     
       
   543     if ( iElapsedTimeTextItem )
       
   544         {
       
   545         iElapsedTimeTextItem->SetTextL( iElapsedTimeText );
       
   546         }
       
   547 
       
   548     if ( iRemainingTimeTextItem )
       
   549         {
       
   550         iRemainingTimeTextItem->SetTextL( iRemainingTimeText );
       
   551         }
       
   552     }
       
   553 
       
   554 // -----------------------------------------------------------------------------
       
   555 // CCamNaviProgressBarModel::DrawElapsedTimeText
       
   556 // Draws the elapsed record time to the navi pane 
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 void 
       
   560 CCamNaviProgressBarModel::DrawElapsedTimeText( CBitmapContext& aGc ) const
       
   561     {
       
   562     if ( !iFlash && iElapsedTimeTextItem )
       
   563         {
       
   564         iElapsedTimeTextItem->Draw( aGc );
       
   565         }
       
   566     }
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CCamNaviProgressBarModel::DrawRemainingTimeText
       
   570 // Draws the remaining record time to the navi pane 
       
   571 // -----------------------------------------------------------------------------
       
   572 //
       
   573 void 
       
   574 CCamNaviProgressBarModel::DrawRemainingTimeText( CBitmapContext&    aGc, 
       
   575                                                  MAknsSkinInstance* /*aSkin*/ ) const
       
   576     {
       
   577     if ( iRemainingTimeTextItem )
       
   578         {
       
   579         iRemainingTimeTextItem->Draw( aGc );
       
   580         }
       
   581     }
       
   582 
       
   583 // -----------------------------------------------------------------------------
       
   584 // CCamNaviProgressBarModel::DrawProgressBar
       
   585 // Draws the progress bar to the navi pane 
       
   586 // -----------------------------------------------------------------------------
       
   587 //
       
   588 void 
       
   589 CCamNaviProgressBarModel::DrawProgressBar( CBitmapContext& aGc ) const
       
   590     {
       
   591     PRINT( _L("Camera => CCamNaviProgressBarModel::DrawProgressBar"))
       
   592 
       
   593     // Draw frame
       
   594     TRect rect = iProgressBarRect.Rect();
       
   595 
       
   596     aGc.BitBlt( rect.iTl, iProgressBarFrame );
       
   597     
       
   598     // Draw the progress bar
       
   599 
       
   600     // Define the area of bitmap that is to be drawn 
       
   601     TRect srcRect( 0, 0, 0, iProgressBarBitmap->SizeInPixels().iHeight );
       
   602     TInt newWidth = rect.Width();
       
   603 
       
   604     // If remaining record time is zero, do not try to perform the percentage
       
   605     // calculation, the progress bar will be full
       
   606     if ( iRecordTimeRemaining.Int64() > 0 )
       
   607         {
       
   608         newWidth = static_cast<TInt>(( iRecordTimeElapsed.Int64() * rect.Width() ) 
       
   609                       / ( iRecordTimeElapsed.Int64() + iRecordTimeRemaining.Int64() ));
       
   610         }
       
   611     else
       
   612         {
       
   613         // empty statement to remove Lint error.
       
   614         }
       
   615 
       
   616     srcRect.SetWidth( newWidth );
       
   617 
       
   618     aGc.BitBltMasked( rect.iTl, iProgressBarBitmap, srcRect, iProgressBarMask, ETrue );
       
   619     }
       
   620 
       
   621 // ---------------------------------------------------------
       
   622 // CCamNaviProgressBarModel::SetExtentL
       
   623 // Sets the extent
       
   624 // ---------------------------------------------------------
       
   625 //
       
   626 void CCamNaviProgressBarModel::SetExtentL( const TRect& aExtent )
       
   627   {
       
   628   iExtent = aExtent;
       
   629   }
       
   630     
       
   631 // ---------------------------------------------------------
       
   632 // CCamNaviProgressBarModel::RegisterObserverL
       
   633 // Registers an observer
       
   634 // ---------------------------------------------------------
       
   635 //
       
   636 void CCamNaviProgressBarModel::RegisterObserverL(MCamObserver* aObserver)
       
   637     {
       
   638     iObserverHandler->RegisterObserverL(aObserver);
       
   639     }
       
   640 
       
   641 // ---------------------------------------------------------
       
   642 // CCamNaviProgressBarModel::DeregisterObserver
       
   643 // Deregisters an observer
       
   644 // ---------------------------------------------------------
       
   645 //
       
   646 void CCamNaviProgressBarModel::DeregisterObserver(MCamObserver* aObserver)
       
   647     {
       
   648     iObserverHandler->DeregisterObserver(aObserver);
       
   649     }
       
   650 
       
   651 // ---------------------------------------------------------
       
   652 // CCamNaviProgressBarModel::BroadcastEvent
       
   653 // Broadcasts an event to all observers
       
   654 // ---------------------------------------------------------
       
   655 //
       
   656 void CCamNaviProgressBarModel::BroadcastEvent(TCamObserverEvent aEvent)
       
   657     {
       
   658     iObserverHandler->BroadcastEvent(aEvent);
       
   659     }
       
   660     
       
   661 // ---------------------------------------------------------
       
   662 // CCamNaviProgressBarModel::HandleObservedEvent
       
   663 // Handles observed events
       
   664 // ---------------------------------------------------------
       
   665 //
       
   666 void CCamNaviProgressBarModel::HandleObservedEvent(TCamObserverEvent aEvent)
       
   667     {
       
   668     if( aEvent == ECamObserverEventRecordingIconUpdated )
       
   669         {
       
   670         BroadcastEvent(ECamObserverEventNaviModelUpdated);
       
   671         }
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------
       
   675 // CCamNaviProgressBarModel::DoCancel
       
   676 // Called when the flashing timer elapses
       
   677 // ---------------------------------------------------------
       
   678 //
       
   679 TInt CCamNaviProgressBarModel::FlashCallBack( TAny* aAny )
       
   680     {
       
   681     CCamNaviProgressBarModel* self = static_cast<CCamNaviProgressBarModel*>( aAny );
       
   682     TTime time( self->iRecordTimeElapsed.Int64() );
       
   683     TDateTime recordTime = time.DateTime();
       
   684     if ( recordTime.Second() != 0 )
       
   685         {
       
   686         self->iFlashingTimer->Cancel();
       
   687         self->iFlash = EFalse;
       
   688         }
       
   689     else
       
   690         {
       
   691         self->iFlash = !self->iFlash;
       
   692         self->BroadcastEvent( ECamObserverEventNaviModelUpdated );
       
   693         }
       
   694     return KErrNone;
       
   695     }
       
   696 
       
   697 // ---------------------------------------------------------
       
   698 // CCamNaviProgressBarModel::TouchLayoutL
       
   699 // ---------------------------------------------------------
       
   700 void CCamNaviProgressBarModel::TouchLayoutL()
       
   701     {
       
   702     TInt variant = 0; // portrait
       
   703     TInt iconVariant = 1;
       
   704     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   705         {
       
   706         variant = 1; // landscape
       
   707         iconVariant = 0;
       
   708         }
       
   709 
       
   710     TAknLayoutRect progressPaneLayout;
       
   711     progressPaneLayout.LayoutRect( iExtent,
       
   712             AknLayoutScalable_Apps::vid4_progress_pane( variant ) );
       
   713     
       
   714     TRect progressPaneRect = progressPaneLayout.Rect();
       
   715     iElapsedTimeTextItem->SetLayoutL( progressPaneRect,
       
   716         AknLayoutScalable_Apps::vid4_progress_pane_t1( iconVariant ) );
       
   717     iRemainingTimeTextItem->SetLayoutL( progressPaneRect,
       
   718         AknLayoutScalable_Apps::vid4_progress_pane_t2( iconVariant ) );
       
   719     iProgressIconRect.LayoutRect( progressPaneRect,
       
   720         AknLayoutScalable_Apps::vid4_progress_pane_g4( iconVariant ) );
       
   721 
       
   722     // Progress bar
       
   723     iProgressBarRect.LayoutRect( progressPaneRect,
       
   724         AknLayoutScalable_Apps::wait_bar_pane_cp07( iconVariant ) );
       
   725     }
       
   726 
       
   727 // ---------------------------------------------------------
       
   728 // CCamNaviProgressBarModel::NonTouchLayoutL
       
   729 // Read nontouch layout for primary camera
       
   730 // ---------------------------------------------------------
       
   731 void CCamNaviProgressBarModel::NonTouchLayoutL()  
       
   732     {
       
   733     TInt variant = 0; // Magic: layout Opt1
       
   734     
       
   735     TInt cba =  1; // Magic: layout Opt1 
       
   736         
       
   737     TAknLayoutRect progressPaneLayout;
       
   738     
       
   739     progressPaneLayout.LayoutRect( iExtent,
       
   740         AknLayoutScalable_Apps::vid6_indi_pane( variant ) );  
       
   741     TRect progressPaneRect = progressPaneLayout.Rect();
       
   742 
       
   743     iVidStorageIconRect.LayoutRect( progressPaneRect,
       
   744         AknLayoutScalable_Apps::vid6_indi_pane_g3( cba ) );
       
   745     iElapsedTimeTextItem->SetLayoutL( progressPaneRect,
       
   746         AknLayoutScalable_Apps::vid6_indi_pane_t2( cba ) );
       
   747     iRemainingTimeTextItem->SetLayoutL( progressPaneRect,
       
   748         AknLayoutScalable_Apps::vid6_indi_pane_t3( cba ) );
       
   749     iProgressIconRect.LayoutRect( progressPaneRect,
       
   750         AknLayoutScalable_Apps::wait_bar_pane_cp08( 0 ) ); 
       
   751 
       
   752     // Progress bar
       
   753     iProgressBarRect.LayoutRect( progressPaneRect,
       
   754         AknLayoutScalable_Apps::wait_bar_pane_cp08( 0 ) );       
       
   755     }
       
   756 
       
   757 // ---------------------------------------------------------
       
   758 // CCamNaviProgressBarModel::NonTouchLayoutSecondaryL
       
   759 // Read nontouch layout for secondary camera
       
   760 // ---------------------------------------------------------
       
   761 void CCamNaviProgressBarModel::NonTouchLayoutSecondaryL()
       
   762     {
       
   763     TRect screenRect;
       
   764     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect );
       
   765     iExtent = screenRect;
       
   766     // Magic numbers used for layout variation
       
   767     TAknLayoutRect progressPaneLayout;
       
   768     progressPaneLayout.LayoutRect( iExtent,
       
   769              AknLayoutScalable_Apps::vid6_indi_pane( 3 ) );  
       
   770 
       
   771     iVidStorageIconRect.LayoutRect( progressPaneLayout.Rect(),
       
   772             AknLayoutScalable_Apps::vid6_indi_pane_g3( 3 ) );
       
   773     
       
   774     TRect progressPaneRect = progressPaneLayout.Rect();
       
   775     iElapsedTimeTextItem->SetLayoutL( progressPaneRect,
       
   776         AknLayoutScalable_Apps::vid6_indi_pane_t2( 2 ) );
       
   777     iRemainingTimeTextItem->SetLayoutL( progressPaneRect,
       
   778         AknLayoutScalable_Apps::vid6_indi_pane_t3( 2 ) );
       
   779     iProgressIconRect.LayoutRect( progressPaneRect,
       
   780         AknLayoutScalable_Apps::wait_bar_pane_cp08( 1 ) );
       
   781 
       
   782     // Progress bar
       
   783     iProgressBarRect.LayoutRect( progressPaneRect,
       
   784         AknLayoutScalable_Apps::wait_bar_pane_cp08( 1 ) );
       
   785     }
       
   786 
       
   787 // End of File