phoneuis/dialer/src/cdialernumberentry.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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:  Manager for numberentry 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <eikenv.h>
       
    21 #include <eikapp.h>
       
    22 #include <gulicon.h>
       
    23 #include <w32std.h>
       
    24 #include <baclipb.h>            // CClipboard
       
    25 #include <dialer.rsg>
       
    26 #include <eikimage.h>           // CEikImage
       
    27 #include <barsread.h>           // TResourceReader
       
    28 #include <eiklabel.h> 
       
    29 #include <aknappui.h>
       
    30 #include <AknUtils.h>
       
    31 #include <AknsDrawUtils.h>
       
    32 #include <applayout.cdl.h>
       
    33 #include <AknLayoutFont.h>
       
    34 #include <AknLayout2Def.h>
       
    35 #include <AknPhoneNumberEditor.h>
       
    36 #include <AknLayout2ScalableDef.h>
       
    37 #include <AknsBasicBackgroundControlContext.h>
       
    38 #include <AknsFrameBackgroundControlContext.h>
       
    39 #include <aknlayoutscalable_apps.cdl.h>
       
    40 #include <layoutmetadata.cdl.h>
       
    41 
       
    42 #include "cdialernumberentry.h"
       
    43 #include "dialercommon.h"
       
    44 #include "dialertrace.h"
       
    45 #include "dialer.hrh"
       
    46 #include "mnumberentry.h"
       
    47 
       
    48 
       
    49 const TInt KNumberEntryControlCount = 2; //  = number entry, label
       
    50 
       
    51 // ========================= MEMBER FUNCTIONS ================================
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // NewL
       
    55 // Symbian OS two phased constructor
       
    56 // 
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CDialerNumberEntry* CDialerNumberEntry::NewL( 
       
    60     const CCoeControl& aContainer )
       
    61     {
       
    62     CDialerNumberEntry* self = 
       
    63         new( ELeave )CDialerNumberEntry( aContainer );
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop();    // self
       
    67     return self;
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // ConstructL
       
    73 // Symbian OS two phased constructor
       
    74 // 
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CDialerNumberEntry::ConstructL()
       
    78     {   
       
    79    	DIALER_PRINT("numberentry::ConstructL<");  
       
    80     BaseConstructL();
       
    81  
       
    82     // Create number entry editor    
       
    83     iEditor = new( ELeave ) CAknPhoneNumberEditor;
       
    84     iEditor->SetContainerWindowL( *this );
       
    85     iEditor->SetParent( this );
       
    86     iEditor->SetMopParent( this );
       
    87     TResourceReader reader;
       
    88     iCoeEnv->CreateResourceReaderLC( reader, R_INPUTFIELD );
       
    89     ConstructEditorFromResourceL( reader );
       
    90     
       
    91     iFrameContext = CAknsFrameBackgroundControlContext::NewL(
       
    92             KAknsIIDNone, TRect(0,0,4,4), TRect(1,1,3,3), EFalse );    
       
    93             
       
    94     iFrameContext->SetFrame( KAknsIIDQsnFrCall2Rect );      
       
    95     
       
    96     iFrameContext->SetParentContext( 
       
    97         AknsDrawUtils::ControlContextOfParent(this) );           
       
    98                 
       
    99     CleanupStack::PopAndDestroy();    // reader    
       
   100     iEditor->SetObserver( this );
       
   101     
       
   102     iLabel = new( ELeave ) CEikLabel;
       
   103     iLabel->SetContainerWindowL( *this );
       
   104     iLabel->SetParent( this );
       
   105     iLabel->SetMopParent( this ); 
       
   106     iLabel->SetTextL( KNullDesC );
       
   107     iLabel->MakeVisible( EFalse );    
       
   108     CheckLabelSkinningColor();
       
   109      
       
   110     ActivateL();
       
   111     DIALER_PRINT("numberentry::ConstructL>");
       
   112     }
       
   113 
       
   114 
       
   115 // Constructor
       
   116 CDialerNumberEntry::CDialerNumberEntry(
       
   117     const CCoeControl& aContainer )
       
   118     : CDialerContainerBase ( const_cast<CCoeControl&>(aContainer)  )
       
   119 	{
       
   120 	}
       
   121 
       
   122 
       
   123 // Destructor
       
   124 CDialerNumberEntry::~CDialerNumberEntry()
       
   125     {
       
   126     AknsUtils::DeregisterControlPosition( this );
       
   127     
       
   128     delete iEditor;
       
   129     delete iFrameContext;
       
   130     delete iLabel;
       
   131     
       
   132     }
       
   133 
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CDialerNumberEntry::SetNumberEntryObserver 
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 void CDialerNumberEntry::SetNumberEntryObserver( 
       
   140                                 MNumberEntryObserver& aObserver )
       
   141     {
       
   142     iObserver = &aObserver;
       
   143     }
       
   144         
       
   145 // ---------------------------------------------------------------------------
       
   146 // CDialerNumberEntry::SetFocus
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CDialerNumberEntry::SetFocus( TBool aFocus, 
       
   150                                             TDrawNow /*aDrawNow*/ )
       
   151     {
       
   152     DIALER_PRINT("numberentry::SetFocus<");
       
   153     
       
   154     iEditor->SetFocus( aFocus );
       
   155      
       
   156     DIALER_PRINT("numberentry::SetFocus>");    
       
   157     }
       
   158 
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CDialerNumberEntry::TextLength 
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 TInt CDialerNumberEntry::TextLength()
       
   165     {
       
   166     return iEditor->TextLength();
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CDialerNumberEntry::GetNumberEntry
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 CCoeControl* CDialerNumberEntry::GetNumberEntry( ) const
       
   174     {
       
   175     return iEditor;
       
   176     }
       
   177     
       
   178 // ---------------------------------------------------------------------------
       
   179 // CDialerNumberEntry::CreateNumberEntry
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 void CDialerNumberEntry::CreateNumberEntry()
       
   183     {
       
   184     iEditor->SetFocus( ETrue );
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CDialerNumberEntry::ChangeEditorMode
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TInt CDialerNumberEntry::ChangeEditorMode( TBool aDefaultMode )
       
   192     {
       
   193     return iEditor->ChangeEditorMode( aDefaultMode );
       
   194     }
       
   195     
       
   196 // ---------------------------------------------------------------------------
       
   197 // CDialerNumberEntry::GetEditorMode  
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 TInt CDialerNumberEntry::GetEditorMode() const
       
   201     {
       
   202     return iEditor->GetEditorMode();
       
   203     }
       
   204     
       
   205 // ---------------------------------------------------------------------------
       
   206 // CDialerNumberEntry::SetTextToNumberEntry
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 void CDialerNumberEntry::SetTextToNumberEntry( const TDesC& aDesC )
       
   210     {
       
   211     DIALER_PRINT("numberentry::SetTextToNumberEntry<");
       
   212         	
       
   213     iEditor->SetText( aDesC );   
       
   214     iEditor->DrawNow();
       
   215     
       
   216     DIALER_PRINT("numberentry::SetTextToNumberEntry>");
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CDialerNumberEntry::GetTextFromNumberEntry
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 void CDialerNumberEntry::GetTextFromNumberEntry( TDes& aDesC )
       
   224     {
       
   225     iEditor->GetText( aDesC );
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // CDialerNumberEntry::ResetEditorToDefaultValues
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 void CDialerNumberEntry::ResetEditorToDefaultValues()
       
   233     {
       
   234     iEditor->SetFocus( EFalse );
       
   235     SetTextToNumberEntry( KNullDesC );
       
   236     iEditor->ResetEditorToDefaultValues();
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // CDialerNumberEntry::SetNumberEntryPromptTextL
       
   241 //  
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 void CDialerNumberEntry::SetNumberEntryPromptTextL( const TDesC& aPromptText )
       
   245     {
       
   246     if ( aPromptText.Length() )
       
   247         {
       
   248         iLabel->MakeVisible( ETrue );
       
   249         }
       
   250     else
       
   251         {
       
   252         iLabel->MakeVisible( EFalse );
       
   253         }
       
   254     
       
   255     iLabel->SetTextL( aPromptText );   
       
   256     }
       
   257 
       
   258 // ----------------------------------------------------------------------------
       
   259 // CDialerNumberEntry::HandleCommandL
       
   260 // Handles NE specific commands.
       
   261 // ----------------------------------------------------------------------------
       
   262 //
       
   263 TBool CDialerNumberEntry::HandleCommandL( TDialerCommandId aCommand)
       
   264     {
       
   265     DIALER_PRINTF("numberentry::HandleCommandL<:", aCommand); 
       
   266     	
       
   267     TBool handled( ETrue );
       
   268     switch ( aCommand )
       
   269         {
       
   270         case EDialerCmdTouchInput:  // open touch input (VKB)
       
   271             {
       
   272             StartVirtualKeyBoard();
       
   273             }
       
   274             break;
       
   275         default:
       
   276             {
       
   277             handled = EFalse;
       
   278             }
       
   279             break;
       
   280         }
       
   281         
       
   282     DIALER_PRINT("numberentry::HandleCommandL>");         
       
   283     return handled;
       
   284     }
       
   285 
       
   286 // ---------------------------------------------------------------------------
       
   287 // CDialerNumberEntry::ClearEditorFlags
       
   288 // ---------------------------------------------------------------------------
       
   289 //
       
   290 void CDialerNumberEntry::ClearEditorFlags()
       
   291     {
       
   292     iEditor->ResetEditorToDefaultValues();
       
   293     }
       
   294 
       
   295 // ---------------------------------------------------------------------------
       
   296 //  CDialerNumberEntry::HandleControlEventL
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 void CDialerNumberEntry::HandleControlEventL( CCoeControl* aControl, 
       
   300                                               TCoeEvent aEventType )
       
   301     {
       
   302     DIALER_PRINT("numberentry::HandleControlEventL<"); 
       
   303     
       
   304     TInt format( KDialerNELayoutLargeFont );
       
   305     if ( aControl == iEditor && aEventType == EEventStateChanged )
       
   306         {
       
   307         HandleEditorFormatting();
       
   308         InformNumberEntryState();        
       
   309         iEditor->DrawDeferred();
       
   310         
       
   311         }
       
   312         
       
   313     DIALER_PRINT("numberentry::HandleControlEventL>");                
       
   314     }
       
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 // CDialerNumberEntry::OfferKeyEventL
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 TKeyResponse CDialerNumberEntry::OfferKeyEventL( 
       
   321                                             const TKeyEvent& aKeyEvent, 
       
   322                                             TEventCode aType )
       
   323     {   
       
   324     return iEditor->OfferKeyEventL( aKeyEvent, aType );
       
   325     }
       
   326     
       
   327 // ---------------------------------------------------------------------------
       
   328 // CDialerNumberEntry::CountComponentControls 
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 TInt CDialerNumberEntry::CountComponentControls() const
       
   332     {
       
   333     return KNumberEntryControlCount;
       
   334     }
       
   335 
       
   336 // ---------------------------------------------------------------------------
       
   337 // CDialerNumberEntry::ComponentControl
       
   338 // ---------------------------------------------------------------------------
       
   339 //
       
   340 CCoeControl* CDialerNumberEntry::ComponentControl( TInt aIndex ) const
       
   341     {
       
   342     __ASSERT_DEBUG( aIndex < KNumberEntryControlCount, 
       
   343                              User::Panic(_L("Dialer"), KErrArgument) );
       
   344     
       
   345     if ( aIndex == 0 )
       
   346         {
       
   347         return iEditor;
       
   348         }
       
   349     else if ( aIndex == 1 )
       
   350         {
       
   351         return iLabel;
       
   352         }
       
   353     return NULL;
       
   354     }
       
   355 
       
   356 // ---------------------------------------------------------------------------
       
   357 // CDialerNumberEntry::Draw
       
   358 // ---------------------------------------------------------------------------
       
   359 //
       
   360 void CDialerNumberEntry::Draw( const TRect& /*aRect*/ ) const
       
   361     {
       
   362     CWindowGc& gc = SystemGc( );
       
   363     gc.SetBrushColor( AKN_LAF_COLOR( 0 /** White - get from layout */ ));
       
   364     TRect rect = Rect();
       
   365     
       
   366     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   367     
       
   368     // Draw the skin background of the parent 
       
   369     if ( !AknsDrawUtils::DrawFrame( skin,
       
   370                              (CWindowGc&) gc,  
       
   371                              iOuterRect,
       
   372                              iInnerRect,
       
   373                              KAknsIIDQsnFrCall2Rect,
       
   374                              KAknsIIDDefault ))
       
   375         {
       
   376         DIALER_PRINT("numberentry::Draw.Frame.failed"); 
       
   377         }
       
   378                             
       
   379     gc.SetBrushStyle( CGraphicsContext::ENullBrush );        
       
   380     }
       
   381 
       
   382 
       
   383 // ---------------------------------------------------------------------------
       
   384 // CDialerNumberEntry::SetVariety
       
   385 // Set variety according to status
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 void CDialerNumberEntry::SetVariety()
       
   389     {
       
   390     }
       
   391 
       
   392 // ---------------------------------------------------------------------------
       
   393 // CDialerNumberEntry::SetLayout
       
   394 // ---------------------------------------------------------------------------
       
   395 //
       
   396 void CDialerNumberEntry::SetLayout()
       
   397     {
       
   398     AknsUtils::RegisterControlPosition( this );
       
   399 
       
   400     TDialerVariety variety( EDialerVarietyLandscape );
       
   401     if (  !Layout_Meta_Data::IsLandscapeOrientation() )
       
   402         {
       
   403         variety = EDialerVarietyPortrait;
       
   404         }      
       
   405         
       
   406     TRect parentRect( Rect() );
       
   407     TAknTextComponentLayout neLayout = 
       
   408                         AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety ); 
       
   409 
       
   410     AknLayoutUtils::LayoutControl(
       
   411         iEditor, parentRect, 
       
   412         neLayout.C(),
       
   413         neLayout.l(),
       
   414         neLayout.t(),
       
   415         neLayout.r(),
       
   416         neLayout.b(),
       
   417         neLayout.W(),
       
   418         neLayout.H()
       
   419         );
       
   420 
       
   421     UpdateNumberEntryFormats(); 
       
   422       
       
   423     RectFrameInnerOuterRects(
       
   424            Rect(),
       
   425            iOuterRect,
       
   426            iInnerRect );
       
   427 
       
   428     iFrameContext->SetFrameRects( iOuterRect, iInnerRect );
       
   429                 
       
   430     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   431     AknsDrawUtils::PrepareFrame( skin,
       
   432                                  iOuterRect,
       
   433                                  iInnerRect,
       
   434                                  KAknsIIDQsnFrCall2Rect,
       
   435                                  KAknsIIDDefault ); 
       
   436     // Label layout
       
   437 
       
   438     // Portrait variety is temporarily used also in landscape.
       
   439     // Landscape layout data is now unavailable. 
       
   440     TAknTextComponentLayout labelLayout = 
       
   441                         AknLayoutScalable_Apps::dialer2_ne_pane_t2( 
       
   442                                                     EDialerVarietyPortrait );
       
   443     // Temporary solution 
       
   444     labelLayout.Setl(neLayout.l());
       
   445     AknLayoutUtils::LayoutLabel( iLabel, parentRect, labelLayout );
       
   446     
       
   447     HandleEditorFormatting();
       
   448     iEditor->DrawDeferred();
       
   449     
       
   450     }
       
   451 
       
   452 // ---------------------------------------------------------------------------
       
   453 // CDialerNumberEntry::ConstructEditorFromResourceL 
       
   454 // ---------------------------------------------------------------------------
       
   455 //
       
   456 void CDialerNumberEntry::ConstructEditorFromResourceL( 
       
   457                                 TResourceReader& aReader )
       
   458     {
       
   459     TInt maxChars = aReader.ReadInt16();
       
   460     TInt maxLines = aReader.ReadInt16();
       
   461     HBufC* truncation = aReader.ReadHBufCL();
       
   462     CleanupStack::PushL( truncation );
       
   463     TInt formatCount = aReader.ReadInt16();
       
   464     iEditor->ConstructL( maxChars, maxLines, formatCount, *truncation );  
       
   465     CleanupStack::PopAndDestroy( truncation );       
       
   466     iFormatCount = formatCount;
       
   467 
       
   468     for ( TInt ii = 0; ii < iFormatCount; ii++ )
       
   469         {
       
   470         CAknPhoneNumberEditor::TFormat format( aReader );
       
   471 	    CalculateLayout( format, ii );
       
   472         iEditor->AddFormat( format );
       
   473         }
       
   474 
       
   475     iEditor->SetFormat( KDialerNELayoutLargeFont );
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------------------------
       
   479 // CDialerNumberEntry::UpdateNumberEntryFormats
       
   480 // ---------------------------------------------------------------------------
       
   481 //
       
   482 void CDialerNumberEntry::UpdateNumberEntryFormats( )
       
   483     {
       
   484     DIALER_PRINT("numberentry::UpdateNumberEntryFormats<");
       
   485     TInt currentFormat = iEditor->CurrentFormatIndex();
       
   486 
       
   487     for ( TInt ii = 0; ii < iFormatCount; ii++ )
       
   488         {
       
   489         CAknPhoneNumberEditor::TFormat format( iEditor->Format( ii ) );
       
   490 		CalculateLayout( format, ii );
       
   491         iEditor->Format( ii ) = format;
       
   492         }
       
   493 
       
   494     iEditor->SetFormat( currentFormat );
       
   495     DIALER_PRINT("numberentry::UpdateNumberEntryFormats>");
       
   496     }
       
   497     
       
   498 // ---------------------------------------------------------------------------
       
   499 // CDialerNumberEntry::CalculateLayout
       
   500 // ---------------------------------------------------------------------------
       
   501 //
       
   502 void CDialerNumberEntry::CalculateLayout( 
       
   503         CAknPhoneNumberEditor::TFormat& aFormat, TInt aNEVariety )
       
   504     {
       
   505     TAknLayoutText textsLargeFontLine1Text;
       
   506     TAknLayoutText textsLargeFontLine2Text;
       
   507     TAknLayoutText textsLargeFontLine3Text;
       
   508     
       
   509     TAknLayoutText textsSmallFontLine1Text;
       
   510     TAknLayoutText textsSmallFontLine2Text;
       
   511     TAknLayoutText textsSmallFontLine3Text;    		
       
   512       
       
   513     const CAknLayoutFont* layoutFont;
       
   514 	
       
   515 	switch ( aNEVariety )
       
   516 		{
       
   517 		case KDialerNELayoutLargeFont:
       
   518 			{
       
   519 			TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 0;
       
   520 			
       
   521             TAknLayoutScalableParameterLimits limits = 
       
   522                 AknLayoutScalable_Apps::dialer2_ne_pane_t1_ParamLimits( 
       
   523                                                          variety );                
       
   524             //Line 1
       
   525             textsLargeFontLine1Text.LayoutText( Rect(), 
       
   526                  AknLayoutScalable_Apps::dialer2_ne_pane_t1( 
       
   527                                                          variety, 0, 0 ) );  
       
   528             //Line 2     
       
   529             textsLargeFontLine2Text.LayoutText( Rect(), 
       
   530                  AknLayoutScalable_Apps::dialer2_ne_pane_t1( 
       
   531                                                          variety, 
       
   532                                                          0, 
       
   533                                                          1 ) );
       
   534             //Last row
       
   535             textsLargeFontLine3Text.LayoutText( Rect(), 
       
   536                 AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety,
       
   537                                                             0, 
       
   538                                                             limits.LastRow() ) );
       
   539 
       
   540             //Need to add one row because zero is the first line                
       
   541             aFormat.iNumLines =  limits.LastRow()+1;
       
   542                             	
       
   543         	//take font from line 1    
       
   544             aFormat.iFont = textsLargeFontLine1Text.Font();
       
   545             layoutFont = CAknLayoutFont::AsCAknLayoutFontOrNull( aFormat.iFont);
       
   546             aFormat.iBottomBaselineOffset = 
       
   547                                          layoutFont->BaselineToTextPaneBottom();
       
   548             //outer rect from last line
       
   549             aFormat.iOuterRect = textsLargeFontLine3Text.TextRect();
       
   550             // have to add extra gap
       
   551             aFormat.iOuterRect.iTl.iY -= aFormat.iBottomBaselineOffset; 
       
   552          
       
   553             //calculate baselineSeparation from the difference of the second 
       
   554             //line and the first line bottom right Y coordinates            
       
   555             TInt baselineSeparation = textsLargeFontLine2Text.TextRect().iBr.iY 
       
   556                 - textsLargeFontLine1Text.TextRect().iBr.iY;
       
   557             
       
   558             aFormat.iOuterRect.iTl.iY -= ( (aFormat.iNumLines - 1) 
       
   559                                             * baselineSeparation );
       
   560             aFormat.iBaselineSeparation = baselineSeparation;  									
       
   561 			}
       
   562 			break;
       
   563 		case KDialerNELayoutSmallFont:
       
   564 			{
       
   565 			TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 3 : 1;
       
   566 			
       
   567             TAknLayoutScalableParameterLimits limits = 
       
   568                 AknLayoutScalable_Apps::dialer2_ne_pane_t1_ParamLimits( 
       
   569                                                                 variety );                   
       
   570             //Line 1
       
   571             textsSmallFontLine1Text.LayoutText( Rect(), 
       
   572                  AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety,0,0 ) );  
       
   573             //Line 2     
       
   574             textsSmallFontLine2Text.LayoutText( Rect(), 
       
   575                  AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety,0,1 ) );
       
   576             //Last row
       
   577             textsSmallFontLine3Text.LayoutText( Rect(), 
       
   578                  AknLayoutScalable_Apps::dialer2_ne_pane_t1( 
       
   579                                                          variety,
       
   580                                                          0, 
       
   581                                                          limits.LastRow() ) ); 
       
   582             
       
   583             //Need to add one row because zero is the first line
       
   584             aFormat.iNumLines =  limits.LastRow()+1;
       
   585                                                                    
       
   586         	 //take font from line 1     
       
   587             aFormat.iFont = textsSmallFontLine1Text.Font();
       
   588             layoutFont = CAknLayoutFont::AsCAknLayoutFontOrNull( 
       
   589                                                            aFormat.iFont);
       
   590             aFormat.iBottomBaselineOffset = 
       
   591                                         layoutFont->BaselineToTextPaneBottom();
       
   592             //outer rect from line 3
       
   593             aFormat.iOuterRect = textsSmallFontLine3Text.TextRect();
       
   594             // have to add extra gap
       
   595             aFormat.iOuterRect.iTl.iY -= aFormat.iBottomBaselineOffset; 
       
   596             
       
   597             //calculate baselineSeparation from the difference of the second 
       
   598             //line and the first line bottom right Y coordinates
       
   599             TInt baselineSeparation = textsSmallFontLine2Text.TextRect().iBr.iY 
       
   600                 - textsSmallFontLine1Text.TextRect().iBr.iY;
       
   601             
       
   602             aFormat.iOuterRect.iTl.iY -= ( (aFormat.iNumLines - 1) 
       
   603                                             * baselineSeparation );
       
   604             aFormat.iBaselineSeparation = baselineSeparation; 					
       
   605 			} 
       
   606 			break;
       
   607 	 	default:
       
   608 	 		break;
       
   609 		} 				
       
   610 	}
       
   611 
       
   612 // ---------------------------------------------------------------------------
       
   613 // CDialerNumberEntry::HandleResourceChange  
       
   614 // ---------------------------------------------------------------------------
       
   615 //
       
   616 void CDialerNumberEntry::HandleResourceChange( TInt aType )
       
   617     {
       
   618     CCoeControl::HandleResourceChange( aType );
       
   619     
       
   620     if ( aType == KAknsMessageSkinChange )
       
   621         {
       
   622         CheckLabelSkinningColor(); 
       
   623         }
       
   624     }
       
   625 // ---------------------------------------------------------------------------
       
   626 // CDialerNumberEntry::HandleEditorFormatting  
       
   627 // ---------------------------------------------------------------------------
       
   628 //
       
   629 void CDialerNumberEntry::HandleEditorFormatting()
       
   630     {
       
   631     TInt format( KDialerNELayoutLargeFont );
       
   632   
       
   633     if ( !iEditor->WouldTextFitInFormat( KDialerNELayoutLargeFont )  )
       
   634         {
       
   635         format = KDialerNELayoutSmallFont;
       
   636         }
       
   637    
       
   638     if ( iEditor->CurrentFormatIndex() != format )
       
   639         {
       
   640         iEditor->DrawDeferred();
       
   641         iEditor->SetFormat( format );              
       
   642         iFrameContext->SetRect( Rect() );                
       
   643         }
       
   644     
       
   645     }
       
   646 
       
   647 // ---------------------------------------------------------------------------
       
   648 // CDialerNumberEntry::StartVirtualKeyBoard 
       
   649 // ---------------------------------------------------------------------------
       
   650 //
       
   651 void CDialerNumberEntry::StartVirtualKeyBoard( )
       
   652     {
       
   653     // To change focus to VKB, if not called VKB will not come visible
       
   654     CEikonEnv::Static()->SyncNotifyFocusObserversOfChangeInFocus();
       
   655     iEditor->OpenVKB();
       
   656     }
       
   657   
       
   658 // ---------------------------------------------------------------------------
       
   659 // CDialerNumberEntry::MopSupplyObject
       
   660 // ---------------------------------------------------------------------------
       
   661 //
       
   662 TTypeUid::Ptr CDialerNumberEntry::MopSupplyObject( TTypeUid aId )  
       
   663     {
       
   664     if ( aId.iUid == MAknsControlContext::ETypeId && iFrameContext )
       
   665         {
       
   666         return MAknsControlContext::SupplyMopObject( aId, iFrameContext );
       
   667         }
       
   668     else
       
   669         {
       
   670         return CCoeControl::MopSupplyObject( aId );
       
   671         } 
       
   672     }    
       
   673     
       
   674 // -----------------------------------------------------------------------------
       
   675 // CDialerNumberEntry::RectFrameInnerOuterRects
       
   676 // -----------------------------------------------------------------------------
       
   677 //
       
   678 void CDialerNumberEntry::RectFrameInnerOuterRects( const TRect& aFrameRect,
       
   679                                               TRect& aOuterRect,
       
   680                                               TRect& aInnerRect )
       
   681     {
       
   682     if ( Layout_Meta_Data::IsMirrored() )
       
   683         {
       
   684         TAknLayoutRect frameTopRight;        
       
   685         frameTopRight.LayoutRect( 
       
   686          aFrameRect, 
       
   687          AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g3().LayoutLine() );                
       
   688                 
       
   689         TAknLayoutRect frameBottomLeft;        
       
   690         frameBottomLeft.LayoutRect( 
       
   691          aFrameRect, 
       
   692          AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g4().LayoutLine() );                        
       
   693 
       
   694         aOuterRect = TRect( frameTopRight.Rect().iTl, 
       
   695                             frameBottomLeft.Rect().iBr );
       
   696                 
       
   697         aInnerRect = TRect( frameTopRight.Rect().iBr, 
       
   698                             frameBottomLeft.Rect().iTl );    
       
   699         }
       
   700     else
       
   701         {
       
   702         TAknLayoutRect frameTopLeft;        
       
   703         frameTopLeft.LayoutRect( 
       
   704          aFrameRect, 
       
   705          AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g2().LayoutLine() );
       
   706 
       
   707         TAknLayoutRect frameBottomRight;        
       
   708         frameBottomRight.LayoutRect( 
       
   709          aFrameRect, 
       
   710          AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g5().LayoutLine() );
       
   711         
       
   712         aOuterRect = TRect( frameTopLeft.Rect().iTl, 
       
   713                             frameBottomRight.Rect().iBr );
       
   714         aInnerRect = TRect( frameTopLeft.Rect().iBr, 
       
   715                             frameBottomRight.Rect().iTl );    
       
   716         }                    
       
   717     }    
       
   718     
       
   719 // -----------------------------------------------------------------------------
       
   720 // CDialerNumberEntry::InformNumberEntryState()
       
   721 // -----------------------------------------------------------------------------
       
   722 //
       
   723 void CDialerNumberEntry::InformNumberEntryState()
       
   724     {
       
   725     if ( !iNumberContents && iEditor->TextLength() )
       
   726         {
       
   727         // Hide prompt text
       
   728         if ( iLabel->Text()->Length() )
       
   729             {
       
   730             iLabel->MakeVisible( EFalse );     
       
   731             }         
       
   732         iNumberContents = ETrue;
       
   733         }
       
   734     else if ( iNumberContents && !iEditor->TextLength() )
       
   735         {  
       
   736         // Show prompt text
       
   737         if ( iLabel->Text()->Length() )
       
   738             {
       
   739             iLabel->MakeVisible( ETrue );     
       
   740             } 
       
   741         iNumberContents = EFalse;
       
   742         } 
       
   743 
       
   744     if( iObserver )
       
   745         {
       
   746         iObserver->NumberEntryStateChanged( iNumberContents );
       
   747         }
       
   748     
       
   749     }
       
   750     
       
   751 // -----------------------------------------------------------------------------
       
   752 // CDialerNumberEntry::CheckLabelSkinningColor()
       
   753 // -----------------------------------------------------------------------------
       
   754 //
       
   755 void CDialerNumberEntry::CheckLabelSkinningColor()
       
   756     {
       
   757     // Check skinning colour for the prompt text:
       
   758     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   759     TRgb skinColor;
       
   760     TInt error = 
       
   761         AknsUtils::GetCachedColor( 
       
   762             skin, 
       
   763             skinColor, 
       
   764             KAknsIIDQsnTextColors,
       
   765             EAknsCIQsnTextColorsCG51 );
       
   766             
       
   767     if ( error == KErrNone )
       
   768         {
       
   769         // Ignore error
       
   770         TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, skinColor ) );
       
   771         }   
       
   772     }
       
   773     
       
   774 // End of File