77 |
80 |
78 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
79 // CMRFieldContainer::NewL |
82 // CMRFieldContainer::NewL |
80 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
81 // |
84 // |
82 CMRFieldContainer* CMRFieldContainer::NewL( |
85 CMRFieldContainer* CMRFieldContainer::NewL( |
83 MESMRFieldStorage& aFactory, |
86 MESMRFieldStorage& aFactory, |
84 const CCoeControl& aParent ) |
87 const CCoeControl& aParent ) |
85 { |
88 { |
86 FUNC_LOG; |
89 FUNC_LOG; |
87 CMRFieldContainer* self = new( ELeave )CMRFieldContainer( aFactory ); |
90 CMRFieldContainer* self = new( ELeave )CMRFieldContainer( aFactory ); |
88 CleanupStack::PushL( self ); |
91 CleanupStack::PushL( self ); |
192 { |
194 { |
193 field->SetPreItemIndex( iFocusedFieldIndex ); |
195 field->SetPreItemIndex( iFocusedFieldIndex ); |
194 iFocusedFieldIndex = ind; |
196 iFocusedFieldIndex = ind; |
195 field->SetCurrentItemIndex( iFocusedFieldIndex ); |
197 field->SetCurrentItemIndex( iFocusedFieldIndex ); |
196 |
198 |
197 // Remove focus from previous position |
199 // Remove focus from previous position |
198 focusedField->SetOutlineFocusL( EFalse ); |
200 focusedField->SetOutlineFocusL( EFalse ); |
199 focusedField->SetFocus( EFalse ); |
201 focusedField->SetFocus( EFalse ); |
200 |
202 focusedField->MoveToScreen( EFalse ); |
|
203 |
201 // Set focus to new position |
204 // Set focus to new position |
202 field->SetOutlineFocusL( ETrue ); |
205 field->SetOutlineFocusL( ETrue ); |
203 field->SetFocus( ETrue ); |
206 field->SetFocus( ETrue ); |
|
207 field->MoveToScreen( ETrue ); |
204 |
208 |
205 // Scrollbar and physics update is done here |
209 // Scrollbar and physics update is done here |
206 ScrollControlVisible( iFocusedFieldIndex ); |
210 ScrollControlVisible( iFocusedFieldIndex ); |
207 |
211 |
208 DrawDeferred(); |
212 DrawDeferred(); |
209 } |
213 } |
210 |
214 |
211 return EKeyWasConsumed; |
215 return EKeyWasConsumed; |
212 } |
216 } |
256 { |
260 { |
257 field->SetPreItemIndex( iFocusedFieldIndex ); |
261 field->SetPreItemIndex( iFocusedFieldIndex ); |
258 iFocusedFieldIndex = ind; |
262 iFocusedFieldIndex = ind; |
259 field->SetCurrentItemIndex( iFocusedFieldIndex ); |
263 field->SetCurrentItemIndex( iFocusedFieldIndex ); |
260 |
264 |
261 // Remove focus from previous position |
265 // Remove focus from previous position |
262 focusedField->SetOutlineFocusL( EFalse ); |
266 focusedField->SetOutlineFocusL( EFalse ); |
263 focusedField->SetFocus( EFalse ); |
267 focusedField->SetFocus( EFalse ); |
264 |
268 focusedField->MoveToScreen( EFalse ); |
|
269 |
265 // Set focus to new position |
270 // Set focus to new position |
266 field->SetOutlineFocusL( ETrue ); |
271 field->SetOutlineFocusL( ETrue ); |
267 field->SetFocus( ETrue ); |
272 field->SetFocus( ETrue ); |
|
273 field->MoveToScreen( ETrue ); |
268 |
274 |
269 // Scrollbar and physics update is done here |
275 // Scrollbar and physics update is done here |
270 ScrollControlVisible( iFocusedFieldIndex ); |
276 ScrollControlVisible( iFocusedFieldIndex ); |
271 |
277 |
272 DrawDeferred(); |
278 DrawDeferred(); |
273 } |
279 } |
274 |
280 |
275 return EKeyWasConsumed; |
281 return EKeyWasConsumed; |
276 } |
282 } |
285 // |
291 // |
286 TKeyResponse CMRFieldContainer::MoveFocusVisibleL() |
292 TKeyResponse CMRFieldContainer::MoveFocusVisibleL() |
287 { |
293 { |
288 FUNC_LOG; |
294 FUNC_LOG; |
289 /* |
295 /* |
290 * Move focus to first completely visible field in the view, |
296 * Move focus to first completely visible field in the view, |
291 * if focus was in a field that was not visible in the view. |
297 * if focus was in a field that was not visible in the view. |
292 * Use case: After pointer scroll focus is hidden. User presses |
298 * Use case: After pointer scroll focus is hidden. User presses |
293 * arrow keys -> Focus appears to the first visible field on the upper |
299 * arrow keys -> Focus appears to the first visible field on the upper |
294 * or bottom part of the viewable area. |
300 * or bottom part of the viewable area. |
295 */ |
301 */ |
296 |
302 |
297 TKeyResponse response( EKeyWasNotConsumed ); |
303 TKeyResponse response( EKeyWasNotConsumed ); |
298 |
304 |
299 CESMRField* focusedField = FocusedField(); |
305 CESMRField* focusedField = FocusedField(); |
300 CESMRField* visibleField = NULL; |
306 CESMRField* visibleField = NULL; |
301 TRect view( Parent()->Rect() ); |
307 TRect view( Parent()->Rect() ); |
353 if ( visibleField ) |
359 if ( visibleField ) |
354 { |
360 { |
355 // Remove existing focus |
361 // Remove existing focus |
356 focusedField->SetOutlineFocusL( EFalse ); |
362 focusedField->SetOutlineFocusL( EFalse ); |
357 focusedField->SetFocus( EFalse ); |
363 focusedField->SetFocus( EFalse ); |
358 |
364 |
359 // Set focus to new field |
365 // Set focus to new field |
360 visibleField->SetOutlineFocusL( ETrue ); |
366 visibleField->SetOutlineFocusL( ETrue ); |
361 visibleField->SetFocus( ETrue ); |
367 visibleField->SetFocus( ETrue ); |
362 |
368 |
363 response = EKeyWasConsumed; |
369 response = EKeyWasConsumed; |
364 |
370 |
365 DrawDeferred(); |
371 DrawDeferred(); |
366 } |
372 } |
367 |
373 |
368 return response; |
374 return response; |
369 } |
375 } |
370 |
376 |
371 // --------------------------------------------------------------------------- |
377 // --------------------------------------------------------------------------- |
372 // CMRFieldContainer::SetFieldContainerObserver |
378 // CMRFieldContainer::SetFieldContainerObserver |
373 // --------------------------------------------------------------------------- |
379 // --------------------------------------------------------------------------- |
374 // |
380 // |
375 void CMRFieldContainer::SetFieldContainerObserver( |
381 void CMRFieldContainer::SetFieldContainerObserver( |
376 MMRFieldContainerObserver* aObserver ) |
382 MMRFieldContainerObserver* aObserver ) |
377 { |
383 { |
378 FUNC_LOG; |
384 FUNC_LOG; |
379 iObserver = aObserver; |
385 iObserver = aObserver; |
380 } |
386 } |
407 { |
422 { |
408 FUNC_LOG; |
423 FUNC_LOG; |
409 /* |
424 /* |
410 * Returns the minimum size required by the field container |
425 * Returns the minimum size required by the field container |
411 */ |
426 */ |
412 |
427 |
413 TSize containerSize; |
428 TSize containerSize; |
414 |
429 |
|
430 // Calculate height as the sum of the heights of the visible fields |
415 const TInt count( iFactory.Count() ); |
431 const TInt count( iFactory.Count() ); |
416 |
432 |
417 for ( TInt i(0); i < count; ++i ) |
433 for ( TInt i(0); i < count; ++i ) |
418 { |
434 { |
419 CESMRField* field = iFactory.Field( i ); |
435 CESMRField* field = iFactory.Field( i ); |
420 if ( field->IsVisible() ) |
436 if ( field->IsVisible() ) |
421 { |
437 { |
422 TRect rect( field->Rect() ); |
438 TRect rect( field->Rect() ); |
423 containerSize.iHeight += rect.Height(); |
439 containerSize.iHeight += rect.Height(); |
424 } |
440 } |
425 } |
441 } |
426 |
442 |
427 containerSize.iWidth = Parent()->Rect().Width(); |
443 containerSize.iWidth = Parent()->Rect().Width(); |
428 |
444 |
429 return containerSize; |
445 return containerSize; |
430 } |
446 } |
431 |
447 |
432 // --------------------------------------------------------------------------- |
448 // --------------------------------------------------------------------------- |
433 // CMRFieldContainer::SizeChanged |
449 // CMRFieldContainer::SizeChanged |
434 // --------------------------------------------------------------------------- |
450 // --------------------------------------------------------------------------- |
435 // |
451 // |
436 void CMRFieldContainer::SizeChanged() |
452 void CMRFieldContainer::SizeChanged() |
437 { |
453 { |
438 FUNC_LOG; |
454 FUNC_LOG; |
439 |
455 |
440 // TEST CODE: |
456 // For example when orientation changes, we might need to scroll |
441 TRect fieldcontainerRect = Rect(); |
|
442 TRect parentRect = Parent()->Rect(); |
|
443 |
|
444 |
|
445 // For example when orientation changes, we might need to scroll |
|
446 // the currently focused control visible again. This handles also |
457 // the currently focused control visible again. This handles also |
447 // scrollbar and physics updates. |
458 // scrollbar and physics updates. |
448 ScrollControlVisible( KErrNotFound ); |
459 ScrollControlVisible( KErrNotFound ); |
449 |
460 |
450 TPoint tl( Position() ); |
461 TPoint tl( Position() ); |
451 |
462 |
452 const TInt count( iFactory.Count() ); |
463 const TInt count( iFactory.Count() ); |
453 |
464 |
454 // Loop all the visible fields and set size and position in the list |
465 // Loop all the visible fields and set size and position in the list |
456 { |
467 { |
457 CESMRField* field = iFactory.Field( i ); |
468 CESMRField* field = iFactory.Field( i ); |
458 |
469 |
459 if ( field->IsVisible() ) |
470 if ( field->IsVisible() ) |
460 { |
471 { |
461 LayoutField( *field, tl ); |
472 TPoint pos( tl ); |
|
473 |
|
474 // If field is not focused, layout it outside screen |
|
475 if ( i != iFocusedFieldIndex ) |
|
476 { |
|
477 pos.iX = KOffScreenPositionX; |
|
478 } |
|
479 |
|
480 LayoutField( *field, pos ); |
462 |
481 |
463 TInt height = field->Size().iHeight; |
482 TInt height = field->Size().iHeight; |
464 tl.iY += height; |
483 tl.iY += height; |
465 } |
484 } |
466 } |
485 } |
467 } |
486 } |
468 |
487 |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // CMRFieldContainer::HandlePointerEventL |
|
491 // --------------------------------------------------------------------------- |
|
492 // |
|
493 void CMRFieldContainer::HandlePointerEventL( const TPointerEvent &aPointerEvent ) |
|
494 { |
|
495 FUNC_LOG; |
|
496 |
|
497 // Find out to which field this pointer event is intended to |
|
498 TInt fieldCount( iFactory.Count() ); |
|
499 |
|
500 for( TInt i = 0; i < fieldCount; ++i ) |
|
501 { |
|
502 CCoeControl* field = iFactory.Field( i ); |
|
503 if( field->Rect().Contains( aPointerEvent.iPosition ) && |
|
504 field->IsVisible() ) |
|
505 { |
|
506 field->HandlePointerEventL( aPointerEvent ); |
|
507 } |
|
508 } |
|
509 } |
|
510 |
469 // --------------------------------------------------------------------------- |
511 // --------------------------------------------------------------------------- |
470 // CMRFieldContainer::ControlSizeChanged |
512 // CMRFieldContainer::ControlSizeChanged |
471 // --------------------------------------------------------------------------- |
513 // --------------------------------------------------------------------------- |
472 // |
514 // |
473 void CMRFieldContainer::ControlSizeChanged( CESMRField* aField ) |
515 void CMRFieldContainer::ControlSizeChanged( CESMRField* aField ) |
474 { |
516 { |
475 FUNC_LOG; |
517 FUNC_LOG; |
476 /* |
518 /* |
477 * Called whenever a fields size has changed. Requires always |
519 * Called whenever a fields size has changed. Requires always |
478 * relayouting. |
520 * relayouting. |
479 */ |
521 */ |
480 |
522 |
481 if ( !aField ) |
523 if ( !aField ) |
482 { |
524 { |
483 SizeChanged(); |
525 SizeChanged(); |
488 TSize old( aField->Size() ); |
530 TSize old( aField->Size() ); |
489 TSize size( aField->MinimumSize() ); |
531 TSize size( aField->MinimumSize() ); |
490 if( size != old ) |
532 if( size != old ) |
491 { |
533 { |
492 aField->SetSize( size ); |
534 aField->SetSize( size ); |
493 |
535 |
494 TPoint tl( aField->Position() ); |
536 TPoint tl( aField->Position() ); |
495 TInt index = IndexByFieldId( iFactory, aField->FieldId() ); |
537 TInt index = IndexByFieldId( iFactory, aField->FieldId() ); |
496 |
538 |
497 // Move fields below this particular field |
539 // Move fields below this particular field |
498 tl.iY += size.iHeight; |
540 tl.iY += size.iHeight; |
499 MoveFields( index + 1, tl ); |
541 MoveFields( index + 1, tl ); |
500 |
542 |
501 // Fields have been re-layouted / moved. This requires resetting |
543 // Fields have been re-layouted / moved. This requires resetting |
502 // the size of this field container. |
544 // the size of this field container. |
503 SetSize( MinimumSize() ); |
545 SetSizeWithoutNotification( MinimumSize() ); |
504 |
546 |
505 // Update also scrollbar and physics |
547 // Update also scrollbar and physics |
506 iObserver->UpdateScrollBarAndPhysics(); |
548 iObserver->UpdateScrollBarAndPhysics(); |
507 |
549 |
508 if( index == iFocusedFieldIndex ) |
550 if( index <= iFocusedFieldIndex ) |
509 { |
551 { |
510 // Scroll this field completely visible, if required. |
552 // Scroll this field completely visible, if required. |
511 // This updates also scrollbar and physics if scrolling |
553 // This updates also scrollbar and physics if scrolling |
512 // is done. |
554 // is done. |
513 ScrollControlVisible( iFocusedFieldIndex ); |
555 ScrollControlVisible( iFocusedFieldIndex ); |
514 } |
556 } |
515 |
557 |
516 DrawDeferred(); |
558 DrawDeferred(); |
517 } |
559 } |
518 } |
560 } |
519 } |
561 } |
520 |
562 |
539 |
581 |
540 TPoint tl( Rect().iTl ); |
582 TPoint tl( Rect().iTl ); |
541 TInt prevIndex = index - 1; |
583 TInt prevIndex = index - 1; |
542 |
584 |
543 // Get previous visible field position |
585 // Get previous visible field position |
544 // Index 0 must be included in attendee field case, |
586 // Index 0 must be included in attendee field case, |
545 // to avoid field collision. But in response field, |
587 // to avoid field collision. But in response field, |
546 // causes misplacing of area. |
588 // causes misplacing of area. |
547 if ( ( prevIndex >= 0 ) && ( aFieldId != EESMRFieldResponseArea ) ) |
589 if ( ( prevIndex >= 0 ) && ( aFieldId != EESMRFieldResponseArea ) ) |
548 { |
590 { |
549 CESMRField* previous = NULL; |
591 CESMRField* previous = NULL; |
550 do |
592 do |
556 tl.iY = previous->Rect().iBr.iY; |
598 tl.iY = previous->Rect().iBr.iY; |
557 } |
599 } |
558 |
600 |
559 // Layout field |
601 // Layout field |
560 LayoutField( *field, tl); |
602 LayoutField( *field, tl); |
|
603 // Move field off screen if it is not focused |
|
604 field->MoveToScreen( index == iFocusedFieldIndex ); |
561 |
605 |
562 // Move following fields |
606 // Move following fields |
563 tl.iY += field->Size().iHeight; |
607 tl.iY += field->Size().iHeight; |
564 MoveFields( ++index, tl ); |
608 MoveFields( ++index, tl ); |
565 |
609 |
566 // Set fieldcontainer size again, because |
610 // Set fieldcontainer size again, because |
567 // the amount of fields has changed. |
611 // the amount of fields has changed. |
568 SetSize( MinimumSize() ); |
612 SetSizeWithoutNotification( MinimumSize() ); |
569 |
613 |
570 // Scrollbar and physics require updating. |
614 // Scrollbar and physics require updating. |
571 iObserver->UpdateScrollBarAndPhysics(); |
615 iObserver->UpdateScrollBarAndPhysics(); |
572 } |
616 } |
573 |
617 |
574 DrawDeferred(); |
618 DrawDeferred(); |
575 } |
619 } |
576 |
620 |
577 // --------------------------------------------------------------------------- |
621 // --------------------------------------------------------------------------- |
578 // CMRFieldContainer::HideControl() |
622 // CMRFieldContainer::HideControl() |
594 TBool focused = ( index == iFocusedFieldIndex )? ETrue : EFalse; |
638 TBool focused = ( index == iFocusedFieldIndex )? ETrue : EFalse; |
595 |
639 |
596 TPoint pos( field->Position() ); |
640 TPoint pos( field->Position() ); |
597 MoveFields( index, pos ); |
641 MoveFields( index, pos ); |
598 |
642 |
599 // Set fieldcontainer size again, because |
643 // Set fieldcontainer size again, because |
600 // the amount of fields has changed. |
644 // the amount of fields has changed. |
601 SetSize( MinimumSize() ); |
645 SetSizeWithoutNotification( MinimumSize() ); |
602 |
646 |
603 // Scrollbar and physics require updating. |
647 // Scrollbar and physics require updating. |
604 iObserver->UpdateScrollBarAndPhysics(); |
648 iObserver->UpdateScrollBarAndPhysics(); |
605 |
649 |
606 if ( focused && !field->IsNonFocusing() ) |
650 if ( focused && !field->IsNonFocusing() ) |
607 { |
651 { |
608 // Set focus to next field, or if removed field was the last |
652 // Set focus to next field, or if removed field was the last |
609 // field, then move focus to last visible field |
653 // field, then move focus to last visible field |
610 TInt lastVisibleFieldIndex( LastVisibleField( aFieldId ) ); |
654 TInt lastVisibleFieldIndex( LastVisibleField( aFieldId ) ); |
611 |
655 |
612 // If field was the last one... |
656 // If field was the last one... |
613 if( lastVisibleFieldIndex == index ) |
657 if( lastVisibleFieldIndex == index ) |
614 { |
658 { |
615 // ... Set focus to last visible field. |
659 // ... Set focus to last visible field. |
616 TRAP_IGNORE( DoSetFocusL( lastVisibleFieldIndex ) ) |
660 TRAP_IGNORE( DoSetFocusL( lastVisibleFieldIndex ) ) |
720 { |
764 { |
721 field = iFactory.Field( aInd ); |
765 field = iFactory.Field( aInd ); |
722 } |
766 } |
723 |
767 |
724 ASSERT( field ); |
768 ASSERT( field ); |
725 |
769 |
726 TRect fieldRect( field->Position(), field->Size() ); |
770 TRect fieldRect( field->Position(), field->Size() ); |
727 TRect parentRect( Parent()->Rect() ); |
771 TRect parentRect( Parent()->Rect() ); |
728 |
772 |
729 /* |
773 /* |
730 * Case 1: Field's height is less than the viewable area height, |
774 * Case 1: Field's height is less than the viewable area height, |
731 * let's scroll the whole field visible. |
775 * let's scroll the whole field visible. |
732 */ |
776 */ |
733 if( fieldRect.Height() < parentRect.Height() ) |
777 if( fieldRect.Height() < parentRect.Height() ) |
734 { |
778 { |
735 // Scrolling down, let's move fields up |
779 // Scrolling down, let's move fields up |
736 if( fieldRect.iBr.iY > parentRect.iBr.iY ) |
780 if( fieldRect.iBr.iY > parentRect.iBr.iY ) |
737 { |
781 { |
738 iObserver->ScrollFieldsUp( |
782 iObserver->ScrollFieldsUp( |
739 fieldRect.iBr.iY - parentRect.iBr.iY ); |
783 fieldRect.iBr.iY - parentRect.iBr.iY ); |
740 } |
784 } |
741 // scrolling up, let's move field down |
785 // scrolling up, let's move field down |
742 if( fieldRect.iTl.iY < parentRect.iTl.iY ) |
786 if( fieldRect.iTl.iY < parentRect.iTl.iY ) |
743 { |
787 { |
744 iObserver->ScrollFieldsDown( |
788 iObserver->ScrollFieldsDown( |
745 parentRect.iTl.iY - fieldRect.iTl.iY ); |
789 parentRect.iTl.iY - fieldRect.iTl.iY ); |
746 } |
790 } |
747 } |
791 } |
748 |
792 |
749 /* |
793 /* |
750 * Case 2: Field's height is more than the viewable area's height. |
794 * Case 2: Field's height is more than the viewable area's height. |
751 */ |
795 */ |
752 else |
796 else |
753 { |
797 { |
755 if( field->FieldMode() == EESMRFieldModeView ) |
799 if( field->FieldMode() == EESMRFieldModeView ) |
756 { |
800 { |
757 // Focus to this field is coming from above |
801 // Focus to this field is coming from above |
758 if( field->PreItemIndex() < field->CurrentItemIndex() ) |
802 if( field->PreItemIndex() < field->CurrentItemIndex() ) |
759 { |
803 { |
760 // Let's scroll the top of the field to the |
804 // Let's scroll the top of the field to the |
761 // top of the viewable area |
805 // top of the viewable area |
762 iObserver->ScrollFieldsUp( |
806 iObserver->ScrollFieldsUp( |
763 fieldRect.iTl.iY - parentRect.iTl.iY ); |
807 fieldRect.iTl.iY - parentRect.iTl.iY ); |
764 |
808 |
765 } |
809 } |
766 // Focus to this field is coming from below |
810 // Focus to this field is coming from below |
767 if( field->PreItemIndex() > field->CurrentItemIndex() ) |
811 if( field->PreItemIndex() > field->CurrentItemIndex() ) |
768 { |
812 { |
769 // Let's scroll the bottom of the field to the |
813 // Let's scroll the bottom of the field to the |
770 // bottom of the viewable area |
814 // bottom of the viewable area |
771 iObserver->ScrollFieldsDown( |
815 iObserver->ScrollFieldsDown( |
772 parentRect.iBr.iY - fieldRect.iBr.iY ); |
816 parentRect.iBr.iY - fieldRect.iBr.iY ); |
773 } |
817 } |
774 } |
818 } |
775 |
819 |
776 // Field is in edit mode |
820 // Field is in edit mode |
777 if( field->FieldMode() == EESMRFieldModeEdit ) |
821 if( field->FieldMode() == EESMRFieldModeEdit ) |
778 { |
822 { |
779 TInt viewBottom( parentRect.iBr.iY ); |
823 TInt viewBottom( parentRect.iBr.iY ); |
780 |
824 |
818 |
862 |
819 // Scrollbar and physics update is done here |
863 // Scrollbar and physics update is done here |
820 iObserver->ScrollFieldsDown( px ); |
864 iObserver->ScrollFieldsDown( px ); |
821 } |
865 } |
822 } |
866 } |
823 } |
867 } |
824 } |
868 } |
825 } |
869 } |
826 |
870 |
827 // --------------------------------------------------------------------------- |
871 // --------------------------------------------------------------------------- |
828 // CMRFieldContainer::RePositionFields |
872 // CMRFieldContainer::RePositionFields |
829 // --------------------------------------------------------------------------- |
873 // --------------------------------------------------------------------------- |
830 // |
874 // |
831 void CMRFieldContainer::RePositionFields( TInt aAmount ) |
875 void CMRFieldContainer::RePositionFields( TInt aAmount ) |
832 { |
876 { |
833 FUNC_LOG; |
877 FUNC_LOG; |
834 |
878 |
835 // Movement downwards |
879 // Movement downwards |
836 if( aAmount >= 0 ) |
880 if( aAmount >= 0 ) |
837 { |
881 { |
838 // Also scrollbar and physics update is done here |
882 // Also scrollbar and physics update is done here |
839 iObserver->ScrollFieldsDown( aAmount ); |
883 iObserver->ScrollFieldsDown( aAmount ); |
862 // |
906 // |
863 void CMRFieldContainer::MoveFields( TInt aIndex, TPoint& aTl ) |
907 void CMRFieldContainer::MoveFields( TInt aIndex, TPoint& aTl ) |
864 { |
908 { |
865 FUNC_LOG; |
909 FUNC_LOG; |
866 /* |
910 /* |
867 * Moves fields from the given index towards the last item. |
911 * Moves fields from the given index towards the last item. |
868 * This function does not update scrollbar or physics. |
912 * This function does not update scrollbar or physics. |
869 */ |
913 */ |
870 |
914 |
871 const TInt count( iFactory.Count() ); |
915 const TInt count( iFactory.Count() ); |
872 |
916 |
873 for ( TInt i = aIndex; i < count; ++i ) |
917 for ( TInt i = aIndex; i < count; ++i ) |
874 { |
918 { |
875 CESMRField* field = iFactory.Field( i ); |
919 CESMRField* field = iFactory.Field( i ); |
876 |
920 |
877 if ( field->IsVisible() ) |
921 if ( field->IsVisible() ) |
878 { |
922 { |
879 field->SetPosition( aTl ); |
923 field->SetPosition( aTl ); |
880 |
924 |
881 aTl.iY += field->Size().iHeight; |
925 aTl.iY += field->Size().iHeight; |
882 } |
926 } |
883 } |
927 } |
884 } |
928 } |
885 |
929 |
892 FUNC_LOG; |
936 FUNC_LOG; |
893 /* |
937 /* |
894 * Layouts given field according to the size required by the field and |
938 * Layouts given field according to the size required by the field and |
895 * given TPoint. This function does not update scrollbar or physics. |
939 * given TPoint. This function does not update scrollbar or physics. |
896 */ |
940 */ |
897 |
941 |
898 TSize size( aField.MinimumSize() ); |
942 TSize size( aField.MinimumSize() ); |
899 aField.SetPosition( aTl ); |
943 aField.SetExtent( aTl, size ); |
900 aField.SetSize( size ); |
|
901 } |
944 } |
902 |
945 |
903 // --------------------------------------------------------------------------- |
946 // --------------------------------------------------------------------------- |
904 // CMRFieldContainer::IsLastVisibleField |
947 // CMRFieldContainer::IsLastVisibleField |
905 // --------------------------------------------------------------------------- |
948 // --------------------------------------------------------------------------- |
906 // |
949 // |
907 TInt CMRFieldContainer::LastVisibleField( |
950 TInt CMRFieldContainer::LastVisibleField( |
908 TESMREntryFieldId aFieldId ) |
951 TESMREntryFieldId aFieldId ) |
909 { |
952 { |
910 /* |
953 /* |
911 * Helper function to find out the last visible field in the list. |
954 * Helper function to find out the last visible field in the list. |
912 */ |
955 */ |
913 |
956 |
914 TInt lastVisibleFieldIndex( 0 ); |
957 TInt lastVisibleFieldIndex( 0 ); |
915 TInt count( iFactory.Count() ); |
958 TInt count( iFactory.Count() ); |
916 |
959 |
917 // Go through fields from last field towards the first field |
960 // Go through fields from last field towards the first field |
918 for( TInt i( 1 ); i > count; ++i ) |
961 for( TInt i( 1 ); i > count; ++i ) |
919 { |
962 { |
920 // Once last visible field is found... |
963 // Once last visible field is found... |
921 if( iFactory.Field( count - i )->IsVisible() ) |
964 if( iFactory.Field( count - i )->IsVisible() ) |
922 { |
965 { |
923 // ... Compare it to the given field index ... |
966 // ... Compare it to the given field index ... |
924 if( iFactory.Field( count - i )->FieldId() == aFieldId ) |
967 if( iFactory.Field( count - i )->FieldId() == aFieldId ) |
925 { |
968 { |
926 // ... And if match is found, given fieldId is the |
969 // ... And if match is found, given fieldId is the |
927 // the last visible field. |
970 // the last visible field. |
928 lastVisibleFieldIndex = |
971 lastVisibleFieldIndex = |
929 IndexByFieldId( iFactory, aFieldId ); |
972 IndexByFieldId( iFactory, aFieldId ); |
930 } |
973 } |
931 else |
974 else |
932 { |
975 { |
933 // Otherwise return the found last visible field. |
976 // Otherwise return the found last visible field. |
934 lastVisibleFieldIndex = |
977 lastVisibleFieldIndex = |
935 IndexByFieldId( iFactory, |
978 IndexByFieldId( iFactory, |
936 iFactory.Field( count - i )->FieldId() ); |
979 iFactory.Field( count - i )->FieldId() ); |
937 } |
980 } |
938 break; |
981 break; |
939 } |
982 } |
940 } |
983 } |
941 |
984 |
942 return lastVisibleFieldIndex; |
985 return lastVisibleFieldIndex; |
943 } |
986 } |
944 |
987 |
945 // --------------------------------------------------------------------------- |
988 // --------------------------------------------------------------------------- |
946 // CMRFieldContainer::DoSetFocusL |
989 // CMRFieldContainer::DoSetFocusL |
950 { |
993 { |
951 FUNC_LOG; |
994 FUNC_LOG; |
952 /* |
995 /* |
953 * Sets the focus according to the given index. |
996 * Sets the focus according to the given index. |
954 */ |
997 */ |
955 |
998 |
956 TInt count( iFactory.Count() ); |
999 TInt count( iFactory.Count() ); |
957 aNewFocusIndex = Max( 0, Min( aNewFocusIndex, count - 1 ) ); |
1000 aNewFocusIndex = Max( 0, Min( aNewFocusIndex, count - 1 ) ); |
958 |
1001 |
959 if ( aNewFocusIndex != iFocusedFieldIndex ) |
1002 if ( aNewFocusIndex != iFocusedFieldIndex ) |
960 { |
1003 { |
961 // Get current focused field |
1004 // Get current focused field |
962 CESMRField* old = iFactory.Field( iFocusedFieldIndex ); |
1005 CESMRField* old = iFactory.Field( iFocusedFieldIndex ); |
963 |
1006 |
964 // Get next focused field |
1007 // Get next focused field |
965 CESMRField* field = iFactory.Field( aNewFocusIndex ); |
1008 CESMRField* field = iFactory.Field( aNewFocusIndex ); |
966 |
1009 |
967 // Do sanity checks |
1010 // Do sanity checks |
968 while ( aNewFocusIndex < count && !field->IsVisible() ) |
1011 while ( aNewFocusIndex < count && !field->IsVisible() ) |
969 { |
1012 { |
970 field = iFactory.Field( aNewFocusIndex++ ); |
1013 field = iFactory.Field( aNewFocusIndex++ ); |
971 } |
1014 } |
978 field = iFactory.Field( aNewFocusIndex-- ); |
1021 field = iFactory.Field( aNewFocusIndex-- ); |
979 } |
1022 } |
980 } |
1023 } |
981 |
1024 |
982 ASSERT( field->IsVisible() ); |
1025 ASSERT( field->IsVisible() ); |
983 |
1026 |
984 // Update current and previous item indexes |
1027 // Update current and previous item indexes |
985 field->SetPreItemIndex( iFocusedFieldIndex ); |
1028 field->SetPreItemIndex( iFocusedFieldIndex ); |
986 iFocusedFieldIndex = aNewFocusIndex; |
1029 iFocusedFieldIndex = aNewFocusIndex; |
987 field->SetCurrentItemIndex( iFocusedFieldIndex ); |
1030 field->SetCurrentItemIndex( iFocusedFieldIndex ); |
988 |
1031 |
989 // Remove focus from old |
1032 // Remove focus from old |
990 old->SetOutlineFocusL( EFalse ); |
1033 old->SetOutlineFocusL( EFalse ); |
991 old->SetFocus( EFalse ); |
1034 old->SetFocus( EFalse ); |
992 |
1035 old->MoveToScreen( EFalse ); |
|
1036 |
993 // update focus index to new index |
1037 // update focus index to new index |
994 field->SetOutlineFocusL( ETrue ); |
1038 field->SetOutlineFocusL( ETrue ); |
995 field->SetFocus( ETrue ); |
1039 field->SetFocus( ETrue ); |
996 |
1040 field->MoveToScreen( ETrue ); |
|
1041 |
997 // This handles also scrollbar and physics updating, |
1042 // This handles also scrollbar and physics updating, |
998 // if view scrolling is done. |
1043 // if view scrolling is done. |
999 ScrollControlVisible( iFocusedFieldIndex ); |
1044 ScrollControlVisible( iFocusedFieldIndex ); |
1000 |
1045 |
1001 DrawDeferred(); |
1046 DrawDeferred(); |
1002 } |
1047 } |
1003 } |
1048 } |
1004 |
1049 |
1005 |
1050 |
|
1051 // --------------------------------------------------------------------------- |
|
1052 // CMRFieldContainer::SetScrolling |
|
1053 // --------------------------------------------------------------------------- |
|
1054 // |
|
1055 void CMRFieldContainer::SetScrolling( TBool aScrolling ) |
|
1056 { |
|
1057 FUNC_LOG; |
|
1058 |
|
1059 iScrolling = aScrolling; |
|
1060 |
|
1061 // Move focused field away from screen if container is scrolling. |
|
1062 // Otherwise move it to screen. |
|
1063 CESMRField* field = iFactory.Field( iFocusedFieldIndex ); |
|
1064 field->MoveToScreen( !iScrolling ); |
|
1065 } |
|
1066 |
|
1067 |
|
1068 // --------------------------------------------------------------------------- |
|
1069 // CMRFieldContainer::Draw |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // |
|
1072 void CMRFieldContainer::Draw( const TRect& aRect ) const |
|
1073 { |
|
1074 FUNC_LOG; |
|
1075 |
|
1076 // Get visible screen area from parent (list pane) |
|
1077 TRect parent( Parent()->Rect() ); |
|
1078 |
|
1079 // Current container position used to calculate actual field positions |
|
1080 TPoint tl( iPosition ); |
|
1081 |
|
1082 // Field index to skip |
|
1083 TInt fieldToSkip = KErrNotFound; |
|
1084 |
|
1085 if ( !iScrolling ) |
|
1086 { |
|
1087 // Container is not scrolling. Don't draw focused field from buffer |
|
1088 fieldToSkip = iFocusedFieldIndex; |
|
1089 } |
|
1090 |
|
1091 // Draw all visible fields which are not on screen |
|
1092 TInt count( iFactory.Count() ); |
|
1093 |
|
1094 for ( TInt i = 0; i < count; ++i ) |
|
1095 { |
|
1096 CESMRField* field = iFactory.Field( i ); |
|
1097 if ( field->IsVisible() ) |
|
1098 { |
|
1099 // Calculate actual field rect on screen |
|
1100 TRect screenRect( tl, field->Size() ); |
|
1101 |
|
1102 // Draw field if it intersects with screen visible area |
|
1103 if ( i != fieldToSkip |
|
1104 && screenRect.Intersects( parent ) ) |
|
1105 { |
|
1106 field->Draw( screenRect ); |
|
1107 } |
|
1108 // Move next field top left corner |
|
1109 tl.iY += screenRect.Height(); |
|
1110 } |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 // --------------------------------------------------------------------------- |
|
1115 // CMRFieldContainer::ScrollContainer |
|
1116 // --------------------------------------------------------------------------- |
|
1117 // |
|
1118 void CMRFieldContainer::ScrollContainer( const TPoint& aTl ) |
|
1119 { |
|
1120 FUNC_LOG; |
|
1121 |
|
1122 // Set scrolling flag and move focused field off screen |
|
1123 SetScrolling( ETrue ); |
|
1124 // Update control position, |
|
1125 // but dont propagate the change to component controls |
|
1126 iPosition = aTl; |
|
1127 } |
|
1128 |
|
1129 // --------------------------------------------------------------------------- |
|
1130 // CMRFieldContainer::Synchronize |
|
1131 // --------------------------------------------------------------------------- |
|
1132 // |
|
1133 void CMRFieldContainer::Synchronize() |
|
1134 { |
|
1135 FUNC_LOG; |
|
1136 |
|
1137 // Set actual control positions (y-coordinate) to visible fields |
|
1138 TPoint tl( iPosition ); |
|
1139 |
|
1140 TInt count( iFactory.Count() ); |
|
1141 |
|
1142 for ( TInt i = 0; i < count; ++i ) |
|
1143 { |
|
1144 CESMRField* field = iFactory.Field( i ); |
|
1145 if ( field->IsVisible() ) |
|
1146 { |
|
1147 TPoint pos( field->Position().iX, tl.iY ); |
|
1148 tl.iY += field->Size().iHeight; |
|
1149 field->SetPosition( pos ); |
|
1150 } |
|
1151 } |
|
1152 SetScrolling( EFalse ); |
|
1153 } |
|
1154 |
1006 // End of file |
1155 // End of file |