192 delete iAacListBox; |
194 delete iAacListBox; |
193 delete iLongTapDetector; |
195 delete iLongTapDetector; |
194 } |
196 } |
195 |
197 |
196 // --------------------------------------------------------------------------- |
198 // --------------------------------------------------------------------------- |
|
199 // From MNcsPopupListBoxObserver. |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 TBool CNcsHeaderContainer::PopupVisibilityChangingL( TBool aVisible ) |
|
203 { |
|
204 CNcsComposeViewContainer& parent = |
|
205 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
206 |
|
207 if ( aVisible ) |
|
208 { |
|
209 DoScrollFocusToTop(); |
|
210 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
|
211 } |
|
212 else |
|
213 { |
|
214 // Scroll editor top, if it can be fully displayed. |
|
215 if ( parent.ContentTotalHeight() < parent.VisibleAreaHeight() ) |
|
216 { |
|
217 parent.Scroll( 0, ETrue ); |
|
218 } |
|
219 } |
|
220 |
|
221 parent.UpdateScrollBarVisibility( !aVisible ); |
|
222 ShowPopupMenuBarL( aVisible ); |
|
223 return ETrue; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // From MNcsPopupListBoxObserver. |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CNcsHeaderContainer::PopupItemSelectedL() |
|
231 { |
|
232 DoPopupSelectL(); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
197 // CNcsHeaderContainer::FocusChanged |
236 // CNcsHeaderContainer::FocusChanged |
198 // --------------------------------------------------------------------------- |
237 // --------------------------------------------------------------------------- |
199 // |
238 // |
200 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow ) |
239 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow ) |
201 { |
240 { |
202 FUNC_LOG; |
241 FUNC_LOG; |
203 |
242 |
204 CCoeControl* focused = iFocused; |
243 CCoeControl* focused = iFocused; |
205 |
244 |
206 if ( !focused ) |
245 if ( !focused ) |
207 { |
246 { |
208 focused = FindFocused(); |
247 focused = FindFocused(); |
209 iFocused = focused; |
248 iFocused = focused; |
210 } |
249 } |
211 |
250 |
212 if ( !IsFocused() ) |
251 if ( !IsFocused() ) |
213 { |
252 { |
214 if ( focused ) |
253 if ( focused ) |
215 { |
254 { |
216 // We're loosing focus (probably going to message body) |
255 // We're loosing focus (probably going to message body) |
217 // Commit changes and make sure no controls are focused. |
256 // Commit changes and make sure no controls are focused. |
218 TRAP_IGNORE( CommitFieldL( focused ) ); |
257 if ( iParent.IsFocused() ) |
|
258 { |
|
259 TRAP_IGNORE( CommitFieldL( focused ) ); |
|
260 } |
219 focused->SetFocus( EFalse, aDrawNow ); |
261 focused->SetFocus( EFalse, aDrawNow ); |
220 iFocused = NULL; |
|
221 } |
262 } |
222 |
263 |
223 // Remove MSK label when header loses focus |
264 // Remove MSK label when header loses focus |
224 TRAP_IGNORE( SetMskL() ); |
265 TRAP_IGNORE( SetMskL() ); |
225 } |
266 } |
226 else if ( IsFocused() && !focused ) |
267 else |
227 { |
268 { |
228 // We're gaining focus from the message body |
269 if ( !focused ) |
229 // Set the focus to the last control in the control array |
270 { |
230 // (either attachment line or subject field) |
271 // We're gaining focus from the message body |
231 CCoeControlArray::TCursor cur = Components().End(); |
272 // Set the focus to the last control in the control array |
232 cur.Prev(); |
273 // (either attachment line or subject field) |
233 cur.Control<CCoeControl>()->SetFocus( ETrue, aDrawNow ); |
274 CCoeControlArray::TCursor cur = Components().End(); |
234 iFocused = cur.Control<CCoeControl>(); |
275 cur.Prev(); |
235 } |
276 iFocused = cur.Control<CCoeControl>(); |
236 } |
277 } |
237 |
278 iFocused->SetFocus( ETrue, aDrawNow ); |
238 // --------------------------------------------------------------------------- |
|
239 // CNcsHeaderContainer::ShowCursor |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CNcsHeaderContainer::ShowCursor( TBool aShow, TDrawNow aDrawNow ) |
|
243 { |
|
244 CCoeControl* focused = FindFocused(); |
|
245 if ( focused ) |
|
246 { |
|
247 iFocused = focused; |
|
248 } |
|
249 if ( iFocused ) |
|
250 { |
|
251 iFocused->SetFocus( aShow, aDrawNow ); |
|
252 } |
279 } |
253 } |
280 } |
254 |
281 |
255 // ----------------------------------------------------------------------------- |
282 // ----------------------------------------------------------------------------- |
256 // CNcsHeaderContainer::Draw() const |
283 // CNcsHeaderContainer::Draw() const |
341 // |
368 // |
342 // ----------------------------------------------------------------------------- |
369 // ----------------------------------------------------------------------------- |
343 void CNcsHeaderContainer::HandlePointerEventL( |
370 void CNcsHeaderContainer::HandlePointerEventL( |
344 const TPointerEvent& aPointerEvent ) |
371 const TPointerEvent& aPointerEvent ) |
345 { |
372 { |
346 FUNC_LOG; |
373 FUNC_LOG; |
|
374 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
375 { |
|
376 CCoeControl* component = 0; |
|
377 for ( TInt i=0; i < Components().Count(); ++i ) |
|
378 { |
|
379 TRect rc = Components().At( i ).iControl->Rect(); |
|
380 if ( rc.Contains( aPointerEvent.iPosition ) ) |
|
381 { |
|
382 component = Components().At( i ).iControl; |
|
383 } |
|
384 } |
|
385 |
|
386 if ( component ) |
|
387 { |
|
388 CCoeControl* pOldCtrl = FindFocused(); |
|
389 CCoeControl* pNewCtrl= component; |
|
390 |
|
391 if ( pOldCtrl != pNewCtrl ) |
|
392 { |
|
393 // Unfocus the control |
|
394 if ( pOldCtrl ) |
|
395 { |
|
396 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
397 } |
|
398 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
399 iFocused = pNewCtrl; |
|
400 // Commit changes to previously focused field. |
|
401 if ( pOldCtrl ) |
|
402 { |
|
403 CommitFieldL( pOldCtrl ); |
|
404 } |
|
405 |
|
406 // If the attachments label has changed focus |
|
407 if ( pOldCtrl == iAttachmentField || |
|
408 pNewCtrl == iAttachmentField ) |
|
409 { |
|
410 DrawAttachmentFocusNow(); |
|
411 } |
|
412 |
|
413 CNcsComposeViewContainer* container = |
|
414 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
415 container->UpdateScrollBar(); |
|
416 } |
|
417 |
|
418 DrawDeferred(); |
|
419 } |
|
420 } |
|
421 |
347 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
422 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
348 { |
423 { |
349 CCoeControl* clicked = 0; |
424 if ( iLongTapEventConsumed ) |
350 for ( TInt i=0; i < Components().Count(); ++i ) |
425 { |
351 { |
426 iLongTapEventConsumed = EFalse; |
352 TRect rc = Components().At( i ).iControl->Rect(); |
427 return; |
353 if ( rc.Contains( aPointerEvent.iPosition ) ) |
428 } |
354 { |
429 |
355 clicked = Components().At( i ).iControl; |
430 CCoeControl* component = 0; |
356 } |
431 for ( TInt i=0; i < Components().Count(); ++i ) |
357 } |
432 { |
358 |
433 TRect rc = Components().At( i ).iControl->Rect(); |
359 if ( clicked ) |
434 if ( rc.Contains( aPointerEvent.iPosition ) ) |
360 { |
435 { |
361 CCoeControl* pOldCtrl = FindFocused(); |
436 component = Components().At( i ).iControl; |
362 CCoeControl* pNewCtrl= clicked; |
437 } |
363 |
438 } |
364 if ( pOldCtrl != pNewCtrl ) |
439 |
365 { |
440 if ( component && component == iFocused ) |
366 // Unfocus the control |
441 { |
367 if ( pOldCtrl ) |
442 TBool physicsActionOngoing( EFalse ); |
368 { |
443 if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone ) |
369 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
444 { |
370 } |
|
371 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
372 iFocused = pNewCtrl; |
|
373 // Commit changes to previously focused field. |
|
374 if ( pOldCtrl ) |
|
375 { |
|
376 CommitFieldL( pOldCtrl ); |
|
377 } |
|
378 |
|
379 // If the attachments label has changed focus |
|
380 if ( pOldCtrl == iAttachmentField || |
|
381 pNewCtrl == iAttachmentField ) |
|
382 { |
|
383 DrawAttachmentFocusNow(); |
|
384 } |
|
385 |
|
386 CNcsComposeViewContainer* container = |
|
387 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
388 container->UpdateScrollBar(); |
|
389 } |
|
390 |
|
391 if( iLongTapEventConsumed ) |
|
392 { |
|
393 iLongTapEventConsumed = EFalse; |
|
394 return; |
|
395 } |
|
396 |
|
397 TBool physicsActionOngoing( EFalse ); |
|
398 if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone ) |
|
399 { |
|
400 physicsActionOngoing = ETrue; |
445 physicsActionOngoing = ETrue; |
401 } |
446 } |
402 |
447 |
403 if( pNewCtrl == iAttachmentField && !physicsActionOngoing ) |
448 if ( component == iAttachmentField && !physicsActionOngoing ) |
404 { |
449 { |
405 CNcsComposeViewContainer& parent = |
450 CNcsComposeViewContainer& parent = |
406 static_cast<CNcsComposeViewContainer&>( iParent ); |
451 static_cast<CNcsComposeViewContainer&>( iParent ); |
407 parent.HandleAttachmentsOpenCommandL(); |
452 parent.HandleAttachmentsOpenCommandL(); |
408 } |
453 } |
409 } |
454 } |
410 } |
455 } |
411 |
456 |
412 CCoeControl::HandlePointerEventL( aPointerEvent ); |
457 CCoeControl::HandlePointerEventL( aPointerEvent ); |
413 } |
458 } |
414 |
459 |
415 // ----------------------------------------------------------------------------- |
460 // ----------------------------------------------------------------------------- |
416 // CNcsHeaderContainer::HandleLongTapL() |
461 // CNcsHeaderContainer::HandleLongTapL() |
417 // |
462 // |
561 // --------------------------------------------------------------------------- |
608 // --------------------------------------------------------------------------- |
562 // CNcsHeaderContainer::FindFocused |
609 // CNcsHeaderContainer::FindFocused |
563 // --------------------------------------------------------------------------- |
610 // --------------------------------------------------------------------------- |
564 // |
611 // |
565 CCoeControl* CNcsHeaderContainer::FindFocused() const |
612 CCoeControl* CNcsHeaderContainer::FindFocused() const |
566 { |
613 { |
567 FUNC_LOG; |
614 FUNC_LOG; |
568 CCoeControlArray::TCursor cur = Components().Begin(); |
615 CCoeControlArray::TCursor cur = Components().Begin(); |
569 do |
616 do |
570 { |
617 { |
571 if ( cur.Control<CCoeControl>()->IsFocused() ) |
618 if ( cur.Control<CCoeControl>()->IsFocused() ) |
572 { |
619 { |
573 return cur.Control<CCoeControl>(); |
620 return cur.Control<CCoeControl>(); |
574 } |
621 } |
575 } |
622 } |
576 while ( cur.Next() ); |
623 while ( cur.Next() ); |
577 return NULL; |
624 return NULL; |
578 } |
625 } |
579 |
626 |
580 // ----------------------------------------------------------------------------- |
627 // ----------------------------------------------------------------------------- |
581 // CNcsHeaderContainer::ChangeFocusL() |
628 // CNcsHeaderContainer::ChangeFocusL() |
582 // Handles key events |
629 // Handles key events |
583 // ----------------------------------------------------------------------------- |
630 // ----------------------------------------------------------------------------- |
584 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent ) |
631 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent ) |
585 { |
632 { |
586 FUNC_LOG; |
633 FUNC_LOG; |
587 ASSERT( aKeyEvent.iCode == EKeyDownArrow || |
634 ASSERT( aKeyEvent.iCode == EKeyDownArrow || |
588 aKeyEvent.iCode == EKeyUpArrow ); |
635 aKeyEvent.iCode == EKeyUpArrow ); |
589 TKeyResponse ret( EKeyWasNotConsumed ); |
636 TKeyResponse ret( EKeyWasNotConsumed ); |
590 |
637 |
591 CCoeControl* pOldCtrl = FindFocused(); |
638 CCoeControl* pOldCtrl = FindFocused(); |
592 |
639 |
593 // If nothing is focused we return |
640 // If nothing is focused we return |
594 if ( !pOldCtrl ) return ret; |
641 if ( !pOldCtrl ) return ret; |
595 |
642 |
596 //If this is the first control in the list, don't change focus |
643 //If this is the first control in the list, don't change focus |
597 CCoeControlArray::TCursor cur = Components().Find(pOldCtrl); |
644 CCoeControlArray::TCursor cur = Components().Find(pOldCtrl); |
598 if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() ) |
645 if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() ) |
599 { |
646 { |
600 return ret; |
647 return ret; |
601 } |
648 } |
602 |
649 |
603 // Unfocus the control |
650 // Unfocus the control |
604 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
651 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
605 |
652 |
606 CCoeControl* pNewCtrl= NULL; |
653 CCoeControl* pNewCtrl= NULL; |
607 if ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) |
654 if ( ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) || |
608 { |
655 ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() ) ) |
609 pNewCtrl = cur.Control<CCoeControl>(); |
656 { |
610 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
657 pNewCtrl = cur.Control<CCoeControl>(); |
|
658 iFocused = pNewCtrl; |
|
659 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
611 ret = EKeyWasConsumed; |
660 ret = EKeyWasConsumed; |
612 } |
661 } |
613 else if ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() ) |
662 |
614 { |
663 CNcsComposeViewContainer* container = |
615 pNewCtrl = cur.Control<CCoeControl>(); |
|
616 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
617 ret = EKeyWasConsumed; |
|
618 } |
|
619 |
|
620 CNcsComposeViewContainer* container = |
|
621 static_cast<CNcsComposeViewContainer*>( &iParent ); |
664 static_cast<CNcsComposeViewContainer*>( &iParent ); |
622 if ( pOldCtrl == iToField ) |
665 if ( pOldCtrl == iToField ) |
623 { |
666 { |
624 container->CommitL( EToField ); |
667 container->CommitL( EToField ); |
625 } |
668 } |
880 if ( pOldCtrl ) |
919 if ( pOldCtrl ) |
881 { |
920 { |
882 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
921 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
883 } |
922 } |
884 |
923 |
|
924 iFocused = iAttachmentField; |
885 iAttachmentField->SetFocus( ETrue, ENoDrawNow ); |
925 iAttachmentField->SetFocus( ETrue, ENoDrawNow ); |
886 iFieldSizeObserver.UpdateFieldPosition( iAttachmentField ); |
926 iFieldSizeObserver.UpdateFieldPosition( iAttachmentField ); |
887 } |
927 } |
888 } |
928 } |
889 |
929 |
890 // ----------------------------------------------------------------------------- |
930 // ----------------------------------------------------------------------------- |
891 // CNcsHeaderContainer::HideAttachmentLabel() |
931 // CNcsHeaderContainer::HideAttachmentLabel() |
892 // ----------------------------------------------------------------------------- |
932 // ----------------------------------------------------------------------------- |
893 // |
933 // |
894 void CNcsHeaderContainer::HideAttachmentLabel() |
934 void CNcsHeaderContainer::HideAttachmentLabel() |
895 { |
935 { |
896 FUNC_LOG; |
936 FUNC_LOG; |
897 // check if we are focused and in that case |
937 // check if we are focused and in that case |
898 // unfocus attachment filed and focus previous control |
938 // unfocus attachment filed and focus previous control |
899 CCoeControl* pOldCtrl = FindFocused(); |
939 CCoeControl* pOldCtrl = FindFocused(); |
900 CCoeControl* pNewCtrl = NULL; |
940 CCoeControl* pNewCtrl = NULL; |
901 |
941 |
902 if ( pOldCtrl == iAttachmentField ) |
942 if ( pOldCtrl == iAttachmentField ) |
903 { |
943 { |
904 CCoeControlArray::TCursor cur = Components().Find( pOldCtrl ); |
944 CCoeControlArray::TCursor cur = Components().Find( pOldCtrl ); |
905 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
945 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
906 |
946 |
907 if ( cur.Prev() ) |
947 if ( cur.Prev() ) |
908 { |
948 { |
909 pNewCtrl = cur.Control<CCoeControl>(); |
949 pNewCtrl = cur.Control<CCoeControl>(); |
910 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
950 iFocused = pNewCtrl; |
911 } |
951 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
952 } |
912 } |
953 } |
913 else |
954 else |
914 { |
955 { |
915 pNewCtrl = pOldCtrl; // no need to move focus |
956 pNewCtrl = pOldCtrl; // no need to move focus |
916 } |
957 } |
917 |
958 |
918 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
959 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
919 { |
960 { |
920 DrawAttachmentFocusNow(); |
961 DrawAttachmentFocusNow(); |
921 } |
962 } |
922 |
963 |
923 iAttachmentField->MakeVisible( EFalse ); |
964 iAttachmentField->MakeVisible( EFalse ); |
924 Components().Remove( iAttachmentField ); |
965 Components().Remove( iAttachmentField ); |
925 |
966 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
926 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
927 |
967 |
928 // Scroll to currently focused field |
968 // Scroll to currently focused field |
929 if ( pNewCtrl ) |
969 if ( pNewCtrl ) |
930 { |
970 { |
931 iFieldSizeObserver.UpdateFieldPosition( pNewCtrl ); |
971 iFieldSizeObserver.UpdateFieldPosition( pNewCtrl ); |
932 } |
972 } |
933 |
973 |
934 } |
974 } |
935 |
975 |
936 // ----------------------------------------------------------------------------- |
976 // ----------------------------------------------------------------------------- |
937 // CNcsHeaderContainer::SetBccFieldVisibleL() |
977 // CNcsHeaderContainer::SetBccFieldVisibleL() |
938 // ----------------------------------------------------------------------------- |
978 // ----------------------------------------------------------------------------- |
939 // |
979 // |
940 void CNcsHeaderContainer::SetBccFieldVisibleL( |
980 void CNcsHeaderContainer::SetBccFieldVisibleL( |
941 TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
981 TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
942 { |
982 { |
943 FUNC_LOG; |
983 FUNC_LOG; |
944 if ( iBccField->IsVisible() == aVisible ) |
984 if ( iBccField->IsVisible() == aVisible ) |
945 { |
985 { |
946 return; |
986 return; |
947 } |
987 } |
948 |
988 |
949 if ( aVisible ) |
989 if ( aVisible ) |
950 { |
990 { |
951 CCoeControlArray::TCursor cur = Components().Find( iSubjectField ); |
991 CCoeControlArray::TCursor cur = Components().Find( iSubjectField ); |
952 Components().InsertLC( cur, iBccField ); |
992 Components().InsertLC( cur, iBccField ); |
953 CleanupStack::Pop( iBccField ); |
993 CleanupStack::Pop( iBccField ); |
954 |
994 |
955 if ( aFocus ) |
995 if ( aFocus ) |
956 { |
996 { |
957 CCoeControl* focused = FindFocused(); |
997 CCoeControl* focused = FindFocused(); |
958 |
998 |
959 if ( focused ) |
999 if ( focused ) |
960 { |
1000 { |
961 focused->SetFocus( EFalse ); |
1001 focused->SetFocus( EFalse, aDrawNow ); |
962 } |
1002 } |
963 iBccField->SetFocus( ETrue ); |
1003 iBccField->SetFocus( ETrue, aDrawNow ); |
964 iFocused = iBccField; |
1004 iFocused = iBccField; |
965 iBccField->SelectAllTextL(); |
1005 iBccField->SelectAllTextL(); |
966 } |
1006 } |
967 } |
1007 } |
968 else |
1008 else |
969 { |
1009 { |
970 if ( iBccField->IsFocused() ) |
1010 if ( iBccField->IsFocused() ) |
971 { |
1011 { |
972 CCoeControlArray::TCursor cur = Components().Find( iBccField ); |
1012 CCoeControlArray::TCursor cur = Components().Find( iBccField ); |
973 ASSERT( cur.IsValid() ); |
1013 ASSERT( cur.IsValid() ); |
974 |
1014 |
975 iBccField->SetFocus( EFalse ); |
1015 iBccField->SetFocus( EFalse ); |
976 |
1016 |
977 cur.Prev(); // Get the control before this field |
1017 cur.Prev(); // Get the control before this field |
978 cur.Control<CCoeControl>()->SetFocus( ETrue ); |
1018 CCoeControl* focused = cur.Control<CCoeControl>(); |
979 } |
1019 focused->SetFocus( ETrue ); |
980 Components().Remove( iBccField ); |
1020 iFocused = focused; |
981 iFocused = iSubjectField; |
1021 } |
982 } |
1022 Components().Remove( iBccField ); |
|
1023 } |
983 |
1024 |
984 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
1025 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
985 |
1026 |
986 if ( aDrawNow == EDrawNow ) |
1027 if ( aDrawNow == EDrawNow ) |
987 { |
1028 { |
988 DrawDeferred(); |
1029 DrawDeferred(); |
989 } |
1030 } |
990 } |
1031 } |
991 |
1032 |
992 // ----------------------------------------------------------------------------- |
1033 // ----------------------------------------------------------------------------- |
993 // CNcsHeaderContainer::SetCcFieldVisibleL() |
1034 // CNcsHeaderContainer::SetCcFieldVisibleL() |
994 // ----------------------------------------------------------------------------- |
1035 // ----------------------------------------------------------------------------- |
995 void CNcsHeaderContainer::SetCcFieldVisibleL( |
1036 void CNcsHeaderContainer::SetCcFieldVisibleL( |
996 TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
1037 TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
997 { |
1038 { |
998 FUNC_LOG; |
1039 FUNC_LOG; |
999 if ( iCcField->IsVisible() == aVisible ) |
1040 if ( iCcField->IsVisible() == aVisible ) |
1000 { |
1041 { |
1001 return; |
1042 return; |
1002 } |
1043 } |
1003 |
1044 |
1004 if ( aVisible ) |
1045 if ( aVisible ) |
1005 { |
1046 { |
1006 Components().InsertAfterLC( Components().Id( *iToField ), iCcField ); |
1047 Components().InsertAfterLC( Components().Id( *iToField ), iCcField ); |
1007 CleanupStack::Pop( iCcField ); |
1048 CleanupStack::Pop( iCcField ); |
1008 |
1049 |
1009 if ( aFocus ) |
1050 if ( aFocus ) |
1010 { |
1051 { |
1011 CCoeControl* focused = FindFocused(); |
1052 CCoeControl* focused = FindFocused(); |
1012 if ( focused ) |
1053 if ( focused ) |
1013 { |
1054 { |
1014 focused->SetFocus( EFalse ); |
1055 focused->SetFocus( EFalse, aDrawNow ); |
1015 } |
1056 } |
1016 iCcField->SetFocus( ETrue ); |
1057 iCcField->SetFocus( ETrue, aDrawNow ); |
1017 iFocused = iCcField; |
1058 iFocused = iCcField; |
1018 iCcField->SelectAllTextL(); |
1059 iCcField->SelectAllTextL(); |
1019 } |
1060 } |
1020 } |
1061 } |
1021 else |
1062 else |
1022 { |
1063 { |
1023 if( iCcField->IsFocused() ) |
1064 if( iCcField->IsFocused() ) |
1024 { |
1065 { |
1025 iCcField->SetFocus( EFalse ); |
1066 iCcField->SetFocus( EFalse ); |
1026 iToField->SetFocus( ETrue ); |
1067 iToField->SetFocus( ETrue ); |
1027 } |
1068 iFocused = iToField; |
1028 Components().Remove( iCcField ); |
1069 } |
1029 iFocused = iToField; |
1070 Components().Remove( iCcField ); |
1030 } |
1071 } |
1031 |
1072 |
1032 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
1073 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
1033 |
1074 |
1034 if ( aDrawNow == EDrawNow ) |
1075 if ( aDrawNow == EDrawNow ) |
1035 { |
1076 { |
1036 DrawDeferred(); |
1077 DrawDeferred(); |
1037 } |
1078 } |
1038 } |
1079 } |
1039 |
1080 |
1040 // ----------------------------------------------------------------------------- |
1081 // ----------------------------------------------------------------------------- |
1041 // CNcsHeaderContainer::MopSupplyObject |
1082 // CNcsHeaderContainer::MopSupplyObject |
1042 // From CCoeControl. |
1083 // From CCoeControl. |
1155 // CNcsHeaderContainer::UpdatePopupContactListL() |
1196 // CNcsHeaderContainer::UpdatePopupContactListL() |
1156 // ----------------------------------------------------------------------------- |
1197 // ----------------------------------------------------------------------------- |
1157 // |
1198 // |
1158 void CNcsHeaderContainer::UpdatePopupContactListL( |
1199 void CNcsHeaderContainer::UpdatePopupContactListL( |
1159 const TDesC& aMatchString, TBool /*aListAll*/ ) |
1200 const TDesC& aMatchString, TBool /*aListAll*/ ) |
1160 { |
1201 { |
1161 FUNC_LOG; |
1202 FUNC_LOG; |
1162 |
1203 |
1163 // do update only for address fields |
1204 // do update only for address fields |
1164 CCoeControl* focused = FindFocused(); |
1205 CCoeControl* focused = FindFocused(); |
1165 |
1206 |
1166 if ( !IsAddressInputField( focused ) ) |
1207 if ( !IsAddressInputField( focused ) ) |
1167 { |
1208 { |
1168 return; |
1209 return; |
1169 } |
1210 } |
1170 |
1211 |
1171 if ( aMatchString.CompareC( KNullDesC ) == 0 || |
1212 if ( aMatchString.CompareC( KNullDesC ) == 0 || |
1172 aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 ) |
1213 aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 ) |
1173 { |
1214 { |
1174 ClosePopupContactListL(); |
1215 ClosePopupContactListL(); |
1175 return; |
1216 return; |
1176 } |
1217 } |
1177 |
1218 |
1178 if( !iAacListBox->IsVisible() ) |
1219 if( !iAacListBox->IsVisible() ) |
1179 { |
1220 { |
1180 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
1221 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
1181 iAacListBox->InitAndSearchL( aMatchString, 1 ); |
1222 iAacListBox->InitAndSearchL( aMatchString, 1 ); |
1182 iAacListBox->ActivateL(); |
1223 iAacListBox->ActivateL(); |
1183 } |
1224 } |
1184 else |
1225 else |
1185 { |
1226 { |
1186 iAacListBox->SetSearchTextL( aMatchString ); |
1227 iAacListBox->SetSearchTextL( aMatchString ); |
1187 } |
1228 } |
1188 } |
1229 } |
1189 |
1230 |
1190 // ----------------------------------------------------------------------------- |
1231 // ----------------------------------------------------------------------------- |
1191 // CNcsHeaderContainer::ClosePopupContactListL() |
1232 // CNcsHeaderContainer::ClosePopupContactListL() |
1192 // ----------------------------------------------------------------------------- |
1233 // ----------------------------------------------------------------------------- |
1193 // |
1234 // |
1194 void CNcsHeaderContainer::ClosePopupContactListL() |
1235 void CNcsHeaderContainer::ClosePopupContactListL() |
1195 { |
1236 { |
1196 FUNC_LOG; |
1237 FUNC_LOG; |
1197 |
|
1198 if ( iAacListBox->IsVisible() ) |
1238 if ( iAacListBox->IsVisible() ) |
1199 { |
1239 { |
1200 iAacListBox->MakeVisible( EFalse ); |
1240 iAacListBox->ClosePopupL(); |
1201 ShowPopupMenuBarL( EFalse ); |
1241 } |
1202 |
1242 |
1203 // The focused address field should be redrawn after the popup is |
1243 // The focused address field should be redrawn after the popup is |
1204 // closed to fix the field border. |
1244 // closed to fix the field border. |
1205 if ( iToField->IsFocused() ) |
1245 if ( iToField->IsFocused() ) |
1206 { |
1246 { |
1207 iToField->DrawDeferred(); |
1247 iToField->DrawDeferred(); |
1208 } |
1248 } |
1209 else if ( iCcField->IsFocused() ) |
1249 else if ( iCcField->IsFocused() ) |
1210 { |
1250 { |
1211 iCcField->DrawDeferred(); |
1251 iCcField->DrawDeferred(); |
1212 } |
1252 } |
1213 else if ( iBccField->IsFocused() ) |
1253 else if ( iBccField->IsFocused() ) |
1214 { |
1254 { |
1215 iBccField->DrawDeferred(); |
1255 iBccField->DrawDeferred(); |
1216 } |
1256 } |
1217 } |
1257 } |
1218 } |
|
1219 |
1258 |
1220 // --------------------------------------------------------------------------- |
1259 // --------------------------------------------------------------------------- |
1221 // CNcsHeaderContainer::ShowPopupMenuBarL |
1260 // CNcsHeaderContainer::ShowPopupMenuBarL |
1222 // --------------------------------------------------------------------------- |
1261 // --------------------------------------------------------------------------- |
1223 // |
1262 // |
2020 container->CommitL( ESubjectField ); |
2071 container->CommitL( ESubjectField ); |
2021 } |
2072 } |
2022 } |
2073 } |
2023 } |
2074 } |
2024 |
2075 |
2025 // ----------------------------------------------------------------------------- |
2076 // --------------------------------------------------------------------------- |
2026 // CNcsHeaderContainer::DoScroll |
2077 // Scrolls editor to make cursor visible, if it is outside the visible area |
2027 // ----------------------------------------------------------------------------- |
2078 // --------------------------------------------------------------------------- |
2028 // |
2079 // |
2029 void CNcsHeaderContainer::DoScroll() |
2080 void CNcsHeaderContainer::DoScroll() |
2030 { |
2081 { |
2031 // scroll the screen if the cursor goes beyond the screen |
2082 // scroll the screen if the cursor goes beyond the screen |
2032 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
2083 CNcsComposeViewContainer& parent = |
2033 |
2084 static_cast<CNcsComposeViewContainer&>( iParent ); |
2034 TInt screenPos( -Position().iY ); |
2085 |
2035 TInt cursorPos( CursorPosition() ); |
2086 // Scrolling based on cursor line number can only be done when |
2036 TInt lineHeight( Rect().Height() / LineCount() ); |
2087 // header composer and one of its fields is focused. |
2037 TInt screenHeight( parent.Rect().Height() ); |
2088 if ( IsFocused() ) |
2038 |
2089 { |
2039 if ( cursorPos - lineHeight < screenPos ) |
2090 const TRect rect = Rect(); |
2040 { |
2091 const TInt screenPos = iOrigin.iY - rect.iTl.iY; |
2041 screenPos = cursorPos - lineHeight; |
2092 const TInt screenHeight = parent.VisibleAreaHeight(); |
2042 } |
2093 |
2043 else if( cursorPos + lineHeight > screenPos + screenHeight ) |
2094 const TInt lineNumber = CursorLineNumber(); |
2044 { |
2095 const TInt lineHeight = rect.Height() / LineCount(); |
2045 screenPos = cursorPos + lineHeight - screenHeight; |
2096 const TInt linePos = lineNumber * lineHeight; |
2046 } |
2097 |
2047 |
2098 TInt targetPos = screenPos; |
2048 parent.Scroll( screenPos ); |
2099 if ( linePos - lineHeight < screenPos ) |
|
2100 { |
|
2101 targetPos = linePos - lineHeight; |
|
2102 } |
|
2103 else if ( linePos + lineHeight > screenPos + screenHeight ) |
|
2104 { |
|
2105 targetPos = linePos + lineHeight - screenHeight; |
|
2106 } |
|
2107 |
|
2108 parent.Scroll( targetPos ); |
|
2109 } |
|
2110 } |
|
2111 |
|
2112 // --------------------------------------------------------------------------- |
|
2113 // Scrolls focused editor line to the top of visible area. |
|
2114 // --------------------------------------------------------------------------- |
|
2115 // |
|
2116 void CNcsHeaderContainer::DoScrollFocusToTop() |
|
2117 { |
|
2118 CNcsComposeViewContainer& parent = |
|
2119 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
2120 |
|
2121 // Calculate the position of the focused editor line. |
|
2122 const TRect rect = Rect(); |
|
2123 const TInt lineNumber = CursorLineNumber(); |
|
2124 const TInt lineHeight = rect.Height() / LineCount(); |
|
2125 const TInt targetPos = ( lineNumber - 1 ) * lineHeight; |
|
2126 |
|
2127 parent.Scroll( targetPos ); |
2049 } |
2128 } |
2050 |
2129 |
2051 // --------------------------------------------------------------------------- |
2130 // --------------------------------------------------------------------------- |
2052 // CNcsHeaderContainer::SetPhysicsEmulationOngoing |
2131 // CNcsHeaderContainer::SetPhysicsEmulationOngoing |
2053 // --------------------------------------------------------------------------- |
2132 // --------------------------------------------------------------------------- |