uifw/AvKon/src/akndiscreetpopupcontrol.cpp
branchRCL_3
changeset 23 3d340a0166ff
parent 18 0aa5fbdfbc30
child 55 aecbbf00d063
equal deleted inserted replaced
18:0aa5fbdfbc30 23:3d340a0166ff
    47 enum TAknDiscreetPopupControlFlags
    47 enum TAknDiscreetPopupControlFlags
    48     {
    48     {
    49     EPressedDown,     // Pointer down is received in popup area
    49     EPressedDown,     // Pointer down is received in popup area
    50     EDismissed,       // Popup is dismissed (pointer up is received in popup area)
    50     EDismissed,       // Popup is dismissed (pointer up is received in popup area)
    51     EGlobal,          // Popup is global
    51     EGlobal,          // Popup is global
    52     EDragged          // Pointer is dragged while popup open
    52     EDragged,         // Pointer is dragged while popup open
       
    53     EStartTimerAgain  // Start timer again when timer is out and keep pressing  
    53     };
    54     };
    54 
    55 
    55 
    56 
    56 // ======== MEMBER FUNCTIONS ========
    57 // ======== MEMBER FUNCTIONS ========
    57 
    58 
   410 // ---------------------------------------------------------------------------
   411 // ---------------------------------------------------------------------------
   411 //
   412 //
   412 void CAknDiscreetPopupControl::DoTimeOut()
   413 void CAknDiscreetPopupControl::DoTimeOut()
   413     {
   414     {
   414 	_AKNTRACE_FUNC_ENTER;
   415 	_AKNTRACE_FUNC_ENTER;
   415     if ( !iInternalFlags.IsSet( EPressedDown ) )
   416     if ( !iInternalFlags.IsSet( EPressedDown ) || 
       
   417     	 iInternalFlags.IsSet( EStartTimerAgain ) )
   416         {
   418         {
   417         TRAP_IGNORE( RequestExitL() );
   419         TRAP_IGNORE( RequestExitL() );
   418         }
   420         }
   419     else
   421     else
   420         {
   422         {
   421         iTimer->Cancel();
   423         iTimer->Cancel();
       
   424         // if time is out and keep pressing, start short timer again.
       
   425         iInternalFlags.Set( EStartTimerAgain );
       
   426         iTimer->Start( KShortTimeout, 
       
   427                        0, 
       
   428                        TCallBack( TimeOut, this ) );
   422         }
   429         }
   423 	_AKNTRACE_FUNC_EXIT;
   430 	_AKNTRACE_FUNC_EXIT;
   424     }
   431     }
   425 
   432 
   426 
   433 
   436         {
   443         {
   437         iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose );
   444         iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose );
   438         }
   445         }
   439     HidePopup();
   446     HidePopup();
   440     ReportEventL( MCoeControlObserver::EEventRequestExit );
   447     ReportEventL( MCoeControlObserver::EEventRequestExit );
       
   448     iInternalFlags.Clear( EStartTimerAgain );
   441     iInternalFlags.Clear( EPressedDown );
   449     iInternalFlags.Clear( EPressedDown );
   442     _AKNTRACE_FUNC_EXIT;
   450     _AKNTRACE_FUNC_EXIT;
   443     }
   451     }
   444 
   452 
   445 
   453 
   761 void CAknDiscreetPopupControl::HandlePointerEventL( 
   769 void CAknDiscreetPopupControl::HandlePointerEventL( 
   762     const TPointerEvent& aPointerEvent )
   770     const TPointerEvent& aPointerEvent )
   763     {
   771     {
   764     TBool eventInRect( Rect().Contains( aPointerEvent.iPosition ) );
   772     TBool eventInRect( Rect().Contains( aPointerEvent.iPosition ) );
   765     
   773     
   766     // The discreet popup which is global won't handle pointer event if there is notifier be popping up.
   774     // Pointer down - set pressed-down state (popup completely visible while
   767     if( !iInternalFlags.IsSet( EGlobal ) || iCoeEnv->RootWin().OrdinalPriority() < ECoeWinPriorityAlwaysAtFront ) 
   775     // pressed-down)
   768         {
   776     if ( aPointerEvent.iType == TPointerEvent::EButton1Down 
   769         // Pointer down - set pressed-down state (popup completely visible while
   777          && eventInRect
   770         // pressed-down)
   778          && iInternalFlags.IsClear( EDismissed ) )
   771         if ( aPointerEvent.iType == TPointerEvent::EButton1Down 
   779         {
   772         	 && eventInRect
   780         _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Down" );
   773              && iInternalFlags.IsClear( EDismissed ) )
   781         SetPressedDownState( ETrue );
   774             {
   782         ImmediateFeedback( ETouchFeedbackSensitive );
   775             _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Down" );
   783         }
   776             SetPressedDownState( ETrue );
   784 
   777             ImmediateFeedback( ETouchFeedbackSensitive );
   785     // Pointer drag - reset pressed-down state if pointer out of popup area
   778             }
   786     else if ( aPointerEvent.iType == TPointerEvent::EDrag )
   779     
   787         {
   780         // Pointer drag - reset pressed-down state if pointer out of popup area
   788         _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EDrag" );
   781         else if ( aPointerEvent.iType == TPointerEvent::EDrag )
   789         iInternalFlags.Set( EDragged );
   782             {
   790         if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) )
   783             _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EDrag" );
   791             {
   784             iInternalFlags.Set( EDragged );
   792             iInternalFlags.Clear( EPressedDown );
   785             if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) )
   793             }
   786                 {
   794         else if ( eventInRect && !iInternalFlags.IsSet( EPressedDown ) )
   787                 iInternalFlags.Clear( EPressedDown );
   795             {
   788                 }
   796             iInternalFlags.Set( EPressedDown );
   789             else if ( eventInRect && !iInternalFlags.IsSet( EPressedDown ) )
   797             }
   790                 {
   798         }
   791                 iInternalFlags.Set( EPressedDown );
   799 
   792                 }
   800     // Pointer up - reset pressed-down state 
   793             }
   801     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   794     
   802         {        
   795         // Pointer up - reset pressed-down state 
   803         _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Up" );
   796         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   804         if ( eventInRect )
   797             {        
   805             {
   798             _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Up" );
   806             NotifyObserverL();
   799             if ( eventInRect )
   807             }        
   800                 {
   808         // Start fading away
   801                 NotifyObserverL();
   809         if ( iInternalFlags.IsClear( EDismissed ) )
   802                 }        
   810             {
   803             // Start fading away
   811             iInternalFlags.Set( EDismissed );
   804             if ( iInternalFlags.IsClear( EDismissed ) )
   812             RequestExitL();
   805                 {
   813             }
   806                 iInternalFlags.Set( EDismissed );
   814         SetPressedDownState( EFalse );
   807                 RequestExitL();
   815         }
   808                 }
   816     }
   809             SetPressedDownState( EFalse );
       
   810             }
       
   811         }
       
   812 
       
   813     }
       
   814