emailuis/emailui/src/ncsheadercontainer.cpp
branchRCL_3
changeset 73 c8382f7b54ef
parent 64 3533d4323edc
child 80 726fba06891a
equal deleted inserted replaced
70:968773a0b6ef 73:c8382f7b54ef
    21 #include <StringLoader.h>
    21 #include <StringLoader.h>
    22 #include <aknViewAppUi.h>
    22 #include <aknViewAppUi.h>
    23 #include <aknnotewrappers.h> //CAknInformationNote
    23 #include <aknnotewrappers.h> //CAknInformationNote
    24 #include <FreestyleEmailUi.rsg>
    24 #include <FreestyleEmailUi.rsg>
    25 #include <aknphysics.h>
    25 #include <aknphysics.h>
       
    26 #include <AknPriv.hrh>
    26 
    27 
    27 #include "cfsmailbox.h"
    28 #include "cfsmailbox.h"
    28 #include <FreestyleEmailUi.rsg>
    29 #include <FreestyleEmailUi.rsg>
       
    30 #include <layoutmetadata.cdl.h>
    29 
    31 
    30 #include "FSEmailBuildFlags.h"
    32 #include "FSEmailBuildFlags.h"
    31 #include "ncsheadercontainer.h"
    33 #include "ncsheadercontainer.h"
    32 #include "ncscomposeviewcontainer.h"
    34 #include "ncscomposeviewcontainer.h"
    33 #include "ncsemailaddressobject.h"
    35 #include "ncsemailaddressobject.h"
    79 	CAknPhysics* aPhysics ): 
    81 	CAknPhysics* aPhysics ): 
    80 	iParent( aParent ),
    82 	iParent( aParent ),
    81 	iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ),
    83 	iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ),
    82 	iMailBox( aMailBox ),
    84 	iMailBox( aMailBox ),
    83 	iLongTapEventConsumed( EFalse ),
    85 	iLongTapEventConsumed( EFalse ),
    84     iPhysics( aPhysics )
    86     iPhysics( aPhysics ),
       
    87     iSplitScreenVKBEnabled( EFalse )
    85 	{
    88 	{
    86     FUNC_LOG;
    89     FUNC_LOG;
    87 	}
    90 	}
    88 
    91 
    89 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
   157         {
   160         {
   158         controls.Remove( iBccField );
   161         controls.Remove( iBccField );
   159         }
   162         }
   160 
   163 
   161     // initially attachments field is hidden
   164     // initially attachments field is hidden
   162 	iAttachmentField->MakeVisible( EFalse );
   165     iAttachmentField->MakeVisible( EFalse );
   163 	controls.Remove( iAttachmentField );
   166     controls.Remove( iAttachmentField );
   164 
   167 
   165 	// test whether mailbox supports remote lookup
   168     // test whether mailbox supports remote lookup
   166 	TBool remoteLookupSupported = 
   169     TBool remoteLookupSupported = 
   167         TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox );
   170         TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox );
   168 	
   171 
   169 	iAacListBox = CNcsPopupListBox::NewL( 
   172     iAacListBox = CNcsPopupListBox::NewL( 
   170 	        this, iMailBox, *this, remoteLookupSupported );
   173         this, iMailBox, *this, remoteLookupSupported );
   171 	iAacListBox->MakeVisible( EFalse );
       
   172 
   174 
   173     iRALInProgress = EFalse;
   175     iRALInProgress = EFalse;
   174 
   176 
   175     iToField->EnableKineticScrollingL( iPhysics );
   177     iToField->EnableKineticScrollingL( iPhysics );
   176     iCcField->EnableKineticScrollingL( iPhysics );
   178     iCcField->EnableKineticScrollingL( iPhysics );
   192 	delete iAacListBox;
   194 	delete iAacListBox;
   193 	delete iLongTapDetector;
   195 	delete iLongTapDetector;
   194 	}
   196 	}
   195 
   197 
   196 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
       
   199 // From MNcsPopupListBoxObserver.
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 TBool CNcsHeaderContainer::PopupVisibilityChangingL( TBool aVisible )
       
   203     {
       
   204     CNcsComposeViewContainer& parent =
       
   205         static_cast<CNcsComposeViewContainer&>( iParent );
       
   206 
       
   207     if ( aVisible )
       
   208         {
       
   209         DoScrollFocusToTop();
       
   210         iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
       
   211         }
       
   212     else
       
   213         {
       
   214         // Scroll editor top, if it can be fully displayed.
       
   215         if ( parent.ContentTotalHeight() < parent.VisibleAreaHeight() )
       
   216             {
       
   217             parent.Scroll( 0, ETrue );
       
   218             }
       
   219         }
       
   220 
       
   221     parent.UpdateScrollBarVisibility( !aVisible );
       
   222     ShowPopupMenuBarL( aVisible );
       
   223     return ETrue;
       
   224     }
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 // From MNcsPopupListBoxObserver.
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 void CNcsHeaderContainer::PopupItemSelectedL()
       
   231     {
       
   232     DoPopupSelectL();
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------------------------
   197 // CNcsHeaderContainer::FocusChanged
   236 // CNcsHeaderContainer::FocusChanged
   198 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   199 //
   238 //
   200 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow )
   239 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow )
   201 	{
   240     {
   202     FUNC_LOG;
   241     FUNC_LOG;
   203     
   242 
   204     CCoeControl* focused = iFocused;
   243     CCoeControl* focused = iFocused;
   205     
   244 
   206     if ( !focused )
   245     if ( !focused )
   207         {
   246         {
   208         focused = FindFocused();
   247         focused = FindFocused();
   209         iFocused = focused;
   248         iFocused = focused;
   210         }
   249         }
   211     
   250 
   212     if ( !IsFocused() )
   251     if ( !IsFocused() )
   213         {
   252         {
   214         if ( focused )
   253         if ( focused )
   215             {
   254             {
   216             // We're loosing focus (probably going to message body)
   255             // We're loosing focus (probably going to message body)
   217             // Commit changes and make sure no controls are focused.
   256             // Commit changes and make sure no controls are focused.
   218             TRAP_IGNORE( CommitFieldL( focused ) );
   257             if ( iParent.IsFocused() )
       
   258                 {
       
   259                 TRAP_IGNORE( CommitFieldL( focused ) );
       
   260                 }
   219             focused->SetFocus( EFalse, aDrawNow );
   261             focused->SetFocus( EFalse, aDrawNow );
   220             iFocused = NULL;
       
   221             }
   262             }
   222 
   263 
   223         // Remove MSK label when header loses focus
   264         // Remove MSK label when header loses focus
   224         TRAP_IGNORE( SetMskL() );
   265         TRAP_IGNORE( SetMskL() );
   225 		}
   266         }
   226 	else if ( IsFocused() && !focused )
   267     else
   227 		{
   268         {
   228 		// We're gaining focus from the message body
   269         if ( !focused )
   229 		// Set the focus to the last control in the control array
   270             {
   230 		// (either attachment line or subject field)
   271             // We're gaining focus from the message body
   231 		CCoeControlArray::TCursor cur = Components().End();
   272             // Set the focus to the last control in the control array
   232 		cur.Prev();
   273             // (either attachment line or subject field)
   233 		cur.Control<CCoeControl>()->SetFocus( ETrue, aDrawNow );
   274             CCoeControlArray::TCursor cur = Components().End();
   234         iFocused = cur.Control<CCoeControl>();
   275             cur.Prev();
   235 		}
   276             iFocused = cur.Control<CCoeControl>();
   236 	}
   277             }
   237 
   278         iFocused->SetFocus( ETrue, aDrawNow );
   238 // ---------------------------------------------------------------------------
       
   239 // CNcsHeaderContainer::ShowCursor
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 void CNcsHeaderContainer::ShowCursor( TBool aShow, TDrawNow aDrawNow )
       
   243     {
       
   244     CCoeControl* focused = FindFocused();
       
   245     if ( focused )
       
   246         {
       
   247         iFocused = focused;
       
   248         }
       
   249     if ( iFocused ) 
       
   250         {
       
   251         iFocused->SetFocus( aShow, aDrawNow );
       
   252         }
   279         }
   253     }
   280     }
   254 
   281 
   255 // -----------------------------------------------------------------------------
   282 // -----------------------------------------------------------------------------
   256 // CNcsHeaderContainer::Draw() const
   283 // CNcsHeaderContainer::Draw() const
   341 // 
   368 // 
   342 // -----------------------------------------------------------------------------
   369 // -----------------------------------------------------------------------------
   343 void CNcsHeaderContainer::HandlePointerEventL( 
   370 void CNcsHeaderContainer::HandlePointerEventL( 
   344         const TPointerEvent& aPointerEvent )
   371         const TPointerEvent& aPointerEvent )
   345     {
   372     {
   346 	FUNC_LOG;
   373     FUNC_LOG;
       
   374     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   375         {
       
   376         CCoeControl* component = 0;
       
   377         for ( TInt i=0; i < Components().Count(); ++i )
       
   378             {
       
   379             TRect rc = Components().At( i ).iControl->Rect();
       
   380             if ( rc.Contains( aPointerEvent.iPosition ) )
       
   381                 {
       
   382                 component = Components().At( i ).iControl;
       
   383                 }
       
   384             }
       
   385 
       
   386         if ( component )
       
   387             {
       
   388             CCoeControl* pOldCtrl = FindFocused();
       
   389             CCoeControl* pNewCtrl= component;
       
   390 
       
   391             if ( pOldCtrl != pNewCtrl )
       
   392                 {
       
   393                 // Unfocus the control
       
   394                 if ( pOldCtrl )
       
   395                     {
       
   396                     pOldCtrl->SetFocus( EFalse, ENoDrawNow );
       
   397                     }
       
   398                 pNewCtrl->SetFocus( ETrue, ENoDrawNow );
       
   399                 iFocused = pNewCtrl;
       
   400                 // Commit changes to previously focused field.
       
   401                 if ( pOldCtrl )
       
   402                     {
       
   403                     CommitFieldL( pOldCtrl );
       
   404                     }
       
   405 
       
   406                 // If the attachments label has changed focus
       
   407                 if ( pOldCtrl == iAttachmentField || 
       
   408                         pNewCtrl == iAttachmentField )
       
   409                     {
       
   410                     DrawAttachmentFocusNow();
       
   411                     }
       
   412 
       
   413                 CNcsComposeViewContainer* container = 
       
   414                         static_cast<CNcsComposeViewContainer*>( &iParent );
       
   415                 container->UpdateScrollBar();
       
   416                 }
       
   417 
       
   418             DrawDeferred();
       
   419             }
       
   420         }
       
   421 
   347     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   422     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   348         {
   423         {
   349 		CCoeControl* clicked = 0;
   424         if ( iLongTapEventConsumed )
   350 		for ( TInt i=0; i < Components().Count(); ++i )
   425             {
   351 			{
   426             iLongTapEventConsumed = EFalse;
   352 			TRect rc = Components().At( i ).iControl->Rect();
   427             return;
   353 			if ( rc.Contains( aPointerEvent.iPosition ) )
   428             }
   354 				{
   429 
   355 				clicked = Components().At( i ).iControl;
   430         CCoeControl* component = 0;
   356 				}
   431         for ( TInt i=0; i < Components().Count(); ++i )
   357 			}
   432             {
   358 
   433             TRect rc = Components().At( i ).iControl->Rect();
   359 	    if ( clicked )
   434             if ( rc.Contains( aPointerEvent.iPosition ) )
   360 	        {
   435                 {
   361 			CCoeControl* pOldCtrl = FindFocused();
   436                 component = Components().At( i ).iControl;
   362 			CCoeControl* pNewCtrl= clicked;
   437                 }
   363 			
   438             }
   364 			if ( pOldCtrl != pNewCtrl )
   439 
   365 				{
   440         if ( component && component == iFocused )
   366 				// Unfocus the control
   441             {
   367 				if ( pOldCtrl )
   442             TBool physicsActionOngoing( EFalse );
   368 					{
   443             if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone )
   369 					pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   444                 {
   370 					}
       
   371 				pNewCtrl->SetFocus( ETrue, ENoDrawNow );
       
   372 				iFocused = pNewCtrl;
       
   373 				// Commit changes to previously focused field.
       
   374 				if ( pOldCtrl )
       
   375 					{
       
   376 					CommitFieldL( pOldCtrl );
       
   377 					}
       
   378 
       
   379 				// If the attachments label has changed focus
       
   380 				if ( pOldCtrl == iAttachmentField || 
       
   381 					 pNewCtrl == iAttachmentField )
       
   382 					{
       
   383 					DrawAttachmentFocusNow();
       
   384 					}
       
   385 				
       
   386 				CNcsComposeViewContainer* container = 
       
   387 					static_cast<CNcsComposeViewContainer*>( &iParent );
       
   388 				container->UpdateScrollBar();
       
   389 				}
       
   390 			
       
   391 			if( iLongTapEventConsumed )
       
   392 				{
       
   393 				iLongTapEventConsumed = EFalse;
       
   394 				return;
       
   395 				}        
       
   396 
       
   397 			TBool physicsActionOngoing( EFalse );
       
   398 			if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone )
       
   399 			{
       
   400                 physicsActionOngoing = ETrue;
   445                 physicsActionOngoing = ETrue;
   401             }
   446                 }
   402 			
   447 
   403 			if( pNewCtrl == iAttachmentField && !physicsActionOngoing )
   448             if ( component == iAttachmentField && !physicsActionOngoing )
   404 				{
   449                 {
   405 				CNcsComposeViewContainer& parent = 
   450                 CNcsComposeViewContainer& parent = 
   406 					static_cast<CNcsComposeViewContainer&>( iParent );
   451                         static_cast<CNcsComposeViewContainer&>( iParent );
   407 				parent.HandleAttachmentsOpenCommandL();
   452                 parent.HandleAttachmentsOpenCommandL();
   408 				}          
   453                 }
   409 	        }
   454             }
   410         }
   455         }
   411 
   456 
   412 	CCoeControl::HandlePointerEventL( aPointerEvent );
   457     CCoeControl::HandlePointerEventL( aPointerEvent );
   413     }
   458     }
   414 
   459 
   415 // -----------------------------------------------------------------------------
   460 // -----------------------------------------------------------------------------
   416 // CNcsHeaderContainer::HandleLongTapL()
   461 // CNcsHeaderContainer::HandleLongTapL()
   417 // 
   462 // 
   464     {
   509     {
   465     FUNC_LOG;
   510     FUNC_LOG;
   466     TKeyResponse ret( EKeyWasNotConsumed );
   511     TKeyResponse ret( EKeyWasNotConsumed );
   467     
   512     
   468     TBool doScroll( EFalse );
   513     TBool doScroll( EFalse );
   469     
   514 
   470     if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
   515     if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
   471     	{
   516         {
   472         if ( iAacListBox && iAacListBox->IsVisible() && 
   517         if ( iAacListBox && iAacListBox->IsVisible() && 
   473              !iAacListBox->IsPopupEmpty() )
   518              !iAacListBox->IsPopupEmpty() )
   474         	{
   519             {
   475            	return iAacListBox->OfferKeyEventL( aKeyEvent, aType );
   520             return iAacListBox->OfferKeyEventL( aKeyEvent, aType );
   476         	}
   521             }
   477         else
   522         else
   478 	        {
   523             {
   479 		    ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType );
   524             ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType );
   480 		    
   525             doScroll = ( ret == EKeyWasConsumed ); 
   481     		doScroll = ( ret == EKeyWasConsumed ); 
   526             }
   482 	        }
       
   483 
   527 
   484         if ( ret == EKeyWasNotConsumed ) 
   528         if ( ret == EKeyWasNotConsumed ) 
   485         	{
   529             {
   486             ret = ChangeFocusL( aKeyEvent );
   530             ret = ChangeFocusL( aKeyEvent );
   487         	DrawDeferred();
   531             DrawDeferred();
   488         	}
   532             }
   489     	}
   533         }
   490     else
   534     else
   491     	{
   535     	{
   492         if ( FindFocused() == iAttachmentField )
   536         if ( FindFocused() == iAttachmentField )
   493         	{
   537         	{
   494         	if ( aType == EEventKey )
   538         	if ( aType == EEventKey )
   527 		         ( aKeyEvent.iCode == EKeyEnter || 
   571 		         ( aKeyEvent.iCode == EKeyEnter || 
   528 		           aKeyEvent.iScanCode == EStdKeyEnter) )
   572 		           aKeyEvent.iScanCode == EStdKeyEnter) )
   529 		        {
   573 		        {
   530 		        FindFocused()->OfferKeyEventL( aKeyEvent, aType );
   574 		        FindFocused()->OfferKeyEventL( aKeyEvent, aType );
   531 		        ret = EKeyWasConsumed;
   575 		        ret = EKeyWasConsumed;
       
   576 		        doScroll = ETrue;
   532 		        }
   577 		        }
   533 		    }
   578 		    }
   534     	}
   579     	}
   535     if ( ret == EKeyWasNotConsumed )
   580     if ( ret == EKeyWasNotConsumed )
   536     	{
   581     	{
   537     	CCoeControl* focused = FindFocused();
   582     	CCoeControl* focused = FindFocused();
   538     	if ( focused )
   583     	if ( focused )
   539     		{
   584     		{
   540     		ret = focused->OfferKeyEventL( aKeyEvent, aType );
   585     		ret = focused->OfferKeyEventL( aKeyEvent, aType );
   541     		
   586     		
   542     		if(aType==EEventKeyDown)
   587     		if( aType == EEventKeyDown &&
       
   588     		    aKeyEvent.iScanCode != EStdKeyUpArrow &&
       
   589     		    aKeyEvent.iScanCode != EStdKeyDownArrow )
   543     		    {
   590     		    {
   544     		    doScroll = ETrue; 
   591     		    doScroll = ETrue; 
   545     		    }
   592     		    }
   546     		else 
   593     		else 
   547     		    {
   594     		    {
   561 // ---------------------------------------------------------------------------
   608 // ---------------------------------------------------------------------------
   562 // CNcsHeaderContainer::FindFocused
   609 // CNcsHeaderContainer::FindFocused
   563 // ---------------------------------------------------------------------------
   610 // ---------------------------------------------------------------------------
   564 //
   611 //
   565 CCoeControl* CNcsHeaderContainer::FindFocused() const
   612 CCoeControl* CNcsHeaderContainer::FindFocused() const
   566 	{
   613     {
   567     FUNC_LOG;
   614     FUNC_LOG;
   568 	CCoeControlArray::TCursor cur = Components().Begin();
   615     CCoeControlArray::TCursor cur = Components().Begin();
   569 	do 
   616     do 
   570 		{
   617         {
   571 		if ( cur.Control<CCoeControl>()->IsFocused() )
   618         if ( cur.Control<CCoeControl>()->IsFocused() )
   572 			{
   619             {
   573 			return cur.Control<CCoeControl>();
   620             return cur.Control<CCoeControl>();
   574 			}
   621             }
   575 		} 
   622         } 
   576 	while ( cur.Next() );
   623     while ( cur.Next() );
   577 	return NULL;
   624     return NULL;
   578 	}
   625     }
   579 
   626 
   580 // -----------------------------------------------------------------------------
   627 // -----------------------------------------------------------------------------
   581 // CNcsHeaderContainer::ChangeFocusL()
   628 // CNcsHeaderContainer::ChangeFocusL()
   582 // Handles key events
   629 // Handles key events
   583 // -----------------------------------------------------------------------------
   630 // -----------------------------------------------------------------------------
   584 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent )
   631 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent )
   585 	{
   632     {
   586     FUNC_LOG;
   633     FUNC_LOG;
   587 	ASSERT( aKeyEvent.iCode == EKeyDownArrow || 
   634     ASSERT( aKeyEvent.iCode == EKeyDownArrow || 
   588 	        aKeyEvent.iCode == EKeyUpArrow );
   635             aKeyEvent.iCode == EKeyUpArrow );
   589     TKeyResponse ret( EKeyWasNotConsumed );
   636     TKeyResponse ret( EKeyWasNotConsumed );
   590 
   637 
   591     CCoeControl* pOldCtrl = FindFocused();
   638     CCoeControl* pOldCtrl = FindFocused();
   592 
   639 
   593     // If nothing is focused we return
   640     // If nothing is focused we return
   594     if ( !pOldCtrl ) return ret;
   641     if ( !pOldCtrl ) return ret;
   595     
   642     
   596     //If this is the first control in the list, don't change focus
   643     //If this is the first control in the list, don't change focus
   597     CCoeControlArray::TCursor cur = Components().Find(pOldCtrl);
   644     CCoeControlArray::TCursor cur = Components().Find(pOldCtrl);
   598     if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() )
   645     if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() )
   599     	{
   646         {
   600     	return ret;
   647         return ret;
   601     	}
   648         }
   602     
   649 
   603     // Unfocus the control
   650     // Unfocus the control
   604 	pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   651     pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   605     
   652 
   606 	CCoeControl* pNewCtrl= NULL;
   653     CCoeControl* pNewCtrl= NULL;
   607     if ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) 
   654     if ( ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) ||
   608     	{
   655          ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() ) )
   609 	    pNewCtrl = cur.Control<CCoeControl>();
   656         {
   610 		pNewCtrl->SetFocus( ETrue, ENoDrawNow );
   657         pNewCtrl = cur.Control<CCoeControl>();
       
   658         iFocused = pNewCtrl;
       
   659         pNewCtrl->SetFocus( ETrue, ENoDrawNow );
   611         ret = EKeyWasConsumed;
   660         ret = EKeyWasConsumed;
   612     	}
   661         }
   613     else if ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() )
   662 
   614     	{
   663     CNcsComposeViewContainer* container = 
   615 	    pNewCtrl = cur.Control<CCoeControl>();
       
   616 		pNewCtrl->SetFocus( ETrue, ENoDrawNow );
       
   617         ret = EKeyWasConsumed;
       
   618     	}
       
   619 
       
   620         CNcsComposeViewContainer* container = 
       
   621             static_cast<CNcsComposeViewContainer*>( &iParent );
   664             static_cast<CNcsComposeViewContainer*>( &iParent );
   622     if ( pOldCtrl == iToField )
   665     if ( pOldCtrl == iToField )
   623         {
   666         {
   624         container->CommitL( EToField );
   667         container->CommitL( EToField );
   625         }
   668         }
   633         }
   676         }
   634     else if ( pOldCtrl == iSubjectField)
   677     else if ( pOldCtrl == iSubjectField)
   635         {
   678         {
   636         container->CommitL( ESubjectField );
   679         container->CommitL( ESubjectField );
   637         }
   680         }
   638     
   681 
   639 	// If the attachments label has changed focus
   682     // If the attachments label has changed focus
   640 	if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
   683     if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
   641 		{
   684         {
   642 		DrawAttachmentFocusNow();
   685         DrawAttachmentFocusNow();
   643 		}
   686         }
   644 	
   687 
   645     // if focus was changed, update scroll bar
   688     // if focus was changed, update scroll bar
   646     if ( ret == EKeyWasConsumed )
   689     if ( ret == EKeyWasConsumed )
   647         {
   690         {
   648         container->UpdateScrollBar();
   691         container->UpdateScrollBar();
   649         DoScroll();
   692         DoScroll();
   650         }
   693         }
   651 
   694 
   652 	// NOTE: If we're leaving the header (down was pushed on last control)
   695     // NOTE: If we're leaving the header (down was pushed on last control)
   653 	//       then we return EKeyWasNotConsumed to make sure the
   696     //       then we return EKeyWasNotConsumed to make sure the
   654 	//		 parent moves the focus to the control below this container
   697     //		 parent moves the focus to the control below this container
   655     return ret;
   698     return ret;
   656 	}
   699 	}
   657 
   700 
   658 // -----------------------------------------------------------------------------
   701 // -----------------------------------------------------------------------------
   659 // CNcsHeaderContainer::UpdateFieldPosition()
   702 // CNcsHeaderContainer::UpdateFieldPosition()
   711 // -----------------------------------------------------------------------------
   754 // -----------------------------------------------------------------------------
   712 // CNcsHeaderContainer::SizeChanged()
   755 // CNcsHeaderContainer::SizeChanged()
   713 // set size
   756 // set size
   714 // -----------------------------------------------------------------------------
   757 // -----------------------------------------------------------------------------
   715 void CNcsHeaderContainer::SizeChanged()
   758 void CNcsHeaderContainer::SizeChanged()
   716 	{
   759     {
   717     FUNC_LOG;
   760     FUNC_LOG;
   718 
       
   719     const TRect rect( Rect() );
   761     const TRect rect( Rect() );
   720 
   762 
   721     TInt currentLine( 0 );
   763     TInt currentLine( 0 );
   722     CCoeControlArray::TCursor cur = Components().Begin();
   764     CCoeControlArray::TCursor cur = Components().Begin();
   723     do
   765     do
   731             // during layout (e.g. when orientation is changed => edit field
   773             // during layout (e.g. when orientation is changed => edit field
   732             // length may change => it grows or shrinks)
   774             // length may change => it grows or shrinks)
   733             currentLine += ToNcsControl( cur )->LayoutLineCount();
   775             currentLine += ToNcsControl( cur )->LayoutLineCount();
   734             }
   776             }
   735         } while ( cur.Next() );
   777         } while ( cur.Next() );
   736         
   778 
   737 	if( iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() )
   779     if ( iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() )
   738 		{
   780         {
   739 		iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
   781         iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
   740 		}
   782         }
   741 	}
   783 	}
   742 
   784 
   743 // -----------------------------------------------------------------------------
   785 // -----------------------------------------------------------------------------
   744 // CNcsHeaderContainer::PositionChanged()
   786 // CNcsHeaderContainer::PositionChanged()
   745 // set size
   787 // set size
   797 // ---------------------------------------------------------------------------
   839 // ---------------------------------------------------------------------------
   798 // CNcsHeaderContainer::GetToLineHeight
   840 // CNcsHeaderContainer::GetToLineHeight
   799 // ---------------------------------------------------------------------------
   841 // ---------------------------------------------------------------------------
   800 //
   842 //
   801 TInt CNcsHeaderContainer::GetToLineHeight() const
   843 TInt CNcsHeaderContainer::GetToLineHeight() const
   802 	{
   844     {
   803 	FUNC_LOG;
   845     FUNC_LOG;
   804 	TInt lineHeight = 0;
   846     TInt lineHeight = 0;
   805 	
   847 
   806 	if(iToField)
   848     if ( iToField )
   807 		{
   849         {
   808 	    TRect lineRect;
   850         TRect lineRect;
   809 	    TRAPD(err, iToField->GetLineRectL(lineRect) );
   851         iToField->GetLineRect( lineRect );
   810 	   	if(err == KErrNone)
   852         lineHeight = lineRect.Height();
   811 	        {
   853         }
   812 	        lineHeight = lineRect.iBr.iY - lineRect.iTl.iY;
   854     return lineHeight;
   813 	        }
   855     }
   814 		}
   856 
   815 	return lineHeight;
       
   816 	}
       
   817       
       
   818 // ---------------------------------------------------------------------------
   857 // ---------------------------------------------------------------------------
   819 // CNcsHeaderContainer::GetTotalHeight
   858 // CNcsHeaderContainer::GetTotalHeight
   820 // ---------------------------------------------------------------------------
   859 // ---------------------------------------------------------------------------
   821 //
   860 //
   822 TInt CNcsHeaderContainer::GetTotalHeight() const
   861 TInt CNcsHeaderContainer::GetTotalHeight() const
   880         if ( pOldCtrl )
   919         if ( pOldCtrl )
   881             {
   920             {
   882             pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   921             pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   883             }
   922             }
   884 
   923 
       
   924         iFocused = iAttachmentField;
   885         iAttachmentField->SetFocus( ETrue, ENoDrawNow );
   925         iAttachmentField->SetFocus( ETrue, ENoDrawNow );
   886         iFieldSizeObserver.UpdateFieldPosition( iAttachmentField );
   926         iFieldSizeObserver.UpdateFieldPosition( iAttachmentField );
   887         }
   927         }
   888     }
   928     }
   889 
   929 
   890 // -----------------------------------------------------------------------------
   930 // -----------------------------------------------------------------------------
   891 // CNcsHeaderContainer::HideAttachmentLabel()
   931 // CNcsHeaderContainer::HideAttachmentLabel()
   892 // -----------------------------------------------------------------------------
   932 // -----------------------------------------------------------------------------
   893 //
   933 //
   894 void CNcsHeaderContainer::HideAttachmentLabel()
   934 void CNcsHeaderContainer::HideAttachmentLabel()
   895 	{
   935     {
   896     FUNC_LOG;
   936     FUNC_LOG;
   897 	// check if we are focused and in that case
   937     // check if we are focused and in that case
   898 	// unfocus attachment filed and focus previous control
   938     // unfocus attachment filed and focus previous control
   899     CCoeControl* pOldCtrl = FindFocused();
   939     CCoeControl* pOldCtrl = FindFocused();
   900     CCoeControl* pNewCtrl = NULL;
   940     CCoeControl* pNewCtrl = NULL;
   901     
   941 
   902     if ( pOldCtrl == iAttachmentField )
   942     if ( pOldCtrl == iAttachmentField )
   903         {
   943         {
   904         CCoeControlArray::TCursor cur = Components().Find( pOldCtrl );
   944         CCoeControlArray::TCursor cur = Components().Find( pOldCtrl );
   905 	    pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   945         pOldCtrl->SetFocus( EFalse, ENoDrawNow );
   906 
   946 
   907 	    if ( cur.Prev() )
   947         if ( cur.Prev() )
   908 	        {
   948             {
   909 	        pNewCtrl = cur.Control<CCoeControl>();
   949             pNewCtrl = cur.Control<CCoeControl>();
   910 		    pNewCtrl->SetFocus( ETrue, ENoDrawNow );
   950             iFocused = pNewCtrl;
   911 	        }
   951             pNewCtrl->SetFocus( ETrue, ENoDrawNow );
       
   952             }
   912         }
   953         }
   913     else
   954     else
   914         {
   955         {
   915         pNewCtrl = pOldCtrl; // no need to move focus
   956         pNewCtrl = pOldCtrl; // no need to move focus
   916         }
   957         }
   917 
   958 
   918 	if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
   959     if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
   919 		{
   960         {
   920 		DrawAttachmentFocusNow();
   961         DrawAttachmentFocusNow();
   921 		}
   962         }
   922 
   963 
   923 	iAttachmentField->MakeVisible( EFalse );
   964     iAttachmentField->MakeVisible( EFalse );
   924 	Components().Remove( iAttachmentField );
   965     Components().Remove( iAttachmentField );
   925     
   966     TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
   926 	TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
       
   927 
   967 
   928     // Scroll to currently focused field
   968     // Scroll to currently focused field
   929 	if ( pNewCtrl )
   969     if ( pNewCtrl )
   930 	    {
   970         {
   931 	    iFieldSizeObserver.UpdateFieldPosition( pNewCtrl );
   971         iFieldSizeObserver.UpdateFieldPosition( pNewCtrl );
   932 	    }
   972         }
   933 	
   973 
   934 	}
   974     }
   935 
   975 
   936 // -----------------------------------------------------------------------------
   976 // -----------------------------------------------------------------------------
   937 // CNcsHeaderContainer::SetBccFieldVisibleL()
   977 // CNcsHeaderContainer::SetBccFieldVisibleL()
   938 // -----------------------------------------------------------------------------
   978 // -----------------------------------------------------------------------------
   939 //
   979 //
   940 void CNcsHeaderContainer::SetBccFieldVisibleL( 
   980 void CNcsHeaderContainer::SetBccFieldVisibleL( 
   941         TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
   981         TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
   942     {
   982     {
   943     FUNC_LOG;
   983     FUNC_LOG;
   944 	if ( iBccField->IsVisible() == aVisible )
   984     if ( iBccField->IsVisible() == aVisible )
   945 		{
   985         {
   946 		return;
   986         return;
   947 		}
   987         }
   948 
   988 
   949 	if ( aVisible )
   989     if ( aVisible )
   950 		{
   990         {
   951 		CCoeControlArray::TCursor cur = Components().Find( iSubjectField );
   991         CCoeControlArray::TCursor cur = Components().Find( iSubjectField );
   952 		Components().InsertLC( cur, iBccField );
   992         Components().InsertLC( cur, iBccField );
   953 		CleanupStack::Pop( iBccField );
   993         CleanupStack::Pop( iBccField );
   954 
   994 
   955 		if ( aFocus )
   995         if ( aFocus )
   956 			{
   996             {
   957 			CCoeControl* focused = FindFocused();
   997             CCoeControl* focused = FindFocused();
   958 
   998 
   959 			if ( focused )
   999             if ( focused )
   960 				{
  1000                 {
   961 				focused->SetFocus( EFalse );
  1001                 focused->SetFocus( EFalse, aDrawNow );
   962 				}
  1002                 }
   963 			iBccField->SetFocus( ETrue );
  1003             iBccField->SetFocus( ETrue, aDrawNow );
   964             iFocused = iBccField;
  1004             iFocused = iBccField;
   965 			iBccField->SelectAllTextL();
  1005             iBccField->SelectAllTextL();
   966 			}
  1006             }
   967 		}
  1007         }
   968 	else
  1008     else
   969 		{
  1009         {
   970 		if ( iBccField->IsFocused() )
  1010         if ( iBccField->IsFocused() )
   971 			{
  1011             {
   972 			CCoeControlArray::TCursor cur = Components().Find( iBccField );
  1012             CCoeControlArray::TCursor cur = Components().Find( iBccField );
   973 			ASSERT( cur.IsValid() );
  1013             ASSERT( cur.IsValid() );
   974 			
  1014 
   975 			iBccField->SetFocus( EFalse );
  1015             iBccField->SetFocus( EFalse );
   976 
  1016 
   977 			cur.Prev(); // Get the control before this field
  1017             cur.Prev(); // Get the control before this field
   978 			cur.Control<CCoeControl>()->SetFocus( ETrue );
  1018             CCoeControl* focused = cur.Control<CCoeControl>();
   979 			}
  1019             focused->SetFocus( ETrue );
   980 		Components().Remove( iBccField );
  1020             iFocused = focused;
   981         iFocused = iSubjectField;
  1021             }
   982 		}
  1022         Components().Remove( iBccField );
       
  1023         }
   983 
  1024 
   984     TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
  1025     TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
   985 
  1026 
   986 	if ( aDrawNow == EDrawNow )
  1027     if ( aDrawNow == EDrawNow )
   987 		{
  1028         {
   988 	    DrawDeferred();
  1029         DrawDeferred();
   989 		}
  1030         }
   990 	}
  1031     }
   991 
  1032 
   992 // -----------------------------------------------------------------------------
  1033 // -----------------------------------------------------------------------------
   993 // CNcsHeaderContainer::SetCcFieldVisibleL()
  1034 // CNcsHeaderContainer::SetCcFieldVisibleL()
   994 // -----------------------------------------------------------------------------
  1035 // -----------------------------------------------------------------------------
   995 void CNcsHeaderContainer::SetCcFieldVisibleL( 
  1036 void CNcsHeaderContainer::SetCcFieldVisibleL( 
   996         TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
  1037         TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
   997 	{
  1038     {
   998     FUNC_LOG;
  1039     FUNC_LOG;
   999 	if ( iCcField->IsVisible() == aVisible )
  1040     if ( iCcField->IsVisible() == aVisible )
  1000 		{
  1041         {
  1001 		return;
  1042         return;
  1002 		}
  1043         }
  1003 
  1044 
  1004 	if ( aVisible )
  1045     if ( aVisible )
  1005 		{
  1046         {
  1006 		Components().InsertAfterLC( Components().Id( *iToField ), iCcField );
  1047         Components().InsertAfterLC( Components().Id( *iToField ), iCcField );
  1007 		CleanupStack::Pop( iCcField );
  1048         CleanupStack::Pop( iCcField );
  1008 
  1049 
  1009 		if ( aFocus )
  1050         if ( aFocus )
  1010 			{
  1051             {
  1011 			CCoeControl* focused = FindFocused();
  1052             CCoeControl* focused = FindFocused();
  1012 			if ( focused )
  1053             if ( focused )
  1013 				{
  1054                 {
  1014 				focused->SetFocus( EFalse );
  1055                 focused->SetFocus( EFalse, aDrawNow );
  1015 				}
  1056                 }
  1016 			iCcField->SetFocus( ETrue );
  1057             iCcField->SetFocus( ETrue, aDrawNow );
  1017             iFocused = iCcField;
  1058             iFocused = iCcField;
  1018 			iCcField->SelectAllTextL();
  1059             iCcField->SelectAllTextL();
  1019 			}
  1060             }
  1020 		}
  1061         }
  1021 	else
  1062     else
  1022 		{
  1063         {
  1023 		if( iCcField->IsFocused() )
  1064         if( iCcField->IsFocused() )
  1024 			{
  1065             {
  1025 			iCcField->SetFocus( EFalse );
  1066             iCcField->SetFocus( EFalse );
  1026 			iToField->SetFocus( ETrue );
  1067             iToField->SetFocus( ETrue );
  1027 			}
  1068             iFocused = iToField;
  1028 		Components().Remove( iCcField );
  1069             }
  1029         iFocused = iToField;
  1070         Components().Remove( iCcField );
  1030 		}
  1071         }
  1031     
  1072 
  1032 	TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
  1073     TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
  1033 
  1074 
  1034     if ( aDrawNow == EDrawNow )
  1075     if ( aDrawNow == EDrawNow )
  1035 		{
  1076         {
  1036 	    DrawDeferred();
  1077         DrawDeferred();
  1037 		}
  1078         }
  1038     }
  1079     }
  1039 
  1080 
  1040 // -----------------------------------------------------------------------------
  1081 // -----------------------------------------------------------------------------
  1041 // CNcsHeaderContainer::MopSupplyObject
  1082 // CNcsHeaderContainer::MopSupplyObject
  1042 // From CCoeControl.
  1083 // From CCoeControl.
  1155 // CNcsHeaderContainer::UpdatePopupContactListL()
  1196 // CNcsHeaderContainer::UpdatePopupContactListL()
  1156 // -----------------------------------------------------------------------------
  1197 // -----------------------------------------------------------------------------
  1157 //
  1198 //
  1158 void CNcsHeaderContainer::UpdatePopupContactListL( 
  1199 void CNcsHeaderContainer::UpdatePopupContactListL( 
  1159         const TDesC& aMatchString, TBool /*aListAll*/ )
  1200         const TDesC& aMatchString, TBool /*aListAll*/ )
  1160 	{
  1201     {
  1161     FUNC_LOG;
  1202     FUNC_LOG;
  1162 
  1203 
  1163     // do update only for address fields
  1204     // do update only for address fields
  1164 	CCoeControl* focused = FindFocused();
  1205     CCoeControl* focused = FindFocused();
  1165 	
  1206 
  1166 	if ( !IsAddressInputField( focused ) )
  1207     if ( !IsAddressInputField( focused ) )
  1167 	    {
  1208         {
  1168 	    return;
  1209         return;
  1169 	    }
  1210         }
  1170 	    
  1211 
  1171 	if ( aMatchString.CompareC( KNullDesC ) == 0 || 
  1212     if ( aMatchString.CompareC( KNullDesC ) == 0 || 
  1172 	     aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 )
  1213             aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 )
  1173 		{
  1214         {
  1174 		ClosePopupContactListL();
  1215         ClosePopupContactListL();
  1175 		return;
  1216         return;
  1176 		}
  1217         }
  1177 	
  1218 
  1178 	if( !iAacListBox->IsVisible() )
  1219     if( !iAacListBox->IsVisible() )
  1179 		{
  1220         {
  1180         iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
  1221         iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
  1181         iAacListBox->InitAndSearchL( aMatchString, 1 );
  1222         iAacListBox->InitAndSearchL( aMatchString, 1 );
  1182         iAacListBox->ActivateL();
  1223         iAacListBox->ActivateL();
  1183 		}
  1224         }
  1184 	else
  1225     else
  1185 		{
  1226         {
  1186 		iAacListBox->SetSearchTextL( aMatchString );
  1227         iAacListBox->SetSearchTextL( aMatchString );
  1187 		}
  1228         }
  1188 	}
  1229     }
  1189 
  1230 
  1190 // -----------------------------------------------------------------------------
  1231 // -----------------------------------------------------------------------------
  1191 // CNcsHeaderContainer::ClosePopupContactListL()
  1232 // CNcsHeaderContainer::ClosePopupContactListL()
  1192 // -----------------------------------------------------------------------------
  1233 // -----------------------------------------------------------------------------
  1193 //
  1234 //
  1194 void CNcsHeaderContainer::ClosePopupContactListL()
  1235 void CNcsHeaderContainer::ClosePopupContactListL()
  1195 	{
  1236     {
  1196     FUNC_LOG;
  1237     FUNC_LOG;
  1197 
       
  1198     if ( iAacListBox->IsVisible() )
  1238     if ( iAacListBox->IsVisible() )
  1199         {
  1239         {
  1200         iAacListBox->MakeVisible( EFalse );
  1240         iAacListBox->ClosePopupL();
  1201         ShowPopupMenuBarL( EFalse );
  1241         }
  1202         
  1242 
  1203         // The focused address field should be redrawn after the popup is
  1243     // The focused address field should be redrawn after the popup is
  1204         // closed to fix the field border.
  1244     // closed to fix the field border.
  1205         if ( iToField->IsFocused() )
  1245     if ( iToField->IsFocused() )
  1206             {
  1246         {
  1207             iToField->DrawDeferred();
  1247         iToField->DrawDeferred();
  1208             }
  1248         }
  1209         else if ( iCcField->IsFocused() )
  1249     else if ( iCcField->IsFocused() )
  1210             {
  1250         {
  1211             iCcField->DrawDeferred();
  1251         iCcField->DrawDeferred();
  1212             }
  1252         }
  1213         else if ( iBccField->IsFocused() )
  1253     else if ( iBccField->IsFocused() )
  1214             {
  1254         {
  1215             iBccField->DrawDeferred();
  1255         iBccField->DrawDeferred();
  1216             }
  1256         }
  1217         }
  1257     }
  1218 	}
       
  1219 
  1258 
  1220 // ---------------------------------------------------------------------------
  1259 // ---------------------------------------------------------------------------
  1221 // CNcsHeaderContainer::ShowPopupMenuBarL
  1260 // CNcsHeaderContainer::ShowPopupMenuBarL
  1222 // ---------------------------------------------------------------------------
  1261 // ---------------------------------------------------------------------------
  1223 //
  1262 //
  1301 	{
  1340 	{
  1302     FUNC_LOG;
  1341     FUNC_LOG;
  1303 	iSubjectField->SelectAllTextL();
  1342 	iSubjectField->SelectAllTextL();
  1304 	}
  1343 	}
  1305 
  1344 
  1306 // -----------------------------------------------------------------------------
  1345 // ---------------------------------------------------------------------------
  1307 // CNcsHeaderContainer::CalculatePopupRect
  1346 // CNcsHeaderContainer::CalculatePopupRect
  1308 // -----------------------------------------------------------------------------
  1347 // ---------------------------------------------------------------------------
       
  1348 //
  1309 TRect CNcsHeaderContainer::CalculatePopupRect()
  1349 TRect CNcsHeaderContainer::CalculatePopupRect()
  1310     {
  1350     {
  1311     FUNC_LOG;
  1351     FUNC_LOG;
  1312     // get focused control rect
  1352     // get focused control rect
  1313     TRect popupRect;
  1353     TRect popupRect;
  1319             static_cast<CNcsAddressInputField*>( focused );
  1359             static_cast<CNcsAddressInputField*>( focused );
  1320 
  1360 
  1321         TPoint editorPos = aifEditor->Editor()->PositionRelativeToScreen();
  1361         TPoint editorPos = aifEditor->Editor()->PositionRelativeToScreen();
  1322         TRect editorRect = aifEditor->Editor()->Rect();
  1362         TRect editorRect = aifEditor->Editor()->Rect();
  1323 
  1363 
  1324         popupRect.iTl = TPoint( editorPos.iX, 
  1364         // When layouts are available we'll use them. Until that these are now
  1325             editorPos.iY + aifEditor->CursorPosition() + 1 );
  1365         // hardcoded!
  1326 
  1366         TInt tlXPos = 3;
  1327         popupRect.iBr = TPoint( editorPos.iX + editorRect.Width(),
  1367         TInt tlYPos = editorPos.iY + aifEditor->CursorPosition() + 1;
       
  1368         
       
  1369         if ( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  1370              iSplitScreenVKBEnabled )
       
  1371             {
       
  1372             tlXPos = iAvkonAppUi->ApplicationRect().Width() / 2;
       
  1373             tlYPos = 3;
       
  1374             }
       
  1375         
       
  1376         popupRect.iTl = TPoint( tlXPos, tlYPos );
       
  1377 
       
  1378         
       
  1379         popupRect.iBr = TPoint( iAvkonAppUi->ApplicationRect().iBr.iX  - 3,
  1328             iParent.PositionRelativeToScreen().iY + iParent.Rect().Height() );
  1380             iParent.PositionRelativeToScreen().iY + iParent.Rect().Height() );
  1329         }
  1381         }
  1330 
  1382 
  1331     return popupRect;
  1383     return popupRect;
  1332     }
  1384     }
  1338 	{
  1390 	{
  1339     FUNC_LOG;
  1391     FUNC_LOG;
  1340     __ASSERT_DEBUG( iAacListBox, Panic( ENcsBasicUi ) );
  1392     __ASSERT_DEBUG( iAacListBox, Panic( ENcsBasicUi ) );
  1341     __ASSERT_DEBUG( &iMailBox, Panic( ENcsBasicUi ) );
  1393     __ASSERT_DEBUG( &iMailBox, Panic( ENcsBasicUi ) );
  1342 
  1394 
  1343 	if( iAacListBox->IsRemoteLookupItemSelected() )
  1395 	if ( iAacListBox->IsRemoteLookupItemSelected() )
  1344 		{
  1396 		{
  1345 		CCoeControl* focused = FindFocused();
  1397 		CCoeControl* focused = FindFocused();
  1346 		
  1398 		
  1347 		if ( IsAddressInputField( focused ) )
  1399 		if ( IsAddressInputField( focused ) )
  1348 		    {
  1400 		    {
  1868     FUNC_LOG;
  1920     FUNC_LOG;
  1869     TInt totalLineCount( 0 );
  1921     TInt totalLineCount( 0 );
  1870     CCoeControlArray::TCursor cur = Components().Begin();
  1922     CCoeControlArray::TCursor cur = Components().Begin();
  1871     do
  1923     do
  1872         {
  1924         {
  1873         totalLineCount += ToNcsControl( cur )->LayoutLineCount();                       
  1925         totalLineCount += ToNcsControl( cur )->LayoutLineCount();
  1874         } 
  1926         } 
  1875     while ( cur.Next() );
  1927     while ( cur.Next() );
  1876     
  1928     
  1877     return totalLineCount;
  1929     return totalLineCount;
  1878     }
  1930     }
  1879 
  1931 
  1880 
       
  1881 // ---------------------------------------------------------------------------
  1932 // ---------------------------------------------------------------------------
  1882 // CNcsHeaderContainer::IsAddressInputField
  1933 // CNcsHeaderContainer::IsAddressInputField
  1883 // ---------------------------------------------------------------------------
  1934 // ---------------------------------------------------------------------------
  1884 //
  1935 //
  1885 TBool CNcsHeaderContainer::IsAddressInputField(
  1936 TBool CNcsHeaderContainer::IsAddressInputField(
  1979         static_cast<CNcsComposeViewContainer*>( &iParent );
  2030         static_cast<CNcsComposeViewContainer*>( &iParent );
  1980     container->AppendAddressesL();
  2031     container->AppendAddressesL();
  1981     }
  2032     }
  1982 
  2033 
  1983 void CNcsHeaderContainer::FixSemicolonInAddressFieldsL()
  2034 void CNcsHeaderContainer::FixSemicolonInAddressFieldsL()
  1984 	{
  2035     {
  1985 		iToField->FixSemicolonAtTheEndL();
  2036     iToField->FixSemicolonAtTheEndL();
  1986 		iCcField->FixSemicolonAtTheEndL();
  2037     iCcField->FixSemicolonAtTheEndL();
  1987 		iBccField->FixSemicolonAtTheEndL();
  2038     iBccField->FixSemicolonAtTheEndL();
  1988 	}
  2039     }
  1989 
  2040 
  1990 TBool CNcsHeaderContainer::IsRemoteSearchInprogress() const
  2041 TBool CNcsHeaderContainer::IsRemoteSearchInprogress() const
  1991     {
  2042     {
  1992     return iRALInProgress;
  2043     return iRALInProgress;
  1993     }
  2044     }
  2020             container->CommitL( ESubjectField );
  2071             container->CommitL( ESubjectField );
  2021             }
  2072             }
  2022         }
  2073         }
  2023     }
  2074     }
  2024 
  2075 
  2025 // -----------------------------------------------------------------------------
  2076 // ---------------------------------------------------------------------------
  2026 // CNcsHeaderContainer::DoScroll
  2077 // Scrolls editor to make cursor visible, if it is outside the visible area
  2027 // -----------------------------------------------------------------------------
  2078 // ---------------------------------------------------------------------------
  2028 // 
  2079 // 
  2029 void CNcsHeaderContainer::DoScroll()
  2080 void CNcsHeaderContainer::DoScroll()
  2030     {
  2081     {
  2031     // scroll the screen if the cursor goes beyond the screen
  2082     // scroll the screen if the cursor goes beyond the screen
  2032     CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
  2083     CNcsComposeViewContainer& parent = 
  2033     
  2084         static_cast<CNcsComposeViewContainer&>( iParent );
  2034     TInt screenPos( -Position().iY );
  2085 
  2035     TInt cursorPos( CursorPosition() );
  2086     // Scrolling based on cursor line number can only be done when
  2036     TInt lineHeight( Rect().Height() / LineCount() );
  2087     // header composer and one of its fields is focused.
  2037     TInt screenHeight( parent.Rect().Height() );
  2088     if ( IsFocused() )
  2038 
  2089         {
  2039     if ( cursorPos - lineHeight < screenPos )
  2090         const TRect rect = Rect();
  2040         {
  2091         const TInt screenPos =  iOrigin.iY - rect.iTl.iY;
  2041         screenPos = cursorPos - lineHeight;             
  2092         const TInt screenHeight = parent.VisibleAreaHeight();
  2042         }
  2093 
  2043     else if( cursorPos + lineHeight > screenPos + screenHeight )
  2094         const TInt lineNumber = CursorLineNumber();
  2044         {
  2095         const TInt lineHeight = rect.Height() / LineCount();
  2045         screenPos = cursorPos + lineHeight - screenHeight;
  2096         const TInt linePos = lineNumber * lineHeight;
  2046         }
  2097 
  2047 
  2098         TInt targetPos = screenPos;
  2048     parent.Scroll( screenPos );
  2099         if ( linePos - lineHeight < screenPos )
       
  2100             {
       
  2101             targetPos = linePos - lineHeight;
       
  2102             }
       
  2103         else if ( linePos + lineHeight > screenPos + screenHeight )
       
  2104             {
       
  2105             targetPos = linePos + lineHeight - screenHeight;
       
  2106             }
       
  2107 
       
  2108         parent.Scroll( targetPos );
       
  2109         }
       
  2110     }
       
  2111 
       
  2112 // ---------------------------------------------------------------------------
       
  2113 // Scrolls focused editor line to the top of visible area.
       
  2114 // ---------------------------------------------------------------------------
       
  2115 //
       
  2116 void CNcsHeaderContainer::DoScrollFocusToTop()
       
  2117     {
       
  2118     CNcsComposeViewContainer& parent =
       
  2119         static_cast<CNcsComposeViewContainer&>( iParent );
       
  2120 
       
  2121     // Calculate the position of the focused editor line.
       
  2122     const TRect rect = Rect();
       
  2123     const TInt lineNumber = CursorLineNumber();
       
  2124     const TInt lineHeight = rect.Height() / LineCount();
       
  2125     const TInt targetPos = ( lineNumber - 1 ) * lineHeight;
       
  2126 
       
  2127     parent.Scroll( targetPos );
  2049     }
  2128     }
  2050 
  2129 
  2051 // ---------------------------------------------------------------------------
  2130 // ---------------------------------------------------------------------------
  2052 // CNcsHeaderContainer::SetPhysicsEmulationOngoing
  2131 // CNcsHeaderContainer::SetPhysicsEmulationOngoing
  2053 // ---------------------------------------------------------------------------
  2132 // ---------------------------------------------------------------------------
  2057     iToField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2136     iToField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2058     iCcField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2137     iCcField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2059     iBccField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2138     iBccField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2060     iSubjectField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2139     iSubjectField->SetPhysicsEmulationOngoing( aPhysOngoing );
  2061     }
  2140     }
       
  2141 
       
  2142 // ---------------------------------------------------------------------------
       
  2143 // CNcsHeaderContainer::HandleResourceChange
       
  2144 // ---------------------------------------------------------------------------
       
  2145 //
       
  2146 void CNcsHeaderContainer::HandleResourceChange( TInt aType )
       
  2147     {
       
  2148     FUNC_LOG;
       
  2149     CCoeControl::HandleResourceChange( aType );
       
  2150     if ( aType == KAknSplitInputEnabled || aType == KAknSplitInputDisabled )
       
  2151         {
       
  2152         iSplitScreenVKBEnabled = ( aType == KAknSplitInputEnabled );
       
  2153         if ( iAacListBox->IsVisible() )
       
  2154             {
       
  2155             iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
       
  2156             }
       
  2157         }
       
  2158     }
       
  2159 
       
  2160 // ---------------------------------------------------------------------------
       
  2161 // Set origin for header's top position.
       
  2162 // ---------------------------------------------------------------------------
       
  2163 //
       
  2164 void CNcsHeaderContainer::SetOrigin( TPoint& aOrigin )
       
  2165     {
       
  2166     iOrigin = aOrigin;
       
  2167     }
       
  2168