emailuis/emailui/src/ncsaddressinputfield.cpp
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     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:  compose view container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "emailtrace.h"
       
    22 #include <AknIconUtils.h>
       
    23 #include <avkon.hrh>
       
    24 #include <aknlists.h>
       
    25 #include <aknPopup.h>
       
    26 #include <aknbutton.h>
       
    27 #include <StringLoader.h>
       
    28 #include <eiklabel.h>
       
    29 #include <eikimage.h>
       
    30 #include <eikenv.h>
       
    31 #include <AknsDrawUtils.h>
       
    32 #include <sysutil.h>
       
    33 #include <AknUtils.h>
       
    34 #include <FreestyleEmailUi.rsg>
       
    35 #include <aknphysics.h>
       
    36 #include <centralrepository.h>
       
    37 
       
    38 #include "FreestyleEmailUiAppui.h"
       
    39 #include "FreestyleEmailUiLayoutData.h"
       
    40 #include "FreestyleEmailUiLayoutHandler.h"
       
    41 #include "ncsaddressinputfield.h"
       
    42 #include "ncsconstants.h"
       
    43 #include "ncsaifeditor.h"
       
    44 #include "ncsfieldsizeobserver.h"
       
    45 #include "ncsutility.h"
       
    46 #include "ncsheadercontainer.h"
       
    47 #include "txtrich.h"
       
    48 #include "freestyleemailcenrepkeys.h"
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CNcsAddressInputField::CNcsAddressInputField(
       
    55 	TNcsInputFieldType aFieldType,
       
    56 	MNcsFieldSizeObserver* aSizeObserver,
       
    57 	MNcsAddressPopupList* aAddressPopupList,
       
    58 	CNcsHeaderContainer* aParentControl ):
       
    59 	MNcsControl( aSizeObserver ),
       
    60 	iParentControl( aParentControl ),
       
    61 	iAddressPopupList( aAddressPopupList ),
       
    62 	iFieldType( aFieldType )
       
    63     {
       
    64     FUNC_LOG;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CNcsAddressInputField::NewL()
       
    69 // Two-phased constructor.
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CNcsAddressInputField* CNcsAddressInputField::NewL(
       
    73 	TInt aLabelTextId,
       
    74 	TNcsInputFieldType aFieldType,
       
    75 	MNcsFieldSizeObserver* aSizeObserver,
       
    76 	MNcsAddressPopupList* aAddressPopupList,
       
    77 	CNcsHeaderContainer* aParentControl )
       
    78     {
       
    79     FUNC_LOG;
       
    80     CNcsAddressInputField* self = new ( ELeave ) CNcsAddressInputField(
       
    81             aFieldType, aSizeObserver, aAddressPopupList, aParentControl );
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL( aLabelTextId );
       
    84     CleanupStack::Pop( self );
       
    85     return self;
       
    86     }
       
    87 
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CNcsAddressInputField::ConstructL()
       
    91 // Symbian 2nd phase constructor can leave.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CNcsAddressInputField::ConstructL( TInt aLabelTextId )
       
    95 	{
       
    96     FUNC_LOG;
       
    97 	// Create label
       
    98 	//Load the label string
       
    99 	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
       
   100 
       
   101 	TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
       
   102 	CreateControlsL( captionText );
       
   103 	
       
   104 	iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver,
       
   105                                                 captionText );
       
   106     // iTextEditor is not completely constructed until in SetContainerWindowL()
       
   107 
       
   108 	iTextEditor->SetPopupList(iAddressPopupList);
       
   109 
       
   110 	CleanupStack::PopAndDestroy( aTextBuf );
       
   111 	}
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Destructor
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 CNcsAddressInputField::~CNcsAddressInputField()
       
   118     {
       
   119     FUNC_LOG;
       
   120     delete iTextEditor;
       
   121     delete iButton;
       
   122     delete iLabel;
       
   123 // <cmail> Platform layout change
       
   124     /*if ( iFont )
       
   125         {
       
   126         ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
       
   127         iFont = NULL;
       
   128         }</cmail>*/
       
   129     }
       
   130 
       
   131 //<cmail>
       
   132 // -----------------------------------------------------------------------------
       
   133 // CNcsHeaderContainer::CreateControlsL()
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CNcsAddressInputField::CreateControlsL( const TDesC& aControlText )
       
   137     {
       
   138     FUNC_LOG;
       
   139     if( AknLayoutUtils::PenEnabled() )
       
   140         {
       
   141         //Create button
       
   142         TRect buttRect( 10, 10, 70, 100 );
       
   143         iButton = CAknButton::NewL( NULL, NULL, NULL, NULL, aControlText, TPtrC(), KAknButtonTextLeft, 0 );
       
   144         iButton->SetTextColorIds( KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG63 );
       
   145         iButton->SetContainerWindowL( *iParentControl );
       
   146         iButton->SetObserver( this );
       
   147         iButton->SetRect( buttRect );
       
   148         iButton->MakeVisible( ETrue );
       
   149         iButton->ActivateL();
       
   150         }
       
   151     else
       
   152         {
       
   153         //Create label
       
   154         iLabel = new ( ELeave ) CNcsLabel( *this, NULL );
       
   155         iLabel->SetTextL( aControlText );
       
   156         iLabel->SetBrushStyle(CWindowGc::ENullBrush);
       
   157         }
       
   158     }
       
   159 //</cmail>
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // SetContainerWindow
       
   163 // Don't construct the window dependent elements until the window
       
   164 // container is set
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void CNcsAddressInputField::SetContainerWindowL( const CCoeControl& aContainer )
       
   168     {
       
   169     FUNC_LOG;
       
   170     CCoeControl::SetContainerWindowL(aContainer);
       
   171 
       
   172 	InitComponentArrayL();
       
   173 	// Check if we need to construct the components
       
   174 	if (Components().Count() == 2) return;
       
   175 
       
   176 	// Load the controls into the compoent array
       
   177 	CCoeControlArray& controls = Components();
       
   178 	controls.SetControlsOwnedExternally(ETrue);
       
   179 	//<cmail>
       
   180 	if( iButton )
       
   181 	    {
       
   182 	    controls.AppendLC( iButton );
       
   183 	    CleanupStack::Pop( iButton );
       
   184 	    }
       
   185 	else
       
   186 	    {
       
   187 	    controls.AppendLC( iLabel );
       
   188 	    CleanupStack::Pop( iLabel );
       
   189 	    }
       
   190 	//</cmail>
       
   191 	controls.AppendLC(iTextEditor);
       
   192     CleanupStack::Pop(iTextEditor);
       
   193 
       
   194 // <cmail>
       
   195 
       
   196 	// Setup the text editor
       
   197 	iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
       
   198 // </cmail>
       
   199 
       
   200     iTextEditor->SetBorder( TGulBorder::ENone );
       
   201 	iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
       
   202 	iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap );
       
   203 
       
   204      CRepository* repository = NULL;
       
   205      TRAPD( err, repository = CRepository::NewL( KFreestyleEmailCenRep ) );
       
   206      if ( !err )
       
   207          {
       
   208          TInt value( 0 );
       
   209          err = repository->Get( KEmailFeatureSplitScreen, value );
       
   210          if( !err && value )
       
   211             {
       
   212              iTextEditor->SetAknEditorFlags( iTextEditor->AknEditorFlags() | EAknEditorFlagEnablePartialScreen );
       
   213              }
       
   214          }
       
   215     delete repository;
       
   216     repository = NULL;
       
   217     
       
   218 	iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase );
       
   219 	iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
       
   220     iTextEditor->SetEdwinSizeObserver( this );
       
   221     iTextEditor->SetupEditorL();
       
   222 
       
   223     // Setup the label
       
   224     UpdateFontSize();
       
   225 
       
   226     // Setup text alignment according the mirrored/normal layout.
       
   227     if ( AknLayoutUtils::LayoutMirrored() )
       
   228         {
       
   229         if( iLabel )
       
   230             iLabel->SetAlignment( EHRightVCenter );
       
   231         }
       
   232     else
       
   233         {
       
   234         if( iLabel )
       
   235             iLabel->SetAlignment( EHLeftVCenter );
       
   236         }
       
   237     
       
   238     // this needs to be bidi as in mirrored layout 
       
   239     // writing language left to right can be set 
       
   240     iTextEditor->SetAlignment( EAknEditorAlignBidi );
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CNcsAddressInputField::Draw() const
       
   245 // Draws the display
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 void CNcsAddressInputField::Draw( const TRect& /*aRect*/ ) const
       
   249 	{
       
   250     FUNC_LOG;
       
   251  	}
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CNcsAddressInputField::GetMinLabelLength()
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 TInt CNcsAddressInputField::GetMinLabelLength() const
       
   258 	{
       
   259     FUNC_LOG;
       
   260     return iLabel ? iLabel->Font()->TextWidthInPixels( *iLabel->Text() ) : 0;
       
   261 	}
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CNcsAddressInputField::SizeChanged()
       
   265 // set size
       
   266 // -----------------------------------------------------------------------------
       
   267 //
       
   268 void CNcsAddressInputField::SizeChanged()
       
   269 	{
       
   270     FUNC_LOG;
       
   271 
       
   272    	TRect rect = Rect();
       
   273  
       
   274    	if( AknLayoutUtils::PenEnabled() )
       
   275    	    {
       
   276    	    LayoutTouch();
       
   277    	    }
       
   278    	  else
       
   279    	    {
       
   280    	    LayoutNonTouch();
       
   281    	    }
       
   282 
       
   283     // This needs to be bidi as in mirrored layout 
       
   284     // writing language left to right can be set. 
       
   285     // Need to set here as layout sets it also to left or right.
       
   286     iTextEditor->SetAlignment( EAknEditorAlignBidi );
       
   287    	    
       
   288     UpdateFontSize();
       
   289     
       
   290     if (iTextEditor->ScrollBarFrame())
       
   291         {
       
   292         TRect rc = iTextEditor->Rect();
       
   293         if (AknLayoutUtils::LayoutMirrored())
       
   294             {
       
   295             rc.iTl.iX += iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
       
   296             }
       
   297         else
       
   298             {
       
   299             rc.iBr.iX -= iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
       
   300             }
       
   301         iTextEditor->SetRect(rc);
       
   302         }
       
   303     
       
   304     PositionChanged();
       
   305 	}
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CNcsHeaderContainer::PositionChanged()
       
   309 // set size
       
   310 // -----------------------------------------------------------------------------
       
   311 void CNcsAddressInputField::PositionChanged()
       
   312 	{
       
   313     FUNC_LOG;
       
   314     
       
   315     // keep the button in view as long as possible
       
   316     if( iButton && iParentControl->IsVisible() )
       
   317     	{
       
   318 		const TRect rect( Rect() );
       
   319 		const TRect buttonRect( iButton->Rect() );
       
   320 		
       
   321 		TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY );
       
   322 		
       
   323 		if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY )
       
   324 			{
       
   325 			iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) );
       
   326 			}
       
   327 		else
       
   328 			{
       
   329 			iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) );
       
   330 			}
       
   331     	}
       
   332 	}
       
   333 
       
   334 //<cmail>
       
   335 // -----------------------------------------------------------------------------
       
   336 // CNcsAddressInputField::LayoutNonTouch()
       
   337 // 
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 void CNcsAddressInputField::LayoutNonTouch()
       
   341     {
       
   342     const TRect rect( Rect() );
       
   343     NcsUtility::LayoutCaptionLabel( iLabel, rect );
       
   344     NcsUtility::LayoutDetailEdwin( iTextEditor, rect, iEditorLineCount, EFalse );  
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // CNcsAddressInputField::LayoutTouch()
       
   349 // 
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void CNcsAddressInputField::LayoutTouch()
       
   353     {
       
   354     const TRect rect( Rect() );
       
   355     NcsUtility::LayoutCaptionButton( iButton, rect );
       
   356     NcsUtility::LayoutDetailEdwinTouch( iTextEditor, rect, iEditorLineCount, EFalse );  
       
   357 
       
   358     // save the original field positions so that we can the button in view
       
   359     iOriginalFieldPos = rect.iTl;
       
   360     iOriginalButtonPos = iButton->Position();    
       
   361 
       
   362     iTextEditor->UpdateCustomDrawer();
       
   363     }
       
   364     
       
   365 // -----------------------------------------------------------------------------
       
   366 // CNcsAddressInputField::HandlePointerEventL()
       
   367 // Handles pointer events
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 void CNcsAddressInputField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   371     {
       
   372 	FUNC_LOG;
       
   373     iTextEditor->HandlePointerEventL(aPointerEvent);
       
   374     if( iButton )
       
   375         {
       
   376         iButton->HandlePointerEventL( aPointerEvent );
       
   377         }
       
   378     iTextEditor->HandleTextChangedL();
       
   379     
       
   380     switch( aPointerEvent.iType )
       
   381     	{
       
   382     	case TPointerEvent::EButton1Down:
       
   383     		{
       
   384             // Save start position so that it can be used in
       
   385             // drag/scrolling calculations
       
   386             iStartPosition = aPointerEvent.iPosition;
       
   387             iIsDraggingStarted = EFalse;
       
   388             break;
       
   389     		}
       
   390     		
       
   391     	case TPointerEvent::EDrag:
       
   392     		{
       
   393             if ( !iIsDraggingStarted && iPhysics )
       
   394                 {
       
   395                 TInt drag( iStartPosition.iY - aPointerEvent.iPosition.iY );
       
   396                 if ( Abs( drag ) > iPhysics->DragThreshold() )
       
   397                     {
       
   398 					iIsDraggingStarted = ETrue;
       
   399                     }
       
   400                 }
       
   401             break;
       
   402     		}
       
   403     	}
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CNcsAddressInputField::HandleControlEventL()
       
   408 // 
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 void CNcsAddressInputField::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType )
       
   412     {
       
   413     if( aEventType == EEventStateChanged )
       
   414         {
       
   415         if( aControl == iButton && !iIsDraggingStarted )
       
   416             {
       
   417             iParentControl->OpenPhonebookL();
       
   418             }
       
   419         }
       
   420     }
       
   421 //</cmail>
       
   422 
       
   423 // -----------------------------------------------------------------------------
       
   424 // CNcsAddressInputField::OfferKeyEventL()
       
   425 // Handles key events
       
   426 // -----------------------------------------------------------------------------
       
   427 //
       
   428 TKeyResponse 
       
   429 CNcsAddressInputField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   430 	{
       
   431     FUNC_LOG;
       
   432 	TKeyResponse ret( EKeyWasNotConsumed );
       
   433 
       
   434 	if( aKeyEvent.iCode == EKeyOK )
       
   435 		{
       
   436 		iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
       
   437 		iTextEditor->UpdateAddressListAllL();
       
   438 		}
       
   439 	else
       
   440 		{
       
   441 		ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType );
       
   442 		}
       
   443 
       
   444 	return ret;
       
   445 	}
       
   446 
       
   447 // -----------------------------------------------------------------------------
       
   448 // CNcsAddressInputField::FocusChanged()
       
   449 // -----------------------------------------------------------------------------
       
   450 //
       
   451 void CNcsAddressInputField::FocusChanged( TDrawNow aDrawNow )
       
   452 	{
       
   453     FUNC_LOG;
       
   454 	if ( IsFocused() )
       
   455 		{
       
   456 		iTextEditor->SetFocus( ETrue, aDrawNow );
       
   457         //TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) );
       
   458 
       
   459         // make sure that control is visible on screen
       
   460 		if ( Rect().iTl.iY < 0 )
       
   461 			{
       
   462 			TPoint pt = TPoint( 0, 0 );
       
   463 			Reposition( pt,Rect().Width() );
       
   464             iSizeObserver->UpdateFieldPosition( this );
       
   465 			}
       
   466 		else
       
   467 		    {
       
   468 		    TPoint pos = PositionRelativeToScreen();
       
   469 		    pos.iY += Size().iHeight;
       
   470     	    CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
       
   471     	    TPixelsAndRotation pix;
       
   472     		screenDev->GetDefaultScreenSizeAndRotation( pix );
       
   473     		const TInt h = pix.iPixelSize.iHeight;
       
   474     		if ( pos.iY >= h - h / 3 )
       
   475     		    {
       
   476     			TPoint pt = TPoint( 0, h / 3 );
       
   477     			Reposition( pt,Rect().Width() );
       
   478                 iSizeObserver->UpdateFieldPosition( this );
       
   479     		    }
       
   480 		    }
       
   481 
       
   482         if ( iParentControl )
       
   483             {
       
   484             TRAP_IGNORE( iParentControl->SetMskL() );
       
   485             }
       
   486 		}
       
   487     else
       
   488         {
       
   489         if ( iTextEditor->SelectionLength()== 0 )
       
   490             {
       
   491             TRAP_IGNORE( iTextEditor->HandleTextChangedL() );
       
   492             }
       
   493         
       
   494         iTextEditor->SetFocus( EFalse );
       
   495         TRAP_IGNORE( iAddressPopupList->ClosePopupContactListL() );
       
   496         }
       
   497 
       
   498 	if ( aDrawNow )
       
   499 		{
       
   500 		DrawNow();
       
   501 		}
       
   502 	}
       
   503 
       
   504 // -----------------------------------------------------------------------------
       
   505 // CNcsAddressInputField::MinimumHeight()
       
   506 // -----------------------------------------------------------------------------
       
   507 //
       
   508 TInt CNcsAddressInputField::MinimumHeight() const
       
   509     {
       
   510     FUNC_LOG;
       
   511     // <cmail> Platform layout changes
       
   512     /*TNcsMeasures m = NcsUtility::Measures();
       
   513 	TInt height = m.iAifHeight - m.iAifEditorHeight + iEditorMinimumHeight;
       
   514 	TInt height2 = m.iAifHeight;
       
   515     return Max( height, height2 );
       
   516     */
       
   517 
       
   518     //return NcsUtility::MinimumHeaderSize( Rect(), iEditorLineCount ).iHeight;
       
   519     // </cmail> Platform layout changes
       
   520     return 0;
       
   521     }
       
   522 
       
   523 // -----------------------------------------------------------------------------
       
   524 // CNcsAddressInputField::HandleEdwinSizeEventL()
       
   525 // -----------------------------------------------------------------------------
       
   526 //
       
   527 TBool CNcsAddressInputField::HandleEdwinSizeEventL(
       
   528 	CEikEdwin* /*aEdwin*/,
       
   529     TEdwinSizeEvent /*aEventType*/,
       
   530     TSize aDesirableEdwinSize )
       
   531     {
       
   532     FUNC_LOG;
       
   533 // <cmail> Platform layout change
       
   534     /*TInt ret( EFalse );
       
   535     TInt htLine = iTextEditor->GetLineHeightL();
       
   536     TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine;
       
   537 
       
   538     if( numLinesDesired < KMaxAddressFieldLines &&
       
   539         iEditorMinimumHeight != aDesirableEdwinSize.iHeight )
       
   540         {
       
   541         iEditorMinimumHeight = aDesirableEdwinSize.iHeight;
       
   542 
       
   543         if( iSizeObserver )
       
   544             ret = iSizeObserver->UpdateFieldSizeL();
       
   545         iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
       
   546 
       
   547         }
       
   548     else if (iEditorMinimumHeight != htLine * KMaxAddressFieldLines)
       
   549         {
       
   550         //We may still need to resize the controll.
       
   551         iEditorMinimumHeight = htLine * KMaxAddressFieldLines;
       
   552         iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn );
       
   553         if (iSizeObserver)
       
   554             ret = iSizeObserver->UpdateFieldSizeL();
       
   555         }
       
   556     return ret;*/
       
   557 
       
   558     TInt ret( EFalse );
       
   559     TInt htLine = iTextEditor->GetLineHeightL();
       
   560     TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine;
       
   561     // commented because of EGWG-83ECSR, no negative feedback after removing
       
   562     //CEikScrollBarFrame& scrollBarFrame( *iTextEditor->CreateScrollBarFrameL() );
       
   563     iEditorLineCount = numLinesDesired;
       
   564     //scrollBarFrame.SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
       
   565     if ( iSizeObserver )
       
   566         {
       
   567         ret = iSizeObserver->UpdateFieldSizeL();
       
   568         }
       
   569     return ret;
       
   570 // </cmail>
       
   571     }
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 // CNcsAddressInputField::AddAddressL()
       
   575 // -----------------------------------------------------------------------------
       
   576 //
       
   577 void CNcsAddressInputField::AddAddressL( const CNcsEmailAddressObject& aAddress )
       
   578     {
       
   579     FUNC_LOG;
       
   580     iTextEditor->AddAddressL( aAddress );
       
   581     }
       
   582 
       
   583 // -----------------------------------------------------------------------------
       
   584 // CNcsAddressInputField::AddAddressL()
       
   585 // -----------------------------------------------------------------------------
       
   586 //
       
   587 void CNcsAddressInputField::AddAddressL( const TDesC& aEmail )
       
   588 	{
       
   589     FUNC_LOG;
       
   590 	iTextEditor->AddAddressL( KNullDesC(), aEmail );
       
   591 	}
       
   592 
       
   593 // -----------------------------------------------------------------------------
       
   594 // CNcsAddressInputField::SelectAllTextL()
       
   595 // -----------------------------------------------------------------------------
       
   596 //
       
   597 void CNcsAddressInputField::SelectAllTextL()
       
   598 	{
       
   599     FUNC_LOG;
       
   600 	iTextEditor->SelectAllL();
       
   601 	}
       
   602 
       
   603 // <cmail> Platform layout changes
       
   604 // -----------------------------------------------------------------------------
       
   605 // CNcsAddressInputField::Reposition()
       
   606 // -----------------------------------------------------------------------------
       
   607 //
       
   608 void CNcsAddressInputField::Reposition( TPoint& aPt, TInt /*aWidth*/ )
       
   609 	{
       
   610     FUNC_LOG;
       
   611 	/*
       
   612     TSize sz( aWidth, MinimumHeight() );
       
   613 	if ( Rect() != TRect( aPt, sz ) )
       
   614 		{
       
   615 		SetExtent( aPt, sz);
       
   616 		}
       
   617     aPt.iY += Size().iHeight;
       
   618     */
       
   619     SetPosition( aPt );
       
   620     // </cmail> Platform layout changes
       
   621 	}
       
   622 
       
   623 // -----------------------------------------------------------------------------
       
   624 // CNcsAddressInputField::GetLabelText()
       
   625 // -----------------------------------------------------------------------------
       
   626 //
       
   627 const TDesC& CNcsAddressInputField::GetLabelText() const
       
   628 	{
       
   629     FUNC_LOG;
       
   630 	return iLabel ? *iLabel->Text() : KEmptyReturnValue();
       
   631 	}
       
   632 
       
   633 // <cmail> Platform layout change
       
   634 // ---------------------------------------------------------------------------
       
   635 // CNcsAddressInputField::LayoutLineCount
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 TInt CNcsAddressInputField::LayoutLineCount() const
       
   639     {
       
   640     FUNC_LOG;
       
   641     if( iLabel && !AknLayoutUtils::PenEnabled() )
       
   642         {
       
   643         return ( IsVisible() ? Max( 1, iEditorLineCount ) : 0 ) + iLabel->LayoutLineCount();
       
   644         }
       
   645     else
       
   646         {
       
   647         return ( IsVisible() ? Max( 1, iEditorLineCount ) : 0 );
       
   648         }
       
   649     }
       
   650 // </cmail> Platform layout change
       
   651 
       
   652 // -----------------------------------------------------------------------------
       
   653 // CNcsAddressInputField::LineCount()
       
   654 // -----------------------------------------------------------------------------
       
   655 //
       
   656 TInt CNcsAddressInputField::LineCount() const
       
   657 	{
       
   658     FUNC_LOG;
       
   659 	return iTextEditor->LineCount();
       
   660 	}
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // CNcsAddressInputField::ScrollableLines()
       
   664 // -----------------------------------------------------------------------------
       
   665 //
       
   666 TInt CNcsAddressInputField::ScrollableLines() const
       
   667 	{
       
   668     FUNC_LOG;
       
   669 	return iTextEditor->ScrollableLines();
       
   670 	}
       
   671 
       
   672 // -----------------------------------------------------------------------------
       
   673 // CNcsAddressInputField::GetNumChars()
       
   674 // -----------------------------------------------------------------------------
       
   675 //
       
   676 TInt CNcsAddressInputField::GetNumChars() const
       
   677 	{
       
   678     FUNC_LOG;
       
   679 	return iTextEditor->GetNumChars();
       
   680 	}
       
   681 
       
   682 // -----------------------------------------------------------------------------
       
   683 // CNcsAddressInputField::CursorLineNumber()
       
   684 // -----------------------------------------------------------------------------
       
   685 //
       
   686 TInt CNcsAddressInputField::CursorLineNumber() const
       
   687 	{
       
   688     FUNC_LOG;
       
   689 	return iTextEditor->CursorLineNumber();
       
   690 	}
       
   691 
       
   692 // -----------------------------------------------------------------------------
       
   693 // CNcsAddressInputField::CursorPosition()
       
   694 // -----------------------------------------------------------------------------
       
   695 //
       
   696 TInt CNcsAddressInputField::CursorPosition() const
       
   697 	{
       
   698     FUNC_LOG;
       
   699 	TInt pos = iTextEditor->CursorPosition();
       
   700 	//Add the delta between the top of the edit control
       
   701 	//and the top of the parent control
       
   702 	pos += iTextEditor->Rect().iTl.iY - Rect().iTl.iY ;
       
   703 	return pos;
       
   704 	}
       
   705 
       
   706 // -----------------------------------------------------------------------------
       
   707 // CNcsAddressInputField::Editor()
       
   708 // -----------------------------------------------------------------------------
       
   709 //
       
   710 CNcsEditor* CNcsAddressInputField::Editor() const
       
   711 	{
       
   712     FUNC_LOG;
       
   713 	return iTextEditor;
       
   714 	}
       
   715 
       
   716 // -----------------------------------------------------------------------------
       
   717 // CNcsAddressInputField::IsEmpty()
       
   718 // -----------------------------------------------------------------------------
       
   719 //
       
   720 TBool CNcsAddressInputField::IsEmpty() const
       
   721 	{
       
   722     FUNC_LOG;
       
   723 	return iTextEditor->TextLength() ==  0;
       
   724 	}
       
   725 
       
   726 // -----------------------------------------------------------------------------
       
   727 // CNcsAddressInputField::GetLookupTextLC()
       
   728 // -----------------------------------------------------------------------------
       
   729 //
       
   730 HBufC* CNcsAddressInputField::GetLookupTextLC() const
       
   731 	{
       
   732     FUNC_LOG;
       
   733 	return iTextEditor->GetLookupTextLC();
       
   734 	}
       
   735 
       
   736 // -----------------------------------------------------------------------------
       
   737 // CNcsAddressInputField::GetAddressesL()
       
   738 // -----------------------------------------------------------------------------
       
   739 //
       
   740 const RPointerArray<CNcsEmailAddressObject>&
       
   741 CNcsAddressInputField::GetAddressesL( TBool aParseNow )
       
   742 	{
       
   743 	if ( aParseNow )
       
   744 		{
       
   745 		iTextEditor->CheckAddressWhenFocusLostL();
       
   746 		}
       
   747 	return iTextEditor->GetAddressesL();
       
   748 	}
       
   749 
       
   750 // -----------------------------------------------------------------------------
       
   751 // CNcsAddressInputField::EmailAddressObjectBySelection()
       
   752 // -----------------------------------------------------------------------------
       
   753 //
       
   754 const CNcsEmailAddressObject* CNcsAddressInputField::EmailAddressObjectBySelection() const
       
   755 	{
       
   756     FUNC_LOG;
       
   757 	return iTextEditor->EmailAddressObjectBySelection();
       
   758 	}
       
   759 
       
   760 // -----------------------------------------------------------------------------
       
   761 // CNcsAddressInputField::TextEditor()
       
   762 // -----------------------------------------------------------------------------
       
   763 //
       
   764 CEikEdwin* CNcsAddressInputField::TextEditor() const
       
   765 	{
       
   766     FUNC_LOG;
       
   767 	return iTextEditor;
       
   768 	}
       
   769 
       
   770 // -----------------------------------------------------------------------------
       
   771 // CNcsAddressInputField::GetLineRectL()
       
   772 // -----------------------------------------------------------------------------
       
   773 //
       
   774 void CNcsAddressInputField::GetLineRectL( TRect& aLineRect ) const
       
   775 	{
       
   776     FUNC_LOG;
       
   777     return iTextEditor->GetLineRectL( aLineRect );
       
   778 	}
       
   779 
       
   780 // -----------------------------------------------------------------------------
       
   781 // CNcsAddressInputField::SetMaxLabelLength()
       
   782 // -----------------------------------------------------------------------------
       
   783 //
       
   784 void CNcsAddressInputField::SetMaxLabelLength( TInt aMaxLength )
       
   785 	{
       
   786     FUNC_LOG;
       
   787 	iMaximumLabelLength = aMaxLength;
       
   788 	}
       
   789 
       
   790 // -----------------------------------------------------------------------------
       
   791 // CNcsAddressInputField::SetTextColorL()
       
   792 // -----------------------------------------------------------------------------
       
   793 //
       
   794 void CNcsAddressInputField::SetTextColorL( TLogicalRgb aColor )
       
   795 	{
       
   796     FUNC_LOG;
       
   797 	iTextEditor->SetTextColorL( aColor );
       
   798 	}
       
   799 
       
   800 // -----------------------------------------------------------------------------
       
   801 // CNcsAddressInputField::SetAddressesL()
       
   802 // -----------------------------------------------------------------------------
       
   803 //
       
   804 void CNcsAddressInputField::SetAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses )
       
   805 	{
       
   806     FUNC_LOG;
       
   807 	iTextEditor->SetAddressesL( aAddresses );
       
   808 	}
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // CNcsAddressInputField::AppendAddressesL()
       
   812 // -----------------------------------------------------------------------------
       
   813 //
       
   814 void CNcsAddressInputField::AppendAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses )
       
   815 	{
       
   816     FUNC_LOG;
       
   817 	iTextEditor->AppendAddressesL( aAddresses );
       
   818 	}
       
   819 
       
   820 // -----------------------------------------------------------------------------
       
   821 // CNcsAddressInputField::UpdateFontSize()
       
   822 // -----------------------------------------------------------------------------
       
   823 //
       
   824 void CNcsAddressInputField::UpdateFontSize()
       
   825 	{
       
   826     FUNC_LOG;
       
   827     // <cmail> Platform layout change
       
   828     /*if ( iFont )
       
   829         {
       
   830         ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
       
   831         iFont = NULL;
       
   832         }
       
   833 
       
   834 	TNcsMeasures m = NcsUtility::Measures();
       
   835 	if ( !iFont )
       
   836 	    {
       
   837 	    TRAP_IGNORE( iFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont, m.iLabelFontHeightPx) );
       
   838 	    }*/
       
   839     CCoeControl* control = iButton ? ( CCoeControl* )iButton : ( CCoeControl* )iLabel;
       
   840 	iFont = NcsUtility::GetLayoutFont( control->Rect(), NcsUtility::ENcsHeaderCaptionFont );
       
   841 	if( control == iButton )
       
   842 	    {
       
   843 	    iButton->SetTextFont( iFont );
       
   844 	    }
       
   845 	else
       
   846 	    {
       
   847 	    iLabel->SetFont( iFont );
       
   848 	    }
       
   849     iTextEditor->UpdateFontSize();
       
   850     // </cmail> Platform layout change
       
   851 	}
       
   852 
       
   853 // -----------------------------------------------------------------------------
       
   854 // CNcsAddressInputField::HandleResourceChange()
       
   855 // -----------------------------------------------------------------------------
       
   856 //
       
   857 void CNcsAddressInputField::HandleResourceChange( TInt aType )
       
   858     {
       
   859     FUNC_LOG;
       
   860     CCoeControl::HandleResourceChange( aType );
       
   861     if ( aType == KAknsMessageSkinChange ||
       
   862          aType == KEikMessageColorSchemeChange )
       
   863         {
       
   864         UpdateFontSize();
       
   865         // <cmail> Platform layout change
       
   866         iTextEditor->HandleResourceChange( aType ); // CreateScrollBarFrameL()->DrawScrollBarsNow();
       
   867         // </cmail> Platform layout change
       
   868         }
       
   869     }
       
   870 
       
   871 void CNcsAddressInputField::FixSemicolonAtTheEndL()
       
   872 	{
       
   873 	FUNC_LOG;
       
   874 
       
   875     if ( 0 != iTextEditor->TextLength() &&
       
   876          !iTextEditor->HasSemicolonAtTheEndL() )
       
   877         {
       
   878         CRichText* rt = iTextEditor->RichText();
       
   879         if ( rt )
       
   880             {
       
   881             rt->InsertL( rt->DocumentLength(), _L(";") );
       
   882             iTextEditor->SetCursorPosL( rt->DocumentLength(), EFalse );
       
   883             iTextEditor->CheckAddressWhenFocusLostL();
       
   884             }
       
   885         }
       
   886 	}
       
   887 
       
   888 void CNcsAddressInputField::EnableKineticScrollingL( CAknPhysics* aPhysics )
       
   889     {
       
   890 	iPhysics = aPhysics;
       
   891     iTextEditor->EnableKineticScrollingL( aPhysics );
       
   892     iTextEditor->TextLayout()->RestrictScrollToTopsOfLines( ETrue );
       
   893     }
       
   894 
       
   895 void CNcsAddressInputField::SetPhysicsEmulationOngoing( TBool aPhysOngoing )
       
   896     {
       
   897     iTextEditor->SetPhysicsEmulationOngoing( aPhysOngoing );
       
   898     iButton->EnableFeedback( !aPhysOngoing );
       
   899     }