uifw/EikStd/dlgsrc/EIKCAPC.CPP
branchRCL_3
changeset 23 3d340a0166ff
parent 10 9f56a4e1b8ab
child 29 a8834a2e9a96
equal deleted inserted replaced
18:0aa5fbdfbc30 23:3d340a0166ff
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   281 /**
   281 /**
   282 * 
   282 * 
   283 * Extension class for additional data members.
   283 * Extension class for additional data members.
   284 *
   284 *
   285 */
   285 */
   286 NONSHARABLE_CLASS( CEikCapCExtension ): public MEikFormAnimObserver
   286 NONSHARABLE_CLASS( CEikCapCExtension ) : public CBase,
       
   287                                          public MEikFormAnimObserver
   287     {
   288     {
   288     friend class CEikCaptionedControl ;
   289     friend class CEikCaptionedControl ;
   289 
   290 
   290 private:
   291 private:
   291     CEikCapCExtension();
   292     CEikCapCExtension();
   377     iSelf( NULL ), 
   378     iSelf( NULL ), 
   378     iEditModeHighlightControlContext ( NULL ) ,
   379     iEditModeHighlightControlContext ( NULL ) ,
   379     iViewModeHighlightControlContext ( NULL ) ,
   380     iViewModeHighlightControlContext ( NULL ) ,
   380     iEditModeHighlightControlContextPressed( NULL ),
   381     iEditModeHighlightControlContextPressed( NULL ),
   381     iViewModeHighlightControlContextPressed( NULL ),
   382     iViewModeHighlightControlContextPressed( NULL ),
   382     iPreviousRect( TPoint(0, 0), TSize(0, 0) ) ,
   383     iPreviousRect( 0, 0, 0, 0 ),
   383     iPreviousState( EFalse ) ,
   384     iPreviousState( EFalse ) ,
   384     iPressDownEffect( EFalse ),
   385     iPressDownEffect( EFalse ),
   385     iXOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   386     iXOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   386     iYOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   387     iYOffsetForDataPaneInEditMode( ELayoutEmpty ) ,
   387     iDrawNoWhiteBackground( EFalse ),
   388     iDrawNoWhiteBackground( EFalse ),
   388     iAnimation( NULL )
   389     iAnimation( NULL )
   389 	, iIndicator(NULL),
   390 	, iIndicator(NULL),
   390 	iIndicator2(NULL),
   391 	iIndicator2(NULL),
   391 	iObserver(NULL),
   392 	iObserver(NULL),
       
   393 	iSimulatedDownEvent( EFalse ),
   392     iFeedback( MTouchFeedback::Instance() ),
   394     iFeedback( MTouchFeedback::Instance() ),
   393 	iIdle(NULL),
   395 	iIdle(NULL),
   394 	iIdleData(NULL),
   396 	iIdleData(NULL),
   395     iPartiallyVisible( EFalse )
   397     iPartiallyVisible( EFalse )
   396     {
   398     {
   398     if ( iAvkonAppUi )
   400     if ( iAvkonAppUi )
   399         {
   401         {
   400         iUsesSingleClick = iAvkonAppUi->IsSingleClickCompatible();
   402         iUsesSingleClick = iAvkonAppUi->IsSingleClickCompatible();
   401         }
   403         }
   402     _AKNTRACE_FUNC_EXIT;
   404     _AKNTRACE_FUNC_EXIT;
   403     };
   405     }
   404 
   406 
   405 CEikCapCExtension::~CEikCapCExtension()
   407 CEikCapCExtension::~CEikCapCExtension()
   406     {
   408     {
   407     _AKNTRACE_FUNC_ENTER;
   409     _AKNTRACE_FUNC_ENTER;
   408     // Remember to unacquire animation
   410     // Remember to unacquire animation
   486     // Extend form item touch area to whole item area
   488     // Extend form item touch area to whole item area
   487     if ( iSelf->iIsEditable
   489     if ( iSelf->iIsEditable
   488          && ( aPointerEvent.iType == TPointerEvent::EButton1Down 
   490          && ( aPointerEvent.iType == TPointerEvent::EButton1Down 
   489             || aPointerEvent.iType == TPointerEvent::EButton1Up ) )
   491             || aPointerEvent.iType == TPointerEvent::EButton1Up ) )
   490         {
   492         {
   491 
       
   492         // Check control type
   493         // Check control type
   493         TBool edwinControl( LaunchInputType() );
   494         TBool edwinControl( LaunchInputType() );
   494         TBool simulate = EFalse;
   495         TBool simulate = EFalse;
   495         if ( aPointerEvent.iType == TPointerEvent::EButton1Down
   496 
   496                 && iSelf->Rect().Contains( aPointerEvent.iPosition )
   497         if ( iSelf->Rect().Contains( aPointerEvent.iPosition ) )
   497                 && !iSelf->iControl->Rect().Contains(
   498             {
   498                         aPointerEvent.iPosition ) )
   499             if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
   499             {
   500                  !iSelf->iControl->Rect().Contains( aPointerEvent.iPosition ) )
   500             iSimulatedDownEvent = ETrue;
   501                 {
   501             if ( !edwinControl )
   502                 iSimulatedDownEvent = ETrue;
   502                 {
       
   503                 simulate = ETrue;
   503                 simulate = ETrue;
   504                 }
   504                 }
   505             }
   505             else if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
   506         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up
   506                       iSimulatedDownEvent )
   507                 && iSimulatedDownEvent )
   507                 {
   508             {
   508                 simulate = ETrue;
   509             simulate = ETrue;
   509                 }
   510             }
   510             }
   511 
   511 
   512         // Simulate pointer event to control
   512         // Simulate pointer event to control
   513         if ( simulate && !edwinControl )
   513         if ( simulate && !edwinControl )
   514             {
   514             {
   517                 iSelf->iControl->Rect().iTl + TPoint( 1, 1 );
   517                 iSelf->iControl->Rect().iTl + TPoint( 1, 1 );
   518             iSelf->iControl->HandlePointerEventL( controlEvent );
   518             iSelf->iControl->HandlePointerEventL( controlEvent );
   519             }
   519             }
   520 
   520 
   521         // With edwin do action directly (due to cursor problems)
   521         // With edwin do action directly (due to cursor problems)
   522         else if ( edwinControl && simulate
   522         else if ( edwinControl &&
   523                 && aPointerEvent.iType == TPointerEvent::EButton1Up )
   523                   simulate &&
   524             {
   524                   ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   525             CAknExtendedInputCapabilities* input( NULL );
   525                     aPointerEvent.iType == TPointerEvent::EButton1Down ) )
   526             iSelf->iControl->InputCapabilities().ObjectProvider(
   526             {
   527                     )->MopGetObjectNoChaining( input );
   527             // Basic list feedback is given instead of sensitive edit
   528             if ( input )
   528             // feedback when tapping editor fields in forms.
   529                 {
   529             if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   530                 iFeedback->InstantFeedback(
   530                 {
   531                         iSelf->iControl,  ETouchFeedbackEdit,
   531                 iFeedback->InstantFeedback( iSelf->iControl,
   532                         ETouchFeedbackVibra, aPointerEvent );
   532                                             ETouchFeedbackList );
   533                 input->ReportEventL(
   533                 }
       
   534             else
       
   535                 {
       
   536                 iFeedback->InstantFeedback( iSelf->iControl,
       
   537                                             ETouchFeedbackList,
       
   538                                             ETouchFeedbackVibra,
       
   539                                             aPointerEvent );
       
   540                 
       
   541                 CAknExtendedInputCapabilities* input( NULL );
       
   542                 iSelf->iControl->InputCapabilities().ObjectProvider(
       
   543                         )->MopGetObjectNoChaining( input );
       
   544                 
       
   545                 if ( input )
       
   546                     {
       
   547                     input->ReportEventL(
   534                         CAknExtendedInputCapabilities::\
   548                         CAknExtendedInputCapabilities::\
   535                         MAknEventObserver::EActivatePenInputRequest,
   549                             MAknEventObserver::EActivatePenInputRequest,
   536                         NULL );
   550                         NULL );
   537                 }
   551                     }
   538             }
   552                 }
       
   553             }
       
   554 
   539         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   555         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   540             {
   556             {
   541             iSimulatedDownEvent = EFalse;
   557             iSimulatedDownEvent = EFalse;
   542             }
   558             }
   543         }
   559         }
  1403 	ext->iIdleData = NULL;
  1419 	ext->iIdleData = NULL;
  1404 	_AKNTRACE_FUNC_EXIT;
  1420 	_AKNTRACE_FUNC_EXIT;
  1405 	return EFalse;	
  1421 	return EFalse;	
  1406 }
  1422 }
  1407 
  1423 
  1408 void CEikCaptionedControl::ScrollBackEditor()
  1424 void CEikCaptionedControl::ScrollBackEditorL()
  1409 {
  1425     {
  1410 _AKNTRACE_FUNC_ENTER;
  1426     _AKNTRACE_FUNC_ENTER;
  1411         //
  1427     //
  1412 		// For long single-line edwin, scroll horizontally to show beginning of the edwin
  1428     // For long single-line edwin, scroll horizontally to show beginning
  1413 		// when focus changes away from the edwin.
  1429     // of the edwin when focus changes away from the edwin.
  1414 		// 
  1430     // 
  1415       	if ( iIsEditable && ControlIsAnEdwin(iControlType) )
  1431     if ( iIsEditable && ControlIsAnEdwin( iControlType ) )
  1416 			{
  1432         {
  1417 			delete iExtension->iIdle;
  1433         delete iExtension->iIdle;
  1418 			delete iExtension->iIdleData;
  1434         iExtension->iIdle = NULL;
  1419 			iExtension->iIdleData = new (ELeave) CIdleCallbackData;
  1435         delete iExtension->iIdleData;
  1420 			iExtension->iIdleData->iCtrl = this;
  1436         iExtension->iIdleData = NULL;
  1421 			iExtension->iIdleData->iExt = iExtension;
  1437         iExtension->iIdleData = new (ELeave) CIdleCallbackData;
  1422 			iExtension->iIdle = CIdle::NewL(0);
  1438         iExtension->iIdleData->iCtrl = this;
  1423 			iExtension->iIdle->Start(TCallBack(&IdleCallback, iExtension->iIdleData));
  1439         iExtension->iIdleData->iExt = iExtension;
  1424 			}	
  1440         iExtension->iIdle = CIdle::NewL( 0 );
  1425 _AKNTRACE_FUNC_EXIT;
  1441         iExtension->iIdle->Start(
  1426 }
  1442             TCallBack( &IdleCallback, iExtension->iIdleData ) );
       
  1443         }
       
  1444     _AKNTRACE_FUNC_EXIT;
       
  1445     }
  1427 
  1446 
  1428 EXPORT_C void CEikCaptionedControl::FocusChanged(TDrawNow aDrawNow)
  1447 EXPORT_C void CEikCaptionedControl::FocusChanged(TDrawNow aDrawNow)
  1429     {    
  1448     {    
  1430     _AKNTRACE_FUNC_ENTER;
  1449     _AKNTRACE_FUNC_ENTER;
  1431     // Only form controls need to adapt animation to focus changes.
  1450     // Only form controls need to adapt animation to focus changes.
  1436             {
  1455             {
  1437             iExtension->iAnimation->Pause();
  1456             iExtension->iAnimation->Pause();
  1438             }
  1457             }
  1439         else if( iIsCurrentLine && !iIsEditable ) // Current and in view mode
  1458         else if( iIsCurrentLine && !iIsEditable ) // Current and in view mode
  1440             {
  1459             {
  1441             CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
  1460             CAknAppUi* aui = static_cast<CAknAppUi*>(iEikonEnv->AppUi());
  1442             if( aui->IsForeground() )
  1461             if( aui->IsForeground() )
  1443                 {
  1462                 {
  1444                 iExtension->iAnimation->Play();
  1463                 iExtension->iAnimation->Play();
  1445                 }
  1464                 }
  1446             }
  1465             }
  1837 // CEikCaptionedControl::TextColorIndex
  1856 // CEikCaptionedControl::TextColorIndex
  1838 // ---------------------------------------------------------------------------
  1857 // ---------------------------------------------------------------------------
  1839 //
  1858 //
  1840 TAknsQsnTextColorsIndex CEikCaptionedControl::TextColorIndex() const
  1859 TAknsQsnTextColorsIndex CEikCaptionedControl::TextColorIndex() const
  1841     {
  1860     {
  1842     TAknsQsnTextColorsIndex colorIndex = EAknsCIQsnTextColorsCG8;
  1861     TAknsQsnTextColorsIndex colorIndex = EAknsCIQsnTextColorsCG6;
  1843 
  1862 
  1844     // Note control doesn't use highlight text color
  1863     // Note control doesn't use highlight text color
  1845     if ( iControlType != EAknCtNote )
  1864     if ( iControlType != EAknCtNote )
  1846         {
  1865         {
  1847         if ( iIsCurrentLine && iDialogPage->HighlightVisible() )
  1866         if ( iIsCurrentLine && iDialogPage->HighlightVisible() )
  1848             {
  1867             {
  1849             colorIndex = EAknsCIQsnTextColorsCG10;
  1868             colorIndex = EAknsCIQsnTextColorsCG8;
  1850             }
  1869             }
  1851         }
  1870         }
  1852     
  1871     
  1853     return colorIndex;
  1872     return colorIndex;
  1854     }
  1873     }
  2000                 _AKNTRACE_FUNC_EXIT;
  2019                 _AKNTRACE_FUNC_EXIT;
  2001                 return;
  2020                 return;
  2002                 }
  2021                 }
  2003             }
  2022             }
  2004         }
  2023         }
  2005      if (iIsFormControl)
  2024 
  2006         {
  2025     TBool edwinControl( ControlIsAnEdwin( iControlType ) );
  2007         if ( PressedDownState()&&
  2026     
  2008             aPointerEvent.iType == TPointerEvent::EButton1Down )
  2027      if ( iIsFormControl )
       
  2028         {
       
  2029         if ( !PressedDownState() &&
       
  2030              aPointerEvent.iType == TPointerEvent::EButton1Down )
  2009             {
  2031             {
  2010             SetPressedDownState( ETrue );
  2032             SetPressedDownState( ETrue );
  2011             DrawDeferred();    
  2033             DrawDeferred();
  2012             }
  2034             }
  2013         else if(aPointerEvent.iType == TPointerEvent::EButton1Up)
  2035         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
  2014             {
  2036             {
  2015             _AKNTRACE("TPointerEvent::EButton1Up");
  2037             _AKNTRACE( "TPointerEvent::EButton1Up" );
  2016             SetPressedDownState( EFalse );
  2038             SetPressedDownState( EFalse );
  2017             DrawDeferred();
  2039             DrawDeferred();
  2018             }       
  2040             }
       
  2041         
       
  2042         if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down || 
       
  2043                aPointerEvent.iType == TPointerEvent::EButton1Up ) &&
       
  2044              iIsEditable &&
       
  2045              edwinControl &&
       
  2046              iExtension &&
       
  2047              iExtension->iFeedback &&
       
  2048              iControl->Rect().Contains( aPointerEvent.iPosition ) )
       
  2049             {
       
  2050             CEikEdwin* edwin = static_cast<CEikEdwin*>( iControl );
       
  2051             if ( edwin &&
       
  2052                  ( edwin->UserFlags() & CEikEdwin::EDisplayOnly ||
       
  2053                    edwin->IsReadOnly() ) )
       
  2054                 {
       
  2055                 // For edwins in view only mode we must produce the feedback
       
  2056                 // here, as the edwin itself doesn't.
       
  2057                 if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  2058                     {
       
  2059                     iExtension->iFeedback->InstantFeedback( iControl,
       
  2060                                                             ETouchFeedbackList );
       
  2061                     }
       
  2062                 else
       
  2063                     {
       
  2064                     iExtension->iFeedback->InstantFeedback( iControl,
       
  2065                                                             ETouchFeedbackList,
       
  2066                                                             ETouchFeedbackVibra,
       
  2067                                                             aPointerEvent );
       
  2068                     }
       
  2069                 }
       
  2070             }
  2019         }
  2071         }
  2020     
  2072     
  2021     if ( !iIsEditable && (ControlIsAnEdwin(iControlType) || ControlIsAMfne(iControlType))
  2073     if ( !iIsEditable && ( edwinControl || ControlIsAMfne( iControlType ) )
  2022        &&( iDialogPage && CEikDialogPage::EDouble == iDialogPage->FormLayout() ))
  2074        &&( iDialogPage && CEikDialogPage::EDouble == iDialogPage->FormLayout() ))
  2023         {
  2075         {
  2024         _AKNTRACE_FUNC_EXIT;
  2076         _AKNTRACE_FUNC_EXIT;
  2025 		return;
  2077 		return;
  2026         }
  2078         }
  2027 
  2079 
  2028     CCoeControl::HandlePointerEventL(aPointerEvent);    
  2080     CCoeControl::HandlePointerEventL(aPointerEvent);    
  2029      
  2081      
  2030     if ( iExtension )
  2082     if ( iExtension && iIsFormControl )
  2031         {
  2083         {
  2032         iExtension->SimulatePointerEventToControlL( aPointerEvent );
  2084         iExtension->SimulatePointerEventToControlL( aPointerEvent );
  2033         }
  2085         }
  2034     }
  2086     }
  2035 
  2087