phoneuis/dialer/src/cdialerkeypadcontainer.cpp
branchRCL_3
changeset 6 38529f706030
parent 5 2a26698d78ba
child 7 544e34b3255a
equal deleted inserted replaced
5:2a26698d78ba 6:38529f706030
    31 #include <aknlayoutscalable_apps.cdl.h>
    31 #include <aknlayoutscalable_apps.cdl.h>
    32 #include <layoutmetadata.cdl.h>
    32 #include <layoutmetadata.cdl.h>
    33 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR
    33 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR
    34 #include <touchfeedback.h>
    34 #include <touchfeedback.h>
    35 #include <aknlayoutscalable_avkon.cdl.h>
    35 #include <aknlayoutscalable_avkon.cdl.h>
    36 #include <aknsframebackgroundcontrolcontext.h>
    36 #include <AknsFrameBackgroundControlContext.h>
    37 
    37 
    38 #include "cdialerkeypadcontainer.h"
    38 #include "cdialerkeypadcontainer.h"
    39 #include "dialercommon.h"
    39 #include "dialercommon.h"
    40 #include "dialertrace.h"
    40 #include "dialertrace.h"
    41 
    41 
   174     
   174     
   175     CCoeControl::HandlePointerEventL( aPointerEvent );    
   175     CCoeControl::HandlePointerEventL( aPointerEvent );    
   176 
   176 
   177     if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) 
   177     if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) 
   178         {
   178         {
   179         iPointerEvent = aPointerEvent;    
   179         iPointerEvent = aPointerEvent; 
       
   180         iKeyUpSimulatedDueToDragging = EFalse;
   180         }
   181         }
   181     DIALER_PRINT("KeyPadContainer::HandlePointerEventL>");     
   182     DIALER_PRINT("KeyPadContainer::HandlePointerEventL>");     
   182     }
   183     }
   183     
   184     
   184 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
   350 //
   351 //
   351 void CDialerKeyPadContainer::CreateButtonsL()
   352 void CDialerKeyPadContainer::CreateButtonsL()
   352     {
   353     {
   353     DIALER_PRINT("KeyPadContainer::CreateButtonsL<");
   354     DIALER_PRINT("KeyPadContainer::CreateButtonsL<");
   354     
   355     
   355     TInt flags ( KAknButtonReportOnLongPress|
   356     TInt flags ( KAknButtonReportOnKeyDown  |
   356                  KAknButtonReportOnKeyDown  |
       
   357                  KAknButtonRequestExitOnButtonUpEvent );
   357                  KAknButtonRequestExitOnButtonUpEvent );
   358     
   358     
   359     for ( TInt i = 0; i < KNumberOfButtons; i++ )
   359     for ( TInt i = 0; i < KNumberOfButtons; i++ )
   360         {
   360         {
   361         const TPtrC numLabel = iKeyLabelManager->ButtonNumLabel( i );
   361         const TPtrC numLabel = iKeyLabelManager->ButtonNumLabel( i );
   398                                                 TCoeEvent aEventType )
   398                                                 TCoeEvent aEventType )
   399     {
   399     {
   400     DIALER_PRINTF("KeyPadContainer::HandleControlEventL.EventType=",
   400     DIALER_PRINTF("KeyPadContainer::HandleControlEventL.EventType=",
   401                  (TInt)aEventType);
   401                  (TInt)aEventType);
   402     
   402     
   403    if ( aEventType == EEventStateChanged   || 
   403     if ( aEventType == EEventStateChanged   || 
   404         aEventType == EEventRequestCancel ||
   404          aEventType == EEventRequestCancel ||
   405         aEventType == EEventRequestExit)
   405          aEventType == EEventRequestExit ||
       
   406          aEventType == CDialerKeyPadButton::EEventDraggingOutsideButton )
   406         
   407         
   407         {
   408         {
   408         // Find tapped control 
   409         // Find tapped control 
   409 
   410 
   410         CDialerKeyPadButton* tappedButton = NULL;
   411         CDialerKeyPadButton* tappedButton = NULL;
   415                 tappedButton = iButtons[i];
   416                 tappedButton = iButtons[i];
   416                 break;
   417                 break;
   417                 }    
   418                 }    
   418             }
   419             }
   419         
   420         
   420         __ASSERT_ALWAYS( tappedButton, 
   421         if ( !tappedButton )
   421         _L("CDialerKeyPadContainer::HandleControlEventL, invalid button handle")); // TODO: This is meaningless statement, use either Panic or make this only comment.
   422             {
       
   423             __ASSERT_DEBUG( EFalse, DialerPanic( EDialerPanicEventFromUnknownControl ) );
       
   424             return;
       
   425             }
   422         
   426         
   423         // Send key event to phone.
   427         // Send key event to phone.
   424         TKeyEvent keyEvent;
   428         TKeyEvent keyEvent;
   425         keyEvent.iScanCode = tappedButton->ScanCode();
   429         keyEvent.iScanCode = tappedButton->ScanCode();
   426         keyEvent.iModifiers = ( EModifierNumLock | EModifierKeypad ); // Mark that this event is dialer simulated
   430         keyEvent.iModifiers = ( EModifierNumLock | EModifierKeypad ); // Mark that this event is dialer simulated
   427         keyEvent.iRepeats = 0;  
   431         keyEvent.iRepeats = 0;
   428              
   432         
   429         switch ( aEventType )
   433         switch ( aEventType )
   430             {
   434             {
   431             case EEventRequestExit:
   435             case EEventRequestExit:
   432             case EEventRequestCancel:
   436             case EEventRequestCancel:
   433                 {
   437                 {
   434                 DIALER_PRINT("HandleControlEventL.EEventRequestExit");
   438                 DIALER_PRINT("HandleControlEventL.EEventRequestExit");
   435                 iButtonPressedDown = EFalse;
   439                 iButtonPressedDown = EFalse;
   436                 keyEvent.iCode = 0;
   440                 if ( !iKeyUpSimulatedDueToDragging )
   437                 ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyUp );
   441                     {
       
   442                     keyEvent.iCode = 0;
       
   443                     ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyUp );
       
   444                     }
       
   445                 iKeyUpSimulatedDueToDragging = EFalse;
   438                 }
   446                 }
   439                 break;
   447                 break;
       
   448                 
   440             case EEventStateChanged:
   449             case EEventStateChanged:
   441                 {    
   450                 {    
   442                 DIALER_PRINT("HandleControlEventL.EEventStateChanged");
   451                 DIALER_PRINT("HandleControlEventL.EEventStateChanged");
   443                 iButtonPressedDown = ETrue;
   452                 iButtonPressedDown = ETrue;
   444                 keyEvent.iCode = tappedButton->KeyCode();
   453                 keyEvent.iCode = tappedButton->KeyCode();
   445                 iParentControl.PrepareForFocusGainL();
   454                 iParentControl.PrepareForFocusGainL();
   446 
   455 
   447                 ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyDown );    
   456                 ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyDown );
   448 
   457 
   449                 if( iButtonPressedDown )
   458                 if( iButtonPressedDown )
   450                     {
   459                     {
   451                     // Send event key if key havent be lifted up already
   460                     // Send event key if key havent be lifted up already
   452                     ControlEnv()->SimulateKeyEventL( keyEvent, EEventKey );
   461                     ControlEnv()->SimulateKeyEventL( keyEvent, EEventKey );
   453                     }
   462                     }
   454                 }
   463                 }
   455                 break;
   464                 break;
       
   465             
       
   466             case CDialerKeyPadButton::EEventDraggingOutsideButton:
       
   467                 {
       
   468                 DIALER_PRINT("HandleControlEventL.EEventDraggingOutsideButton");
       
   469                 // User hasn't released touch yet but in order to cancel
       
   470                 // long press action handled and initiated by parent control, 
       
   471                 // we must send key up event now.
       
   472                 if ( !iKeyUpSimulatedDueToDragging )
       
   473                     {
       
   474                     keyEvent.iCode = 0;
       
   475                     ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyUp );
       
   476                     iKeyUpSimulatedDueToDragging = ETrue;
       
   477                     }
       
   478                 }
       
   479                 break;
       
   480                 
   456             default:
   481             default:
   457             break;
   482             break;
   458             }
   483             }
   459         }
   484         }
   460     DIALER_PRINT("KeyPadContainer::HandleControlEventL>");        
   485     DIALER_PRINT("KeyPadContainer::HandleControlEventL>");
   461     }
   486     }
   462     
   487 
   463 // ---------------------------------------------------------------------------
   488 // ---------------------------------------------------------------------------
   464 // CDialerKeyPadContainer::HandleResourceChange
   489 // CDialerKeyPadContainer::HandleResourceChange
   465 //
   490 //
   466 // Forwards skin change event to buttons
   491 // Forwards skin change event to buttons
   467 //
   492 //
   573 //
   598 //
   574 void CDialerKeyPadContainer::EnableTactileFeedback( const TBool aEnable )
   599 void CDialerKeyPadContainer::EnableTactileFeedback( const TBool aEnable )
   575     {
   600     {
   576     for ( TInt i=0; i < iButtons.Count(); i++ )
   601     for ( TInt i=0; i < iButtons.Count(); i++ )
   577         {
   602         {
   578         (( CDialerKeyPadButton* )iButtons[i])->EnableAudioFeedback( aEnable );
   603         iButtons[i]->EnableAudioFeedback( aEnable );
   579         }
   604         }
   580 
   605 
   581     }
   606     }
   582 // End of File
   607 // End of File