emailuis/emailui/src/ncscomposeviewcontainer.cpp
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 3 a4d6f1ea0416
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
    73 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    74 // CNcsComposeViewContainer::NewL()
    74 // CNcsComposeViewContainer::NewL()
    75 // Two-phased constructor.
    75 // Two-phased constructor.
    76 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    77 //
    77 //
    78 CNcsComposeViewContainer* CNcsComposeViewContainer::NewL( CNcsComposeView& aView,
    78 CNcsComposeViewContainer* CNcsComposeViewContainer::NewL( 
    79     const TRect& aRect, CFSMailBox& aMailBox, CFsAutoSaver& aAutoSaver,
    79     CNcsComposeView& aView, const TRect& aRect, CFSMailBox& aMailBox, 
    80     TInt aFlags )
    80     CFsAutoSaver& aAutoSaver, TInt aFlags )
    81     {
    81     {
    82     FUNC_LOG;
    82     FUNC_LOG;
    83 
    83 
    84     CNcsComposeViewContainer* self = new ( ELeave ) CNcsComposeViewContainer(
    84     CNcsComposeViewContainer* self = new ( ELeave ) CNcsComposeViewContainer(
    85         aView, aAutoSaver, aMailBox );
    85         aView, aAutoSaver, aMailBox );
    99     {
    99     {
   100     FUNC_LOG;
   100     FUNC_LOG;
   101 
   101 
   102     SetMopParent( &iView );
   102     SetMopParent( &iView );
   103     CreateWindowL();
   103     CreateWindowL();
   104 	// <cmail>
       
   105     // iApplicationRect = aRect;
       
   106 	// </cmail>
       
   107 
   104 
   108     // Setup the control array
   105     // Setup the control array
   109     InitComponentArrayL();
   106     InitComponentArrayL();
   110     CCoeControlArray& controls = Components();
   107     CCoeControlArray& controls = Components();
   111     controls.SetControlsOwnedExternally( ETrue );
   108     controls.SetControlsOwnedExternally( ETrue );
   122     iMessageField->SetAlignment( EAknEditorAlignBidi );
   119     iMessageField->SetAlignment( EAknEditorAlignBidi );
   123     iMessageField->SetAknEditorInputMode( EAknEditorTextInputMode );
   120     iMessageField->SetAknEditorInputMode( EAknEditorTextInputMode );
   124     controls.AppendLC( iMessageField );
   121     controls.AppendLC( iMessageField );
   125     CleanupStack::Pop( iMessageField );
   122     CleanupStack::Pop( iMessageField );
   126 
   123 
   127     // <cmail> Platform layout change
       
   128     iMessageField->SetNcsFontType( NcsUtility::ENcsBodytextFont );
   124     iMessageField->SetNcsFontType( NcsUtility::ENcsBodytextFont );
   129     // </cmail>
       
   130 
   125 
   131     // Listen edwin events and size events from message body field
   126     // Listen edwin events and size events from message body field
   132     iMessageField->AddEdwinObserverL( this );
   127     iMessageField->AddEdwinObserverL( this );
   133     iMessageField->SetEdwinSizeObserver( this );
   128     iMessageField->SetEdwinSizeObserver( this );
   134 
   129 
   146     iReadOnlyQuoteField->AddEdwinObserverL( this );
   141     iReadOnlyQuoteField->AddEdwinObserverL( this );
   147     iReadOnlyQuoteField->SetEdwinSizeObserver( this );
   142     iReadOnlyQuoteField->SetEdwinSizeObserver( this );
   148 
   143 
   149     // Create the scroll bar
   144     // Create the scroll bar
   150     iScrollBar = new( ELeave ) CAknDoubleSpanScrollBar( this );
   145     iScrollBar = new( ELeave ) CAknDoubleSpanScrollBar( this );
   151     iScrollBar->ConstructL( this, this, CEikScrollBar::EVertical, aRect.Height() );
   146     iScrollBar->ConstructL( 
       
   147             this, this, CEikScrollBar::EVertical, aRect.Height() );
   152     iScrollBar->MakeVisible( ETrue );
   148     iScrollBar->MakeVisible( ETrue );
   153     iScrollBar->SetModelL( &iScrollBarModel );
   149     iScrollBar->SetModelL( &iScrollBarModel );
   154 
   150 
   155     iMessageField->SetupEditorL();
   151     iMessageField->SetupEditorL();
   156     iReadOnlyQuoteField->SetupEditorL();
   152     iReadOnlyQuoteField->SetupEditorL();
   157 
   153 
   158     SetRect( aRect );
   154     SetRect( aRect );
   159 
   155 
   160     //<cmail> S60 skin support
       
   161     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   156     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   162         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
   157         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
   163     // <cmail>
   158 
   164 	//iMessageField->SetSkinBackgroundControlContextL( iBgContext );
       
   165 	// </cmail>
       
   166     iLongTapDetector = CAknLongTapDetector::NewL( this );
   159     iLongTapDetector = CAknLongTapDetector::NewL( this );
   167     //</cmail>
       
   168 
   160 
   169     UpdateScrollBarL();
   161     UpdateScrollBarL();
   170 
   162 
   171     ActivateL();
   163     ActivateL();
   172 
   164 
   192         iContactHandler->ClearObservers();
   184         iContactHandler->ClearObservers();
   193         }
   185         }
   194 	delete iHeader;
   186 	delete iHeader;
   195     delete iScrollBar;
   187     delete iScrollBar;
   196     delete iMessageField;
   188     delete iMessageField;
   197     // <cmail>
       
   198     delete iBgContext;
   189     delete iBgContext;
   199 	delete iLongTapDetector;
   190 	delete iLongTapDetector;
   200     // </cmail>
       
   201     delete iReadOnlyQuoteField;
   191     delete iReadOnlyQuoteField;
   202     delete iReadOnlyQuote;
   192     delete iReadOnlyQuote;
   203 
   193 
   204     delete iPhysics;
   194     delete iPhysics;
   205     iPhysics = NULL;
   195     iPhysics = NULL;
   209 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   210 // CNcsComposeViewContainer::FocusChanged
   200 // CNcsComposeViewContainer::FocusChanged
   211 //
   201 //
   212 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   213 //
   203 //
   214 void CNcsComposeViewContainer::FocusChanged(TDrawNow aDrawNow)
   204 void CNcsComposeViewContainer::FocusChanged( TDrawNow aDrawNow )
   215     {
   205     {
   216     FUNC_LOG;
   206     FUNC_LOG;
   217 
   207 
   218 	if ( iFocused != iHeader &&
   208 	if ( iFocused != iHeader &&
   219 	     iFocused != iMessageField &&
   209 	     iFocused != iMessageField &&
   220 	     iFocused != iReadOnlyQuoteField )
   210 	     iFocused != iReadOnlyQuoteField )
   221         {
   211         {
   222 		iFocused = iHeader;
   212 		iFocused = iHeader;
   223         }
   213         }
   224 	iFocused->SetFocus( ETrue, aDrawNow );
   214 	iFocused->SetFocus( ETrue, aDrawNow );
   225 	// <cmail>
       
   226 	iView.HandleContainerChangeRequiringToolbarRefresh();
   215 	iView.HandleContainerChangeRequiringToolbarRefresh();
   227 	// </cmail>
   216 
   228 	if ( aDrawNow )
   217 	if ( aDrawNow )
   229 	    {
   218 	    {
   230 		DrawNow();
   219 		DrawNow();
   231 	    }
   220 	    }
   232 
   221 
   240     {
   229     {
   241     FUNC_LOG;
   230     FUNC_LOG;
   242     iHeader->SetMskL();
   231     iHeader->SetMskL();
   243     }
   232     }
   244 
   233 
   245 //<cmail>
       
   246 
       
   247 // -----------------------------------------------------------------------------
   234 // -----------------------------------------------------------------------------
   248 // CNcsComposeViewContainer::HandlePointerEventL()
   235 // CNcsComposeViewContainer::HandlePointerEventL()
   249 //
   236 //
   250 // -----------------------------------------------------------------------------
   237 // -----------------------------------------------------------------------------
   251 //
   238 //
   252 void CNcsComposeViewContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   239 void CNcsComposeViewContainer::HandlePointerEventL( 
       
   240         const TPointerEvent& aPointerEvent )
   253     {
   241     {
   254 	FUNC_LOG;
   242 	FUNC_LOG;
   255 
   243 
   256     CCoeControl::HandlePointerEventL( aPointerEvent );
   244     CCoeControl::HandlePointerEventL( aPointerEvent );
   257 
   245 
   258     if ( iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   246     if ( aPointerEvent.iType != TPointerEvent::EButton1Down &&
       
   247          iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   259         {
   248         {
   260     	iLongTapDetector->PointerEventL( aPointerEvent );
   249     	iLongTapDetector->PointerEventL( aPointerEvent );
   261         }
   250         }
   262 	   
   251 	   
   263     switch( aPointerEvent.iType )
   252     switch( aPointerEvent.iType )
   264     	{
   253     	{
   265     	case TPointerEvent::EButton1Down:
   254     	case TPointerEvent::EButton1Down:
   266     		{
   255     		{
   267             // Save current and original position so that those can be used in
   256             // Save current and original position so that those can be used in
   268             // drag/scrolling calculations
   257             // drag/scrolling calculations
   269             iPreviousPosition = iOriginalPosition = aPointerEvent.iParentPosition;
   258             iPreviousPosition = iOriginalPosition = 
       
   259                 aPointerEvent.iParentPosition;
   270             iIsDragging = EFalse;
   260             iIsDragging = EFalse;
   271             iIsFlicking = EFalse;
   261             iIsFlicking = EFalse;
   272 
   262 
   273             if( iPhysics )
   263             if( iPhysics )
   274                 {
   264                 {
   276                 iPhysics->ResetFriction();
   266                 iPhysics->ResetFriction();
   277                 iStartTime.HomeTime();
   267                 iStartTime.HomeTime();
   278                 UpdatePhysicsL();
   268                 UpdatePhysicsL();
   279                 }            
   269                 }            
   280 
   270 
   281             
   271             if ( iHeader->Rect().Contains( aPointerEvent.iPosition ) )
   282 			//Closes the attachment action menu, if it is open.
       
   283 			//Otherwise does nothing
       
   284 			iView.DismissAttachmentActionMenuL();
       
   285 
       
   286             if ( iHeader->Rect().Contains(aPointerEvent.iPosition) )
       
   287                 {
   272                 {
   288                 if (iFocused == iMessageField)
   273                 if ( iFocused == iMessageField )
   289                     {
   274                     {
   290                     iFocused = iHeader;
   275                     iFocused = iHeader;
   291                     iHeader->SetFocus( ETrue,EDrawNow );
   276                     iHeader->SetFocus( ETrue,EDrawNow );
   292                     iMessageField->SetFocus( EFalse, EDrawNow );
   277                     iMessageField->SetFocus( EFalse, EDrawNow );
   293                     iHeader->MakeVisible( ETrue );
   278                     iHeader->MakeVisible( ETrue );
   294                     CommitL(EBodyField);
   279                     CommitL( EBodyField );
   295                     iView.HandleContainerChangeRequiringToolbarRefresh();
   280                     iView.HandleContainerChangeRequiringToolbarRefresh();
   296                     }
   281                     }
   297                 else if (iFocused == iReadOnlyQuoteField)
   282                 else if ( iFocused == iReadOnlyQuoteField )
   298                     {
   283                     {
   299                     iFocused = iMessageField;
   284                     iFocused = iMessageField;
   300                     iReadOnlyQuoteField->SetFocus( EFalse, EDrawNow );
   285                     iReadOnlyQuoteField->SetFocus( EFalse, EDrawNow );
   301                     iHeader->SetFocus( ETrue, EDrawNow );
   286                     iHeader->SetFocus( ETrue, EDrawNow );
   302                     iView.HandleContainerChangeRequiringToolbarRefresh();
   287                     iView.HandleContainerChangeRequiringToolbarRefresh();
   303                     }
   288                     }
   304                 }
   289                 }
   305             else if (iReadOnlyQuoteField->Rect().Contains(aPointerEvent.iPosition))
   290             else if ( iReadOnlyQuoteField->Rect().Contains( 
       
   291                         aPointerEvent.iPosition ) )
   306                 {
   292                 {
   307                 if (iFocused == iMessageField)
   293                 if ( iFocused == iMessageField )
   308                     {
   294                     {
   309                     iFocused = iReadOnlyQuoteField;
   295                     iFocused = iReadOnlyQuoteField;
   310                     iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
   296                     iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
   311                     iMessageField->SetFocus( EFalse, EDrawNow );
   297                     iMessageField->SetFocus( EFalse, EDrawNow );
   312                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   298                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   313                     iView.HandleContainerChangeRequiringToolbarRefresh();
   299                     iView.HandleContainerChangeRequiringToolbarRefresh();
   314                     }
   300                     }
   315                 else if (iFocused == iHeader)
   301                 else if ( iFocused == iHeader )
   316                     {
   302                     {
   317                     iFocused = iReadOnlyQuoteField;
   303                     iFocused = iReadOnlyQuoteField;
   318                     iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
   304                     iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
   319                     iHeader->SetFocus( EFalse, EDrawNow );
   305                     iHeader->SetFocus( EFalse, EDrawNow );
   320                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   306                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   321                     iView.HandleContainerChangeRequiringToolbarRefresh();
   307                     iView.HandleContainerChangeRequiringToolbarRefresh();
   322                     }
   308                     }
   323                 }
   309                 }
   324             else 
   310             else 
   325                 {
   311                 {
   326                 if (iFocused == iHeader)
   312                 if ( iFocused == iHeader )
   327                     {
   313                     {
   328                     iFocused = iMessageField;
   314                     iFocused = iMessageField;
   329                     iHeader->SetFocus( EFalse, EDrawNow );
   315                     iHeader->SetFocus( EFalse, EDrawNow );
   330                     iMessageField->SetFocus( ETrue, EDrawNow );
   316                     iMessageField->SetFocus( ETrue, EDrawNow );
   331                     //iMessageField->SetCursorPosL( iMessageField->TextLength(), EFalse );
       
   332                     iView.HandleContainerChangeRequiringToolbarRefresh();
   317                     iView.HandleContainerChangeRequiringToolbarRefresh();
   333                     }
   318                     }
   334                 else if (iFocused == iReadOnlyQuoteField)
   319                 else if ( iFocused == iReadOnlyQuoteField )
   335                     {
   320                     {
   336                     iFocused = iMessageField;
   321                     iFocused = iMessageField;
   337                     iReadOnlyQuoteField->SetFocus( EFalse, EDrawNow );
   322                     iReadOnlyQuoteField->SetFocus( EFalse, EDrawNow );
   338                     iMessageField->SetFocus( ETrue, EDrawNow );
   323                     iMessageField->SetFocus( ETrue, EDrawNow );
   339                     iView.HandleContainerChangeRequiringToolbarRefresh();
   324                     iView.HandleContainerChangeRequiringToolbarRefresh();
   340                     }
   325                     }
   341                 else 
   326                 else 
   342                     {
   327                     {
   343                     //iMessageField->SetCursorPosL( iMessageField->TextLength(), EFalse );
   328                     const TRect messageFieldRect( iMessageField->Rect() );
   344                     const TRect messageFieldRect(iMessageField->Rect());
   329                     if ( !messageFieldRect.Contains( aPointerEvent.iPosition ) && 
   345                     if (!messageFieldRect.Contains(aPointerEvent.iPosition) && 
   330                          aPointerEvent.iPosition.iY >= messageFieldRect.iTl.iY )
   346                             aPointerEvent.iPosition.iY >= messageFieldRect.iTl.iY ) 
       
   347                         {
   331                         {
   348                         iMessageField->OpenVirtualKeyBoardL();
   332                         iMessageField->OpenVirtualKeyBoardL();
   349                         }
   333                         }
   350                     }
   334                     }
   351                 }
   335                 }
   355     	
   339     	
   356     	case TPointerEvent::EButton1Up:    		
   340     	case TPointerEvent::EButton1Up:    		
   357     		{
   341     		{
   358             if( iIsDragging && iPhysics )
   342             if( iIsDragging && iPhysics )
   359                 {
   343                 {
   360                 TPoint drag(iOriginalPosition - aPointerEvent.iParentPosition);
   344                 TPoint drag( iOriginalPosition - aPointerEvent.iParentPosition );
   361                 iPhysics->StartPhysics(drag, iStartTime);
   345                 iPhysics->StartPhysics( drag, iStartTime );
   362                 iIsFlicking = ETrue;
   346                 iIsFlicking = ETrue;
   363                 iIsDragging = EFalse;
   347                 iIsDragging = EFalse;
   364                 }
   348                 }
   365     		break;
   349     		break;
   366     		}
   350     		}
   387     			TInt areaHeight( Rect().Size().iHeight );
   371     			TInt areaHeight( Rect().Size().iHeight );
   388     			TInt scrollOffset( 0 );
   372     			TInt scrollOffset( 0 );
   389     			
   373     			
   390 				if( totalHeight > areaHeight )
   374 				if( totalHeight > areaHeight )
   391 					{
   375 					{
   392 					// Calculate new scroll offset based on current and previous Y-positions
   376 					// Calculate new scroll offset based on current and
   393 					scrollOffset = topPosition + ( iPreviousPosition.iY - position.iY );
   377 					// previous Y-positions
       
   378 					scrollOffset = topPosition + 
       
   379                         ( iPreviousPosition.iY - position.iY );
   394 					// Ensure that thumb position is in correct range
   380 					// Ensure that thumb position is in correct range
   395 					scrollOffset = Max( scrollOffset, 0 );
   381 					scrollOffset = Max( scrollOffset, 0 );
   396 					scrollOffset = Min( scrollOffset, totalHeight - areaHeight );
   382 					scrollOffset = Min( scrollOffset, 
       
   383                                         totalHeight - areaHeight );
   397 					}
   384 					}
   398 
   385 
   399 				ScrollL( scrollOffset );
   386 				ScrollL( scrollOffset );
   400 				}
   387 				}
   401            
   388            
   409     		{
   396     		{
   410     		// unknown event, ignored
   397     		// unknown event, ignored
   411     		break;
   398     		break;
   412     		}
   399     		}
   413     	}
   400     	}
   414     
   401 
   415     }
   402     if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   416 
   403          iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   417 //</cmail>
   404         {
       
   405         iLongTapDetector->PointerEventL( aPointerEvent );
       
   406         }
       
   407     }
   418 
   408 
   419 // -----------------------------------------------------------------------------
   409 // -----------------------------------------------------------------------------
   420 // CNcsComposeViewContainer::OfferKeyEventL()
   410 // CNcsComposeViewContainer::OfferKeyEventL()
   421 // Handles key events
   411 // Handles key events
   422 // -----------------------------------------------------------------------------
   412 // -----------------------------------------------------------------------------
   423 //
   413 //
   424 TKeyResponse CNcsComposeViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
   414 TKeyResponse CNcsComposeViewContainer::OfferKeyEventL( 
       
   415         const TKeyEvent& aKeyEvent, TEventCode aType )
   425     {
   416     {
   426     FUNC_LOG;
   417     FUNC_LOG;
   427 
   418 
   428     if( iPhysics )
   419     if( iPhysics )
   429         {
   420         {
   431         iPhysics->ResetFriction();
   422         iPhysics->ResetFriction();
   432         }
   423         }
   433 
   424 
   434     TKeyResponse ret( EKeyWasNotConsumed );
   425     TKeyResponse ret( EKeyWasNotConsumed );
   435 
   426 
   436     //<cmail>
       
   437     //we are allowing to change MSK label 
   427     //we are allowing to change MSK label 
   438     SwitchChangeMskOff(EFalse);
   428     SwitchChangeMskOff( EFalse );
   439     //</cmail>
       
   440     
   429     
   441     if ( aKeyEvent.iCode == EKeyYes )
   430     if ( aKeyEvent.iCode == EKeyYes )
   442         {
   431         {
   443         // check that at least one of the address fields has an address
   432         // check that at least one of the address fields has an address
   444         if ( !iHeader->AreAddressFieldsEmpty() )
   433         if ( !iHeader->AreAddressFieldsEmpty() )
   468               aType == EEventKey )
   457               aType == EEventKey )
   469         {
   458         {
   470         iView.HandleCommandL( ENcsCmdSaveDraft );
   459         iView.HandleCommandL( ENcsCmdSaveDraft );
   471         ret = EKeyWasConsumed;
   460         ret = EKeyWasConsumed;
   472         }
   461         }
   473     else if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
   462     else if ( aKeyEvent.iCode == EKeyUpArrow || 
       
   463               aKeyEvent.iCode == EKeyDownArrow )
   474         {
   464         {
   475         ret = iFocused->OfferKeyEventL( aKeyEvent, aType );
   465         ret = iFocused->OfferKeyEventL( aKeyEvent, aType );
   476 
   466 
   477         if ( ret == EKeyWasNotConsumed )
   467         if ( ret == EKeyWasNotConsumed )
   478             {
   468             {
   509 // CNcsComposeViewContainer::UpdateScreenPositionL()
   499 // CNcsComposeViewContainer::UpdateScreenPositionL()
   510 // If the user scrolled down in the message field
   500 // If the user scrolled down in the message field
   511 // we want to scroll up the header and grow the message field.
   501 // we want to scroll up the header and grow the message field.
   512 // -----------------------------------------------------------------------------
   502 // -----------------------------------------------------------------------------
   513 //
   503 //
   514 void CNcsComposeViewContainer::UpdateScreenPositionL( const TUint& /*aKeyCode*/ )
   504 void CNcsComposeViewContainer::UpdateScreenPositionL( 
       
   505         const TUint& /*aKeyCode*/ )
   515     {
   506     {
   516     FUNC_LOG;
   507     FUNC_LOG;
   517 
   508 
   518     // get screen rectangle
   509     // get screen rectangle
   519     const TRect screenRect( Rect() );
   510     const TRect screenRect( Rect() );
   533         iReadOnlyQuoteField->GetLineRectL( lineRect );
   524         iReadOnlyQuoteField->GetLineRectL( lineRect );
   534         lineRect.Move( quotePos );
   525         lineRect.Move( quotePos );
   535         }
   526         }
   536     else
   527     else
   537         {
   528         {
   538         // This function should be used only when focus is in body or read-only quote
   529         // This function should be used only when focus is in body or
       
   530         // read-only quote
   539         return;
   531         return;
   540         }
   532         }
   541     TPoint linePos = lineRect.iTl;
   533     TPoint linePos = lineRect.iTl;
   542 
   534 
   543     TInt minTargetY = lineRect.Height();
   535     TInt minTargetY = lineRect.Height();
   553         {
   545         {
   554         moveY = minTargetY - linePos.iY;
   546         moveY = minTargetY - linePos.iY;
   555         }
   547         }
   556 
   548 
   557     // Check we don't scroll too low
   549     // Check we don't scroll too low
   558     if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < screenRect.Height() )
   550     if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < 
   559         {
   551          screenRect.Height() )
   560         moveY = screenRect.Height() - quotePos.iY - iReadOnlyQuoteField->Size().iHeight;
   552         {
       
   553         moveY = screenRect.Height() - quotePos.iY - 
       
   554             iReadOnlyQuoteField->Size().iHeight;
   561         }
   555         }
   562 
   556 
   563     // Check we don't scroll too high
   557     // Check we don't scroll too high
   564     TPoint headerPos = iHeader->Position();
   558     TPoint headerPos = iHeader->Position();
   565     if ( headerPos.iY + moveY > 0 )
   559     if ( headerPos.iY + moveY > 0 )
   578         quotePos.iY += moveY;
   572         quotePos.iY += moveY;
   579         iReadOnlyQuoteField->SetPosition( quotePos );
   573         iReadOnlyQuoteField->SetPosition( quotePos );
   580 
   574 
   581         iSeparatorLineYPos += moveY;
   575         iSeparatorLineYPos += moveY;
   582         UpdateScrollBarL();
   576         UpdateScrollBarL();
   583 
       
   584         //DrawDeferred();
       
   585         }
   577         }
   586     }
   578     }
   587 
   579 
   588 // -----------------------------------------------------------------------------
   580 // -----------------------------------------------------------------------------
   589 // CNcsComposeViewContainer::UpdateFieldPosition
   581 // CNcsComposeViewContainer::UpdateFieldPosition
   590 //
   582 //
   591 // -----------------------------------------------------------------------------
   583 // -----------------------------------------------------------------------------
   592 //
   584 //
   593 void CNcsComposeViewContainer::UpdateFieldPosition(CCoeControl* aAnchor)
   585 void CNcsComposeViewContainer::UpdateFieldPosition( CCoeControl* aAnchor )
   594     {
   586     {
   595     FUNC_LOG;
   587     FUNC_LOG;
   596 
   588 
   597 	// We may not be completely constructed
   589 	// We may not be completely constructed
   598 	if ( iHeader && iMessageField && iReadOnlyQuoteField )
   590 	if ( iHeader && iMessageField && iReadOnlyQuoteField )
   599 	    {
   591 	    {
   600 	    // First, move all the controls in the header
   592 	    // First, move all the controls in the header
   601 	    iHeader->UpdateFieldPosition(aAnchor);
   593 	    iHeader->UpdateFieldPosition( aAnchor );
   602 
   594 
   603 	    // Then, move the body field below the header
   595 	    // Then, move the body field below the header
   604 	    TRect headerRect = iHeader->Rect();
   596 	    TRect headerRect = iHeader->Rect();
   605 	            
   597 	            
   606 		const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
   598 		const TSize separatorSize( 
       
   599 		        NcsUtility::SeparatorSizeInThisResolution() );
   607 		iSeparatorLineYPos = headerRect.iBr.iY;
   600 		iSeparatorLineYPos = headerRect.iBr.iY;
   608 			
   601 			
   609 		TPoint bodyPos( iMessageField->Position() );
   602 		TPoint bodyPos( iMessageField->Position() );
   610 		bodyPos.iY = iSeparatorLineYPos + separatorSize.iHeight;
   603 		bodyPos.iY = iSeparatorLineYPos + separatorSize.iHeight;
   611 		iMessageField->SetPosition( bodyPos );
   604 		iMessageField->SetPosition( bodyPos );
   612 		
   605 		
   613 		TPoint quotePos( iReadOnlyQuoteField->Position() );
   606 		TPoint quotePos( iReadOnlyQuoteField->Position() );
   614 		quotePos.iY = iMessageField->Rect().iBr.iY;
   607 		quotePos.iY = iMessageField->Rect().iBr.iY;
   615 		iReadOnlyQuoteField->SetPosition( quotePos );
   608 		iReadOnlyQuoteField->SetPosition( quotePos );
   616 
   609 
   617 	    TRAP_IGNORE(UpdateScrollBarL());
   610 	    TRAP_IGNORE( UpdateScrollBarL() );
   618 
   611 
   619 	    DrawDeferred();
   612 	    DrawDeferred();
   620 	    }
   613 	    }
   621 
   614 
   622     }
   615     }
   625 // CNcsComposeViewContainer::ChangeFocusL()
   618 // CNcsComposeViewContainer::ChangeFocusL()
   626 // Handles key events
   619 // Handles key events
   627 // -----------------------------------------------------------------------------
   620 // -----------------------------------------------------------------------------
   628 //
   621 //
   629 
   622 
   630 TKeyResponse CNcsComposeViewContainer::ChangeFocusL( const TKeyEvent& aKeyEvent )
   623 TKeyResponse CNcsComposeViewContainer::ChangeFocusL( 
       
   624         const TKeyEvent& aKeyEvent )
   631     {
   625     {
   632     FUNC_LOG;
   626     FUNC_LOG;
   633 
   627 
   634     TKeyResponse ret( EKeyWasNotConsumed );
   628     TKeyResponse ret( EKeyWasNotConsumed );
   635 
   629 
   646 	        {
   640 	        {
   647             iFocused = iHeader;
   641             iFocused = iHeader;
   648     		iHeader->SetFocus( ETrue,EDrawNow );
   642     		iHeader->SetFocus( ETrue,EDrawNow );
   649     		iMessageField->SetFocus( EFalse, EDrawNow );
   643     		iMessageField->SetFocus( EFalse, EDrawNow );
   650     		iHeader->MakeVisible( ETrue );
   644     		iHeader->MakeVisible( ETrue );
   651             CommitL(EBodyField);
   645             CommitL( EBodyField );
   652             ret = EKeyWasConsumed;
   646             ret = EKeyWasConsumed;
   653 	        }
   647 	        }
   654 	    else if ( aKeyEvent.iCode == EKeyDownArrow && iReadOnlyQuoteField->TextLength() )
   648 	    else if ( aKeyEvent.iCode == EKeyDownArrow && 
       
   649 	              iReadOnlyQuoteField->TextLength() )
   655 	        {
   650 	        {
   656 	        // Focus move to read-only quote only if there is some text in it.
   651 	        // Focus move to read-only quote only if there is some text in it.
   657 	        iFocused = iReadOnlyQuoteField;
   652 	        iFocused = iReadOnlyQuoteField;
   658 	        iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
   653 	        iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
   659 	        iMessageField->SetFocus( EFalse, EDrawNow );
   654 	        iMessageField->SetFocus( EFalse, EDrawNow );
   695 	    }
   690 	    }
   696 
   691 
   697 	return EFalse;
   692 	return EFalse;
   698     }
   693     }
   699 
   694 
   700 // <cmail> Platform layout changes
       
   701 // -----------------------------------------------------------------------------
   695 // -----------------------------------------------------------------------------
   702 // CNcsComposeViewContainer::SizeChanged()
   696 // CNcsComposeViewContainer::SizeChanged()
   703 // set size
   697 // set size
   704 // -----------------------------------------------------------------------------
   698 // -----------------------------------------------------------------------------
   705 //
   699 //
   710     const TRect rect( Rect() );
   704     const TRect rect( Rect() );
   711     iScrollBar->SetRect( NcsUtility::ListCmailScrollbarRect( rect ) );
   705     iScrollBar->SetRect( NcsUtility::ListCmailScrollbarRect( rect ) );
   712     TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) );
   706     TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) );
   713 
   707 
   714     const TInt headerLineCount( iHeader->LayoutLineCount() );
   708     const TInt headerLineCount( iHeader->LayoutLineCount() );
   715     const TPoint headerPos( NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ) );
   709     const TPoint headerPos( 
       
   710             NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ) );
   716     cmailPaneRect.Move( 0, iHeader->Position().iY - headerPos.iY );
   711     cmailPaneRect.Move( 0, iHeader->Position().iY - headerPos.iY );
   717 
   712 
   718     NcsUtility::LayoutHeaderControl( iHeader, cmailPaneRect, 0, headerLineCount );
   713     NcsUtility::LayoutHeaderControl( 
       
   714             iHeader, cmailPaneRect, 0, headerLineCount );
   719 
   715 
   720     // do not used stored headerLineCount, because relayout above may grow or
   716     // do not used stored headerLineCount, because relayout above may grow or
   721     // shrink edit fields
   717     // shrink edit fields
       
   718     NcsUtility::LayoutBodyEdwin( 
       
   719             iMessageField, cmailPaneRect, iHeader->LayoutLineCount(), 
       
   720             iMessageField->LineCount(), iSeparatorLineYPos );
   722     TRAP_IGNORE( iMessageField->FormatAllTextNowL() );
   721     TRAP_IGNORE( iMessageField->FormatAllTextNowL() );
   723     NcsUtility::LayoutBodyEdwin( iMessageField, cmailPaneRect, iHeader->LayoutLineCount(), iMessageField->LineCount(),
       
   724             iSeparatorLineYPos );
       
   725 
   722 
   726     iMessageField->UpdateFontSize();
   723     iMessageField->UpdateFontSize();
   727 
   724 
   728     TInt readOnlyQuoteFieldHeight( 0 );
   725     TInt readOnlyQuoteFieldHeight( 0 );
   729     if ( iReadOnlyQuoteField->TextLength() )
   726     if ( iReadOnlyQuoteField->TextLength() )
   730         {
   727         {
   731         TInt dummySeparatorPos;
   728         TInt dummySeparatorPos;
   732         NcsUtility::LayoutBodyEdwin( iReadOnlyQuoteField, cmailPaneRect, headerLineCount + iMessageField->LineCount(), iReadOnlyQuoteField->LineCount(), 
   729         NcsUtility::LayoutBodyEdwin(
   733         		dummySeparatorPos );
   730                 iReadOnlyQuoteField, cmailPaneRect, 
       
   731                 iHeader->LayoutLineCount() + iMessageField->LineCount(), 
       
   732                 iReadOnlyQuoteField->LineCount(), dummySeparatorPos );
       
   733         TRAP_IGNORE( iReadOnlyQuoteField->FormatAllTextNowL() );
   734         iReadOnlyQuoteField->UpdateFontSize();
   734         iReadOnlyQuoteField->UpdateFontSize();
   735         readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height();
   735         readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height();
   736         }
   736         }
   737 
   737 
   738     if ( iBgContext )
   738     if ( iBgContext )
   740         iBgContext->SetRect( Rect() );
   740         iBgContext->SetRect( Rect() );
   741         }  
   741         }  
   742     iMessageField->SetRealRect( Rect() );
   742     iMessageField->SetRealRect( Rect() );
   743     iReadOnlyQuoteField->SetRealRect( Rect() );
   743     iReadOnlyQuoteField->SetRealRect( Rect() );
   744     
   744     
   745     TInt messageLineHeigth = NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
   745     TInt messageLineHeigth = 
   746     iMessageEditorMinHeigth = cmailPaneRect.Height() - iHeader->Size().iHeight -
   746         NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
   747                               NcsUtility::SeparatorSizeInThisResolution().iHeight -
   747     iMessageEditorMinHeigth = 
   748                               readOnlyQuoteFieldHeight;
   748         cmailPaneRect.Height() - iHeader->Size().iHeight -
       
   749         NcsUtility::SeparatorSizeInThisResolution().iHeight -
       
   750         readOnlyQuoteFieldHeight;
   749     
   751     
   750     iMessageEditorMinHeigth -= iMessageEditorMinHeigth % messageLineHeigth;
   752     iMessageEditorMinHeigth -= iMessageEditorMinHeigth % messageLineHeigth;
   751     if ( iMessageEditorMinHeigth > messageLineHeigth )
   753     if ( iMessageEditorMinHeigth > messageLineHeigth )
   752         {
   754         {
   753         TSize newSize( iMessageField->Size().iWidth,
   755         TSize newSize( iMessageField->Size().iWidth,
   754                        Max( iMessageField->Size().iHeight, iMessageEditorMinHeigth ));
   756                        Max( iMessageField->Size().iHeight, 
       
   757                             iMessageEditorMinHeigth ) );
   755             
   758             
   756         iMessageField->SetSize( newSize );
   759         iMessageField->SetSize( newSize );
   757         }
   760         }
   758     else
   761     else
   759         {
   762         {
   760         iMessageEditorMinHeigth = messageLineHeigth;
   763         iMessageEditorMinHeigth = messageLineHeigth;
   761         }
   764         }
   762 
   765 
   763     UpdateFieldPosition( NULL );
       
   764     
       
   765     TRAP_IGNORE( UpdateScrollBarL() );
   766     TRAP_IGNORE( UpdateScrollBarL() );
   766     DrawNow();
   767     DrawNow();
   767     
   768     
   768     }
   769     }
   769 // </cmail> Platform layout changes
       
   770 
   770 
   771 // -----------------------------------------------------------------------------
   771 // -----------------------------------------------------------------------------
   772 // CNcsComposeViewContainer::Draw() const
   772 // CNcsComposeViewContainer::Draw() const
   773 // Draws the display
   773 // Draws the display
   774 // -----------------------------------------------------------------------------
   774 // -----------------------------------------------------------------------------
   775 //
   775 //
   776 void CNcsComposeViewContainer::Draw( const TRect& /*aRect*/ ) const
   776 void CNcsComposeViewContainer::Draw( const TRect& /*aRect*/ ) const
   777     {
   777     {
   778     FUNC_LOG;
   778     FUNC_LOG;
   779 	// <cmail> S60 skin support
   779 
   780 	if ( iBgContext )
   780 	if ( iBgContext )
   781 	    {
   781 	    {
   782     	CWindowGc& gc = SystemGc();
   782     	CWindowGc& gc = SystemGc();
   783 
   783 
   784     	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   784     	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   812         CPlainText::EOrganiseByParagraph );
   812         CPlainText::EOrganiseByParagraph );
   813     CleanupStack::PopAndDestroy( &inputStream );
   813     CleanupStack::PopAndDestroy( &inputStream );
   814 
   814 
   815     // Activating the field will set the control to the end of the text
   815     // Activating the field will set the control to the end of the text
   816     iMessageField->ActivateL();
   816     iMessageField->ActivateL();
   817     iMessageField->SetCursorPosL(0,EFalse);
   817     iMessageField->SetCursorPosL( 0, EFalse );
   818 
   818 
   819     inputStream.Open( aReadOnlyQuote.Ptr(), aReadOnlyQuote.Size() );
   819     inputStream.Open( aReadOnlyQuote.Ptr(), aReadOnlyQuote.Size() );
   820     CleanupClosePushL( inputStream );
   820     CleanupClosePushL( inputStream );
   821     iReadOnlyQuoteField->RichText()->ImportTextL( 0, inputStream,
   821     iReadOnlyQuoteField->RichText()->ImportTextL( 0, inputStream,
   822         CPlainText::EOrganiseByParagraph );
   822         CPlainText::EOrganiseByParagraph );
   823     CleanupStack::PopAndDestroy( &inputStream );
   823     CleanupStack::PopAndDestroy( &inputStream );
   824 
   824 
   825     // Activating the field will set the control to the end of the text
   825     // Activating the field will set the control to the end of the text
   826     iReadOnlyQuoteField->ActivateL();
   826     iReadOnlyQuoteField->ActivateL();
   827     iReadOnlyQuoteField->SetCursorPosL(0,EFalse);
   827     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   828 
   828 
   829     // Recalculate the size of the body field
   829     // Recalculate the size of the body field
   830     SizeChanged();
   830     SizeChanged();
   831     }
   831     }
   832 
   832 
   881 
   881 
   882 // -----------------------------------------------------------------------------
   882 // -----------------------------------------------------------------------------
   883 // CNcsComposeViewContainer::HandleScrollEventL()
   883 // CNcsComposeViewContainer::HandleScrollEventL()
   884 // -----------------------------------------------------------------------------
   884 // -----------------------------------------------------------------------------
   885 //
   885 //
   886 void CNcsComposeViewContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent /*aEventType*/ )
   886 void CNcsComposeViewContainer::HandleScrollEventL( 
   887     {
   887         CEikScrollBar* aScrollBar, TEikScrollEvent /*aEventType*/ )
   888     // <cmail> Platform layout change
   888     {
   889     FUNC_LOG;
   889     FUNC_LOG;
   890     
   890     
   891     if( iPhysics )
   891     if( iPhysics )
   892         {
   892         {
   893         iPhysics->StopPhysics();
   893         iPhysics->StopPhysics();
   910 		RPointerArray<CNcsEmailAddressObject> ncsObjects;
   910 		RPointerArray<CNcsEmailAddressObject> ncsObjects;
   911 		CleanupResetAndDestroyClosePushL( ncsObjects );
   911 		CleanupResetAndDestroyClosePushL( ncsObjects );
   912 
   912 
   913 		for ( TInt i = 0 ; i < aContacts.Count() ; i++ )
   913 		for ( TInt i = 0 ; i < aContacts.Count() ; i++ )
   914 			{
   914 			{
   915 			CNcsEmailAddressObject* object = CNcsEmailAddressObject::NewL( aContacts[i]->DisplayName(),
   915 			CNcsEmailAddressObject* object = 
       
   916                 CNcsEmailAddressObject::NewL( aContacts[i]->DisplayName(),
   916 					aContacts[i]->EmailAddress() );
   917 					aContacts[i]->EmailAddress() );
   917 			if ( aContacts[i]->MultipleEmails() )
   918 			if ( aContacts[i]->MultipleEmails() )
   918 				{
   919 				{
   919 
   920 
   920 				object->SetDisplayFull( ETrue );
   921 				object->SetDisplayFull( ETrue );
   942 		CleanupStack::PopAndDestroy( &ncsObjects );
   943 		CleanupStack::PopAndDestroy( &ncsObjects );
   943 		}
   944 		}
   944 	iView.HandleContainerChangeRequiringToolbarRefresh();
   945 	iView.HandleContainerChangeRequiringToolbarRefresh();
   945 	}
   946 	}
   946 
   947 
   947 void CNcsComposeViewContainer::OperationErrorL( TContactHandlerCmd, TInt /*aError*/ )
   948 // -----------------------------------------------------------------------------
       
   949 // CNcsComposeViewContainer::OperationErrorL
       
   950 // -----------------------------------------------------------------------------
       
   951 //
       
   952 void CNcsComposeViewContainer::OperationErrorL( 
       
   953         TContactHandlerCmd, TInt /*aError*/ )
   948 	{
   954 	{
   949     FUNC_LOG;
   955     FUNC_LOG;
   950 	//Nothing to do
   956 	//Nothing to do
   951 	}
   957 	}
   952 
   958 
   963         if ( aEventType == MEikEdwinObserver::EEventTextUpdate ||
   969         if ( aEventType == MEikEdwinObserver::EEventTextUpdate ||
   964              aEventType == MEikEdwinObserver::EEventNavigation )
   970              aEventType == MEikEdwinObserver::EEventNavigation )
   965             {
   971             {
   966             iAutoSaver.ReportActivity();
   972             iAutoSaver.ReportActivity();
   967 
   973 
   968             // Update screen position and scroll bar when text changed or cursor moved
   974             // Update screen position and scroll bar when text changed
       
   975             // or cursor moved
   969             UpdateScreenPositionL();
   976             UpdateScreenPositionL();
   970             UpdateScrollBarL();
   977             UpdateScrollBarL();
   971             DrawDeferred();
   978             DrawDeferred();
   972             }
   979             }
   973         }
   980         }
  1054     iScrollBarModel.SetFocusPosition( visiblePosition );
  1061     iScrollBarModel.SetFocusPosition( visiblePosition );
  1055 
  1062 
  1056     iScrollBar->SetModelL( &iScrollBarModel );
  1063     iScrollBar->SetModelL( &iScrollBarModel );
  1057     iScrollBar->DrawNow();
  1064     iScrollBar->DrawNow();
  1058 	}
  1065 	}
  1059 
       
  1060 // -----------------------------------------------------------------------------
       
  1061 // CNcsComposeViewContainer::SetApplicationRect()
       
  1062 // -----------------------------------------------------------------------------
       
  1063 //
       
  1064 // <cmail>
       
  1065 /*
       
  1066 void CNcsComposeViewContainer::SetApplicationRect( TRect aRect )
       
  1067 	{
       
  1068     FUNC_LOG;
       
  1069 
       
  1070 	iApplicationRect = aRect;
       
  1071 
       
  1072 	}
       
  1073 */
       
  1074 // </cmail>
       
  1075 
       
  1076 
  1066 
  1077 // -----------------------------------------------------------------------------
  1067 // -----------------------------------------------------------------------------
  1078 // CNcsComposeViewContainer::SetFocusToMessageFieldL()
  1068 // CNcsComposeViewContainer::SetFocusToMessageFieldL()
  1079 // -----------------------------------------------------------------------------
  1069 // -----------------------------------------------------------------------------
  1080 //
  1070 //
  1101 void CNcsComposeViewContainer::AddQuickTextL( const TDesC& aText )
  1091 void CNcsComposeViewContainer::AddQuickTextL( const TDesC& aText )
  1102     {
  1092     {
  1103     FUNC_LOG;
  1093     FUNC_LOG;
  1104 
  1094 
  1105     // If in 'To' field, go to msg. field
  1095     // If in 'To' field, go to msg. field
  1106     if(!iMessageField->IsFocused())
  1096     if( !iMessageField->IsFocused() )
  1107     	{
  1097     	{
  1108     	SetFocusToMessageFieldL();
  1098     	SetFocusToMessageFieldL();
  1109     	}
  1099     	}
  1110 	TInt pos = iMessageField->CursorPos();
  1100 	TInt pos = iMessageField->CursorPos();
  1111 	TCursorSelection selIns( pos, pos );
  1101 	TCursorSelection selIns( pos, pos );
  1112 	iMessageField->InsertDeleteCharsL( pos, aText, selIns );
  1102 	iMessageField->InsertDeleteCharsL( pos, aText, selIns );
  1113 	//Fix for error EFTG-7Y63XG, moving cursor to the end of inserted text
  1103 	// Fix for error EFTG-7Y63XG, moving cursor to the end of inserted text
  1114 	pos += aText.Length();
  1104 	pos += aText.Length();
  1115 	iMessageField->SetCursorPosL(pos,EFalse);
  1105 	iMessageField->SetCursorPosL( pos, EFalse );
  1116 	DrawDeferred();
  1106 	DrawDeferred();
  1117 
  1107 
  1118     }
  1108     }
  1119 
  1109 
  1120 // -----------------------------------------------------------------------------
  1110 // -----------------------------------------------------------------------------
  1223 	iView.HandleCommandL( EFsEmailUiCmdOpenAttachment );
  1213 	iView.HandleCommandL( EFsEmailUiCmdOpenAttachment );
  1224 
  1214 
  1225 	}
  1215 	}
  1226 
  1216 
  1227 // -----------------------------------------------------------------------------
  1217 // -----------------------------------------------------------------------------
  1228 // CNcsComposeViewContainer::LaunchAttachmentActionMenuL
  1218 // CNcsComposeViewContainer::LaunchStylusPopupMenu
  1229 // Called when right-click happens in the attahcments field
  1219 // Called when long tap happens in the attachments field
  1230 // -----------------------------------------------------------------------------
  1220 // -----------------------------------------------------------------------------
  1231 //
  1221 //
  1232 void CNcsComposeViewContainer::LaunchAttachmentActionMenuL()
  1222 void CNcsComposeViewContainer::LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation )
  1233     {
  1223     {
  1234     FUNC_LOG;
  1224     FUNC_LOG;
  1235     iView.LaunchAttachmentActionMenuL();
  1225     iView.LaunchStylusPopupMenu( aPenEventScreenLocation );
  1236     }
  1226     }
  1237 
  1227 
  1238 // -----------------------------------------------------------------------------
  1228 // -----------------------------------------------------------------------------
  1239 // CNcsComposeViewContainer::GetToFieldAddressesL
  1229 // CNcsComposeViewContainer::GetToFieldAddressesL
  1240 //
  1230 //
  1241 // -----------------------------------------------------------------------------
  1231 // -----------------------------------------------------------------------------
  1242 //
  1232 //
  1243 const RPointerArray<CNcsEmailAddressObject>& CNcsComposeViewContainer::GetToFieldAddressesL( TBool aParseNow )
  1233 const RPointerArray<CNcsEmailAddressObject>& 
       
  1234 CNcsComposeViewContainer::GetToFieldAddressesL( TBool aParseNow )
  1244     {
  1235     {
  1245     return iHeader->GetToFieldAddressesL( aParseNow );
  1236     return iHeader->GetToFieldAddressesL( aParseNow );
  1246     }
  1237     }
  1247 
  1238 
  1248 // -----------------------------------------------------------------------------
  1239 // -----------------------------------------------------------------------------
  1249 // CNcsComposeViewContainer::GetCcFieldAddressesL
  1240 // CNcsComposeViewContainer::GetCcFieldAddressesL
  1250 //
  1241 //
  1251 // -----------------------------------------------------------------------------
  1242 // -----------------------------------------------------------------------------
  1252 //
  1243 //
  1253 const RPointerArray<CNcsEmailAddressObject>& CNcsComposeViewContainer::GetCcFieldAddressesL( TBool aParseNow )
  1244 const RPointerArray<CNcsEmailAddressObject>& 
       
  1245 CNcsComposeViewContainer::GetCcFieldAddressesL( TBool aParseNow )
  1254     {
  1246     {
  1255     return iHeader->GetCcFieldAddressesL( aParseNow );
  1247     return iHeader->GetCcFieldAddressesL( aParseNow );
  1256     }
  1248     }
  1257 
  1249 
  1258 // -----------------------------------------------------------------------------
  1250 // -----------------------------------------------------------------------------
  1259 // CNcsComposeViewContainer::GetBccFieldAddressesL
  1251 // CNcsComposeViewContainer::GetBccFieldAddressesL
  1260 //
  1252 //
  1261 // -----------------------------------------------------------------------------
  1253 // -----------------------------------------------------------------------------
  1262 //
  1254 //
  1263 const RPointerArray<CNcsEmailAddressObject>& CNcsComposeViewContainer::GetBccFieldAddressesL( TBool aParseNow )
  1255 const RPointerArray<CNcsEmailAddressObject>& 
       
  1256 CNcsComposeViewContainer::GetBccFieldAddressesL( TBool aParseNow )
  1264     {
  1257     {
  1265     return iHeader->GetBccFieldAddressesL( aParseNow );
  1258     return iHeader->GetBccFieldAddressesL( aParseNow );
  1266     }
  1259     }
  1267 
  1260 
  1268 // -----------------------------------------------------------------------------
  1261 // -----------------------------------------------------------------------------
  1296     {
  1289     {
  1297     FUNC_LOG;
  1290     FUNC_LOG;
  1298     return iHeader->IsCcFieldVisible();
  1291     return iHeader->IsCcFieldVisible();
  1299     }
  1292     }
  1300 
  1293 
  1301 // <cmail> Removed unneeded IsFocusAif
       
  1302 // </cmail>
       
  1303 
  1294 
  1304 // -----------------------------------------------------------------------------
  1295 // -----------------------------------------------------------------------------
  1305 // CNcsComposeViewContainer::IsFocusAttachments
  1296 // CNcsComposeViewContainer::IsFocusAttachments
  1306 //
  1297 //
  1307 // -----------------------------------------------------------------------------
  1298 // -----------------------------------------------------------------------------
  1476 void CNcsComposeViewContainer::SetMenuBar( CEikButtonGroupContainer* aMenuBar )
  1467 void CNcsComposeViewContainer::SetMenuBar( CEikButtonGroupContainer* aMenuBar )
  1477     {
  1468     {
  1478     FUNC_LOG;
  1469     FUNC_LOG;
  1479 
  1470 
  1480 	iHeader->SetMenuBar(aMenuBar);
  1471 	iHeader->SetMenuBar(aMenuBar);
  1481 
       
  1482     }
  1472     }
  1483 
  1473 
  1484 // -----------------------------------------------------------------------------
  1474 // -----------------------------------------------------------------------------
  1485 // CNcsComposeViewContainer::SetToFieldAddressesL
  1475 // CNcsComposeViewContainer::SetToFieldAddressesL
  1486 //
  1476 //
  1487 // -----------------------------------------------------------------------------
  1477 // -----------------------------------------------------------------------------
  1488 //
  1478 //
  1489 void CNcsComposeViewContainer::SetToFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress )
  1479 void CNcsComposeViewContainer::SetToFieldAddressesL( 
       
  1480         RPointerArray<CNcsEmailAddressObject>& aAddress )
  1490     {
  1481     {
  1491     FUNC_LOG;
  1482     FUNC_LOG;
  1492 
  1483 
  1493     iHeader->SetToFieldAddressesL(aAddress);
  1484     iHeader->SetToFieldAddressesL(aAddress);
  1494 
       
  1495     }
  1485     }
  1496 
  1486 
  1497 // -----------------------------------------------------------------------------
  1487 // -----------------------------------------------------------------------------
  1498 // CNcsComposeViewContainer::SetCcFieldAddressesL
  1488 // CNcsComposeViewContainer::SetCcFieldAddressesL
  1499 //
  1489 //
  1500 // -----------------------------------------------------------------------------
  1490 // -----------------------------------------------------------------------------
  1501 //
  1491 //
  1502 void CNcsComposeViewContainer::SetCcFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress )
  1492 void CNcsComposeViewContainer::SetCcFieldAddressesL( 
       
  1493         RPointerArray<CNcsEmailAddressObject>& aAddress )
  1503     {
  1494     {
  1504     FUNC_LOG;
  1495     FUNC_LOG;
  1505 
  1496 
  1506     iHeader->SetCcFieldAddressesL( aAddress );
  1497     iHeader->SetCcFieldAddressesL( aAddress );
  1507 
       
  1508     }
  1498     }
  1509 
  1499 
  1510 // -----------------------------------------------------------------------------
  1500 // -----------------------------------------------------------------------------
  1511 // CNcsComposeViewContainer::SetBccFieldAddressesL
  1501 // CNcsComposeViewContainer::SetBccFieldAddressesL
  1512 //
  1502 //
  1513 // -----------------------------------------------------------------------------
  1503 // -----------------------------------------------------------------------------
  1514 //
  1504 //
  1515 void CNcsComposeViewContainer::SetBccFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress )
  1505 void CNcsComposeViewContainer::SetBccFieldAddressesL( 
       
  1506         RPointerArray<CNcsEmailAddressObject>& aAddress )
  1516     {
  1507     {
  1517     FUNC_LOG;
  1508     FUNC_LOG;
  1518 
  1509 
  1519     iHeader->SetBccFieldAddressesL( aAddress );
  1510     iHeader->SetBccFieldAddressesL( aAddress );
  1520 
  1511 
  1571     iHeader->SetSubjectL( aSubject );
  1562     iHeader->SetSubjectL( aSubject );
  1572 
  1563 
  1573     }
  1564     }
  1574 
  1565 
  1575 // -----------------------------------------------------------------------------
  1566 // -----------------------------------------------------------------------------
  1576 // CNcsComposeViewContainer::SetAttachmentLabelTextL
  1567 // CNcsComposeViewContainer::SetAttachmentLabelTextsLD
  1577 //
  1568 //
  1578 // -----------------------------------------------------------------------------
  1569 // -----------------------------------------------------------------------------
  1579 //
  1570 //
  1580 void CNcsComposeViewContainer::SetAttachmentLabelTextL( const TDesC& aText )
  1571 void CNcsComposeViewContainer::SetAttachmentLabelTextsLD( 
  1581     {
  1572     CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes )
  1582     FUNC_LOG;
  1573     {
  1583 
  1574     FUNC_LOG;   
  1584 	iHeader->SetAttachmentLabelTextL( aText );
  1575     iHeader->SetAttachmentLabelTextsLD( aAttachmentNames, aAttachmentSizes );
  1585 
  1576     }
  1586     }
  1577 
  1587 
  1578 // -----------------------------------------------------------------------------
  1588 // -----------------------------------------------------------------------------
  1579 // CNcsComposeViewContainer::FocusedAttachmentLabelIndex
  1589 // CNcsComposeViewContainer::SetAttachmentLabelTextL
  1580 //
  1590 //
  1581 // -----------------------------------------------------------------------------
  1591 // -----------------------------------------------------------------------------
  1582 //
  1592 //
  1583 TInt CNcsComposeViewContainer::FocusedAttachmentLabelIndex()
  1593 void CNcsComposeViewContainer::SetAttachmentLabelTextL( const TDesC& aAttachmentName,
  1584     {
  1594                                                         const TDesC& aAttachmentSizeDesc )
  1585     FUNC_LOG;   
  1595     {
  1586     return iHeader->FocusedAttachmentLabelIndex();
  1596     FUNC_LOG;
       
  1597 
       
  1598     iHeader->SetAttachmentLabelTextL( aAttachmentName, aAttachmentSizeDesc );
       
  1599 
       
  1600     }
  1587     }
  1601 
  1588 
  1602 // -----------------------------------------------------------------------------
  1589 // -----------------------------------------------------------------------------
  1603 // CNcsComposeViewContainer::HideAttachmentLabel
  1590 // CNcsComposeViewContainer::HideAttachmentLabel
  1604 //
  1591 //
  1733 		iFocused = iHeader;
  1720 		iFocused = iHeader;
  1734 		iHeader->SetFocus( ETrue, EDrawNow );
  1721 		iHeader->SetFocus( ETrue, EDrawNow );
  1735 		iMessageField->SetFocus( EFalse, EDrawNow );
  1722 		iMessageField->SetFocus( EFalse, EDrawNow );
  1736 		iHeader->MakeVisible( ETrue );
  1723 		iHeader->MakeVisible( ETrue );
  1737     	}
  1724     	}
  1738 
       
  1739 	iHeader->FocusAttachmentField();
  1725 	iHeader->FocusAttachmentField();
  1740 
       
  1741 	}
  1726 	}
  1742 
  1727 
  1743 // -----------------------------------------------------------------------------
  1728 // -----------------------------------------------------------------------------
  1744 // CNcsComposeViewContainer::AreAddressFieldsEmpty
  1729 // CNcsComposeViewContainer::AreAddressFieldsEmpty
  1745 //
  1730 //
  1770 // -----------------------------------------------------------------------------
  1755 // -----------------------------------------------------------------------------
  1771 //
  1756 //
  1772 void CNcsComposeViewContainer::HandleLayoutChangeL()
  1757 void CNcsComposeViewContainer::HandleLayoutChangeL()
  1773     {
  1758     {
  1774     FUNC_LOG;
  1759     FUNC_LOG;
  1775     TRect rect = iView.ClientRect();
  1760     SetRect( iView.ClientRect() );
  1776     SetRect( rect );
       
  1777     if ( iHeader )
  1761     if ( iHeader )
  1778         {
  1762         {
  1779         iHeader->HandleDynamicVariantSwitchL();
  1763         iHeader->HandleDynamicVariantSwitchL();
  1780         }
  1764         }
  1781     UpdateScrollBarL();
  1765     UpdateScrollBarL();
  1792     if ( iHeader )
  1776     if ( iHeader )
  1793         {
  1777         {
  1794         iHeader->HandleDynamicVariantSwitchL();
  1778         iHeader->HandleDynamicVariantSwitchL();
  1795         }
  1779         }
  1796 
  1780 
  1797 // <cmail>
       
  1798     if ( iMessageField )
  1781     if ( iMessageField )
  1799         {
  1782         {
  1800         iMessageField->UpdateFontSize();
  1783         iMessageField->UpdateFontSize();
  1801         }
  1784         }
  1802 
  1785 
  1803     if ( iScrollBar )
  1786     if ( iScrollBar )
  1804         {
  1787         {
  1805         iScrollBar->HandleResourceChange( KAknsMessageSkinChange );
  1788         iScrollBar->HandleResourceChange( KAknsMessageSkinChange );
  1806         iScrollBar->DrawNow();
  1789         iScrollBar->DrawNow();
  1807         }
  1790         }
  1808 // </cmail>
       
  1809     }
  1791     }
  1810 
  1792 
  1811 // -----------------------------------------------------------------------------
  1793 // -----------------------------------------------------------------------------
  1812 // CNcsComposeViewContainer::ContentTotalHeight
  1794 // CNcsComposeViewContainer::ContentTotalHeight
  1813 // Return the total height of the components shown in the view
  1795 // Return the total height of the components shown in the view
  1817     {
  1799     {
  1818     FUNC_LOG;
  1800     FUNC_LOG;
  1819     const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
  1801     const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
  1820 	
  1802 	
  1821 	TInt totalHeight( iHeader->Size().iHeight + 
  1803 	TInt totalHeight( iHeader->Size().iHeight + 
  1822 					  separatorSize.iHeight*2 + iMessageField->Size().iHeight );
  1804 					  separatorSize.iHeight*2 + 
       
  1805 					  iMessageField->Size().iHeight );
  1823 
  1806 
  1824 	if( iReadOnlyQuoteField->IsVisible() )
  1807 	if( iReadOnlyQuoteField->IsVisible() )
  1825 		{
  1808 		{
  1826 		totalHeight += iReadOnlyQuoteField->Size().iHeight;
  1809 		totalHeight += iReadOnlyQuoteField->Size().iHeight;
  1827 		}	
  1810 		}	
  1835 // -----------------------------------------------------------------------------
  1818 // -----------------------------------------------------------------------------
  1836 //
  1819 //
  1837 void CNcsComposeViewContainer::CommitL( TFieldToCommit aFieldToCommit )
  1820 void CNcsComposeViewContainer::CommitL( TFieldToCommit aFieldToCommit )
  1838     {
  1821     {
  1839     FUNC_LOG;
  1822     FUNC_LOG;
  1840     iView.CommitL(ETrue,aFieldToCommit);
  1823     iView.CommitL( ETrue, aFieldToCommit );
  1841     iView.HandleContainerChangeRequiringToolbarRefresh();
  1824     iView.HandleContainerChangeRequiringToolbarRefresh();
  1842     }
  1825     }
  1843 
  1826 
  1844 //<cmail>
       
  1845 // -----------------------------------------------------------------------------
  1827 // -----------------------------------------------------------------------------
  1846 // CNcsComposeViewContainer::SwitchChangeMskOff
  1828 // CNcsComposeViewContainer::SwitchChangeMskOff
  1847 //sets up iSwitchChangeMskOff falg, which disables changes of MSK label if any popup dialog is open
  1829 // sets up iSwitchChangeMskOff falg, which disables changes of MSK label if
       
  1830 // any popup dialog is open
  1848 // -----------------------------------------------------------------------------
  1831 // -----------------------------------------------------------------------------
  1849 void CNcsComposeViewContainer::SwitchChangeMskOff(TBool aTag)
  1832 void CNcsComposeViewContainer::SwitchChangeMskOff(TBool aTag)
  1850     {
  1833     {
  1851     FUNC_LOG;
  1834     FUNC_LOG;
  1852     iHeader->SwitchChangeMskOff(aTag);
  1835     iHeader->SwitchChangeMskOff( aTag );
  1853     }
  1836     }
  1854 //</cmail>
  1837 
  1855 
       
  1856 //<cmail>
       
  1857 // -----------------------------------------------------------------------------
  1838 // -----------------------------------------------------------------------------
  1858 // CNcsHeaderContainer::HandleLongTapEventL()
  1839 // CNcsHeaderContainer::HandleLongTapEventL()
  1859 // Handles key events
  1840 // Handles key events
  1860 // -----------------------------------------------------------------------------
  1841 // -----------------------------------------------------------------------------
  1861 void CNcsComposeViewContainer::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /*aPenEventScreenLocation*/ )
  1842 void CNcsComposeViewContainer::HandleLongTapEventL( 
  1862     {
  1843         const TPoint& aPenEventLocation, 
  1863     FUNC_LOG;
  1844         const TPoint& aPenEventScreenLocation )
  1864     iHeader->HandleLongTapL( aPenEventLocation );
  1845     {
  1865     }
  1846     FUNC_LOG;
  1866 //</cmail>
  1847     iHeader->HandleLongTap( aPenEventLocation, aPenEventScreenLocation );
  1867 
  1848     }
  1868 
  1849 
  1869 //<cmail>
  1850 
  1870 void CNcsComposeViewContainer::FixSemicolonL()
  1851 void CNcsComposeViewContainer::FixSemicolonL()
  1871 	{
  1852 	{
  1872     FUNC_LOG;
  1853     FUNC_LOG;
  1873 	iHeader->FixSemicolonInAddressFieldsL();
  1854 	iHeader->FixSemicolonInAddressFieldsL();
  1874 	}
  1855 	}
  1875 //</cmail>
       
  1876 
  1856 
  1877 // ---------------------------------------------------------------------------
  1857 // ---------------------------------------------------------------------------
  1878 // CNcsComposeViewContainer::UpdatePhysicsL()
  1858 // CNcsComposeViewContainer::UpdatePhysicsL()
  1879 // ---------------------------------------------------------------------------
  1859 // ---------------------------------------------------------------------------
  1880 //
  1860 //
  1884     if ( iPhysics )
  1864     if ( iPhysics )
  1885         {
  1865         {
  1886         const TSize viewSize( Rect().Size() );
  1866         const TSize viewSize( Rect().Size() );
  1887         // We must ensure that world size is at least the size of the view
  1867         // We must ensure that world size is at least the size of the view
  1888         const TSize worldSize( viewSize.iWidth, 
  1868         const TSize worldSize( viewSize.iWidth, 
  1889                 Max(ContentTotalHeight(), viewSize.iHeight) );
  1869                 Max( ContentTotalHeight(), viewSize.iHeight ) );
  1890         iPhysics->InitPhysicsL( worldSize, viewSize, EFalse );
  1870         iPhysics->InitPhysicsL( worldSize, viewSize, EFalse );
  1891         }
  1871         }
  1892     }
  1872     }
  1893 
  1873 
  1894 // -----------------------------------------------------------------------------
  1874 // -----------------------------------------------------------------------------
  1898 void CNcsComposeViewContainer::ScrollL( TInt aTargetPos )
  1878 void CNcsComposeViewContainer::ScrollL( TInt aTargetPos )
  1899 	{
  1879 	{
  1900     FUNC_LOG;
  1880     FUNC_LOG;
  1901 	TPoint headerPos( iHeader->Position() );
  1881 	TPoint headerPos( iHeader->Position() );
  1902 	
  1882 	
  1903 	aTargetPos = Max( 0, Min(aTargetPos, ContentTotalHeight() - Rect().Height()) );
  1883 	aTargetPos = Max( 0, Min( aTargetPos, 
       
  1884 	                          ContentTotalHeight() - Rect().Height()) );
  1904 	
  1885 	
  1905 	TInt moveY = -headerPos.iY - aTargetPos;
  1886 	TInt moveY = -headerPos.iY - aTargetPos;
  1906 	
  1887 	
  1907 	if( moveY )
  1888 	if( moveY )
  1908 		{
  1889 		{
  1925 		UpdateScrollBarL();
  1906 		UpdateScrollBarL();
  1926 		DrawNow();
  1907 		DrawNow();
  1927 		}
  1908 		}
  1928 	}
  1909 	}
  1929 
  1910 
  1930 /**
  1911 // -----------------------------------------------------------------------------
  1931  * @see MAknPhysicsObserver::ViewPositionChanged
  1912 // CNcsComposeViewContainer::ViewPositionChanged
  1932  */
  1913 // From MAknPhysicsObserver
       
  1914 // -----------------------------------------------------------------------------
       
  1915 //
  1933 void CNcsComposeViewContainer::ViewPositionChanged(
  1916 void CNcsComposeViewContainer::ViewPositionChanged(
  1934         const TPoint& aNewPosition,
  1917         const TPoint& aNewPosition,
  1935         TBool /*aDrawNow*/,
  1918         TBool /*aDrawNow*/,
  1936         TUint /*aFlags*/ )
  1919         TUint /*aFlags*/ )
  1937     {
  1920     {
  1942 
  1925 
  1943 		TRAP_IGNORE( ScrollL( scrollOffset ) );
  1926 		TRAP_IGNORE( ScrollL( scrollOffset ) );
  1944 		}
  1927 		}
  1945 	}
  1928 	}
  1946 
  1929 
  1947 /**
  1930 // -----------------------------------------------------------------------------
  1948  * @see MAknPhysicsObserver::PhysicEmulationEnded
  1931 // CNcsComposeViewContainer::PhysicEmulationEnded
  1949  */
  1932 // From MAknPhysicsObserver
       
  1933 // -----------------------------------------------------------------------------
       
  1934 //
  1950 void CNcsComposeViewContainer::PhysicEmulationEnded()
  1935 void CNcsComposeViewContainer::PhysicEmulationEnded()
  1951     {
  1936     {
  1952     FUNC_LOG;
  1937     FUNC_LOG;
  1953     iIsFlicking = EFalse;
  1938     iIsFlicking = EFalse;
  1954     }
  1939     }
  1955 
  1940 
  1956 /**
  1941 // -----------------------------------------------------------------------------
  1957  * @see MAknPhysicsObserver::ViewPosition
  1942 // CNcsComposeViewContainer::ViewPosition
  1958  */
  1943 // From MAknPhysicsObserver
       
  1944 // -----------------------------------------------------------------------------
       
  1945 //
  1959 TPoint CNcsComposeViewContainer::ViewPosition() const
  1946 TPoint CNcsComposeViewContainer::ViewPosition() const
  1960     {
  1947     {
  1961     FUNC_LOG;
  1948     FUNC_LOG;
  1962     return TPoint(0, -iHeader->Position().iY + Rect().Size().iHeight / 2 );
  1949     return TPoint(0, -iHeader->Position().iY + Rect().Size().iHeight / 2 );
  1963     }
  1950     }
  1964 
  1951 
  1965 
  1952 
       
  1953 // -----------------------------------------------------------------------------
       
  1954 // CNcsComposeViewContainer::IsRemoteSearchInprogress
       
  1955 // -----------------------------------------------------------------------------
       
  1956 //
  1966 TBool CNcsComposeViewContainer::IsRemoteSearchInprogress() const
  1957 TBool CNcsComposeViewContainer::IsRemoteSearchInprogress() const
  1967     {
  1958     {
  1968     FUNC_LOG;
  1959     FUNC_LOG;
  1969     return iHeader->IsRemoteSearchInprogress();
  1960     return iHeader->IsRemoteSearchInprogress();
  1970     }
  1961     }