146 CleanupStack::Pop( iReadOnlyQuoteField ); |
146 CleanupStack::Pop( iReadOnlyQuoteField ); |
147 |
147 |
148 // Listen edwin events and size events from smart quote field |
148 // Listen edwin events and size events from smart quote field |
149 iReadOnlyQuoteField->AddEdwinObserverL( this ); |
149 iReadOnlyQuoteField->AddEdwinObserverL( this ); |
150 iReadOnlyQuoteField->SetEdwinSizeObserver( this ); |
150 iReadOnlyQuoteField->SetEdwinSizeObserver( this ); |
151 iReadOnlyQuoteField->EnableKineticScrollingL( iPhysics ); |
151 iReadOnlyQuoteField->EnableKineticScrollingL( iPhysics ); |
152 |
152 |
153 // Create the scroll bar |
153 // Create the scroll bar |
154 iScrollBar = new( ELeave ) CAknDoubleSpanScrollBar( this ); |
154 iScrollBar = new( ELeave ) CAknDoubleSpanScrollBar( this ); |
155 iScrollBar->ConstructL( ETrue, this, this, CEikScrollBar::EVertical, |
155 iScrollBar->ConstructL( ETrue, this, this, CEikScrollBar::EVertical, |
156 aRect.Height() ); |
156 aRect.Height() ); |
197 if ( iAsyncTextFormatter ) |
197 if ( iAsyncTextFormatter ) |
198 { |
198 { |
199 iAsyncTextFormatter->Cancel(); |
199 iAsyncTextFormatter->Cancel(); |
200 delete iAsyncTextFormatter; |
200 delete iAsyncTextFormatter; |
201 } |
201 } |
202 |
202 |
203 if ( iContactHandler ) |
203 if ( iContactHandler ) |
204 { |
204 { |
205 iContactHandler->ClearObservers(); |
205 iContactHandler->ClearObservers(); |
206 } |
206 } |
207 delete iHeader; |
207 delete iHeader; |
208 delete iScrollBar; |
208 delete iScrollBar; |
209 delete iMessageField; |
209 delete iMessageField; |
210 delete iBgContext; |
210 delete iBgContext; |
211 delete iLongTapDetector; |
211 delete iLongTapDetector; |
212 delete iReadOnlyQuoteField; |
212 delete iReadOnlyQuoteField; |
213 delete iReadOnlyQuote; |
213 delete iReadOnlyQuote; |
214 |
214 |
215 delete iPhysics; |
215 delete iPhysics; |
216 iPhysics = NULL; |
216 iPhysics = NULL; |
230 iFocused != iMessageField && |
230 iFocused != iMessageField && |
231 iFocused != iReadOnlyQuoteField ) |
231 iFocused != iReadOnlyQuoteField ) |
232 { |
232 { |
233 iFocused = iHeader; |
233 iFocused = iHeader; |
234 } |
234 } |
|
235 if ( iFocused == iHeader ) |
|
236 { |
|
237 iHeader->ShowCursor( IsFocused() ); |
|
238 } |
235 |
239 |
236 iFocused->SetFocus( IsFocused(), aDrawNow ); |
240 iFocused->SetFocus( IsFocused(), aDrawNow ); |
237 iView.HandleContainerChangeRequiringToolbarRefresh(); |
241 iView.HandleContainerChangeRequiringToolbarRefresh(); |
238 |
242 |
239 if ( aDrawNow ) |
243 if ( aDrawNow ) |
240 { |
244 { |
241 DrawNow(); |
245 DrawNow(); |
242 } |
246 } |
243 } |
247 } |
|
248 |
244 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
245 // CNcsComposeViewContainer::SetMskL() |
250 // CNcsComposeViewContainer::SetMskL() |
246 // |
251 // |
247 // ----------------------------------------------------------------------------- |
252 // ----------------------------------------------------------------------------- |
248 // |
253 // |
259 // |
264 // |
260 void CNcsComposeViewContainer::HandlePointerEventL( |
265 void CNcsComposeViewContainer::HandlePointerEventL( |
261 const TPointerEvent& aPointerEvent ) |
266 const TPointerEvent& aPointerEvent ) |
262 { |
267 { |
263 FUNC_LOG; |
268 FUNC_LOG; |
264 TBool clearSelection(EFalse); |
269 TBool clearSelection(EFalse); |
265 if ( aPointerEvent.iType != TPointerEvent::EButton1Down && |
270 if ( aPointerEvent.iType != TPointerEvent::EButton1Down && |
266 iHeader->NeedsLongTapL( aPointerEvent.iPosition ) ) |
271 iHeader->NeedsLongTapL( aPointerEvent.iPosition ) ) |
267 { |
272 { |
268 iLongTapDetector->PointerEventL( aPointerEvent ); |
273 iLongTapDetector->PointerEventL( aPointerEvent ); |
269 } |
274 } |
270 |
275 |
271 switch( aPointerEvent.iType ) |
276 switch( aPointerEvent.iType ) |
272 { |
277 { |
273 case TPointerEvent::EButton1Down: |
278 case TPointerEvent::EButton1Down: |
274 { |
279 { |
275 // Save current and original position so that those can be used in |
280 // Save current and original position so that those can be used in |
276 // drag/scrolling calculations |
281 // drag/scrolling calculations |
277 iPreviousPosition = iOriginalPosition = aPointerEvent.iPosition; |
282 iPreviousPosition = iOriginalPosition = |
|
283 aPointerEvent.iPosition; |
278 iIsDragging = EFalse; |
284 iIsDragging = EFalse; |
279 iIsFlicking = EFalse; |
285 iIsFlicking = EFalse; |
280 |
286 |
281 if( iPhysics ) |
287 if( iPhysics ) |
282 { |
288 { |
283 iPhysics->StopPhysics(); |
289 iPhysics->StopPhysics(); |
284 iPhysics->ResetFriction(); |
290 iPhysics->ResetFriction(); |
285 iStartTime.HomeTime(); |
291 iStartTime.HomeTime(); |
286 UpdatePhysicsL(); |
292 UpdatePhysicsL(); |
287 } |
293 } |
288 |
294 |
289 if ( iHeader->Rect().Contains( aPointerEvent.iPosition ) ) |
295 if ( iHeader->Rect().Contains( aPointerEvent.iPosition ) ) |
290 { |
296 { |
291 if ( iFocused == iMessageField ) |
297 if ( iFocused == iMessageField ) |
292 { |
298 { |
293 if( iMessageField->SelectionLength() ) |
299 if( iMessageField->SelectionLength() ) |
294 { |
300 { |
295 iMessageField->ClearSelectionL(); |
301 iMessageField->HandleTextChangedL(); |
296 } |
302 } |
297 iMessageField->SetFocus( EFalse, ENoDrawNow ); |
303 iMessageField->SetFocus( EFalse, ENoDrawNow ); |
298 iFocused = iHeader; |
304 iFocused = iHeader; |
299 iHeader->SetFocus( ETrue, ENoDrawNow ); |
305 iHeader->SetFocus( ETrue,ENoDrawNow ); |
300 } |
306 } |
301 else if ( iFocused == iReadOnlyQuoteField ) |
307 else if ( iFocused == iReadOnlyQuoteField ) |
302 { |
308 { |
303 iReadOnlyQuoteField->SetFocus( EFalse, ENoDrawNow ); |
309 iReadOnlyQuoteField->SetFocus( EFalse, ENoDrawNow ); |
304 iFocused = iHeader; |
310 iFocused = iHeader; |
379 |
385 |
380 // Get current pointer position |
386 // Get current pointer position |
381 TPoint position = aPointerEvent.iPosition; |
387 TPoint position = aPointerEvent.iPosition; |
382 |
388 |
383 |
389 |
384 if ( iPhysics ) |
390 if( iPhysics ) |
385 { |
391 { |
386 if ( iIsDragging ) |
392 if ( iIsDragging ) |
387 { |
393 { |
388 TPoint delta( 0, iPreviousPosition.iY - position.iY ); |
394 TPoint delta( 0, iPreviousPosition.iY - position.iY ); |
389 if ( !( iMessageField->SelectionLength() || iReadOnlyQuoteField->SelectionLength() ) ) |
395 if ( !( iMessageField->SelectionLength() || iReadOnlyQuoteField->SelectionLength() ) ) |
390 iPhysics->RegisterPanningPosition( delta ); |
396 iPhysics->RegisterPanningPosition( delta ); |
391 } |
397 } |
392 } |
398 } |
393 else |
399 else |
394 { |
400 { |
395 TInt topPosition( iHeaderPos.iY - iHeader->Position().iY ); |
401 TInt topPosition( -iHeader->Position().iY ); |
396 TInt totalHeight( ContentTotalHeight() ); |
402 |
397 TInt areaHeight( VisibleAreaHeight() ); |
403 TInt totalHeight( ContentTotalHeight() ); |
398 TInt scrollOffset( 0 ); |
404 |
399 |
405 TInt areaHeight( Rect().Size().iHeight ); |
400 if ( totalHeight > areaHeight ) |
406 TInt scrollOffset( 0 ); |
401 { |
407 |
402 // Calculate new scroll offset based on current and |
408 if( totalHeight > areaHeight ) |
403 // previous Y-positions |
409 { |
404 scrollOffset = topPosition + |
410 // Calculate new scroll offset based on current and |
405 ( iPreviousPosition.iY - position.iY ); |
411 // previous Y-positions |
406 // Ensure that thumb position is in correct range |
412 scrollOffset = topPosition + |
407 scrollOffset = Max( scrollOffset, 0 ); |
413 ( iPreviousPosition.iY - position.iY ); |
408 scrollOffset = Min( scrollOffset, |
414 // Ensure that thumb position is in correct range |
409 totalHeight - areaHeight ); |
415 scrollOffset = Max( scrollOffset, 0 ); |
410 } |
416 scrollOffset = Min( scrollOffset, |
411 |
417 totalHeight - areaHeight ); |
412 Scroll( scrollOffset ); |
418 } |
413 } |
419 |
414 |
420 Scroll( scrollOffset ); |
415 // Save current position as previous pos for future calculations |
421 } |
416 iPreviousPosition = position; |
422 |
417 |
423 // Save current position as previous pos for future calculations |
418 break; |
424 iPreviousPosition = position; |
419 } |
425 |
420 |
426 break; |
|
427 } |
|
428 |
421 default: |
429 default: |
422 { |
430 { |
423 // unknown event, ignored |
431 // unknown event, ignored |
424 break; |
432 break; |
425 } |
433 } |
426 } |
434 } |
|
435 |
|
436 CCoeControl::HandlePointerEventL( aPointerEvent ); |
427 |
437 |
428 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && |
438 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && |
429 iHeader->NeedsLongTapL( aPointerEvent.iPosition ) ) |
439 iHeader->NeedsLongTapL( aPointerEvent.iPosition ) ) |
430 { |
440 { |
431 iLongTapDetector->PointerEventL( aPointerEvent ); |
441 iLongTapDetector->PointerEventL( aPointerEvent ); |
432 } |
442 } |
433 |
443 |
434 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
435 if (clearSelection) |
444 if (clearSelection) |
436 { |
445 { |
437 iMessageField->ClearSelectionL(); |
446 iMessageField->HandleTextChangedL(); |
438 } |
447 } |
439 } |
448 } |
440 |
449 |
441 // ----------------------------------------------------------------------------- |
450 // ----------------------------------------------------------------------------- |
442 // CNcsComposeViewContainer::OfferKeyEventL() |
451 // CNcsComposeViewContainer::OfferKeyEventL() |
528 |
540 |
529 return ret; |
541 return ret; |
530 } |
542 } |
531 |
543 |
532 // ----------------------------------------------------------------------------- |
544 // ----------------------------------------------------------------------------- |
533 // CNcsComposeViewContainer::UpdateScreenPosition() |
545 // CNcsComposeViewContainer::UpdateScreenPositionL() |
534 // If the user scrolled down in the message field |
546 // If the user scrolled down in the message field |
535 // we want to scroll up the header and grow the message field. |
547 // we want to scroll up the header and grow the message field. |
536 // ----------------------------------------------------------------------------- |
548 // ----------------------------------------------------------------------------- |
537 // |
549 // |
538 void CNcsComposeViewContainer::UpdateScreenPosition( |
550 void CNcsComposeViewContainer::UpdateScreenPositionL( |
539 const TUint& /*aKeyCode*/ ) |
551 const TUint& /*aKeyCode*/ ) |
540 { |
552 { |
541 FUNC_LOG; |
553 FUNC_LOG; |
542 |
554 |
543 // get screen rectangle |
555 // get screen rectangle |
544 const TRect screenRect = iCmailPaneRect; |
556 const TRect screenRect( Rect() ); |
545 |
557 |
546 TPoint msgPos( iMessageField->Position() ); |
558 TPoint msgPos( iMessageField->Position() ); |
547 TPoint quotePos( iReadOnlyQuoteField->Position() ); |
559 TPoint quotePos( iReadOnlyQuoteField->Position() ); |
548 |
560 |
549 // find out cursor position in absolute coordinates |
561 // find out cursor position in absolute coordinates |
550 TRect lineRect; |
562 TRect lineRect; |
551 if ( iFocused == iMessageField ) |
563 if ( iFocused == iMessageField ) |
552 { |
564 { |
553 iMessageField->GetLineRect( lineRect ); |
565 iMessageField->GetLineRectL( lineRect ); |
554 lineRect.Move( msgPos ); |
566 lineRect.Move( msgPos ); |
555 } |
567 } |
556 else if ( iFocused == iReadOnlyQuoteField ) |
568 else if ( iFocused == iReadOnlyQuoteField ) |
557 { |
569 { |
558 iReadOnlyQuoteField->GetLineRect( lineRect ); |
570 iReadOnlyQuoteField->GetLineRectL( lineRect ); |
559 lineRect.Move( quotePos ); |
571 lineRect.Move( quotePos ); |
560 } |
572 } |
561 else |
573 else |
562 { |
574 { |
563 // This function should be used only when focus is in body or |
575 // This function should be used only when focus is in body or |
564 // read-only quote |
576 // read-only quote |
565 return; |
577 return; |
566 } |
578 } |
567 TPoint linePos = lineRect.iTl; |
579 TPoint linePos = lineRect.iTl; |
568 |
580 |
569 TInt minTargetY = screenRect.iTl.iY + lineRect.Height(); |
581 TInt minTargetY = lineRect.Height(); |
570 TInt maxTargetY = screenRect.iBr.iY - lineRect.Height() * 2; |
582 TInt maxTargetY = screenRect.Height() - lineRect.Height() * 2; |
571 |
583 |
572 TInt moveY = 0; |
584 TInt moveY = 0; |
573 // if cursor goes out of screen then move the controls |
585 // if cursor goes out of screen then move the controls |
574 if ( linePos.iY > maxTargetY ) |
586 if ( linePos.iY > maxTargetY ) |
575 { |
587 { |
580 moveY = minTargetY - linePos.iY; |
592 moveY = minTargetY - linePos.iY; |
581 } |
593 } |
582 |
594 |
583 // Check we don't scroll too low |
595 // Check we don't scroll too low |
584 if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < |
596 if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < |
585 screenRect.iBr.iY ) |
597 screenRect.Height() ) |
586 { |
598 { |
587 moveY = screenRect.iBr.iY - quotePos.iY - |
599 moveY = screenRect.Height() - quotePos.iY - |
588 iReadOnlyQuoteField->Size().iHeight; |
600 iReadOnlyQuoteField->Size().iHeight; |
589 } |
601 } |
590 |
602 |
591 // Check we don't scroll too high |
603 // Check we don't scroll too high |
592 TPoint headerPos = iHeader->Position(); |
604 TPoint headerPos = iHeader->Position(); |
593 if ( headerPos.iY + moveY > iHeaderPos.iY ) |
605 if ( headerPos.iY + moveY > 0 ) |
594 { |
606 { |
595 moveY = iHeaderPos.iY - headerPos.iY; |
607 moveY = -headerPos.iY; |
596 } |
608 } |
597 |
609 |
598 if ( moveY ) |
610 if ( moveY ) |
599 { |
611 { |
600 headerPos.iY += moveY; |
612 headerPos.iY += moveY; |
601 iHeader->SetPosition( headerPos ); |
613 iHeader->SetPosition( headerPos ); |
602 |
614 |
603 iSeparatorLineYPos += moveY; |
|
604 |
|
605 msgPos.iY += moveY; |
615 msgPos.iY += moveY; |
606 iMessageField->SetPosition( msgPos ); |
616 iMessageField->SetPosition( msgPos ); |
607 |
617 |
608 quotePos.iY += moveY; |
618 quotePos.iY += moveY; |
609 iReadOnlyQuoteField->SetPosition( quotePos ); |
619 iReadOnlyQuoteField->SetPosition( quotePos ); |
610 |
620 |
611 const TInt bottom = Rect().iBr.iY; |
621 iSeparatorLineYPos += moveY; |
612 if ( iMessageField->IsFocused() ) |
|
613 { |
|
614 iMessageField->SetCursorVisible( msgPos.iY <= bottom ); |
|
615 } |
|
616 else if ( iReadOnlyQuoteField->IsFocused() ) |
|
617 { |
|
618 iReadOnlyQuoteField->SetCursorVisible( quotePos.iY <= bottom ); |
|
619 } |
|
620 |
|
621 UpdateScrollBar(); |
622 UpdateScrollBar(); |
622 } |
623 } |
623 } |
624 } |
624 |
625 |
625 // ----------------------------------------------------------------------------- |
626 // ----------------------------------------------------------------------------- |
650 |
651 |
651 TPoint quotePos( iReadOnlyQuoteField->Position() ); |
652 TPoint quotePos( iReadOnlyQuoteField->Position() ); |
652 quotePos.iY = iMessageField->Rect().iBr.iY; |
653 quotePos.iY = iMessageField->Rect().iBr.iY; |
653 iReadOnlyQuoteField->SetPosition( quotePos ); |
654 iReadOnlyQuoteField->SetPosition( quotePos ); |
654 |
655 |
655 const TInt bottom = Rect().iBr.iY; |
|
656 if ( iMessageField->IsFocused() ) |
|
657 { |
|
658 iMessageField->SetCursorVisible( bodyPos.iY <= bottom ); |
|
659 } |
|
660 else if ( iReadOnlyQuoteField->IsFocused() ) |
|
661 { |
|
662 iReadOnlyQuoteField->SetCursorVisible( quotePos.iY <= bottom ); |
|
663 } |
|
664 |
|
665 TInt scrollSpan = Max( ContentTotalHeight(), VisibleAreaHeight() + 1 ); |
|
666 iScrollBarModel.SetScrollSpan( scrollSpan ); |
|
667 UpdateScrollBar(); |
656 UpdateScrollBar(); |
668 DrawDeferred(); |
657 DrawDeferred(); |
669 } |
658 } |
670 |
659 |
671 } |
660 } |
692 else if ( iFocused == iMessageField ) |
682 else if ( iFocused == iMessageField ) |
693 { |
683 { |
694 if ( aKeyEvent.iCode == EKeyUpArrow ) |
684 if ( aKeyEvent.iCode == EKeyUpArrow ) |
695 { |
685 { |
696 iFocused = iHeader; |
686 iFocused = iHeader; |
697 iHeader->SetFocus( ETrue, ENoDrawNow ); |
687 iHeader->SetFocusToBottom( ENoDrawNow ); |
698 iMessageField->SetFocus( EFalse, ENoDrawNow ); |
688 iMessageField->SetFocus( EFalse, ENoDrawNow ); |
699 iHeader->MakeVisible( ETrue ); |
689 iHeader->MakeVisible( ETrue ); |
|
690 iHeader->ShowCursor( ETrue ); |
700 CommitL( EBodyField ); |
691 CommitL( EBodyField ); |
701 ret = EKeyWasConsumed; |
692 ret = EKeyWasConsumed; |
702 } |
693 } |
703 else if ( aKeyEvent.iCode == EKeyDownArrow && |
694 else if ( aKeyEvent.iCode == EKeyDownArrow && |
704 iReadOnlyQuoteField->TextLength() ) |
695 iReadOnlyQuoteField->TextLength() ) |
763 const TRect rect( Rect() ); |
753 const TRect rect( Rect() ); |
764 iScrollBar->SetRect( NcsUtility::ListCmailScrollbarRect( rect ) ); |
754 iScrollBar->SetRect( NcsUtility::ListCmailScrollbarRect( rect ) ); |
765 TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) ); |
755 TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) ); |
766 |
756 |
767 const TInt headerLineCount( iHeader->LayoutLineCount() ); |
757 const TInt headerLineCount( iHeader->LayoutLineCount() ); |
768 iHeaderPos = NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ); |
758 const TPoint headerPos( |
769 iHeader->SetOrigin( iHeaderPos ); |
759 NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ) ); |
770 const TPoint currentHeaderPos = iHeader->Position(); |
760 cmailPaneRect.Move( 0, iHeader->Position().iY - headerPos.iY ); |
771 if ( currentHeaderPos.iY > iHeaderPos.iY ) |
|
772 { |
|
773 cmailPaneRect.Move( 0, currentHeaderPos.iY - iHeaderPos.iY ); |
|
774 } |
|
775 iCmailPaneRect = cmailPaneRect; |
761 iCmailPaneRect = cmailPaneRect; |
776 |
762 |
777 NcsUtility::LayoutHeaderControl( |
763 NcsUtility::LayoutHeaderControl( |
778 iHeader, cmailPaneRect, 0, headerLineCount ); |
764 iHeader, cmailPaneRect, 0, headerLineCount ); |
779 |
765 |
790 { |
776 { |
791 TRAP_IGNORE( iMessageField->FormatAllTextNowL() ); |
777 TRAP_IGNORE( iMessageField->FormatAllTextNowL() ); |
792 } |
778 } |
793 |
779 |
794 iMessageField->UpdateFontSize(); |
780 iMessageField->UpdateFontSize(); |
|
781 iSeparatorHeight = NcsUtility::SeparatorSizeInThisResolution().iHeight; |
795 |
782 |
796 TInt readOnlyQuoteFieldHeight( 0 ); |
783 TInt readOnlyQuoteFieldHeight( 0 ); |
797 if ( iReadOnlyQuoteField->TextLength() ) |
784 if ( iReadOnlyQuoteField->TextLength() ) |
798 { |
785 { |
799 TInt dummySeparatorPos; |
786 TInt dummySeparatorPos; |
800 NcsUtility::LayoutBodyEdwin( |
787 NcsUtility::LayoutBodyEdwin( |
801 iReadOnlyQuoteField, cmailPaneRect, |
788 iReadOnlyQuoteField, cmailPaneRect, |
802 iHeader->LayoutLineCount() + iMessageField->LineCount(), |
789 iHeader->LayoutLineCount() + iMessageField->LineCount(), |
803 iReadOnlyQuoteField->LineCount(), dummySeparatorPos ); |
790 iReadOnlyQuoteField->LineCount(), dummySeparatorPos ); |
|
791 |
|
792 TInt quoteOffset = iReadOnlyQuoteField->Rect().iTl.iY - |
|
793 iMessageField->Rect().iBr.iY; |
|
794 |
|
795 if( quoteOffset > iSeparatorHeight ) |
|
796 { |
|
797 TRect quoteRect = iReadOnlyQuoteField->Rect(); |
|
798 quoteRect.Move( 0, iMessageField->Rect().iBr.iY + |
|
799 iSeparatorHeight - quoteRect.iTl.iY ); |
|
800 iReadOnlyQuoteField->SetRect( quoteRect ); |
|
801 } |
|
802 |
804 iReadOnlyQuoteField->SetAlignment( EAknEditorAlignBidi ); |
803 iReadOnlyQuoteField->SetAlignment( EAknEditorAlignBidi ); |
805 // we don't need format again when format was already done |
804 // we don't need format again when format was already done |
806 // during creation of forward/reply message |
805 // during creation of forward/reply message |
807 if ( !iSwitchOffFormattingText ) |
806 if ( !iSwitchOffFormattingText ) |
808 { |
807 { |
809 TRAP_IGNORE( iReadOnlyQuoteField->FormatAllTextNowL() ); |
808 TRAP_IGNORE( iReadOnlyQuoteField->FormatAllTextNowL() ); |
810 } |
809 } |
811 iReadOnlyQuoteField->UpdateFontSize(); |
810 iReadOnlyQuoteField->UpdateFontSize(); |
812 readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height(); |
811 readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height(); |
813 } |
812 } |
814 else |
813 |
815 { |
814 iBgContext->SetRect( Rect() ); |
816 // Set quote field immediatelly bellow message field with zero height. |
815 iMessageField->SetRealRect( Rect() ); |
817 TRect quoteRect = iMessageField->Rect(); |
816 iReadOnlyQuoteField->SetRealRect( Rect() ); |
818 quoteRect.iTl = quoteRect.iBr; |
|
819 iReadOnlyQuoteField->SetRect( quoteRect ); |
|
820 } |
|
821 |
|
822 iBgContext->SetRect( rect ); |
|
823 iMessageField->SetRealRect( rect ); |
|
824 iReadOnlyQuoteField->SetRealRect( rect ); |
|
825 |
817 |
826 TInt messageLineHeigth = |
818 TInt messageLineHeigth = |
827 NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height(); |
819 NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height(); |
828 iSeparatorHeight = NcsUtility::SeparatorSizeInThisResolution().iHeight; |
820 |
829 iMessageEditorMinHeigth = |
821 iMessageEditorMinHeigth = |
830 cmailPaneRect.Height() - iHeader->Size().iHeight - |
822 cmailPaneRect.Height() - iHeader->Size().iHeight - |
831 iSeparatorHeight - |
823 iSeparatorHeight - |
832 readOnlyQuoteFieldHeight; |
824 readOnlyQuoteFieldHeight; |
833 |
825 |
849 } |
841 } |
850 |
842 |
851 // update some layout variables |
843 // update some layout variables |
852 iHeaderHeight = iHeader->Rect().Height(); |
844 iHeaderHeight = iHeader->Rect().Height(); |
853 TRect bodyRect = iMessageField->Rect(); |
845 TRect bodyRect = iMessageField->Rect(); |
854 iReadOnlyQuoteField->SetPosition( |
|
855 TPoint( bodyRect.iTl.iX, bodyRect.iBr.iY ) ); |
|
856 TRect quoteRect = iReadOnlyQuoteField->Rect(); |
846 TRect quoteRect = iReadOnlyQuoteField->Rect(); |
857 |
847 |
858 iTotalComposerHeight = iHeaderHeight + iSeparatorHeight + |
848 iTotalComposerHeight = iHeaderHeight + iSeparatorHeight * 2 + |
859 bodyRect.Height() + quoteRect.Height(); |
849 bodyRect.Height() + quoteRect.Height(); |
860 |
850 |
861 iVisibleAreaHeight = iCmailPaneRect.Height(); |
851 iVisibleAreaHeight = Rect().Height(); |
862 |
852 |
863 // Scroll span is set always to be larger than the window size to |
853 UpdateScrollBar(); |
864 // keep the scroll bar visible. |
854 |
865 TInt scrollSpan = Max( iTotalComposerHeight, iVisibleAreaHeight + 1 ); |
855 iScrollBarModel.SetScrollSpan( iTotalComposerHeight ); |
866 iScrollBarModel.SetScrollSpan( scrollSpan ); |
|
867 iScrollBarModel.SetWindowSize( iVisibleAreaHeight ); |
856 iScrollBarModel.SetWindowSize( iVisibleAreaHeight ); |
868 if ( iHeader->IsFocused() ) |
|
869 { |
|
870 iHeader->DoScroll(); |
|
871 } |
|
872 else |
|
873 { |
|
874 UpdateScreenPosition(); |
|
875 } |
|
876 UpdateScrollBar(); |
|
877 DrawDeferred(); |
857 DrawDeferred(); |
878 } |
858 } |
879 |
859 |
880 // ----------------------------------------------------------------------------- |
860 // ----------------------------------------------------------------------------- |
881 // CNcsComposeViewContainer::Draw() const |
861 // CNcsComposeViewContainer::Draw() const |
986 if ( iReadOnlyQuote && iProcessedField == iMessageField ) |
966 if ( iReadOnlyQuote && iProcessedField == iMessageField ) |
987 { |
967 { |
988 iProcessedField = iReadOnlyQuoteField; |
968 iProcessedField = iReadOnlyQuoteField; |
989 if ( iReadOnlyQuote ) |
969 if ( iReadOnlyQuote ) |
990 { |
970 { |
991 TInt dummySeparatorPos; |
971 TInt dummySeparatorPos; |
992 NcsUtility::LayoutBodyEdwin( iReadOnlyQuoteField, iCmailPaneRect, |
972 NcsUtility::LayoutBodyEdwin( iReadOnlyQuoteField, iCmailPaneRect, |
993 iHeader->LayoutLineCount() + iMessageField->LineCount(), |
973 iHeader->LayoutLineCount() + iMessageField->LineCount(), |
994 iReadOnlyQuoteField->LineCount(), dummySeparatorPos ); |
974 iReadOnlyQuoteField->LineCount(), dummySeparatorPos ); |
995 iReadOnlyQuoteField->SetAlignment( EAknEditorAlignBidi ); |
975 iReadOnlyQuoteField->SetAlignment( EAknEditorAlignBidi ); |
996 |
976 |
997 RMemReadStream inputStream; |
977 RMemReadStream inputStream; |
998 inputStream.Open( iReadOnlyQuote->Ptr(), iReadOnlyQuote->Size() ); |
978 inputStream.Open( iReadOnlyQuote->Ptr(), iReadOnlyQuote->Size() ); |
999 TRAP_IGNORE( iReadOnlyQuoteField->RichText()->ImportTextL( 0, inputStream, |
979 TRAP_IGNORE( iReadOnlyQuoteField->RichText()->ImportTextL( 0, inputStream, |
1000 CPlainText::EOrganiseByParagraph ) ); |
980 CPlainText::EOrganiseByParagraph ) ); |
1001 inputStream.Close(); |
981 inputStream.Close(); |
1002 |
982 |
1200 { |
1183 { |
1201 if ( !iSwitchOffFormattingText ) |
1184 if ( !iSwitchOffFormattingText ) |
1202 { |
1185 { |
1203 aEdwin->SetSize( aDesirableEdwinSize ); |
1186 aEdwin->SetSize( aDesirableEdwinSize ); |
1204 } |
1187 } |
1205 } |
1188 } |
1206 } |
1189 } |
1207 else |
1190 else |
1208 { |
1191 { |
1209 if ( !iSwitchOffFormattingText ) |
1192 if ( !iSwitchOffFormattingText ) |
1210 { |
1193 { |
1211 aEdwin->SetSize( aDesirableEdwinSize ); |
1194 aEdwin->SetSize( aDesirableEdwinSize ); |
1212 } |
1195 } |
1213 } |
1196 } |
1214 |
|
1215 if ( aEdwin == iMessageField ) |
1197 if ( aEdwin == iMessageField ) |
1216 { |
1198 { |
1217 // move the quote field below the body field |
1199 // move the quote field below the body field |
1218 TPoint quotePos = iMessageField->Position(); |
1200 TPoint quotePos = iMessageField->Position(); |
1219 quotePos.iY += iMessageField->Size().iHeight; |
1201 quotePos.iY += iMessageField->Size().iHeight; |
1220 iReadOnlyQuoteField->SetPosition( quotePos ); |
1202 iReadOnlyQuoteField->SetPosition( quotePos ); |
1221 UpdateScreenPosition(); |
1203 UpdateScreenPositionL(); |
1222 } |
1204 } |
1223 |
|
1224 // Update scroll span and position. |
|
1225 TInt scrollSpan = Max( ContentTotalHeight(), VisibleAreaHeight() + 1 ); |
|
1226 iScrollBarModel.SetScrollSpan( scrollSpan ); |
|
1227 UpdateScrollBar(); |
|
1228 |
1205 |
1229 iPrevDesiredHeigth = aDesirableEdwinSize.iHeight; |
1206 iPrevDesiredHeigth = aDesirableEdwinSize.iHeight; |
1230 |
1207 |
1231 return ret; |
1208 return ret; |
1232 } |
1209 } |
1253 void CNcsComposeViewContainer::UpdateScrollBar() |
1230 void CNcsComposeViewContainer::UpdateScrollBar() |
1254 { |
1231 { |
1255 FUNC_LOG; |
1232 FUNC_LOG; |
1256 |
1233 |
1257 TRect headerRect = iHeader->Rect(); |
1234 TRect headerRect = iHeader->Rect(); |
1258 TInt visiblePosition = iHeaderPos.iY - headerRect.iTl.iY; |
1235 TInt visiblePosition = -headerRect.iTl.iY; |
1259 |
1236 |
1260 iScrollBarModel.SetFocusPosition( visiblePosition ); |
1237 iScrollBarModel.SetFocusPosition( visiblePosition ); |
1261 |
1238 |
1262 iScrollBar->SetModel( &iScrollBarModel ); |
1239 iScrollBar->SetModel( &iScrollBarModel ); |
1263 iScrollBar->MakeVisible( !iHeader->IsPopupActive() ); |
1240 iScrollBar->MakeVisible( IsVisible() ); |
1264 } |
|
1265 |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // CNcsComposeViewContainer::UpdateScrollBarVisibility() |
|
1268 // ----------------------------------------------------------------------------- |
|
1269 // |
|
1270 void CNcsComposeViewContainer::UpdateScrollBarVisibility( TBool aVisible ) |
|
1271 { |
|
1272 FUNC_LOG; |
|
1273 iScrollBar->MakeVisible( aVisible ); |
|
1274 } |
1241 } |
1275 |
1242 |
1276 // ----------------------------------------------------------------------------- |
1243 // ----------------------------------------------------------------------------- |
1277 // CNcsComposeViewContainer::SetFocusToMessageFieldL() |
1244 // CNcsComposeViewContainer::SetFocusToMessageFieldL() |
1278 // ----------------------------------------------------------------------------- |
1245 // ----------------------------------------------------------------------------- |
1285 { |
1252 { |
1286 iHeader->SetFocus( EFalse, ENoDrawNow ); |
1253 iHeader->SetFocus( EFalse, ENoDrawNow ); |
1287 iMessageField->SetCursorPosL( 0, EFalse ); |
1254 iMessageField->SetCursorPosL( 0, EFalse ); |
1288 iMessageField->SetFocus( ETrue, ENoDrawNow ); |
1255 iMessageField->SetFocus( ETrue, ENoDrawNow ); |
1289 iFocused = iMessageField; |
1256 iFocused = iMessageField; |
1290 UpdateScreenPosition(); |
1257 UpdateScreenPositionL(); |
1291 DrawDeferred(); |
1258 DrawDeferred(); |
1292 } |
1259 } |
1293 } |
1260 } |
1294 |
1261 |
1295 // ----------------------------------------------------------------------------- |
1262 // ----------------------------------------------------------------------------- |
1408 |
1375 |
1409 return ETrue; |
1376 return ETrue; |
1410 } |
1377 } |
1411 |
1378 |
1412 // ----------------------------------------------------------------------------- |
1379 // ----------------------------------------------------------------------------- |
1413 // CNcsComposeViewContainer::HandleAttachmentsOpenCommand |
1380 // CNcsComposeViewContainer::HandleAttachmentOpenCommand |
1414 // If attachment header field is focused and open key is pressed |
1381 // If attachment header field is focused and open key is pressed |
1415 // ----------------------------------------------------------------------------- |
1382 // ----------------------------------------------------------------------------- |
1416 // |
1383 // |
1417 void CNcsComposeViewContainer::HandleAttachmentsOpenCommandL() |
1384 void CNcsComposeViewContainer::HandleAttachmentOpenCommandL() |
1418 { |
1385 { |
1419 FUNC_LOG; |
1386 FUNC_LOG; |
1420 |
1387 iView.HandleCommandL( EFsEmailUiCmdOpenAttachment ); |
1421 iView.HandleCommandL( EFsEmailUiCmdOpenAttachment ); |
1388 } |
1422 |
1389 |
1423 } |
1390 // ----------------------------------------------------------------------------- |
|
1391 // CNcsComposeViewContainer::HandleAttachmentRemoveCommandL |
|
1392 // If attachment header field is focused and delete key is pressed |
|
1393 // ----------------------------------------------------------------------------- |
|
1394 // |
|
1395 void CNcsComposeViewContainer::HandleAttachmentRemoveCommandL() |
|
1396 { |
|
1397 FUNC_LOG; |
|
1398 iView.HandleCommandL( EFsEmailUiCmdRemoveAttachment ); |
|
1399 } |
1424 |
1400 |
1425 // ----------------------------------------------------------------------------- |
1401 // ----------------------------------------------------------------------------- |
1426 // CNcsComposeViewContainer::LaunchStylusPopupMenu |
1402 // CNcsComposeViewContainer::LaunchStylusPopupMenu |
1427 // Called when long tap happens in the attachments field |
1403 // Called when long tap happens in the attachments field |
1428 // ----------------------------------------------------------------------------- |
1404 // ----------------------------------------------------------------------------- |
2004 // ----------------------------------------------------------------------------- |
1982 // ----------------------------------------------------------------------------- |
2005 // |
1983 // |
2006 TInt CNcsComposeViewContainer::ContentTotalHeight() |
1984 TInt CNcsComposeViewContainer::ContentTotalHeight() |
2007 { |
1985 { |
2008 FUNC_LOG; |
1986 FUNC_LOG; |
2009 TInt totalHeight( iHeader->Size().iHeight + |
1987 TInt totalHeight( iHeader->Size().iHeight + |
2010 iSeparatorHeight + iMessageField->Size().iHeight ); |
1988 iSeparatorHeight * 2 + |
2011 |
1989 iMessageField->Size().iHeight ); |
2012 if ( iReadOnlyQuoteField->IsVisible() ) |
1990 |
2013 { |
1991 if( iReadOnlyQuoteField->IsVisible() ) |
2014 totalHeight += iReadOnlyQuoteField->Size().iHeight; |
1992 { |
2015 } |
1993 totalHeight += iReadOnlyQuoteField->Size().iHeight; |
2016 |
1994 } |
2017 return totalHeight; |
1995 |
2018 } |
1996 return totalHeight; |
2019 |
|
2020 // ----------------------------------------------------------------------------- |
|
2021 // Returns the height of visible composer area. |
|
2022 // ----------------------------------------------------------------------------- |
|
2023 // |
|
2024 TInt CNcsComposeViewContainer::VisibleAreaHeight() |
|
2025 { |
|
2026 return iVisibleAreaHeight; |
|
2027 } |
1997 } |
2028 |
1998 |
2029 // ----------------------------------------------------------------------------- |
1999 // ----------------------------------------------------------------------------- |
2030 // CNcsComposeViewContainer::CommitL() |
2000 // CNcsComposeViewContainer::CommitL() |
|
2001 // |
2031 // ----------------------------------------------------------------------------- |
2002 // ----------------------------------------------------------------------------- |
2032 // |
2003 // |
2033 void CNcsComposeViewContainer::CommitL( TFieldToCommit aFieldToCommit ) |
2004 void CNcsComposeViewContainer::CommitL( TFieldToCommit aFieldToCommit ) |
2034 { |
2005 { |
2035 FUNC_LOG; |
2006 FUNC_LOG; |
2074 void CNcsComposeViewContainer::UpdatePhysicsL() |
2045 void CNcsComposeViewContainer::UpdatePhysicsL() |
2075 { |
2046 { |
2076 FUNC_LOG; |
2047 FUNC_LOG; |
2077 if ( iPhysics ) |
2048 if ( iPhysics ) |
2078 { |
2049 { |
2079 const TSize viewSize( iCmailPaneRect.Size() ); |
2050 const TSize viewSize( Rect().Size() ); |
2080 // We must ensure that world size is at least the size of the view |
2051 // We must ensure that world size is at least the size of the view |
2081 const TSize worldSize( viewSize.iWidth, |
2052 const TSize worldSize( viewSize.iWidth, |
2082 Max( ContentTotalHeight(), viewSize.iHeight ) ); |
2053 Max( ContentTotalHeight(), viewSize.iHeight ) ); |
2083 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
2054 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
2084 } |
2055 } |
2089 // ----------------------------------------------------------------------------- |
2060 // ----------------------------------------------------------------------------- |
2090 // |
2061 // |
2091 void CNcsComposeViewContainer::Scroll( TInt aTargetPos, TBool aDrawNow ) |
2062 void CNcsComposeViewContainer::Scroll( TInt aTargetPos, TBool aDrawNow ) |
2092 { |
2063 { |
2093 FUNC_LOG; |
2064 FUNC_LOG; |
2094 TPoint headerPos = iHeader->Position(); |
2065 TPoint headerPos( iHeader->Position() ); |
2095 const TInt currentPos = iHeaderPos.iY - headerPos.iY; |
2066 TInt moveY = -headerPos.iY - aTargetPos; |
2096 TInt moveY = currentPos - aTargetPos; |
2067 |
2097 |
|
2098 if ( aDrawNow ) |
2068 if ( aDrawNow ) |
2099 { |
2069 { |
2100 moveY = iTotalMoveY + moveY; |
2070 moveY = iTotalMoveY + moveY; |
2101 iTotalMoveY = 0; |
2071 iTotalMoveY = 0; |
2102 if ( moveY ) |
2072 if ( moveY ) |
2103 { |
2073 { |
2104 headerPos.iY += moveY; |
2074 headerPos.iY += moveY; |
2105 iHeader->SetPosition( headerPos ); |
2075 iHeader->SetPosition( headerPos ); |
2106 |
2076 |
2107 // set header invisible if it is not in visible area |
2077 // set header invisible if it is not in visible area |
2108 // this is done to prevent drawing of header when it is not necessary |
2078 // this is done to prevent drawing of header when it is not necessary |
2109 if ( headerPos.iY + iHeaderHeight <= KHeaderVisibilityThreshold && iHeader->IsVisible() ) |
2079 if ( headerPos.iY + iHeaderHeight <= KHeaderVisibilityThreshold && iHeader->IsVisible() ) |
2110 { |
2080 { |
2111 iHeader->MakeVisible( EFalse ); |
2081 iHeader->MakeVisible( EFalse ); |
2112 } |
2082 } |
2113 // set header visible if it is in visible area |
2083 // set header visible if it is in visible area |
2114 else if ( headerPos.iY + iHeaderHeight > KHeaderVisibilityThreshold && !iHeader->IsVisible() ) |
2084 else if ( headerPos.iY + iHeaderHeight > KHeaderVisibilityThreshold && !iHeader->IsVisible() ) |
2115 { |
2085 { |
2116 iHeader->MakeVisible( ETrue ); |
2086 iHeader->MakeVisible( ETrue ); |
2117 } |
2087 } |
2118 |
2088 |
2119 TPoint msgPos( iMessageField->Position() ); |
2089 TPoint msgPos( iMessageField->Position() ); |
2120 msgPos.iY += moveY; |
2090 msgPos.iY += moveY; |
2121 iMessageField->SetPosition( msgPos ); |
2091 iMessageField->SetPosition( msgPos ); |
2122 |
2092 |
2123 TPoint quotePos( iReadOnlyQuoteField->Position() ); |
2093 if( iReadOnlyQuoteField->IsVisible() ) |
2124 quotePos.iY += moveY; |
2094 { |
2125 iReadOnlyQuoteField->SetPosition( quotePos ); |
2095 TPoint readOnlyPos( iReadOnlyQuoteField->Position() ); |
2126 |
2096 readOnlyPos.iY += moveY; |
2127 const TInt bottom = Rect().iBr.iY; |
2097 iReadOnlyQuoteField->SetPosition( readOnlyPos ); |
2128 if ( iMessageField->IsFocused() ) |
2098 } |
2129 { |
2099 |
2130 iMessageField->SetCursorVisible( msgPos.iY <= bottom ); |
2100 iSeparatorLineYPos += moveY; |
2131 } |
2101 |
2132 else if ( iReadOnlyQuoteField->IsFocused() ) |
2102 UpdateScrollBar(); |
2133 { |
2103 DrawDeferred(); |
2134 iReadOnlyQuoteField->SetCursorVisible( quotePos.iY <= bottom ); |
2104 } |
2135 } |
2105 } |
2136 |
|
2137 iSeparatorLineYPos += moveY; |
|
2138 |
|
2139 UpdateScrollBar(); |
|
2140 DrawDeferred(); |
|
2141 } |
|
2142 } |
|
2143 else |
2106 else |
2144 { |
2107 { |
2145 iTotalMoveY += moveY; |
2108 iTotalMoveY += moveY; |
2146 } |
2109 } |
2147 } |
2110 } |
2148 |
2111 |
2149 // ----------------------------------------------------------------------------- |
2112 // ----------------------------------------------------------------------------- |
2150 // CNcsComposeViewContainer::ViewPositionChanged |
2113 // CNcsComposeViewContainer::ViewPositionChanged |
2151 // From MAknPhysicsObserver |
2114 // From MAknPhysicsObserver |
2186 // ----------------------------------------------------------------------------- |
2149 // ----------------------------------------------------------------------------- |
2187 // |
2150 // |
2188 TPoint CNcsComposeViewContainer::ViewPosition() const |
2151 TPoint CNcsComposeViewContainer::ViewPosition() const |
2189 { |
2152 { |
2190 FUNC_LOG; |
2153 FUNC_LOG; |
2191 TInt y = iHeaderPos.iY - iHeader->Position().iY + iVisibleAreaHeight / 2; |
2154 return TPoint(0, -iHeader->Position().iY + iVisibleAreaHeight / 2 ); |
2192 return TPoint( 0, y ); |
2155 } |
2193 } |
2156 |
2194 |
2157 |
2195 // ----------------------------------------------------------------------------- |
2158 // ----------------------------------------------------------------------------- |
2196 // CNcsComposeViewContainer::IsRemoteSearchInprogress |
2159 // CNcsComposeViewContainer::IsRemoteSearchInprogress |
2197 // ----------------------------------------------------------------------------- |
2160 // ----------------------------------------------------------------------------- |
2198 // |
2161 // |