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 |
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; |
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() |
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 { |
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() |
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 |