emailuis/emailui/src/ncsheadercontainer.cpp
branchRCL_3
changeset 34 cd2816114bd1
parent 33 da5135c61bad
child 19 b13141f05c3d
equal deleted inserted replaced
33:da5135c61bad 34:cd2816114bd1
    20 #include "emailtrace.h"
    20 #include "emailtrace.h"
    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 
    26 
    26 #include "cfsmailbox.h"
    27 #include "cfsmailbox.h"
    27 #include <FreestyleEmailUi.rsg>
    28 #include <FreestyleEmailUi.rsg>
    28 
    29 
    29 #include "FSEmailBuildFlags.h"
    30 #include "FSEmailBuildFlags.h"
    55 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    56 // CNcsHeaderContainer::NewL
    57 // CNcsHeaderContainer::NewL
    57 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    58 //
    59 //
    59 CNcsHeaderContainer* CNcsHeaderContainer::NewL( CCoeControl& aParent, 
    60 CNcsHeaderContainer* CNcsHeaderContainer::NewL( CCoeControl& aParent, 
    60     CFSMailBox& aMailBox, TInt aFlags )
    61     CFSMailBox& aMailBox, TInt aFlags, CAknPhysics* aPhysics )
    61     {
    62     {
    62     FUNC_LOG;
    63     FUNC_LOG;
    63     CNcsHeaderContainer* self = 
    64     CNcsHeaderContainer* self = 
    64         new ( ELeave ) CNcsHeaderContainer( aParent, aMailBox );
    65         new ( ELeave ) CNcsHeaderContainer( aParent, aMailBox, aPhysics );
    65     CleanupStack::PushL( self );
    66     CleanupStack::PushL( self );
    66     self->ConstructL( aFlags );
    67     self->ConstructL( aFlags );
    67     CleanupStack::Pop( self );
    68     CleanupStack::Pop( self );
    68     return self;
    69     return self;
    69     }
    70     }
    72 // CNcsHeaderContainer::CNcsHeaderContainer
    73 // CNcsHeaderContainer::CNcsHeaderContainer
    73 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    74 //
    75 //
    75 CNcsHeaderContainer::CNcsHeaderContainer(
    76 CNcsHeaderContainer::CNcsHeaderContainer(
    76 	CCoeControl& aParent, 
    77 	CCoeControl& aParent, 
    77 	CFSMailBox& aMailBox ): 
    78 	CFSMailBox& aMailBox,
       
    79 	CAknPhysics* aPhysics ): 
    78 	iParent( aParent ),
    80 	iParent( aParent ),
    79 	iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ),
    81 	iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ),
    80 	iMailBox( aMailBox ),
    82 	iMailBox( aMailBox ),
    81 	iLongTapEventConsumed( EFalse )
    83 	iLongTapEventConsumed( EFalse ),
       
    84     iPhysics( aPhysics )
    82 	{
    85 	{
    83     FUNC_LOG;
    86     FUNC_LOG;
    84 	}
    87 	}
    85 
    88 
    86 // ---------------------------------------------------------------------------
    89 // ---------------------------------------------------------------------------
   169 
   172 
   170     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   173     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   171         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
   174         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
   172 
   175 
   173     iRALInProgress = EFalse;
   176     iRALInProgress = EFalse;
       
   177 
       
   178     iToField->EnableKineticScrollingL( iPhysics );
       
   179     iCcField->EnableKineticScrollingL( iPhysics );
       
   180     iBccField->EnableKineticScrollingL( iPhysics );
       
   181     iSubjectField->EnableKineticScrollingL( iPhysics );
   174 	}
   182 	}
   175 
   183 
   176 // ---------------------------------------------------------------------------
   184 // ---------------------------------------------------------------------------
   177 // CNcsHeaderContainer::~CNcsHeaderContainer
   185 // CNcsHeaderContainer::~CNcsHeaderContainer
   178 // ---------------------------------------------------------------------------
   186 // ---------------------------------------------------------------------------
   233 
   241 
   234 // ---------------------------------------------------------------------------
   242 // ---------------------------------------------------------------------------
   235 // CNcsHeaderContainer::ShowCursor
   243 // CNcsHeaderContainer::ShowCursor
   236 // ---------------------------------------------------------------------------
   244 // ---------------------------------------------------------------------------
   237 //
   245 //
   238 void CNcsHeaderContainer::ShowCursor( TBool aShow )
   246 void CNcsHeaderContainer::ShowCursor( TBool aShow, TDrawNow aDrawNow )
   239     {
   247     {
   240     CCoeControl* focused = FindFocused();
   248     CCoeControl* focused = FindFocused();
   241     if ( focused )
   249     if ( focused )
   242         {
   250         {
   243         iFocused = focused;
   251         iFocused = focused;
   244         }
   252         }
   245     if ( iFocused ) 
   253     if ( iFocused ) 
   246         {
   254         {
   247         iFocused->SetFocus( aShow, EDrawNow );
   255         iFocused->SetFocus( aShow, aDrawNow );
   248         }
   256         }
   249     }
   257     }
   250 
   258 
   251 // -----------------------------------------------------------------------------
   259 // -----------------------------------------------------------------------------
   252 // CNcsHeaderContainer::Draw() const
   260 // CNcsHeaderContainer::Draw() const
   305 	}
   313 	}
   306 
   314 
   307 void CNcsHeaderContainer::SetMskL()
   315 void CNcsHeaderContainer::SetMskL()
   308     {
   316     {
   309     FUNC_LOG;
   317     FUNC_LOG;
       
   318 
       
   319     // msk change disabled - probably some dialog/popup is visible
       
   320     if( iSwitchChangeMskOff )
       
   321         {
       
   322         return;
       
   323         }
       
   324 
   310     CCoeControl* focused = FindFocused();
   325     CCoeControl* focused = FindFocused();
   311     if ( focused == iToField || focused == iCcField || focused == iBccField )
   326     if ( focused == iToField || focused == iCcField || focused == iBccField )
   312         {
   327         {
   313         if( iSwitchChangeMskOff == EFalse )
   328         ChangeMskCommandL( R_FSE_QTN_MSK_ADD );
       
   329         }
       
   330     else if ( focused == iAttachmentField ) 
       
   331         {
       
   332         if ( GetAttachmentCount() > 1 )
   314             {
   333             {
   315             ChangeMskCommandL( R_FSE_QTN_MSK_ADD );
   334             ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENTS );
   316             }
   335             }
   317         }
   336         else if ( !HasRemoteAttachments() )
   318     else if ( focused == iAttachmentField ) 
   337             {
   319         {
   338             ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENT );
   320             if ( GetAttachmentCount() > 1 )
   339             }
   321                 {
   340         else // message has single remote attachment => no MSK function
   322             ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENTS );
   341             {
   323                 }
       
   324             else if ( !HasRemoteAttachments() )
       
   325                 {
       
   326             ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENT );                
       
   327                 }
       
   328             else // message has single remote attachment => no MSK function
       
   329                 {
       
   330             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
   342             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
   331             }
   343             }
   332         }
   344         }
   333     else if ( focused == iSubjectField )
   345     else if ( focused == iSubjectField )
   334         {
   346         {
   335         ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );       
   347         ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
   336         }
   348         }
   337     else 
   349     else 
   338         {
   350         {
   339         ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
   351         ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
   340         }
   352         }
   346 // -----------------------------------------------------------------------------
   358 // -----------------------------------------------------------------------------
   347 void CNcsHeaderContainer::HandlePointerEventL( 
   359 void CNcsHeaderContainer::HandlePointerEventL( 
   348         const TPointerEvent& aPointerEvent )
   360         const TPointerEvent& aPointerEvent )
   349     {
   361     {
   350 	FUNC_LOG;
   362 	FUNC_LOG;
   351 	CCoeControl* clicked = 0;
   363     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   352     for ( TInt i=0; i < Components().Count(); ++i )
   364         {
   353         {
   365 		CCoeControl* clicked = 0;
   354         TRect rc = Components().At( i ).iControl->Rect();
   366 		for ( TInt i=0; i < Components().Count(); ++i )
   355         if ( rc.Contains( aPointerEvent.iPosition ) )
   367 			{
   356             {
   368 			TRect rc = Components().At( i ).iControl->Rect();
   357             clicked = Components().At( i ).iControl;
   369 			if ( rc.Contains( aPointerEvent.iPosition ) )
       
   370 				{
       
   371 				clicked = Components().At( i ).iControl;
       
   372 				}
       
   373 			}
       
   374 
       
   375 	    if ( clicked )
       
   376 	        {
       
   377 			CCoeControl* pOldCtrl = FindFocused();
       
   378 			CCoeControl* pNewCtrl= clicked;
       
   379 			
       
   380 			if ( pOldCtrl != pNewCtrl )
       
   381 				{
       
   382 				// Unfocus the control
       
   383 				if ( pOldCtrl )
       
   384 					{
       
   385 					pOldCtrl->SetFocus( EFalse, ENoDrawNow );
       
   386 					}
       
   387 				pNewCtrl->SetFocus( ETrue, ENoDrawNow );
       
   388 				iFocused = pNewCtrl;
       
   389 				// Commit changes to previously focused field.
       
   390 				if ( pOldCtrl )
       
   391 					{
       
   392 					CommitFieldL( pOldCtrl );
       
   393 					}
       
   394 
       
   395 				// If the attachments label has changed focus
       
   396 				if ( pOldCtrl == iAttachmentField || 
       
   397 					 pNewCtrl == iAttachmentField )
       
   398 					{
       
   399 					DrawAttachmentFocusNow();
       
   400 					}
       
   401 				
       
   402 				CNcsComposeViewContainer* container = 
       
   403 					static_cast<CNcsComposeViewContainer*>( &iParent );
       
   404 				container->UpdateScrollBarL();
       
   405 				}
       
   406 			
       
   407 			if( iLongTapEventConsumed )
       
   408 				{
       
   409 				iLongTapEventConsumed = EFalse;
       
   410 				return;
       
   411 				}        
       
   412 
       
   413 			TBool physicsActionOngoing( EFalse );
       
   414 			if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone )
       
   415 			{
       
   416                 physicsActionOngoing = ETrue;
   358             }
   417             }
   359         }
   418 			
   360     if ( clicked )
   419 			if( pNewCtrl == iAttachmentField && !physicsActionOngoing )
   361         {
   420 				{
   362         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   363             {
       
   364             CCoeControl* pOldCtrl = FindFocused();
       
   365             CCoeControl* pNewCtrl= clicked;
       
   366             
       
   367             if ( pOldCtrl != pNewCtrl )
       
   368                 {
       
   369                 // Unfocus the control
       
   370                 if ( pOldCtrl )
       
   371                     {
       
   372                     pOldCtrl->SetFocus( EFalse, ENoDrawNow );
       
   373                     }
       
   374                 pNewCtrl->SetFocus( ETrue, ENoDrawNow );
       
   375                 iFocused = pNewCtrl;
       
   376                 // Commit changes to previously focused field.
       
   377                 if ( pOldCtrl )
       
   378                     {
       
   379                     CommitFieldL( pOldCtrl );
       
   380                     }
       
   381 
       
   382                 // If the attachments label has changed focus
       
   383                 if ( pOldCtrl == iAttachmentField || 
       
   384                      pNewCtrl == iAttachmentField )
       
   385                     {
       
   386                     DrawAttachmentFocusNow();
       
   387                     }
       
   388                 
       
   389                 CNcsComposeViewContainer* container = 
       
   390                     static_cast<CNcsComposeViewContainer*>( &iParent );
       
   391                 container->UpdateScrollBarL();
       
   392                 }
       
   393             
       
   394             if( iLongTapEventConsumed )
       
   395         		{
       
   396         		iLongTapEventConsumed = EFalse;
       
   397         		return;
       
   398         		}        	
       
   399             
       
   400             if( pNewCtrl == iAttachmentField )
       
   401             	{
       
   402 				CNcsComposeViewContainer& parent = 
   421 				CNcsComposeViewContainer& parent = 
   403                     static_cast<CNcsComposeViewContainer&>( iParent );
   422 					static_cast<CNcsComposeViewContainer&>( iParent );
   404 				parent.HandleAttachmentsOpenCommandL();
   423 				parent.HandleAttachmentsOpenCommandL();
   405             	}          
   424 				}          
   406             }
   425 	        }
   407         }
   426         }
   408     for ( TInt i=0; i < Components().Count(); ++i )
   427 
   409         {
   428     if ( aPointerEvent.iType != TPointerEvent::EDrag )
   410         Components().At( i ).iControl->HandlePointerEventL( aPointerEvent );
   429     	{
   411         }
   430 		CCoeControl::HandlePointerEventL( aPointerEvent );
       
   431     	}
   412     }
   432     }
   413 
   433 
   414 // -----------------------------------------------------------------------------
   434 // -----------------------------------------------------------------------------
   415 // CNcsHeaderContainer::HandleLongTapL()
   435 // CNcsHeaderContainer::HandleLongTapL()
   416 // 
   436 // 
   669 		SizeChanged();
   689 		SizeChanged();
   670 		return;
   690 		return;
   671 		}
   691 		}
   672 	
   692 	
   673 	CCoeControlArray::TCursor cur = Components().Find( aAnchor );
   693 	CCoeControlArray::TCursor cur = Components().Find( aAnchor );
   674 	ASSERT( cur.IsValid() );
       
   675 
       
   676 	// figure out the new top position of the container
   694 	// figure out the new top position of the container
   677 	TInt top = aAnchor->Rect().iTl.iY;
   695 	TInt top = aAnchor->Rect().iTl.iY;
   678 	while ( cur.Prev() )
   696         if( cur.IsValid() )
   679 		{
   697 		{
   680 		CCoeControl* ctrl = cur.Control<CCoeControl>();
   698 	    while ( cur.Prev() )
   681 		top -= ctrl->Rect().Height();
   699 	    	{
   682 		}
   700 		    CCoeControl* ctrl = cur.Control<CCoeControl>();
   683 
   701 		    top -= ctrl->Rect().Height();
       
   702 		    }
       
   703 		}
   684 	// Then check we didn't move too much and composer still fills the whole
   704 	// Then check we didn't move too much and composer still fills the whole
   685 	// visible area on the screen (i.e. don't scroll below the bottom of the
   705 	// visible area on the screen (i.e. don't scroll below the bottom of the
   686 	// body field)
   706 	// body field)
   687 	CNcsComposeViewContainer& parent = 
   707 	CNcsComposeViewContainer& parent = 
   688         static_cast<CNcsComposeViewContainer&>( iParent );
   708         static_cast<CNcsComposeViewContainer&>( iParent );
  1838     {
  1858     {
  1839     FUNC_LOG;
  1859     FUNC_LOG;
  1840     }
  1860     }
  1841 
  1861 
  1842 // ---------------------------------------------------------------------------
  1862 // ---------------------------------------------------------------------------
       
  1863 // CNcsHeaderContainer::HandleSkinChangeL
       
  1864 // ---------------------------------------------------------------------------
       
  1865 //
       
  1866 void CNcsHeaderContainer::HandleSkinChangeL()
       
  1867     {
       
  1868     FUNC_LOG;
       
  1869     if ( iAacListBox )
       
  1870         {
       
  1871         iAacListBox->HandleResourceChange( KAknsMessageSkinChange );
       
  1872         }
       
  1873     }
       
  1874 
       
  1875 // ---------------------------------------------------------------------------
  1843 // CNcsHeaderContainer::LayoutLineCount
  1876 // CNcsHeaderContainer::LayoutLineCount
  1844 // ---------------------------------------------------------------------------
  1877 // ---------------------------------------------------------------------------
  1845 //
  1878 //
  1846 TInt CNcsHeaderContainer::LayoutLineCount() const
  1879 TInt CNcsHeaderContainer::LayoutLineCount() const
  1847     {
  1880     {