camerauis/cameraapp/generic/src/CamNaviCounterControl.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 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 remaining images/videos in Navi Pane
       
    15 *
       
    16 *  Copyright © 2007 Nokia.  All rights reserved.
       
    17 *  This material, including documentation and any related computer
       
    18 *  programs, is protected by copyright controlled by Nokia.  All
       
    19 *  rights are reserved.  Copying, including reproducing, storing,
       
    20 *  adapting or translating, any or all of this material requires the
       
    21 *  prior written consent of Nokia.  This material also contains
       
    22 *  confidential information which may not be disclosed to others
       
    23 *  without the prior written consent of Nokia.
       
    24 
       
    25 *
       
    26 *
       
    27 */
       
    28 
       
    29 
       
    30 // INCLUDE FILES
       
    31 #include <AknsUtils.h>
       
    32 #include <e32base.h>
       
    33 #include "CamNaviCounterControl.h"
       
    34 #include "CamNaviCounterModel.h"
       
    35 #include "CamAppUi.h"
       
    36 #include "CamUtility.h"
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // ========================= MEMBER FUNCTIONS ================================
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // CCamNaviCounterControl::NewL
       
    44 // Factory construction function
       
    45 // ---------------------------------------------------------
       
    46 //
       
    47 CCamNaviCounterControl* CCamNaviCounterControl::NewL( CCamNaviCounterModel& aModel )
       
    48     {
       
    49     CCamNaviCounterControl* self = new( ELeave ) CCamNaviCounterControl( aModel );
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop( self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // Destructor
       
    57 CCamNaviCounterControl::~CCamNaviCounterControl()
       
    58     {
       
    59     iModel.DeregisterObserver( this );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CCamNaviCounterControl::CCamNaviCounterControl
       
    64 // C++ constructor
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CCamNaviCounterControl::CCamNaviCounterControl(CCamNaviCounterModel& aModel )
       
    68     : iModel ( aModel )
       
    69     {
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CCamNaviCounterControl::ConstructL
       
    74 // Symbian OS 2nd phase constructor
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 void CCamNaviCounterControl::ConstructL()
       
    78     {
       
    79     iModel.RegisterObserverL( this );
       
    80     }                
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CCamNaviCounterControl::SizeChanged
       
    84 // Called by framework when the view size is changed
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 void CCamNaviCounterControl::SizeChanged()
       
    88     {
       
    89     // if the rectangle has width or height
       
    90     if ( Rect().Size() != TSize( 0, 0 ) && iActive )
       
    91         {
       
    92         TRAP_IGNORE(iModel.SetExtentL( Rect() ));
       
    93         TRAP_IGNORE(iModel.ReloadResourceDataL());
       
    94         }
       
    95 
       
    96 //    AknsUtils::RegisterControlPosition( this );
       
    97     }
       
    98     
       
    99 // ---------------------------------------------------------
       
   100 // CCamNaviCounterControl::DrawNaviCtr
       
   101 // Draw the control
       
   102 // ---------------------------------------------------------
       
   103 //
       
   104 void CCamNaviCounterControl::DrawNaviCtr( CBitmapContext& aGc ) const
       
   105 	{
       
   106 	if ( iActive )
       
   107 	    {
       
   108         iModel.DrawNaviCtr( aGc, this );
       
   109 	    }
       
   110 	}
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CCamNaviCounterControl::Draw
       
   114 // Draw the control
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CCamNaviCounterControl::Draw( const TRect& /* aRect */ ) const
       
   118     {
       
   119     PRINT( _L("Camera => CCamNaviCounterControl::Draw" ))
       
   120     
       
   121        CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
   122     if ( appUi->CurrentViewState() != ECamViewStatePostCapture ) 
       
   123 	{
       
   124     		CWindowGc& gc=SystemGc();    
       
   125     		DrawNaviCtr( gc );
       
   126     	}
       
   127 
       
   128     PRINT( _L("Camera <= CCamNaviCounterControl::Draw" ))
       
   129     }
       
   130     
       
   131 // ---------------------------------------------------------
       
   132 // CCamNaviCounterControl::ForceNaviPaneUpdate
       
   133 // Force update of navi-pane (i.e after dismissal of MMC removed error note)
       
   134 // ---------------------------------------------------------
       
   135 //
       
   136 void CCamNaviCounterControl::ForceNaviPaneUpdate()
       
   137     {
       
   138     iModel.ForceNaviPaneUpdate();
       
   139     
       
   140     // redraw
       
   141     CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
   142     
       
   143     if ( appUi && appUi->IsDirectViewfinderActive() )
       
   144         {
       
   145         TRAP_IGNORE(appUi->HandleCommandL( ECamCmdRedrawScreen ));
       
   146         }
       
   147     else
       
   148         {
       
   149         DrawDeferred();
       
   150         }
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------
       
   154 // CCamNaviCounterControl::SetActiveL
       
   155 // Set's whether this control is currently active or not
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 void CCamNaviCounterControl::SetActiveL( TBool aActive )
       
   159     {
       
   160     iActive = aActive;
       
   161     if ( iActive )
       
   162         {
       
   163         ActivateL();
       
   164         iModel.SetExtentL( Rect() );
       
   165         }
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------
       
   169 // CCamNaviCounterControl::HandleObservedEvent
       
   170 // Gets events from observed model
       
   171 // ---------------------------------------------------------
       
   172 //
       
   173 void CCamNaviCounterControl::HandleObservedEvent(TCamObserverEvent aEvent)
       
   174     {
       
   175     PRINT( _L("Camera => CCamNaviCounterControl::HandleObservedEvent" ));
       
   176     if ( ECamObserverEventNaviModelUpdated == aEvent )
       
   177         {
       
   178         if ( iActive )
       
   179             {
       
   180             CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
   181             if ( appUi && appUi->IsDirectViewfinderActive() )
       
   182                 {
       
   183                 TRAP_IGNORE(appUi->HandleCommandL( ECamCmdRedrawScreen ));
       
   184                 }
       
   185             else
       
   186                 {
       
   187 #ifndef __WINS__ 
       
   188               if( appUi && appUi->ReadyToDraw() && appUi->IsBurstEnabled()
       
   189                   && !appUi->SettingsLaunchedFromCamera() )
       
   190                     {
       
   191                     PRINT( _L("Camera <> CCamNaviCounterControl::HandleObservedEvent - draw deferred") );
       
   192                     DrawDeferred();
       
   193                     }
       
   194                
       
   195 #endif
       
   196                 }
       
   197             }
       
   198         }
       
   199     PRINT( _L("Camera <= CCamNaviCounterControl::HandleObservedEvent" ));
       
   200     }
       
   201 
       
   202 // End of File
       
   203 
       
   204