phoneuis/BubbleManager/Src/BMBubbleOutlookBottomText.cpp
changeset 0 5f000ab63145
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    "BMBubbleManager.h" //for enumerations
       
    21 #include    "BMBubbleOutlookBottomText.h"
       
    22 #include    "BMBubbleImageManager.h"
       
    23 #include    "BMResourceManager.h"
       
    24 #include    "BMBubbleHeader.h"
       
    25 #include    "BMUtils.h"
       
    26 #include    "BMLayout.h"
       
    27 #include    "BMLayout2.h"
       
    28 #include    "telbubblecustomelement.h"
       
    29 
       
    30 #include    <eiklabel.h> 
       
    31 #include    <eikimage.h>
       
    32 #include    <eikenv.h>
       
    33 #include    <AknsUtils.h>
       
    34 #include    <AknUtils.h>
       
    35 #include    <AknBidiTextUtils.h>
       
    36 #include    <AknsDrawUtils.h>
       
    37 
       
    38 // ========================= MEMBER FUNCTIONS ================================
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CBubbleOutlookBottomText::CBubbleOutlookBottomText
       
    42 //
       
    43 //  
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CBubbleOutlookBottomText::CBubbleOutlookBottomText( 
       
    47     CBubbleManager& aBubbleManager ) : CBubbleOutlookFiveLined( aBubbleManager )
       
    48     {
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CBubbleOutlookBottomText::ConstructL
       
    53 // 
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 void CBubbleOutlookBottomText::ConstructL()
       
    57     { 
       
    58     CBubbleOutlookFiveLined::ConstructL();
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CBubbleOutlookBottomText::~CBubbleOutlookBottomText
       
    63 //
       
    64 //  
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CBubbleOutlookBottomText::~CBubbleOutlookBottomText()
       
    68     {
       
    69     Reset();
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CBubbleOutlookBottomText::ReadBubbleHeader
       
    74 //
       
    75 //  
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CBubbleOutlookBottomText::ReadBubbleHeader( CBubbleHeader& aHeader )
       
    79     {
       
    80     iHeader = &aHeader;
       
    81     
       
    82     iBubble = iBubbleManager.ResourceManager().ReserveEikImage( ETrue );        
       
    83     
       
    84     iThreeLinedLayout = ( iHeader->CNAP().Length() > 0 );
       
    85     
       
    86     CBubbleOutlookFiveLined::ReadBubbleHeader( aHeader );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CBubbleOutlookBottomText::SizeChanged
       
    91 // called by framework when the view size is changed
       
    92 //  
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CBubbleOutlookBottomText::SizeChanged()
       
    96     {
       
    97     if( !iHeader )
       
    98         {
       
    99         return;
       
   100         }
       
   101 
       
   102     AknsUtils::RegisterControlPosition( this );
       
   103     
       
   104     TRAPD( err, DoCall2LayoutL() );
       
   105     if ( err )    
       
   106         {
       
   107         iBubble->SetPicture( NULL, NULL );
       
   108                 
       
   109         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   110         AknsDrawUtils::PrepareFrame( skin,
       
   111                                      iOuterRect,
       
   112                                      iInnerRect,
       
   113                                      iFrameId,
       
   114                                      KAknsIIDDefault );    
       
   115         }        
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CBubbleOutlookBottomText::PositionChanged
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CBubbleOutlookBottomText::PositionChanged()
       
   123     {
       
   124     AknsUtils::RegisterControlPosition( this );
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // CBubbleOutlookBottomText::DoCall2Layout
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CBubbleOutlookBottomText::DoCall2LayoutL()
       
   132     {
       
   133     iBubble->SetPictureOwnedExternally( EFalse );
       
   134     iBubble->SetPicture( NULL, NULL );
       
   135     
       
   136     const TRect rect = Rect();
       
   137     CBubbleManager::TPhoneCallState callState = iHeader->CallState();
       
   138     switch ( callState )
       
   139         {
       
   140         case CBubbleManager::EIncoming:
       
   141         case CBubbleManager::EOutgoing:
       
   142         case CBubbleManager::EAlerting:
       
   143         case CBubbleManager::EAlertToDisconnected:
       
   144             {
       
   145             ///////////////////////////////////////////////////////////////////
       
   146             // Incoming call layout for single call. Call object text.
       
   147             ///////////////////////////////////////////////////////////////////
       
   148             
       
   149             TInt variety = iThreeLinedLayout ? 4 : 3;
       
   150             
       
   151             TAknLayoutRect bubbleRect;
       
   152             bubbleRect.LayoutRect( 
       
   153                 rect, 
       
   154                 BubbleLayout2::popup_call2_audio_in_background( variety ) );
       
   155             
       
   156             TRect frameRect( TPoint(0,0), bubbleRect.Rect().Size() );
       
   157             TRect outerRect;
       
   158             TRect innerRect;
       
   159             BubbleLayout2::RectFrameInnerOuterRects( frameRect, 
       
   160                                                      outerRect, 
       
   161                                                      innerRect);
       
   162             
       
   163             iFrameId = ( callState == 
       
   164                          CBubbleManager::EAlertToDisconnected ) ?
       
   165                          KAknsIIDQsnFrCall2RectDisconn : 
       
   166                          KAknsIIDQsnFrCall2Rect;
       
   167             
       
   168             iOuterRect = outerRect;
       
   169             iOuterRect.Move( Rect().iTl );
       
   170             iInnerRect = innerRect;
       
   171             iInnerRect.Move( Rect().iTl );                
       
   172             
       
   173             
       
   174             // Call indicator
       
   175             BubbleUtils::LayoutCustomElement(
       
   176                 iBigCallIndicator, 
       
   177                 rect, 
       
   178                 BubbleLayout2::popup_call2_audio_out_call_waiting_icon(1) );
       
   179                 
       
   180             BubbleUtils::LayoutControl( 
       
   181                 iCyphOffImage, 
       
   182                 rect,
       
   183                 BubbleLayout2::popup_call2_audio_in_ciphering_icon(variety) );                                
       
   184             
       
   185             BubbleUtils::LayoutCustomElement(
       
   186                 iNumberType, 
       
   187                 rect, 
       
   188                 BubbleLayout2::popup_call2_audio_in_call_number_type_icon(variety) );
       
   189 
       
   190             BubbleUtils::LayoutLabel( 
       
   191                 iTextLine1, 
       
   192                 rect, 
       
   193                 BubbleLayout2::popup_call2_audio_in_call_text_1(variety));
       
   194 
       
   195             BubbleUtils::LayoutLabel( 
       
   196                 iTextLine2, 
       
   197                 rect, 
       
   198                 BubbleLayout2::popup_call2_audio_in_call_text_2(variety));
       
   199             
       
   200             
       
   201             if ( iThreeLinedLayout )
       
   202                 {
       
   203                 // Textual cli 1
       
   204                 BubbleUtils::LayoutLabel( 
       
   205                     iTextLine3, 
       
   206                     rect, 
       
   207                     BubbleLayout2::popup_call2_audio_in_call_text_3(2));
       
   208             
       
   209                 // Textual cli 2
       
   210                 BubbleUtils::LayoutLabel( 
       
   211                     iTextLine4, 
       
   212                     rect, 
       
   213                     BubbleLayout2::popup_call2_audio_in_cli_textual_2(1));
       
   214 
       
   215                 // Textual cli 3
       
   216                 BubbleUtils::LayoutLabel( 
       
   217                     iTextLine5, 
       
   218                     rect, 
       
   219                     BubbleLayout2::popup_call2_audio_in_cli_textual_3(1));
       
   220                 
       
   221             
       
   222                 CEikLabel* labels[] = { iTextLine4, iTextLine5 };
       
   223                 SetCallObjectTextToLabelsL( iHeader->CallObjectText(),
       
   224                                             2, labels );                    
       
   225                 }
       
   226             else
       
   227                 {
       
   228                 // Textual cli 1
       
   229                 BubbleUtils::LayoutLabel( 
       
   230                     iTextLine3, 
       
   231                     rect, 
       
   232                     BubbleLayout2::popup_call2_audio_in_cli_textual_1(0));
       
   233             
       
   234                 // Textual cli 2
       
   235                 BubbleUtils::LayoutLabel( 
       
   236                     iTextLine4, 
       
   237                     rect, 
       
   238                     BubbleLayout2::popup_call2_audio_in_cli_textual_2(0));
       
   239 
       
   240                 // Textual cli 3
       
   241                 BubbleUtils::LayoutLabel( 
       
   242                     iTextLine5, 
       
   243                     rect, 
       
   244                     BubbleLayout2::popup_call2_audio_in_cli_textual_3(0));
       
   245                 
       
   246             
       
   247                 CEikLabel* labels[] = { iTextLine3, iTextLine4, iTextLine5 };
       
   248                 SetCallObjectTextToLabelsL( iHeader->CallObjectText(),
       
   249                                             3, labels );                
       
   250                 }
       
   251             
       
   252             // Create call object bitmaps
       
   253             iBubble->SetRect( bubbleRect.Rect() );                
       
   254             
       
   255             BubbleUtils::PrepareBubbleImageL( 
       
   256                 iFrameId,
       
   257                 outerRect,
       
   258                 innerRect,
       
   259                 iBubble );
       
   260             
       
   261             break;
       
   262             }
       
   263         default:
       
   264             break;
       
   265         }
       
   266     }
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CBubbleOutlookBottomText::SetCliTextToLabelsL
       
   270 // ---------------------------------------------------------------------------
       
   271 //    
       
   272 void CBubbleOutlookBottomText::SetCallObjectTextToLabelsL(
       
   273     const TDesC& aText,
       
   274     TInt aLabelCount,
       
   275     CEikLabel* aLabels[] )
       
   276     {
       
   277     if ( aLabelCount == 0 )
       
   278         {
       
   279         return;    
       
   280         }
       
   281     
       
   282     CEikLabel* label1 = aLabels[0];
       
   283     if ( !label1 )
       
   284         {
       
   285         return;            
       
   286         }
       
   287         
       
   288     CArrayFix<TPtrC>* wrappedText = 
       
   289         new(ELeave) CArrayFixFlat<TPtrC>(aLabelCount);
       
   290     CleanupStack::PushL( wrappedText );
       
   291     
       
   292     CArrayFix<TInt>* lineWidths = 
       
   293         new(ELeave) CArrayFixFlat<TInt>(aLabelCount);
       
   294     CleanupStack::PushL( lineWidths );
       
   295     
       
   296     for ( TInt index(0); index < aLabelCount; index++ )
       
   297         {
       
   298         CEikLabel* label = aLabels[index];
       
   299         if ( label )         
       
   300             {
       
   301             lineWidths->InsertL( index, label->Size().iWidth );
       
   302             }
       
   303         }
       
   304     
       
   305     HBufC* buffer = HBufC::NewL( aText.Length() + 
       
   306         ( KAknBidiExtraSpacePerLine * aLabelCount ) );
       
   307     CleanupStack::PushL( buffer );
       
   308     *buffer = aText;
       
   309     TPtr text( buffer->Des() );
       
   310     
       
   311     AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( 
       
   312         text,
       
   313         *lineWidths,
       
   314         *label1->Font(),
       
   315         *wrappedText,
       
   316         ETrue );
       
   317     
       
   318     // set wrapped text to labels
       
   319     TInt lineCount = wrappedText->Count();
       
   320     for ( TInt index(0); index < aLabelCount && index < lineCount ; index++ )
       
   321         {
       
   322         CEikLabel* label = aLabels[index];
       
   323         TPtrC& line = wrappedText->At(index);
       
   324          
       
   325         if ( line.Length() && label )         
       
   326             {
       
   327             label->SetTextL( line );    
       
   328             }
       
   329         }
       
   330 
       
   331     CleanupStack::PopAndDestroy( buffer );
       
   332     CleanupStack::PopAndDestroy( lineWidths );
       
   333     CleanupStack::PopAndDestroy( wrappedText );
       
   334     }
       
   335 
       
   336 // End of File