meetingrequest/mrgui/src/cmrlistpane.cpp
branchRCL_3
changeset 22 d620048b4810
parent 18 6b8f3b30d0ec
equal deleted inserted replaced
20:efd4f1afd43e 22:d620048b4810
   153 // ---------------------------------------------------------------------------
   153 // ---------------------------------------------------------------------------
   154 //
   154 //
   155 void CMRListPane::InternalizeL( MESMRCalEntry& aEntry )
   155 void CMRListPane::InternalizeL( MESMRCalEntry& aEntry )
   156     {
   156     {
   157     FUNC_LOG;
   157     FUNC_LOG;
       
   158 
   158     iFactory.InternalizeL( aEntry );
   159     iFactory.InternalizeL( aEntry );
       
   160 
       
   161     // Record visible fields
       
   162     RecordFields();
   159 
   163 
   160     // This is called to make sure everything is drawn correctly
   164     // This is called to make sure everything is drawn correctly
   161     DrawDeferred();
   165     DrawDeferred();
   162     }
   166     }
   163 
   167 
   366     FUNC_LOG;
   370     FUNC_LOG;
   367     iLongTapEventInProgess = EFalse;
   371     iLongTapEventInProgess = EFalse;
   368     // Long tap functionality may vary between fields
   372     // Long tap functionality may vary between fields
   369     // ==> Command field to execute action related to long tap
   373     // ==> Command field to execute action related to long tap
   370     TInt count( iFactory.Count() );
   374     TInt count( iFactory.Count() );
   371 
       
   372     for ( TInt i = 0; i < count; ++i )
   375     for ( TInt i = 0; i < count; ++i )
   373         {
   376         {
   374         CESMRField* field = iFactory.Field( i );
   377         CESMRField* field = iFactory.Field( i );
   375 
   378 
   376         if ( field->IsVisible()
   379         if ( field->IsVisible()
   458 // ---------------------------------------------------------------------------
   461 // ---------------------------------------------------------------------------
   459 //
   462 //
   460 void CMRListPane::ScrollFieldsUp( TInt aPx )
   463 void CMRListPane::ScrollFieldsUp( TInt aPx )
   461     {
   464     {
   462     FUNC_LOG;
   465     FUNC_LOG;
   463     TPoint point = iFieldContainer->Position();
   466     iPositionChanged = ETrue;
   464     point.iY -= aPx;
   467 
   465 
   468     iUpdatedPanePoint = iFieldContainer->Position();
   466     // This initializes Draw also
   469     iUpdatedPanePoint.iY -= aPx;
   467     iFieldContainer->SetPosition( point );
   470 
   468 
   471     if ( !iPointerEventInProgress )
   469     // Non-kinetic scrolling executed. Update
   472         {
   470     // new position to physics.
   473         // We can updace view only if pointer event processing
   471     iPhysics->UpdateVerticalScrollIndex( UpdatedFocusPosition() );
   474         // is not ongoing.
   472 
   475         // If pointer event processing is ongoing, view is updated
   473     DoUpdateScrollBar( UpdatedFocusPosition() );
   476         // in CMRListPane::HandlePointerEventL method.
       
   477         UpdatePosition();
       
   478         }
   474     }
   479     }
   475 
   480 
   476 // ---------------------------------------------------------------------------
   481 // ---------------------------------------------------------------------------
   477 // CMRListPane::ScrollFieldsDown
   482 // CMRListPane::ScrollFieldsDown
   478 // ---------------------------------------------------------------------------
   483 // ---------------------------------------------------------------------------
   479 //
   484 //
   480 void CMRListPane::ScrollFieldsDown( TInt aPx )
   485 void CMRListPane::ScrollFieldsDown( TInt aPx )
   481     {
   486     {
   482     FUNC_LOG;
   487     FUNC_LOG;
   483     TPoint point = iFieldContainer->Position();
   488 
   484     point.iY += aPx;
   489     iPositionChanged = ETrue;
   485 
   490 
   486     // This initializes Draw also
   491     iUpdatedPanePoint = iFieldContainer->Position();
   487     iFieldContainer->SetPosition( point );
   492     iUpdatedPanePoint.iY += aPx;
   488     // Non-kinetic scrolling executed. Update
   493 
   489     // new position to physics.
   494     if ( !iPointerEventInProgress )
   490     iPhysics->UpdateVerticalScrollIndex( UpdatedFocusPosition() );
   495         {
   491 
   496         // We can updace view only if pointer event processing
   492     DoUpdateScrollBar( UpdatedFocusPosition() );
   497         // is not ongoing.
       
   498         // If pointer event processing is ongoing, view is updated
       
   499         // in CMRListPane::HandlePointerEventL method.
       
   500         UpdatePosition();
       
   501         }
   493     }
   502     }
   494 
   503 
   495 
   504 
   496 // ---------------------------------------------------------------------------
   505 // ---------------------------------------------------------------------------
   497 // CMRListPane::UpdateScrollBarAndPhysics
   506 // CMRListPane::UpdateScrollBarAndPhysics
   498 // ---------------------------------------------------------------------------
   507 // ---------------------------------------------------------------------------
   499 //
   508 //
   500 void CMRListPane::UpdateScrollBarAndPhysics()
   509 void CMRListPane::UpdateScrollBarAndPhysics()
   501     {
   510     {
       
   511     FUNC_LOG;
   502     // Update physics world size
   512     // Update physics world size
   503     iPhysics->InitPhysics();
   513     iPhysics->InitPhysics();
   504 
   514 
   505     // Update scrollbar
   515     // Update scrollbar
   506     DoUpdateScrollBar();
   516     DoUpdateScrollBar();
   511 // CMRListPane::ShowControl
   521 // CMRListPane::ShowControl
   512 // ---------------------------------------------------------------------------
   522 // ---------------------------------------------------------------------------
   513 //
   523 //
   514 void CMRListPane::ShowControl( TESMREntryFieldId aFieldId )
   524 void CMRListPane::ShowControl( TESMREntryFieldId aFieldId )
   515     {
   525     {
       
   526     FUNC_LOG;
   516     iFieldContainer->ShowControl( aFieldId );
   527     iFieldContainer->ShowControl( aFieldId );
   517     }
   528     }
   518 
   529 
   519 // ---------------------------------------------------------------------------
   530 // ---------------------------------------------------------------------------
   520 // CMRListPane::ShowControl
   531 // CMRListPane::ShowControl
   521 // ---------------------------------------------------------------------------
   532 // ---------------------------------------------------------------------------
   522 //
   533 //
   523 TBool CMRListPane::IsControlVisible( TESMREntryFieldId aFieldId )
   534 TBool CMRListPane::IsControlVisible( TESMREntryFieldId aFieldId )
   524     {
   535     {
       
   536     FUNC_LOG;
   525     return iFieldContainer->IsControlVisible( aFieldId );
   537     return iFieldContainer->IsControlVisible( aFieldId );
   526     }
   538     }
   527 // ---------------------------------------------------------------------------
   539 // ---------------------------------------------------------------------------
   528 // CMRListPane::GetResponseFieldsFieldId
   540 // CMRListPane::GetResponseFieldsFieldId
   529 // ---------------------------------------------------------------------------
   541 // ---------------------------------------------------------------------------
   530 //
   542 //
   531 TESMREntryFieldId CMRListPane::GetResponseFieldsFieldId()
   543 TESMREntryFieldId CMRListPane::GetResponseFieldsFieldId()
   532     {
   544     {
       
   545     FUNC_LOG;
   533     CESMRField* rfield = iFactory.FieldById( EESMRFieldResponseArea );
   546     CESMRField* rfield = iFactory.FieldById( EESMRFieldResponseArea );
   534 
   547 
   535     if ( rfield && rfield->IsVisible() && !rfield->IsNonFocusing() )
   548     if ( rfield && rfield->IsVisible() && !rfield->IsNonFocusing() )
   536         {
   549         {
   537         return EESMRFieldResponseArea;
   550         return EESMRFieldResponseArea;
   575             }
   588             }
   576         }
   589         }
   577     }
   590     }
   578 
   591 
   579 // ---------------------------------------------------------------------------
   592 // ---------------------------------------------------------------------------
       
   593 // CMRListPane::RecordFields
       
   594 // ---------------------------------------------------------------------------
       
   595 //
       
   596 void CMRListPane::RecordFields()
       
   597     {
       
   598     FUNC_LOG;
       
   599 
       
   600     // Loop all visible fields and record them
       
   601     TInt count( iFactory.Count() );
       
   602     for ( TInt i = 0; i < count; ++i )
       
   603         {
       
   604         CESMRField* field = iFactory.Field( i );
       
   605         if ( field->IsVisible() )
       
   606             {
       
   607             field->RecordField();
       
   608             }
       
   609         }
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------------------------
   580 // CMRListPane::HandlePointerEventL
   613 // CMRListPane::HandlePointerEventL
   581 // ---------------------------------------------------------------------------
   614 // ---------------------------------------------------------------------------
   582 //
   615 //
   583 void CMRListPane::HandlePointerEventL( const TPointerEvent &aPointerEvent )
   616 void CMRListPane::HandlePointerEventL( const TPointerEvent &aPointerEvent )
   584     {
   617     {
   585     // Check if touch is enabled or not
   618     // Check if touch is enabled or not
   586     if( !AknLayoutUtils::PenEnabled() )
   619     if( !AknLayoutUtils::PenEnabled() )
   587         {
   620         {
   588         return;
   621         return;
   589         }
   622         }
       
   623 
       
   624     iPointerEventInProgress = ETrue;
   590 
   625 
   591     // If new down event is received, and
   626     // If new down event is received, and
   592     // iLongTapEventInProgess flag is still ETrue, we need to
   627     // iLongTapEventInProgess flag is still ETrue, we need to
   593     // set it back to EFalse -> Long tap event cannot be in progress
   628     // set it back to EFalse -> Long tap event cannot be in progress
   594     // in this case anymore.
   629     // in this case anymore.
   608         	{
   643         	{
   609 			iLongtapDetector->Cancel();
   644 			iLongtapDetector->Cancel();
   610         	}
   645         	}
   611         }
   646         }
   612 
   647 
   613     if( !iPhysicsActionOngoing )
   648     if( !iPhysicsActionOngoing && TPointerEvent::EDrag != aPointerEvent.iType )
   614     	{
   649     	{
   615 		UpdateClickedField( aPointerEvent );
   650 		UpdateClickedField( aPointerEvent );
   616 
   651 
   617 		// Offer pointer event to long tap detector if field supports long tap
   652 		// Offer pointer event to long tap detector if field supports long tap
   618 		// functionality
   653 		// functionality
   633         else if( aPointerEvent.iType == TPointerEvent::EButton1Up )
   668         else if( aPointerEvent.iType == TPointerEvent::EButton1Up )
   634             {
   669             {
   635 			iLongTapEventInProgess = EFalse;
   670 			iLongTapEventInProgess = EFalse;
   636             }
   671             }
   637     	}
   672     	}
       
   673 
       
   674     if ( iPositionChanged )
       
   675         {
       
   676         // Position has changed during pointer event processing
       
   677         // ==> adjusting UI to correct position.
       
   678         UpdatePosition();
       
   679         }
       
   680 
       
   681     iPointerEventInProgress = EFalse;
   638     }
   682     }
   639 
   683 
   640 // ---------------------------------------------------------------------------
   684 // ---------------------------------------------------------------------------
   641 // CMRListPane::ActivateL
   685 // CMRListPane::ActivateL
   642 // ---------------------------------------------------------------------------
   686 // ---------------------------------------------------------------------------
   687 	iScroll.DrawDeferred();
   731 	iScroll.DrawDeferred();
   688 
   732 
   689 	if( FeedbackScrollMarginExceeded(
   733 	if( FeedbackScrollMarginExceeded(
   690 			Abs( verticalScrollIndex - iPreviousVerticalScrollIndex ) ) )
   734 			Abs( verticalScrollIndex - iPreviousVerticalScrollIndex ) ) )
   691 		{
   735 		{
   692 		HandleTactileFeedback( ETouchFeedbackSlider );
   736 		HandleTactileFeedback( ETouchFeedbackSensitiveList );
   693 
   737 
   694 		iPreviousVerticalScrollIndex = verticalScrollIndex;
   738 		iPreviousVerticalScrollIndex = verticalScrollIndex;
   695 		}
   739 		}
   696     }
   740     }
   697 
   741 
   729     	{
   773     	{
   730 		TInt count( iFactory.Count() );
   774 		TInt count( iFactory.Count() );
   731 		for( TInt i = 0; i < count; ++i )
   775 		for( TInt i = 0; i < count; ++i )
   732 			{
   776 			{
   733 			CESMRField* field = iFactory.Field( i );
   777 			CESMRField* field = iFactory.Field( i );
   734 			if ( field->IsVisible() &&
   778 
   735 					field->Rect().Contains( aPointerEvent.iPosition ) )
   779             // Calculate actual screen rect for field.
       
   780             // If field does not have focus, it is layouted off screen
       
   781             TPoint pos( field->Position() );
       
   782             if ( !field->HasOutlineFocus() )
       
   783                 {
       
   784                 pos.iX = field->Parent()->Position().iX;
       
   785                 }
       
   786             TRect rect( pos, field->Size() );
       
   787 
       
   788             if ( field->IsVisible()
       
   789                  && rect.Contains( aPointerEvent.iPosition ) )
   736 				{
   790 				{
   737 				CESMRField* focusedField = iFieldContainer->FocusedField();
   791 				CESMRField* focusedField = iFieldContainer->FocusedField();
   738 
   792 
   739 				if ( field != focusedField )
   793 				if ( field != focusedField )
   740 					{
   794 					{
   744 					if ( canLoseFocus )
   798 					if ( canLoseFocus )
   745 						{
   799 						{
   746 						iFieldContainer->SetControlFocusedL( field->FieldId() );
   800 						iFieldContainer->SetControlFocusedL( field->FieldId() );
   747 						}
   801 						}
   748 					}
   802 					}
   749 
   803                 else
       
   804                     {
       
   805                     // If field is not focused from coecontrol's point of view
       
   806                     // due to focus strategy, we have to set the field
       
   807                     // focused again.
       
   808                     if( !field->IsFocused() )
       
   809                         {
       
   810                         field->SetOutlineFocusL( ETrue );
       
   811                         field->SetFocus( ETrue );
       
   812                         DrawDeferred();
       
   813                         }
       
   814                     }
   750 				break;
   815 				break;
   751 				}
   816 				}
   752 			}
   817 			}
   753     	}
   818     	}
   754     }
   819     }
   762     FUNC_LOG;
   827     FUNC_LOG;
   763     TInt fieldCount( iFactory.Count() );
   828     TInt fieldCount( iFactory.Count() );
   764 
   829 
   765     for( TInt i = 0; i < fieldCount; ++i )
   830     for( TInt i = 0; i < fieldCount; ++i )
   766         {
   831         {
   767         if( iFactory.Field( i )->Rect().Contains(
   832         CESMRField* field = iFactory.Field( i );
   768                 aPointerEvent.iPosition ) )
   833 
       
   834         // Calculate actual screen rect for field.
       
   835         // If field does not have focus, it is layouted off screen
       
   836         TPoint pos( field->Position() );
       
   837         if ( !field->HasOutlineFocus() )
       
   838             {
       
   839             pos.iX = field->Parent()->Position().iX;
       
   840             }
       
   841         TRect rect( pos, field->Size() );
       
   842 
       
   843         if( rect.Contains( aPointerEvent.iPosition )
       
   844             && field->IsVisible() )
   769             {
   845             {
   770             if( aPointerEvent.iType == TPointerEvent::EButton1Down )
   846             if( aPointerEvent.iType == TPointerEvent::EButton1Down )
   771                 {
   847                 {
   772                 iClickedField = iFactory.Field( i );
   848                 iClickedField = field;
   773                 }
   849                 }
   774             }
   850             }
   775         }
   851         }
   776     }
   852     }
   777 
   853 
   838 		}
   914 		}
   839 
   915 
   840     return ret;
   916     return ret;
   841     }
   917     }
   842 
   918 
       
   919 // ---------------------------------------------------------------------------
       
   920 // CMRListPane::UpdatePosition
       
   921 // ---------------------------------------------------------------------------
       
   922 //
       
   923 void CMRListPane::UpdatePosition()
       
   924     {
       
   925     // This initializes Draw also
       
   926     iFieldContainer->SetPosition( iUpdatedPanePoint );
       
   927 
       
   928     // Non-kinetic scrolling executed. Update
       
   929     // new position to physics.
       
   930     iPhysics->UpdateVerticalScrollIndex( UpdatedFocusPosition() );
       
   931     DoUpdateScrollBar( UpdatedFocusPosition() );
       
   932 
       
   933     iPositionChanged = EFalse;
       
   934     }
       
   935 
   843 // End of file
   936 // End of file