emailuis/emailui/src/ncscomposeviewcontainer.cpp
branchRCL_3
changeset 35 e64954c2c8e2
parent 34 cd2816114bd1
child 24 b5fbb9b25d57
equal deleted inserted replaced
34:cd2816114bd1 35:e64954c2c8e2
   158     CleanupStack::Pop( iScrollBar );
   158     CleanupStack::Pop( iScrollBar );
   159 
   159 
   160     iMessageField->SetupEditorL();
   160     iMessageField->SetupEditorL();
   161     iReadOnlyQuoteField->SetupEditorL();
   161     iReadOnlyQuoteField->SetupEditorL();
   162 
   162 
   163     SetRect( aRect );
       
   164 
       
   165     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   163     iBgContext = CAknsBasicBackgroundControlContext::NewL(
   166         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
   164         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
   167 
   165 
       
   166     SetRect( aRect );
       
   167 
   168     iLongTapDetector = CAknLongTapDetector::NewL( this );
   168     iLongTapDetector = CAknLongTapDetector::NewL( this );
   169 
   169 
   170     ActivateL();
   170     ActivateL();
   171     DrawDeferred();
   171     DrawDeferred();
   172 
   172 
   173     // activate auto save functionality
   173     // activate auto save functionality
   174     iAutoSaver.Enable( ETrue );
   174     iAutoSaver.Enable( ETrue );
   175 
       
   176     }
   175     }
   177 
   176 
   178 // ---------------------------------------------------------------------------
   177 // ---------------------------------------------------------------------------
   179 // CNcsComposeViewContainer::~CNcsComposeViewContainer
   178 // CNcsComposeViewContainer::~CNcsComposeViewContainer
   180 // Destructor
   179 // Destructor
   255 //
   254 //
   256 void CNcsComposeViewContainer::HandlePointerEventL( 
   255 void CNcsComposeViewContainer::HandlePointerEventL( 
   257         const TPointerEvent& aPointerEvent )
   256         const TPointerEvent& aPointerEvent )
   258     {
   257     {
   259     FUNC_LOG;
   258     FUNC_LOG;
   260 
       
   261     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   262 
       
   263     if ( aPointerEvent.iType != TPointerEvent::EButton1Down &&
   259     if ( aPointerEvent.iType != TPointerEvent::EButton1Down &&
   264          iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   260          iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   265         {
   261         {
   266     	iLongTapDetector->PointerEventL( aPointerEvent );
   262     	iLongTapDetector->PointerEventL( aPointerEvent );
   267         }
   263         }
   294 						iMessageField->ClearSelectionL();
   290 						iMessageField->ClearSelectionL();
   295 						}
   291 						}
   296                     iMessageField->SetFocus( EFalse, ENoDrawNow );
   292                     iMessageField->SetFocus( EFalse, ENoDrawNow );
   297                     iFocused = iHeader;
   293                     iFocused = iHeader;
   298                     iHeader->SetFocus( ETrue,ENoDrawNow );
   294                     iHeader->SetFocus( ETrue,ENoDrawNow );
   299                     iHeader->MakeVisible( ETrue );
       
   300                     CommitL( EBodyField );
       
   301                     iView.HandleContainerChangeRequiringToolbarRefresh();
       
   302                     }
   295                     }
   303                 else if ( iFocused == iReadOnlyQuoteField )
   296                 else if ( iFocused == iReadOnlyQuoteField )
   304                     {
   297                     {
   305                     iFocused = iMessageField;
       
   306                     iReadOnlyQuoteField->SetFocus( EFalse, ENoDrawNow );
   298                     iReadOnlyQuoteField->SetFocus( EFalse, ENoDrawNow );
       
   299                     iFocused = iHeader;
   307                     iHeader->SetFocus( ETrue, ENoDrawNow );
   300                     iHeader->SetFocus( ETrue, ENoDrawNow );
   308                     iView.HandleContainerChangeRequiringToolbarRefresh();
       
   309                     }
   301                     }
   310                 }
   302                 }
   311             else if ( iReadOnlyQuoteField->Rect().Contains( 
   303             else if ( iReadOnlyQuoteField->Rect().Contains( 
   312                         aPointerEvent.iPosition ) )
   304                         aPointerEvent.iPosition ) )
   313                 {
   305                 {
   314                 if ( iFocused == iMessageField )
   306                 if ( iFocused == iMessageField )
   315                     {
   307                     {
       
   308                     iMessageField->SetFocus( EFalse, ENoDrawNow );
   316                     iFocused = iReadOnlyQuoteField;
   309                     iFocused = iReadOnlyQuoteField;
   317                     iReadOnlyQuoteField->SetFocus( ETrue, ENoDrawNow );
   310                     iReadOnlyQuoteField->SetFocus( ETrue, ENoDrawNow );
   318                     iMessageField->SetFocus( EFalse, ENoDrawNow );
       
   319                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   311                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   320                     iView.HandleContainerChangeRequiringToolbarRefresh();
       
   321                     }
   312                     }
   322                 else if ( iFocused == iHeader )
   313                 else if ( iFocused == iHeader )
   323                     {
   314                     {
       
   315                     iHeader->SetFocus( EFalse, ENoDrawNow );
   324                     iFocused = iReadOnlyQuoteField;
   316                     iFocused = iReadOnlyQuoteField;
   325                     iReadOnlyQuoteField->SetFocus( ETrue, ENoDrawNow );
   317                     iReadOnlyQuoteField->SetFocus( ETrue, ENoDrawNow );
   326                     iHeader->SetFocus( EFalse, ENoDrawNow );
       
   327                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   318                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
   328                     iView.HandleContainerChangeRequiringToolbarRefresh();
       
   329                     }
   319                     }
   330                 }
   320                 }
   331             else 
   321             else 
   332                 {
   322                 {
   333                 if ( iFocused == iHeader )
   323                 if ( iFocused == iHeader )
   334                     {
   324                     {
   335                     //TRAP_IGNORE( DoUpdateSubjectL() );
       
   336 
       
   337                     iHeader->SetFocus( EFalse, ENoDrawNow );
   325                     iHeader->SetFocus( EFalse, ENoDrawNow );
   338                     iFocused = iMessageField;
   326                     iFocused = iMessageField;
   339                     iMessageField->SetFocus( ETrue, ENoDrawNow );
   327                     iMessageField->SetFocus( ETrue, ENoDrawNow );
   340                     iView.HandleContainerChangeRequiringToolbarRefresh();
       
   341                     }
   328                     }
   342                 else if ( iFocused == iReadOnlyQuoteField )
   329                 else if ( iFocused == iReadOnlyQuoteField )
   343                     {
   330                     {
       
   331                     iReadOnlyQuoteField->SetFocus( EFalse, ENoDrawNow );
   344                     iFocused = iMessageField;
   332                     iFocused = iMessageField;
   345                     iReadOnlyQuoteField->SetFocus( EFalse, ENoDrawNow );
       
   346                     iMessageField->SetFocus( ETrue, ENoDrawNow );
   333                     iMessageField->SetFocus( ETrue, ENoDrawNow );
   347                     iView.HandleContainerChangeRequiringToolbarRefresh();
       
   348                     }
   334                     }
   349                 else 
   335                 else
   350                     {
   336                     {
   351 					iMessageField->ClearSelectionL();
   337                     iMessageField->ClearSelectionL();
   352 
       
   353                     const TRect messageFieldRect( iMessageField->Rect() );
       
   354                     if ( !messageFieldRect.Contains( aPointerEvent.iPosition ) && 
       
   355                          aPointerEvent.iPosition.iY >= messageFieldRect.iTl.iY )
       
   356                         {
       
   357                         iMessageField->OpenVirtualKeyBoardL();
       
   358                         }
       
   359                     }
   338                     }
   360                 }
   339                 }
   361 
   340 
   362 			break;
   341 			break;
   363     		}
   342     		}
   364     	
   343     	
   365     	case TPointerEvent::EButton1Up:    		
   344     	case TPointerEvent::EButton1Up:    		
   366     		{
   345     		{
   367             if( iIsDragging && iPhysics )
   346             if( iIsDragging && iPhysics )
   368                 {
   347                 {
   369                 TPoint drag( iOriginalPosition - aPointerEvent.iParentPosition );
   348                 TPoint drag( iOriginalPosition - aPointerEvent.iPosition );
   370                 iPhysics->StartPhysics( drag, iStartTime );
   349                 iPhysics->StartPhysics( drag, iStartTime );
   371                 iIsFlicking = ETrue;
   350                 iIsFlicking = ETrue;
   372                 iIsDragging = EFalse;
   351                 iIsDragging = EFalse;
   373                 }
   352                 }
   374     		break;
   353     		break;
   381                 TInt drag( iOriginalPosition.iY - aPointerEvent.iPosition.iY );
   360                 TInt drag( iOriginalPosition.iY - aPointerEvent.iPosition.iY );
   382                 if ( Abs( drag ) > iPhysics->DragThreshold() )
   361                 if ( Abs( drag ) > iPhysics->DragThreshold() )
   383                     {
   362                     {
   384 					// If user started dragging, cancel hotspot actions
   363 					// If user started dragging, cancel hotspot actions
   385 					iIsDragging = ETrue;
   364 					iIsDragging = ETrue;
       
   365 					iMessageField->SetCursorVisible( EFalse );
       
   366 					iReadOnlyQuoteField->SetCursorVisible( EFalse );
       
   367 					iHeader->SetPhysicsEmulationOngoing( ETrue );
   386                     }
   368                     }
   387                 }
   369                 }
   388 
   370 
   389             // Get current pointer position
   371             // Get current pointer position
   390             TPoint position = aPointerEvent.iPosition;
   372             TPoint position = aPointerEvent.iPosition;
   418 					scrollOffset = Max( scrollOffset, 0 );
   400 					scrollOffset = Max( scrollOffset, 0 );
   419 					scrollOffset = Min( scrollOffset, 
   401 					scrollOffset = Min( scrollOffset, 
   420                                         totalHeight - areaHeight );
   402                                         totalHeight - areaHeight );
   421 					}
   403 					}
   422 
   404 
   423 				ScrollL( scrollOffset );
   405 				Scroll( scrollOffset );
   424 				}
   406 				}
   425            
   407            
   426 			// Save current position as previous pos for future calculations
   408 			// Save current position as previous pos for future calculations
   427 			iPreviousPosition = position;  
   409 			iPreviousPosition = position;  
   428 			
   410 			
   439     if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   421     if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   440          iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   422          iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
   441         {
   423         {
   442         iLongTapDetector->PointerEventL( aPointerEvent );
   424         iLongTapDetector->PointerEventL( aPointerEvent );
   443         }
   425         }
       
   426 
       
   427     CCoeControl::HandlePointerEventL( aPointerEvent );
   444     }
   428     }
   445 
   429 
   446 // -----------------------------------------------------------------------------
   430 // -----------------------------------------------------------------------------
   447 // CNcsComposeViewContainer::OfferKeyEventL()
   431 // CNcsComposeViewContainer::OfferKeyEventL()
   448 // Handles key events
   432 // Handles key events
   611 
   595 
   612         quotePos.iY += moveY;
   596         quotePos.iY += moveY;
   613         iReadOnlyQuoteField->SetPosition( quotePos );
   597         iReadOnlyQuoteField->SetPosition( quotePos );
   614 
   598 
   615         iSeparatorLineYPos += moveY;
   599         iSeparatorLineYPos += moveY;
   616         UpdateScrollBarL();
   600         UpdateScrollBar();
   617         }
   601         }
   618     }
   602     }
   619 
   603 
   620 // -----------------------------------------------------------------------------
   604 // -----------------------------------------------------------------------------
   621 // CNcsComposeViewContainer::UpdateFieldPosition
   605 // CNcsComposeViewContainer::UpdateFieldPosition
   624 //
   608 //
   625 void CNcsComposeViewContainer::UpdateFieldPosition( CCoeControl* aAnchor )
   609 void CNcsComposeViewContainer::UpdateFieldPosition( CCoeControl* aAnchor )
   626     {
   610     {
   627     FUNC_LOG;
   611     FUNC_LOG;
   628 
   612 
   629 	// We may not be completely constructed
   613     // We may not be completely constructed
   630 	if ( iHeader && iMessageField && iReadOnlyQuoteField )
   614     if ( iHeader && iMessageField && iReadOnlyQuoteField )
   631 	    {
   615         {
   632 	    // First, move all the controls in the header
   616         // First, move all the controls in the header
   633 	    iHeader->UpdateFieldPosition( aAnchor );
   617         iHeader->UpdateFieldPosition( aAnchor );
   634 
   618 
   635 	    // Then, move the body field below the header
   619         // Then, move the body field below the header
   636 	    TRect headerRect = iHeader->Rect();
   620         TRect headerRect = iHeader->Rect();
   637 	            
   621 
   638 		const TSize separatorSize( 
   622         const TSize separatorSize( 
   639 		        NcsUtility::SeparatorSizeInThisResolution() );
   623             NcsUtility::SeparatorSizeInThisResolution() );
   640 		iSeparatorLineYPos = headerRect.iBr.iY;
   624         iSeparatorLineYPos = headerRect.iBr.iY;
   641 			
   625 
   642 		TPoint bodyPos( iMessageField->Position() );
   626         TPoint bodyPos( iMessageField->Position() );
   643 		bodyPos.iY = iSeparatorLineYPos + separatorSize.iHeight;
   627         bodyPos.iY = iSeparatorLineYPos + separatorSize.iHeight;
   644 		iMessageField->SetPosition( bodyPos );
   628         iMessageField->SetPosition( bodyPos );
   645 		
   629 
   646 		TPoint quotePos( iReadOnlyQuoteField->Position() );
   630         TPoint quotePos( iReadOnlyQuoteField->Position() );
   647 		quotePos.iY = iMessageField->Rect().iBr.iY;
   631         quotePos.iY = iMessageField->Rect().iBr.iY;
   648 		iReadOnlyQuoteField->SetPosition( quotePos );
   632         iReadOnlyQuoteField->SetPosition( quotePos );
   649 
   633 
   650 	    TRAP_IGNORE( UpdateScrollBarL() );
   634         UpdateScrollBar();
   651 
   635         DrawDeferred();
   652 	    DrawDeferred();
   636         }
   653 	    }
       
   654 
   637 
   655     }
   638     }
   656 
   639 
   657 // -----------------------------------------------------------------------------
   640 // -----------------------------------------------------------------------------
   658 // CNcsComposeViewContainer::ChangeFocusL()
   641 // CNcsComposeViewContainer::ChangeFocusL()
   721 //
   704 //
   722 TBool CNcsComposeViewContainer::UpdateFieldSizeL( TBool aDoScroll )
   705 TBool CNcsComposeViewContainer::UpdateFieldSizeL( TBool aDoScroll )
   723     {
   706     {
   724     FUNC_LOG;
   707     FUNC_LOG;
   725 
   708 
   726 	// We may not have finished construction
   709     // We may not have finished construction
   727 	if ( iHeader && iMessageField && iReadOnlyQuoteField && !aDoScroll )
   710     if ( iHeader && iMessageField && iReadOnlyQuoteField && !aDoScroll )
   728 	    {
   711         {
   729 	    SizeChanged();
   712         SizeChanged();
   730 	    DrawDeferred();
   713         }
   731 	    }
   714     if ( iHeader && aDoScroll )
   732 	if ( iHeader && aDoScroll )
   715         {
   733 	    {
   716         iHeader->DoScroll();
   734 	    iHeader->DoScrollL();
   717         }
   735 	    }
   718 
   736 
   719     return EFalse;
   737 	return EFalse;
       
   738     }
   720     }
   739 
   721 
   740 // -----------------------------------------------------------------------------
   722 // -----------------------------------------------------------------------------
   741 // CNcsComposeViewContainer::SizeChanged()
   723 // CNcsComposeViewContainer::SizeChanged()
   742 // set size
   724 // set size
   778         TRAP_IGNORE( iReadOnlyQuoteField->FormatAllTextNowL() );
   760         TRAP_IGNORE( iReadOnlyQuoteField->FormatAllTextNowL() );
   779         iReadOnlyQuoteField->UpdateFontSize();
   761         iReadOnlyQuoteField->UpdateFontSize();
   780         readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height();
   762         readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height();
   781         }
   763         }
   782 
   764 
   783     if ( iBgContext )
   765     iBgContext->SetRect( Rect() );
   784         {
       
   785         iBgContext->SetRect( Rect() );
       
   786         }  
       
   787     iMessageField->SetRealRect( Rect() );
   766     iMessageField->SetRealRect( Rect() );
   788     iReadOnlyQuoteField->SetRealRect( Rect() );
   767     iReadOnlyQuoteField->SetRealRect( Rect() );
   789     
   768 
   790     TInt messageLineHeigth = 
   769     TInt messageLineHeigth = 
   791         NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
   770         NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
       
   771     iSeparatorHeight = NcsUtility::SeparatorSizeInThisResolution().iHeight;
   792     iMessageEditorMinHeigth = 
   772     iMessageEditorMinHeigth = 
   793         cmailPaneRect.Height() - iHeader->Size().iHeight -
   773         cmailPaneRect.Height() - iHeader->Size().iHeight -
   794         NcsUtility::SeparatorSizeInThisResolution().iHeight -
   774         iSeparatorHeight -
   795         readOnlyQuoteFieldHeight;
   775         readOnlyQuoteFieldHeight;
   796     
   776     
   797     iMessageEditorMinHeigth -= iMessageEditorMinHeigth % messageLineHeigth;
   777     iMessageEditorMinHeigth -= iMessageEditorMinHeigth % messageLineHeigth;
   798     if ( iMessageEditorMinHeigth > messageLineHeigth )
   778     if ( iMessageEditorMinHeigth > messageLineHeigth )
   799         {
   779         {
   806     else
   786     else
   807         {
   787         {
   808         iMessageEditorMinHeigth = messageLineHeigth;
   788         iMessageEditorMinHeigth = messageLineHeigth;
   809         }
   789         }
   810 
   790 
   811     TRAP_IGNORE( UpdateScrollBarL() );
   791 	// update some layout variables
   812     DrawNow();
   792     TRect headerRect = iHeader->Rect();
       
   793     TRect bodyRect = iMessageField->Rect();
       
   794     TRect quoteRect = iReadOnlyQuoteField->Rect();
       
   795 
       
   796     iTotalComposerHeight = headerRect.Height() + iSeparatorHeight * 2 + 
       
   797 							   bodyRect.Height() + quoteRect.Height();
   813     
   798     
       
   799     iVisibleAreaHeight = Rect().Height();
       
   800         
       
   801     UpdateScrollBar();
       
   802 
       
   803     iScrollBarModel.SetScrollSpan( iTotalComposerHeight );
       
   804     iScrollBarModel.SetWindowSize( iVisibleAreaHeight );
       
   805     DrawDeferred();
   814     }
   806     }
   815 
   807 
   816 // -----------------------------------------------------------------------------
   808 // -----------------------------------------------------------------------------
   817 // CNcsComposeViewContainer::Draw() const
   809 // CNcsComposeViewContainer::Draw() const
   818 // Draws the display
   810 // Draws the display
   820 //
   812 //
   821 void CNcsComposeViewContainer::Draw( const TRect& aRect ) const
   813 void CNcsComposeViewContainer::Draw( const TRect& aRect ) const
   822     {
   814     {
   823     FUNC_LOG;
   815     FUNC_LOG;
   824 
   816 
   825     if ( iBgContext )
   817     CWindowGc& gc = SystemGc();
   826         {
   818     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   827         CWindowGc& gc = SystemGc();
   819     if ( skin )
   828         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   820         {
   829         if ( skin )
   821         AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
   830             {
       
   831             AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
       
   832             }
       
   833         }
   822         }
   834     }
   823     }
   835 
   824 
   836 // -----------------------------------------------------------------------------
   825 // -----------------------------------------------------------------------------
   837 // CNcsComposeViewContainer::SetBodyContentL()
   826 // CNcsComposeViewContainer::SetBodyContentL()
   884 
   873 
   885     TInt messageLength = iMessageField->TextLength();
   874     TInt messageLength = iMessageField->TextLength();
   886     HBufC* message = HBufC::NewLC( messageLength );
   875     HBufC* message = HBufC::NewLC( messageLength );
   887     TPtr messagePtr = message->Des();
   876     TPtr messagePtr = message->Des();
   888     iMessageField->GetText( messagePtr );
   877     iMessageField->GetText( messagePtr );
   889     NcsUtility::ConvertLineEndingsL( message );
   878 
   890     CleanupStack::Pop();
   879     CleanupStack::Pop();
   891     CleanupStack::PushL( message );
   880     CleanupStack::PushL( message );
   892     messageLength = message->Length();
   881     messageLength = message->Length();
   893 
   882 
   894     // Append read-only quote if present
   883     // Append read-only quote if present
   937         iPhysics->ResetFriction();
   926         iPhysics->ResetFriction();
   938         }
   927         }
   939         
   928         
   940     ClosePopupContactListL();
   929     ClosePopupContactListL();
   941 
   930 
   942     ScrollL( aScrollBar->ThumbPosition() );
   931     Scroll( aScrollBar->ThumbPosition() );
   943     }
   932     }
   944 
   933 
   945 // -----------------------------------------------------------------------------
   934 // -----------------------------------------------------------------------------
   946 // CNcsComposeViewContainer::OperationCompleteL
   935 // CNcsComposeViewContainer::OperationCompleteL
   947 // -----------------------------------------------------------------------------
   936 // -----------------------------------------------------------------------------
  1017             iAutoSaver.ReportActivity();
  1006             iAutoSaver.ReportActivity();
  1018 
  1007 
  1019             // Update screen position and scroll bar when text changed
  1008             // Update screen position and scroll bar when text changed
  1020             // or cursor moved
  1009             // or cursor moved
  1021             UpdateScreenPositionL();
  1010             UpdateScreenPositionL();
  1022             UpdateScrollBarL();
  1011             UpdateScrollBar();
  1023             DrawDeferred();
  1012             DrawDeferred();
  1024             }
  1013             }
  1025         }
  1014         }
  1026     }
  1015     }
  1027 
  1016 
  1040 
  1029 
  1041     if ( aDesirableEdwinSize.iHeight < iPrevDesiredHeigth )
  1030     if ( aDesirableEdwinSize.iHeight < iPrevDesiredHeigth )
  1042         {
  1031         {
  1043         if ( aDesirableEdwinSize.iHeight < iMessageEditorMinHeigth )
  1032         if ( aDesirableEdwinSize.iHeight < iMessageEditorMinHeigth )
  1044             {
  1033             {
  1045             ScrollL( 0 );
  1034             Scroll( 0 );
  1046             }
  1035             }
  1047         }
  1036         }
  1048 
  1037 
  1049     if ( aEdwin == iMessageField ) 
  1038     if ( aEdwin == iMessageField ) 
  1050         {
  1039         {
  1077 // -----------------------------------------------------------------------------
  1066 // -----------------------------------------------------------------------------
  1078 //
  1067 //
  1079 TTypeUid::Ptr CNcsComposeViewContainer::MopSupplyObject( TTypeUid aId )
  1068 TTypeUid::Ptr CNcsComposeViewContainer::MopSupplyObject( TTypeUid aId )
  1080     {
  1069     {
  1081     FUNC_LOG;
  1070     FUNC_LOG;
       
  1071     if ( aId.iUid == MAknsControlContext::ETypeId )
       
  1072         {
       
  1073         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
  1074         }
  1082     return CCoeControl::MopSupplyObject( aId );
  1075     return CCoeControl::MopSupplyObject( aId );
  1083     }
  1076     }
  1084 
  1077 
  1085 // -----------------------------------------------------------------------------
  1078 // -----------------------------------------------------------------------------
  1086 // CNcsComposeViewContainer::UpdateScrollBarL()
  1079 // CNcsComposeViewContainer::UpdateScrollBar()
  1087 // -----------------------------------------------------------------------------
  1080 // -----------------------------------------------------------------------------
  1088 //
  1081 //
  1089 void CNcsComposeViewContainer::UpdateScrollBarL()
  1082 void CNcsComposeViewContainer::UpdateScrollBar()
  1090     {
  1083     {
  1091     FUNC_LOG;
  1084     FUNC_LOG;
  1092 
  1085 
  1093     TRect headerRect = iHeader->Rect();
  1086     TRect headerRect = iHeader->Rect();
  1094     TRect bodyRect = iMessageField->Rect();
       
  1095     TRect quoteRect = iReadOnlyQuoteField->Rect();
       
  1096     const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
       
  1097 
       
  1098     TInt totalComposerHeight = headerRect.Height() + separatorSize.iHeight*2 + 
       
  1099 							   bodyRect.Height() + quoteRect.Height();
       
  1100     
       
  1101     TInt visibleAreaHeight = Rect().Height();
       
  1102     TInt visiblePosition = -headerRect.iTl.iY;
  1087     TInt visiblePosition = -headerRect.iTl.iY;
  1103 
  1088 
  1104     iScrollBarModel.SetScrollSpan( totalComposerHeight );
       
  1105     iScrollBarModel.SetWindowSize( visibleAreaHeight );
       
  1106     iScrollBarModel.SetFocusPosition( visiblePosition );
  1089     iScrollBarModel.SetFocusPosition( visiblePosition );
  1107 
  1090 
  1108     iScrollBar->SetModelL( &iScrollBarModel );
  1091     iScrollBar->SetModel( &iScrollBarModel );
  1109     iScrollBar->MakeVisible( IsVisible() );
  1092     iScrollBar->MakeVisible( IsVisible() );
  1110     }
  1093     }
  1111 
  1094 
  1112 // -----------------------------------------------------------------------------
  1095 // -----------------------------------------------------------------------------
  1113 // CNcsComposeViewContainer::SetFocusToMessageFieldL()
  1096 // CNcsComposeViewContainer::SetFocusToMessageFieldL()
  1806         {
  1789         {
  1807         iHeader->HandleDynamicVariantSwitchL();
  1790         iHeader->HandleDynamicVariantSwitchL();
  1808         }
  1791         }
  1809     // force recalculation of the position of every component
  1792     // force recalculation of the position of every component
  1810     UpdateFieldPosition( NULL );
  1793     UpdateFieldPosition( NULL );
  1811     UpdateScrollBarL();
  1794     UpdateScrollBar();
  1812     }
  1795     }
  1813 
  1796 
  1814 // -----------------------------------------------------------------------------
  1797 // -----------------------------------------------------------------------------
  1815 // CNcsComposeViewContainer::HandleSkinChangeL
  1798 // CNcsComposeViewContainer::HandleSkinChangeL
  1816 //
  1799 //
  1841 // Return the total height of the components shown in the view
  1824 // Return the total height of the components shown in the view
  1842 // -----------------------------------------------------------------------------
  1825 // -----------------------------------------------------------------------------
  1843 //
  1826 //
  1844 TInt CNcsComposeViewContainer::ContentTotalHeight()
  1827 TInt CNcsComposeViewContainer::ContentTotalHeight()
  1845     {
  1828     {
  1846     FUNC_LOG;
  1829     FUNC_LOG;	
  1847     const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
       
  1848 	
       
  1849 	TInt totalHeight( iHeader->Size().iHeight + 
  1830 	TInt totalHeight( iHeader->Size().iHeight + 
  1850 					  separatorSize.iHeight*2 + 
  1831 	                  iSeparatorHeight * 2 + 
  1851 					  iMessageField->Size().iHeight );
  1832 					  iMessageField->Size().iHeight );
  1852 
  1833 
  1853 	if( iReadOnlyQuoteField->IsVisible() )
  1834 	if( iReadOnlyQuoteField->IsVisible() )
  1854 		{
  1835 		{
  1855 		totalHeight += iReadOnlyQuoteField->Size().iHeight;
  1836 		totalHeight += iReadOnlyQuoteField->Size().iHeight;
  1916         iPhysics->InitPhysicsL( worldSize, viewSize, EFalse );
  1897         iPhysics->InitPhysicsL( worldSize, viewSize, EFalse );
  1917         }
  1898         }
  1918     }
  1899     }
  1919 
  1900 
  1920 // -----------------------------------------------------------------------------
  1901 // -----------------------------------------------------------------------------
  1921 // CNcsComposeViewContainer::ScrollL()
  1902 // CNcsComposeViewContainer::Scroll()
  1922 // -----------------------------------------------------------------------------
  1903 // -----------------------------------------------------------------------------
  1923 //
  1904 //
  1924 void CNcsComposeViewContainer::ScrollL( TInt aTargetPos )
  1905 void CNcsComposeViewContainer::Scroll( TInt aTargetPos, TBool aDrawNow )
  1925 	{
  1906     {
  1926     FUNC_LOG;
  1907     FUNC_LOG;
  1927 	TPoint headerPos( iHeader->Position() );
  1908 	TPoint headerPos( iHeader->Position() );
  1928 	
       
  1929 	TInt moveY = -headerPos.iY - aTargetPos;
  1909 	TInt moveY = -headerPos.iY - aTargetPos;
  1930 	
  1910 	
  1931 	if( moveY )
  1911     if ( aDrawNow )
  1932 		{
  1912     	{
  1933 		headerPos.iY += moveY;
  1913 		moveY = iTotalMoveY + moveY;
  1934 		iHeader->SetPosition( headerPos );
  1914 		iTotalMoveY = 0;
  1935 		
  1915 		if ( moveY )
  1936 		TPoint msgPos( iMessageField->Position() );
       
  1937 		msgPos.iY += moveY;
       
  1938 		iMessageField->SetPosition( msgPos );
       
  1939 		
       
  1940 		if( iReadOnlyQuoteField->IsVisible() )
       
  1941 			{
  1916 			{
  1942 			TPoint readOnlyPos( iReadOnlyQuoteField->Position() );
  1917 			headerPos.iY += moveY;
  1943 			readOnlyPos.iY += moveY;
  1918 			iHeader->SetPosition( headerPos );
  1944 			iReadOnlyQuoteField->SetPosition( readOnlyPos );
  1919 	
       
  1920 			TPoint msgPos( iMessageField->Position() );
       
  1921 			msgPos.iY += moveY;
       
  1922 			iMessageField->SetPosition( msgPos );
       
  1923 	
       
  1924 			if( iReadOnlyQuoteField->IsVisible() )
       
  1925 				{
       
  1926 				TPoint readOnlyPos( iReadOnlyQuoteField->Position() );
       
  1927 				readOnlyPos.iY += moveY;
       
  1928 				iReadOnlyQuoteField->SetPosition( readOnlyPos );
       
  1929 				}
       
  1930 	
       
  1931 			iSeparatorLineYPos += moveY;
       
  1932 
       
  1933 			UpdateScrollBar();
       
  1934 			DrawNow();
  1945 			}
  1935 			}
  1946 		
  1936     	}
  1947 		iSeparatorLineYPos += moveY;
  1937     else
  1948 	
  1938     	{
  1949 		UpdateScrollBarL();
  1939 		iTotalMoveY += moveY;
  1950 		DrawDeferred();
  1940     	}    	
  1951 		}
  1941     }
  1952 	}
       
  1953 
  1942 
  1954 // -----------------------------------------------------------------------------
  1943 // -----------------------------------------------------------------------------
  1955 // CNcsComposeViewContainer::ViewPositionChanged
  1944 // CNcsComposeViewContainer::ViewPositionChanged
  1956 // From MAknPhysicsObserver
  1945 // From MAknPhysicsObserver
  1957 // -----------------------------------------------------------------------------
  1946 // -----------------------------------------------------------------------------
  1958 //
  1947 //
  1959 void CNcsComposeViewContainer::ViewPositionChanged(
  1948 void CNcsComposeViewContainer::ViewPositionChanged(
  1960         const TPoint& aNewPosition,
  1949     const TPoint& aNewPosition, TBool aDrawNow, TUint /*aFlags*/ )
  1961         TBool /*aDrawNow*/,
  1950     {
  1962         TUint /*aFlags*/ )
  1951     FUNC_LOG;
  1963     {
  1952     TInt scrollOffset = aNewPosition.iY - iVisibleAreaHeight / 2;
  1964     FUNC_LOG;
  1953     Scroll( scrollOffset, aDrawNow );
  1965 	TInt scrollOffset = aNewPosition.iY - Rect().Size().iHeight / 2;
  1954     }
  1966 
       
  1967 	TRAP_IGNORE( ScrollL( scrollOffset ) );
       
  1968 	}
       
  1969 
  1955 
  1970 // -----------------------------------------------------------------------------
  1956 // -----------------------------------------------------------------------------
  1971 // CNcsComposeViewContainer::PhysicEmulationEnded
  1957 // CNcsComposeViewContainer::PhysicEmulationEnded
  1972 // From MAknPhysicsObserver
  1958 // From MAknPhysicsObserver
  1973 // -----------------------------------------------------------------------------
  1959 // -----------------------------------------------------------------------------
  1974 //
  1960 //
  1975 void CNcsComposeViewContainer::PhysicEmulationEnded()
  1961 void CNcsComposeViewContainer::PhysicEmulationEnded()
  1976     {
  1962     {
  1977     FUNC_LOG;
  1963     FUNC_LOG;
  1978     iIsFlicking = EFalse;
  1964     iIsFlicking = EFalse;
       
  1965     iMessageField->SetCursorVisible( ETrue );
       
  1966     iReadOnlyQuoteField->SetCursorVisible( ETrue );
       
  1967     iHeader->SetPhysicsEmulationOngoing( EFalse );
  1979     }
  1968     }
  1980 
  1969 
  1981 // -----------------------------------------------------------------------------
  1970 // -----------------------------------------------------------------------------
  1982 // CNcsComposeViewContainer::ViewPosition
  1971 // CNcsComposeViewContainer::ViewPosition
  1983 // From MAknPhysicsObserver
  1972 // From MAknPhysicsObserver
  1984 // -----------------------------------------------------------------------------
  1973 // -----------------------------------------------------------------------------
  1985 //
  1974 //
  1986 TPoint CNcsComposeViewContainer::ViewPosition() const
  1975 TPoint CNcsComposeViewContainer::ViewPosition() const
  1987     {
  1976     {
  1988     FUNC_LOG;
  1977     FUNC_LOG;
  1989     return TPoint(0, -iHeader->Position().iY + Rect().Size().iHeight / 2 );
  1978     return TPoint(0, -iHeader->Position().iY  + iVisibleAreaHeight / 2 );
  1990     }
  1979     }
  1991 
  1980 
  1992 
  1981 
  1993 // -----------------------------------------------------------------------------
  1982 // -----------------------------------------------------------------------------
  1994 // CNcsComposeViewContainer::IsRemoteSearchInprogress
  1983 // CNcsComposeViewContainer::IsRemoteSearchInprogress