phoneuis/BubbleManager/Src/BMBubbleOutlookFiveLined.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Bubble for call object text display.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "BMBubbleOutlookFiveLined.h"
       
    21 #include    "BMResourceManager.h"
       
    22 #include    "BMBubbleHeader.h"
       
    23 #include    "BMUtils.h"
       
    24 #include    "BMLayout.h"
       
    25 #include    "BMLayout2.h"
       
    26 #include    "BMCustomManager.h"
       
    27 
       
    28 #include    <telbubblecustomelement.h>
       
    29 #include    <telbubbleanim.h>
       
    30 
       
    31 #include    <eiklabel.h>
       
    32 #include    <eikimage.h>
       
    33 #include    <featmgr.h>
       
    34 #include    <AknsDrawUtils.h>
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 //
       
    41 CBubbleOutlookFiveLined::CBubbleOutlookFiveLined( 
       
    42     CBubbleManager& aBubbleManager ) : CBubbleOutlook( aBubbleManager )
       
    43     {
       
    44     }
       
    45 
       
    46 // Symbian OS default constructor can leave.
       
    47 void CBubbleOutlookFiveLined::ConstructL()
       
    48     {
       
    49     iHeader = NULL;
       
    50     iTextLineNumber = 0;
       
    51           
       
    52     CBubbleOutlook::ConstructL( );
       
    53     ActivateL();
       
    54     }
       
    55 
       
    56 // Destructor
       
    57 CBubbleOutlookFiveLined::~CBubbleOutlookFiveLined()
       
    58     {
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CBubbleOutlookFiveLined::Reset
       
    64 //
       
    65 //  
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CBubbleOutlookFiveLined::Reset( )
       
    69     {
       
    70     CBubbleResourceManager& res = iBubbleManager.ResourceManager();
       
    71     res.ReleaseEikImage( iBubble );
       
    72     iBubbleManager.CustomManager().ReleaseCustomElement( iSmallCallIndication );
       
    73     iBubbleManager.CustomManager().ReleaseCustomElement( iNumberType );
       
    74     res.ReleaseEikImage( iTypeIndication1 );
       
    75     res.ReleaseEikImage( iTypeIndication2 );
       
    76     res.ReleaseEikImage( iCyphOffImage );
       
    77     res.ReleaseEikImage( iTnImage );
       
    78     res.ReleaseEikLabel( iTextLine1 );
       
    79     res.ReleaseEikLabel( iTextLine2 );
       
    80     res.ReleaseEikLabel( iTextLine3 );
       
    81     res.ReleaseEikLabel( iTextLine4 );
       
    82     res.ReleaseEikLabel( iTextLine5 );
       
    83     
       
    84     iBubbleManager.CustomManager().ReleaseCustomElement( iBigCallIndicator );
       
    85     
       
    86     iFullText1.Set( NULL, 0 );
       
    87     iFullText2.Set( NULL, 0 );
       
    88     iFullText3.Set( NULL, 0 );
       
    89     iFullText4.Set( NULL, 0 );
       
    90     iFullText5.Set( NULL, 0 );
       
    91     iTextLineNumber = 0;
       
    92 
       
    93     iHeader = NULL;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CBubbleOutlookFiveLined::ReadBubbleHeader
       
    98 //
       
    99 //  
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CBubbleOutlookFiveLined::ReadBubbleHeader( CBubbleHeader& aHeader )
       
   103     {
       
   104     iHeader = &aHeader;
       
   105     
       
   106     CBubbleManager::TPhoneCallState callState = iHeader->CallState( );
       
   107     
       
   108     switch ( callState )
       
   109         {
       
   110         case CBubbleManager::EIncoming:
       
   111         case CBubbleManager::EOutgoing:
       
   112         case CBubbleManager::EAlerting:
       
   113         case CBubbleManager::EAlertToDisconnected:
       
   114             // Set big call indicator icon
       
   115             TBool defaultCallIndicator;
       
   116             iBigCallIndicator = 
       
   117                 iBubbleManager.CustomManager().ReserveCustomElement(
       
   118                     aHeader, 
       
   119                     CTelBubbleCustomElement::EBigCallIndicator,
       
   120                     defaultCallIndicator );
       
   121             
       
   122             // Number type not shown with custom call indicator
       
   123             if ( defaultCallIndicator )
       
   124                 {
       
   125                 // Set number type icon
       
   126                 iNumberType = 
       
   127                     iBubbleManager.CustomManager().ReserveCustomElement(
       
   128                         aHeader, 
       
   129                         CTelBubbleCustomElement::ENumberTypeIcon,
       
   130                         defaultCallIndicator );
       
   131                 }
       
   132             break;
       
   133             
       
   134         default:
       
   135             break;
       
   136         }
       
   137 
       
   138     BubbleUtils::SetCyphOffImage( *iHeader, iCyphOffImage, iBubbleManager );
       
   139       
       
   140     BubbleUtils::ChooseTextsToFiveLines( 
       
   141         *iHeader, 
       
   142         iFullText1, 
       
   143         iFullText2,
       
   144         iFullText3, 
       
   145         iTextLine1,
       
   146         iTextLine2,
       
   147         iTextLine3,
       
   148         iTextLine4,
       
   149         iTextLine5,
       
   150         iBubbleManager,
       
   151         iText1ClipDirection, 
       
   152         iText2ClipDirection,
       
   153         iText3ClipDirection, 
       
   154         iTextLineNumber,
       
   155         iThreeLinedLayout );
       
   156     
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CBubbleOutlookFiveLined::CountComponentControls
       
   161 //
       
   162 // All the controls are not used at all times. Athough we want to
       
   163 // keep the drawing order. 
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 TInt CBubbleOutlookFiveLined::CountComponentControls() const
       
   167     {
       
   168     TInt amount = 0;
       
   169 
       
   170     if ( iNumberType ) 
       
   171         {
       
   172         amount++;
       
   173         }
       
   174 
       
   175     if ( iSmallCallIndication ) 
       
   176         {
       
   177         amount++;
       
   178         }
       
   179 
       
   180     if ( iTypeIndication1 ) 
       
   181         {
       
   182         amount++;
       
   183         }
       
   184 
       
   185     if ( iTypeIndication2 ) 
       
   186         {
       
   187         amount++;
       
   188         }
       
   189 
       
   190     if ( iCyphOffImage ) 
       
   191         {
       
   192         amount++;
       
   193         }
       
   194 
       
   195     if ( iTextLine1 ) 
       
   196         {
       
   197         amount++;
       
   198         }
       
   199 
       
   200     if ( iTextLine2 ) 
       
   201         {
       
   202         amount++;
       
   203         }
       
   204 
       
   205     if ( iTextLine3 ) 
       
   206         {
       
   207         amount++;
       
   208         }
       
   209     
       
   210     if ( iTextLine4 ) 
       
   211         {
       
   212         amount++;
       
   213         }
       
   214 
       
   215     if ( iTextLine5 ) 
       
   216         {
       
   217         amount++;
       
   218         }
       
   219         
       
   220     if ( iTimerCost ) 
       
   221         {
       
   222         amount++;
       
   223         }
       
   224 
       
   225     if ( iBigCallIndicator )
       
   226         {
       
   227         amount++;
       
   228         }
       
   229 
       
   230     return amount;
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // CBubbleOutlookFiveLined::ComponentControl
       
   235 //
       
   236 //  
       
   237 // ---------------------------------------------------------------------------
       
   238 //
       
   239 CCoeControl* CBubbleOutlookFiveLined::ComponentControl(TInt aIndex) const
       
   240     {
       
   241   
       
   242     TInt amount = -1;
       
   243 
       
   244     if ( iNumberType )
       
   245         {
       
   246         amount++;
       
   247         }
       
   248 
       
   249     if ( aIndex == amount )
       
   250         {
       
   251         return iNumberType->Control();
       
   252         }
       
   253 
       
   254     if ( iCyphOffImage )
       
   255         {
       
   256         amount++;
       
   257         }
       
   258 
       
   259     if ( aIndex == amount )
       
   260         {
       
   261         return iCyphOffImage;
       
   262         }
       
   263         
       
   264     if ( iTextLine1 )
       
   265         {
       
   266         amount++;
       
   267         }
       
   268 
       
   269     if ( aIndex == amount )
       
   270         {
       
   271         return iTextLine1;
       
   272         }
       
   273 
       
   274     if ( iTextLine2 )
       
   275         {
       
   276         amount++;
       
   277         }
       
   278 
       
   279     if ( aIndex == amount )
       
   280         {
       
   281         return iTextLine2;
       
   282         }
       
   283 
       
   284     if ( iTextLine3 )
       
   285         {
       
   286         amount++;
       
   287         }
       
   288 
       
   289     if ( aIndex == amount )
       
   290         {
       
   291         return iTextLine3;
       
   292         }
       
   293         
       
   294     if ( iTextLine4 )
       
   295         {
       
   296         amount++;
       
   297         }        
       
   298         
       
   299     if ( aIndex == amount )
       
   300         {
       
   301         return iTextLine4;
       
   302         }
       
   303     
       
   304     if ( iTextLine5 )
       
   305         {
       
   306         amount++;
       
   307         }        
       
   308         
       
   309     if ( aIndex == amount )
       
   310         {
       
   311         return iTextLine5;
       
   312         }        
       
   313 
       
   314     if ( iTimerCost )
       
   315         {
       
   316         amount++;
       
   317         }
       
   318 
       
   319     if ( aIndex == amount )
       
   320         {
       
   321         return iTimerCost;
       
   322         }
       
   323 
       
   324     if ( iSmallCallIndication )
       
   325         {
       
   326         amount++;
       
   327         }
       
   328 
       
   329     if ( aIndex == amount )
       
   330         {
       
   331         return iSmallCallIndication->Control();
       
   332         }
       
   333 
       
   334     if ( iTypeIndication1 )
       
   335         {
       
   336         amount++;
       
   337         }
       
   338 
       
   339     if ( aIndex == amount )
       
   340         {
       
   341         return iTypeIndication1;
       
   342         }
       
   343 
       
   344     if ( iTypeIndication2 )
       
   345         {
       
   346         amount++;
       
   347         }
       
   348 
       
   349     if ( aIndex == amount )
       
   350         {
       
   351         return iTypeIndication2;
       
   352         }
       
   353 
       
   354     if ( iBigCallIndicator )
       
   355         {
       
   356         amount++;
       
   357         }
       
   358 
       
   359     if ( aIndex == amount )
       
   360         {
       
   361         return iBigCallIndicator->Control();
       
   362         }
       
   363 
       
   364     return NULL;
       
   365 
       
   366     }
       
   367 
       
   368 // ---------------------------------------------------------------------------
       
   369 // CBubbleOutlookFiveLined::Draw
       
   370 // 
       
   371 //  
       
   372 // ---------------------------------------------------------------------------
       
   373 //
       
   374 void CBubbleOutlookFiveLined::Draw( const TRect& /*aRect*/ ) const
       
   375     {
       
   376     CGraphicsContext& gc = SystemGc();
       
   377     
       
   378     // Check that proper call header is set
       
   379     if ( iHeader == NULL ) 
       
   380         { 
       
   381         return; 
       
   382         }
       
   383     
       
   384     if ( !iHeader->IsUsed( ) ) 
       
   385         { 
       
   386         return; 
       
   387         }
       
   388     
       
   389     TUint32 callFlag = iHeader->CallFlags( );
       
   390 	CBubbleManager::TPhoneCallState callState = iHeader->CallState( );		
       
   391     
       
   392     // Set texts to fit.
       
   393     switch (iTextLineNumber)
       
   394         {
       
   395         case 0:
       
   396             BubbleUtils::ClipToLabel( 
       
   397                 iFullText1 , iTextLine1 , iText1ClipDirection );
       
   398             BubbleUtils::AddTextToEikLabel( iTextLine2 , KNullDesC );
       
   399             break;
       
   400         case 1:
       
   401             BubbleUtils::SetTextInLabel( 
       
   402                 iFullText1 , iTextLine1 , iText1ClipDirection );
       
   403             BubbleUtils::ClipToLabel( 
       
   404                 iFullText2 , iTextLine2 , iText2ClipDirection );
       
   405             BubbleUtils::ClipToLabel( 
       
   406                 iFullText3 , iTextLine3 , iText2ClipDirection );                
       
   407             break;
       
   408         case 2:
       
   409             BubbleUtils::ClipToLabel( 
       
   410                 iFullText1 , iTextLine1 , iText1ClipDirection );
       
   411             BubbleUtils::SetTextInLabel( 
       
   412                 iFullText2 , iTextLine2 , iText2ClipDirection );
       
   413             break;
       
   414         case 3:
       
   415             BubbleUtils::ClipToLabel( 
       
   416                 iFullText1 , iTextLine1 , iText1ClipDirection );
       
   417             BubbleUtils::ClipToLabel( 
       
   418                 iFullText2 , iTextLine2 , iText2ClipDirection );
       
   419             BubbleUtils::SetTextInLabel( 
       
   420                 iFullText3 , iTextLine3 , iText3ClipDirection );                
       
   421             break;            
       
   422         default:
       
   423             BubbleUtils::AddTextToEikLabel( iTextLine1 , KNullDesC );
       
   424             BubbleUtils::AddTextToEikLabel( iTextLine2 , KNullDesC );
       
   425             BubbleUtils::AddTextToEikLabel( iTextLine3 , KNullDesC );
       
   426             break;
       
   427         }
       
   428 
       
   429     }
       
   430 
       
   431 // ---------------------------------------------------------------------------
       
   432 //CBubbleOutlookFiveLined::DrawTimerCostNow
       
   433 //
       
   434 //  
       
   435 // ---------------------------------------------------------------------------
       
   436 //
       
   437 void CBubbleOutlookFiveLined::DrawTimerCostNow()
       
   438     {
       
   439     if ( iHeader == NULL || iTimerCost == NULL ) 
       
   440         {
       
   441         return;
       
   442         }
       
   443 
       
   444     if ( iHeader->CallState() != CBubbleManager::EActive  
       
   445         || iTimerCost->Text()->Compare( iHeader->TimerCost() ) == 0 ) 
       
   446         {
       
   447         return;
       
   448         }
       
   449     
       
   450     BubbleUtils::ClipToLabel( iHeader->TimerCost() , iTimerCost , 
       
   451         CBubbleManager::ERight );
       
   452     DrawLabelNow( iTimerCost);
       
   453     }
       
   454 
       
   455 // ---------------------------------------------------------------------------
       
   456 // CBubbleOutlookFiveLined::DrawCLINow
       
   457 //
       
   458 //  
       
   459 // ---------------------------------------------------------------------------
       
   460 //
       
   461 void CBubbleOutlookFiveLined::DrawCLINow()
       
   462     {
       
   463     if ( iHeader == NULL ) 
       
   464         {
       
   465         return;
       
   466         }
       
   467     
       
   468     CEikLabel* cli = NULL;
       
   469     
       
   470     if ( iTextLineNumber == 1 )
       
   471         {
       
   472         iFullText3.Set( iHeader->CLI() );
       
   473         cli = iTextLine3;
       
   474         }
       
   475     else
       
   476         {
       
   477         iFullText1.Set( iHeader->CLI() );
       
   478         cli = iTextLine1;
       
   479         }
       
   480     
       
   481     CBubbleManager::TBubbleLabelString full = iHeader->CLI();
       
   482     CBubbleManager::TPhoneClippingDirection clipDir 
       
   483         = iHeader->CLIClipDirection();
       
   484     
       
   485     // Set texts to fit.
       
   486     if ( full.Length() > 0 )
       
   487         {
       
   488         BubbleUtils::ClipToLabel( full , cli , clipDir );
       
   489         BubbleUtils::AddTextToEikLabel( cli , full );
       
   490         }
       
   491     else
       
   492         {
       
   493         BubbleUtils::AddTextToEikLabel( cli , KNullDesC );
       
   494         }
       
   495     
       
   496     // First clear the area and then draw the new text
       
   497     DrawLabelNow( cli );
       
   498     }
       
   499 
       
   500 // ---------------------------------------------------------------------------
       
   501 // CBubbleOutlookFiveLined::DrawBitmaps
       
   502 //
       
   503 //  
       
   504 // ---------------------------------------------------------------------------
       
   505 //
       
   506 void CBubbleOutlookFiveLined::DrawBitmaps( CBitmapContext& aGc ) const
       
   507     {
       
   508     // Check that proper call header is set
       
   509     if ( iHeader == NULL ) 
       
   510         { 
       
   511         return; 
       
   512         }
       
   513     
       
   514     if ( !iHeader->IsUsed() ) 
       
   515         { 
       
   516         return; 
       
   517         }
       
   518     
       
   519     // Now starts actual drawing.
       
   520     aGc.SetBrushColor( AKN_LAF_COLOR( BubbleLayout::LayoutColourWhite() ) );
       
   521 
       
   522     if ( iBubble->Bitmap() )
       
   523         {
       
   524         BubbleUtils::DrawMaskedImage( aGc , iBubble );    
       
   525         }
       
   526     else
       
   527         {
       
   528         // Draw bubble frame
       
   529         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   530         if ( !AknsDrawUtils::DrawFrame( skin,
       
   531                                         (CWindowGc&) aGc,  
       
   532                                         iOuterRect,
       
   533                                         iInnerRect,
       
   534                                         iFrameId,
       
   535                                         KAknsIIDDefault ) )
       
   536             {
       
   537             BubbleUtils::DrawBackgroundRect( aGc, Rect() );
       
   538             }        
       
   539         }        
       
   540     }
       
   541 
       
   542 // ---------------------------------------------------------------------------
       
   543 // CBubbleOutlookFiveLined::HandleAnimationStartL
       
   544 //
       
   545 //  
       
   546 // ---------------------------------------------------------------------------
       
   547 //
       
   548 void CBubbleOutlookFiveLined::HandleAnimationStartL() const
       
   549     {
       
   550     if ( iBigCallIndicator && iBigCallIndicator->ControlType() == 
       
   551          CTelBubbleCustomElement::EBubbleAnimation )
       
   552         {
       
   553         CTelBubbleAnim* anim = 
       
   554             static_cast<CTelBubbleAnim*> ( iBigCallIndicator->Control() );
       
   555         anim->StartAnimationL();    
       
   556         }
       
   557     
       
   558     if ( iSmallCallIndication && iSmallCallIndication->ControlType() == 
       
   559          CTelBubbleCustomElement::EBubbleAnimation )
       
   560         {
       
   561         CTelBubbleAnim* anim = 
       
   562             static_cast<CTelBubbleAnim*> ( iSmallCallIndication->Control() );
       
   563         anim->StartAnimationL();    
       
   564         }
       
   565     
       
   566     if( iNumberType && iNumberType->ControlType() == 
       
   567          CTelBubbleCustomElement::EBubbleAnimation )
       
   568         {
       
   569         CTelBubbleAnim* anim = 
       
   570             static_cast<CTelBubbleAnim*> ( iNumberType->Control() );
       
   571         anim->StartAnimationL();    
       
   572         }
       
   573 
       
   574     }
       
   575 
       
   576 // ---------------------------------------------------------------------------
       
   577 //  CBubbleOutlookFiveLined::DrawCallHeaderText
       
   578 // ---------------------------------------------------------------------------
       
   579 //
       
   580 void CBubbleOutlookFiveLined::DrawCallHeaderText()
       
   581     {
       
   582     if ( iHeader == NULL || iTextLine1 == NULL ) 
       
   583         {
       
   584         return;
       
   585         }
       
   586 
       
   587     if ( iHeader->CallState() != CBubbleManager::EOutgoing )
       
   588         {
       
   589         return;
       
   590         }
       
   591     
       
   592     CEikLabel* label = NULL;
       
   593     iFullText1.Set( iHeader->Text() );
       
   594     label = iTextLine1;
       
   595 
       
   596     CBubbleManager::TPhoneClippingDirection textDir = 
       
   597         iHeader->TextClipDirection();
       
   598 
       
   599     BubbleUtils::ClipToLabel( iHeader->Text(), label, textDir );
       
   600     DrawLabelNow( label );    
       
   601     }
       
   602     
       
   603     
       
   604     
       
   605 //  End of File