phoneplugins/telbranding/src/telbrandingcallindicator.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 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:  Branding specific call indication.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <telbubbleextensiondata.h>
       
    19 #include <AknsUtils.h>
       
    20 #include <eikimage.h>
       
    21 #include <callstatus.mbg> // From bubblemanager
       
    22 #include <aknconsts.h>
       
    23 #include <AknBitmapAnimation.h>  // Animation definition
       
    24 #include <AknUtils.h>
       
    25 
       
    26 #include "telbrandingcallindicator.h"
       
    27 
       
    28 
       
    29 // ======== LOCAL FUNCTIONS ========
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // CTelBrandingCallIndicator::CTelBrandingCallIndicator
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CTelBrandingCallIndicator::CTelBrandingCallIndicator( 
       
    37     MTelBubbleExtensionData& aCallData, CEikImage* aBrand ) :
       
    38     iCallData( aCallData ),
       
    39     iBrand( aBrand ),
       
    40     iCallIndicator( NULL )
       
    41     {
       
    42     }
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CTelBrandingCallIndicator::ConstructL
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void CTelBrandingCallIndicator::ConstructL()
       
    50     {
       
    51     CTelBubbleAnim::ConstructL( 500 );
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CTelBrandingCallIndicator::NewL
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CTelBrandingCallIndicator* CTelBrandingCallIndicator::NewL(
       
    60     MTelBubbleExtensionData& aCallData, CEikImage* aBrand )
       
    61     {
       
    62     CTelBrandingCallIndicator* self = 
       
    63         CTelBrandingCallIndicator::NewLC( aCallData, aBrand );
       
    64     CleanupStack::Pop( self );
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CTelBrandingCallIndicator::NewLC
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CTelBrandingCallIndicator* CTelBrandingCallIndicator::NewLC(
       
    74     MTelBubbleExtensionData& aCallData, CEikImage* aBrand )
       
    75     {
       
    76     CTelBrandingCallIndicator* self = 
       
    77         new( ELeave ) CTelBrandingCallIndicator( aCallData, aBrand );
       
    78     
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL();
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CTelBrandingCallIndicator::~CTelBrandingCallIndicator
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CTelBrandingCallIndicator::~CTelBrandingCallIndicator()
       
    90     {
       
    91     delete iBrand;
       
    92     delete iCallIndicator;
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CTelBrandingCallIndicator::MakeVisible
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CTelBrandingCallIndicator::MakeVisible( TBool aVisible )
       
   100     {
       
   101     CTelBubbleAnim::MakeVisible( aVisible );
       
   102 
       
   103     if( aVisible )
       
   104         {
       
   105         TRAP_IGNORE( DoVisibleL() );
       
   106         }
       
   107     else
       
   108         {
       
   109         StopAnimation();
       
   110         }
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CTelBrandingCallIndicator::Draw
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CTelBrandingCallIndicator::Draw( const TRect& /*aRect*/ ) const
       
   118     {
       
   119     CWindowGc& gc = SystemGc();
       
   120     
       
   121     // Position is botton right corner minus image size
       
   122     TPoint brandPlace = Rect().iBr - iBrand->MinimumSize();
       
   123     TPoint callIndPlace = Rect().iTl;
       
   124 
       
   125     if( AknLayoutUtils::LayoutMirrored() )
       
   126         {
       
   127         // Fix position when arabic variant is in use
       
   128         brandPlace.iX = Rect().iTl.iX;
       
   129         
       
   130         if( iCallIndicator )
       
   131             {
       
   132             callIndPlace.iX = Rect().iBr.iX - iCallIndicator->MinimumSize().iWidth;
       
   133             }
       
   134         
       
   135         }
       
   136     
       
   137     gc.BitBltMasked( brandPlace,
       
   138                      iBrand->Bitmap(),
       
   139                      iBrand->MinimumSize(),
       
   140                      iBrand->Mask(),
       
   141                      ETrue );
       
   142     
       
   143     if( iCallIndicator )
       
   144         {
       
   145         gc.BitBltMasked( callIndPlace,
       
   146             iCallIndicator->Bitmap(),
       
   147             iCallIndicator->MinimumSize(),
       
   148             iCallIndicator->Mask(),
       
   149             ETrue );
       
   150         }
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CTelBrandingCallIndicator::SizeChanged
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CTelBrandingCallIndicator::SizeChanged()
       
   158     {
       
   159     CCoeControl::SizeChanged();
       
   160     TPoint place = Rect().iTl;
       
   161     
       
   162     TSize imageSize = Rect().Size();
       
   163     imageSize.iHeight /= 1.5;
       
   164     imageSize.iWidth /= 1.5;
       
   165 
       
   166     if( AknLayoutUtils::LayoutMirrored() )
       
   167         {
       
   168         // Fix position when arabic variant is in use
       
   169         place.iX = Rect().iBr.iX - imageSize.iWidth;
       
   170         }
       
   171     
       
   172     iAnimation->SetRect( TRect( place, imageSize ) );
       
   173     
       
   174     if ( iBrand->Bitmap() )
       
   175         {
       
   176         AknIconUtils::SetSize( 
       
   177             const_cast<CFbsBitmap*> ( iBrand->Bitmap() ), 
       
   178             imageSize );
       
   179         }
       
   180     
       
   181     if ( iCallIndicator )
       
   182         {
       
   183         AknIconUtils::SetSize( 
       
   184             const_cast<CFbsBitmap*> ( iCallIndicator->Bitmap() ), 
       
   185             imageSize );
       
   186         }
       
   187     
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 // CTelBrandingCallIndicator::DoVisibleL
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CTelBrandingCallIndicator::DoVisibleL()
       
   195     {
       
   196     Reset();
       
   197     delete iCallIndicator;
       
   198     iCallIndicator = NULL;
       
   199     
       
   200     switch( iCallData.State() )
       
   201         {
       
   202         case MTelBubbleExtensionData::EOnHold:
       
   203             // Show icon
       
   204             iCallIndicator = GetImageL( 
       
   205                 KAknsIIDQgnIndiCallHeld,
       
   206                 EMbmCallstatusQgn_indi_call_held,
       
   207                 EMbmCallstatusQgn_indi_call_held_mask );
       
   208             break;
       
   209         case MTelBubbleExtensionData::EAlertToDisconnected:
       
   210         case MTelBubbleExtensionData::EDisconnected:
       
   211             // Show icon
       
   212             iCallIndicator = GetImageL( 
       
   213                 KAknsIIDQgnIndiCallDisconn,
       
   214                 EMbmCallstatusQgn_indi_call_disconn,
       
   215                 EMbmCallstatusQgn_indi_call_disconn_mask );
       
   216             break;
       
   217         case MTelBubbleExtensionData::EOutgoing:
       
   218         case MTelBubbleExtensionData::EActive:
       
   219             // Show icon
       
   220             iCallIndicator = GetImageL( 
       
   221                 KAknsIIDQgnIndiCallActive,
       
   222                 EMbmCallstatusQgn_indi_call_active,
       
   223                 EMbmCallstatusQgn_indi_call_active_mask );
       
   224             break;
       
   225         case MTelBubbleExtensionData::EIncoming:
       
   226         case MTelBubbleExtensionData::EWaiting:
       
   227         case MTelBubbleExtensionData::EAlerting:
       
   228             // frame 1
       
   229             AddBrandedFrameToAnimationL( 
       
   230                 KAknsIIDQgnIndiCallActive,
       
   231                 EMbmCallstatusQgn_indi_call_active,
       
   232                 EMbmCallstatusQgn_indi_call_active_mask );
       
   233             
       
   234             // frame 2
       
   235             AddBrandedFrameToAnimationL( 
       
   236                 KAknsIIDQgnIndiCallActive2,
       
   237                 EMbmCallstatusQgn_indi_call_active_2,
       
   238                 EMbmCallstatusQgn_indi_call_active_2_mask );
       
   239             break;
       
   240             
       
   241         case MTelBubbleExtensionData::ENone:
       
   242         default:
       
   243             // Do nothing
       
   244             break;
       
   245         }
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // CTelBrandingCallIndicator::ShowAnimationL
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 void CTelBrandingCallIndicator::ShowAnimationL()
       
   253     {
       
   254 
       
   255 
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 // CTelBrandingCallIndicator::ShowImageL
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 void CTelBrandingCallIndicator::ShowImageL()
       
   263     {
       
   264 
       
   265     }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // CTelBrandingCallIndicator::AddBrandedFrameToAnimationL
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 void CTelBrandingCallIndicator::AddBrandedFrameToAnimationL( 
       
   272     TAknsItemID aSkinId, TInt aBitmap, TInt aMask )
       
   273     {
       
   274     CEikImage* image = GetImageL( aSkinId, aBitmap, aMask );
       
   275     AddFrameToAnimationLD( image );
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 // CTelBrandingCallIndicator::GetImageL
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 CEikImage* CTelBrandingCallIndicator::GetImageL(
       
   283     TAknsItemID aSkinId, 
       
   284     TInt aBitmap, 
       
   285     TInt aMask )
       
   286     {
       
   287     CFbsBitmap* bitmap;
       
   288     CFbsBitmap* mask;
       
   289     
       
   290     CEikImage* image = new(ELeave) CEikImage;
       
   291     CleanupStack::PushL( image );
       
   292         
       
   293     AknsUtils::CreateIconL( 
       
   294         AknsUtils::SkinInstance(),
       
   295         aSkinId,
       
   296         bitmap,
       
   297         mask,
       
   298         KCallStatusBitmapFile,
       
   299         aBitmap,
       
   300         aMask
       
   301         );
       
   302 
       
   303     image->SetPicture( bitmap, mask );
       
   304     
       
   305     CleanupStack::Pop( image );
       
   306     return image;
       
   307     }
       
   308 
       
   309 // End of file