camerauis/cameraapp/generic/src/CamIndicator.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Camera Indicator control*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknview.h>
       
    21 #include "CamIndicator.h"
       
    22 #include "CamUtility.h"
       
    23 #include "cambitmapitem.h"
       
    24 #include <eikenv.h>
       
    25 #include <eikappui.h>	// For CCoeAppUiBase
       
    26 #include <eikapp.h>		// For CEikApplication
       
    27 #include <AknIconUtils.h>
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 // ---------------------------------------------------------------------------
       
    33 // CCamIndicator::NewL
       
    34 // Symbian OS two-phased constructor
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CCamIndicator* CCamIndicator::NewL( const TRect& aRect )
       
    38     {
       
    39     return new ( ELeave ) CCamIndicator( aRect );
       
    40     }
       
    41 
       
    42 
       
    43 // Destructor
       
    44 CCamIndicator::~CCamIndicator()
       
    45   {
       
    46   PRINT( _L("Camera => ~CCamIndicator") );
       
    47   iIcons.ResetAndDestroy();
       
    48   PRINT( _L("Camera <= ~CCamIndicator") );
       
    49   }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CCamIndicator::CCamIndicator
       
    53 // C++ constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CCamIndicator::CCamIndicator( const TRect& aRect )
       
    57 : iRect( aRect ),
       
    58   iDefaultRect( aRect )
       
    59     {
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CCamIndicator::CCamIndicator
       
    64 // C++ default constructor.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CCamIndicator::CCamIndicator()
       
    68 	{
       
    69 	}
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CCamIndicator::Draw
       
    73 // Draw control
       
    74 // ---------------------------------------------------------
       
    75 //
       
    76 void CCamIndicator::Draw( CBitmapContext& aGc ) const
       
    77     {
       
    78     if ( !iClear )
       
    79         {
       
    80         iIcons[ iCurrentIcon ]->Draw( aGc );
       
    81         }
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CCamIndicator::AddIconL
       
    86 // Add a bitmap icon to array of available icons
       
    87 // ---------------------------------------------------------
       
    88 //
       
    89 void CCamIndicator::AddIconL( TInt32 aBitmapId, TInt32 aMaskId )
       
    90     {
       
    91     CCamBitmapItem* item = CCamBitmapItem::NewL( aBitmapId, aMaskId );
       
    92     CleanupStack::PushL( item );
       
    93     User::LeaveIfError( iIcons.Append( item ) );
       
    94     CleanupStack::Pop( item );
       
    95     item = NULL;
       
    96 
       
    97     // Unused (used to be mask). Just here to make sure the indexing
       
    98     // system remains the same
       
    99     item = CCamBitmapItem::NewL( aBitmapId, aMaskId );
       
   100     CleanupStack::PushL( item );
       
   101     User::LeaveIfError( iIcons.Append( item ) );
       
   102     CleanupStack::Pop( item );
       
   103     item = NULL;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // CCamIndicator::UpdateRect
       
   108 // Update the indicator coords
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 void CCamIndicator::UpdateRect( TRect& aRect )
       
   112     {
       
   113     iRect = aRect;
       
   114     iDefaultRect = iRect;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // CCamIndicator::SetIcon
       
   119 // Set index for current icon (from array of loaded bitmaps)
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 void CCamIndicator::SetIcon( TInt aIndex )
       
   123   {
       
   124   // Mask is used from index (aIndex + 1),
       
   125   // make sure also mask index is in bounds
       
   126   if ( aIndex + 1 < iIcons.Count() )
       
   127     {
       
   128     iClear = EFalse;
       
   129     iCurrentIcon = aIndex;
       
   130     }
       
   131   else
       
   132     {
       
   133     iClear = ETrue;
       
   134     PRINT1( _L("Camera <<warning>> CCamIndicator::SetIcon index out of bounds:%d"), aIndex );
       
   135     }
       
   136   }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // CCamIndicator::ClearIcon
       
   140 // Request for indicator to clear bitmap icon
       
   141 // - indicator will clear itself on redraw
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 void CCamIndicator::ClearIcon()
       
   145     {
       
   146     iClear = ETrue;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CCamIndicator::DisplayIcon
       
   151 // Request for indicator to draw current bitmap icon
       
   152 // ---------------------------------------------------------
       
   153 //
       
   154 void CCamIndicator::DisplayIcon()
       
   155     {
       
   156     iClear = EFalse;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // CCamIndicator::SetFlashing
       
   161 // set flashing state of indicator
       
   162 // ---------------------------------------------------------
       
   163 //
       
   164 void CCamIndicator::SetFlashing( TBool aFlashing )
       
   165     {
       
   166     iFlashing = aFlashing;
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------
       
   170 // CCamIndicator::IsFlashing
       
   171 // return flashing state of indicator
       
   172 // ---------------------------------------------------------
       
   173 //
       
   174 TBool CCamIndicator::IsFlashing() const
       
   175     {
       
   176     return iFlashing;
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------
       
   180 // CCamIndicator::OverridePosition
       
   181 // Allows a new position to be temporarialy specified
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 void CCamIndicator::OverridePosition( const TPoint& aPos )
       
   185     {
       
   186     iRect.iTl = aPos;
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // CCamIndicator::CancelOverridePosition
       
   191 // Cancels the position set by OverridePosition
       
   192 // ---------------------------------------------------------
       
   193 //
       
   194 void CCamIndicator::CancelOverridePosition()
       
   195     {
       
   196     iRect = iDefaultRect;
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------
       
   200 // CCamIndicator::SetRect
       
   201 //
       
   202 // ---------------------------------------------------------
       
   203 //
       
   204 void CCamIndicator::SetRect( const TRect& aRect )
       
   205     {
       
   206     iRect = aRect;
       
   207 
       
   208     for ( TInt i = 0; i < iIcons.Count(); i++ )
       
   209         {
       
   210         TRAP_IGNORE( iIcons[i]->SetLayoutL( aRect ) );
       
   211         }
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------
       
   215 // CCamIndicator::Rect
       
   216 // Indicator layout rect
       
   217 // ---------------------------------------------------------
       
   218 //
       
   219 TRect CCamIndicator::LayoutRect()  
       
   220     {
       
   221     return iRect;
       
   222     }
       
   223 // End of File