uifw/AvKon/src/akndiscreetpopupcontrol.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
    29 #include <gfxtranseffect/gfxtranseffect.h>
    29 #include <gfxtranseffect/gfxtranseffect.h>
    30 #include <akntransitionutils.h>
    30 #include <akntransitionutils.h>
    31 #include <avkon.hrh>
    31 #include <avkon.hrh>
    32 #include "akndiscreetpopupcontrol.h"
    32 #include "akndiscreetpopupcontrol.h"
    33 #include "akndiscreetpopupdrawer.h"
    33 #include "akndiscreetpopupdrawer.h"
       
    34 #include "akntrace.h"
    34 
    35 
    35 _LIT( KDiscreetPopupWindowGroupName, "Discreet pop-up" );
    36 _LIT( KDiscreetPopupWindowGroupName, "Discreet pop-up" );
    36 
    37 
    37 const TInt KShortTimeout( 1500000 );
    38 const TInt KShortTimeout( 1500000 );
    38 const TInt KLongTimeout( 3000000 );
    39 const TInt KLongTimeout( 3000000 );
    70     const TInt& aFlags, 
    71     const TInt& aFlags, 
    71     const TInt& aCommand,
    72     const TInt& aCommand,
    72     const TInt& aPopupId,
    73     const TInt& aPopupId,
    73     MEikCommandObserver* aCommandObserver )
    74     MEikCommandObserver* aCommandObserver )
    74     {
    75     {
       
    76     _AKNTRACE_FUNC_ENTER;
    75     CAknDiscreetPopupControl* self = 
    77     CAknDiscreetPopupControl* self = 
    76         CAknDiscreetPopupControl::NewLC( aGlobal,
    78         CAknDiscreetPopupControl::NewLC( aGlobal,
    77                                          aTitle,
    79                                          aTitle,
    78                                          aText,
    80                                          aText,
    79                                          aIcon,
    81                                          aIcon,
    84                                          aFlags,
    86                                          aFlags,
    85                                          aCommand,
    87                                          aCommand,
    86                                          aPopupId,
    88                                          aPopupId,
    87                                          aCommandObserver );
    89                                          aCommandObserver );
    88     CleanupStack::Pop( self );
    90     CleanupStack::Pop( self );
       
    91     _AKNTRACE_FUNC_EXIT;
    89     return self;
    92     return self;
    90     }
    93     }
    91 
    94 
    92 
    95 
    93 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
   100     const TDesC& aResourceFile,
   103     const TDesC& aResourceFile,
   101     const TInt& aCommand,
   104     const TInt& aCommand,
   102     const TInt& aPopupId,
   105     const TInt& aPopupId,
   103     MEikCommandObserver* aCommandObserver )
   106     MEikCommandObserver* aCommandObserver )
   104     {
   107     {
       
   108     _AKNTRACE_FUNC_ENTER;
   105     CAknDiscreetPopupControl* self = 
   109     CAknDiscreetPopupControl* self = 
   106         CAknDiscreetPopupControl::NewLC( aGlobal, 
   110         CAknDiscreetPopupControl::NewLC( aGlobal, 
   107                                          aCommand, 
   111                                          aCommand, 
   108                                          aPopupId, 
   112                                          aPopupId, 
   109                                          aCommandObserver );
   113                                          aCommandObserver );
   110                                          
   114                                          
   111     self->ConstructFromResourceL( aResourceId, aResourceFile );
   115     self->ConstructFromResourceL( aResourceId, aResourceFile );
   112     CleanupStack::Pop( self );
   116     CleanupStack::Pop( self );
       
   117     _AKNTRACE_FUNC_EXIT;
   113     return self;
   118     return self;
   114     }
   119     }
   115 
   120 
   116 
   121 
   117 // ---------------------------------------------------------------------------
   122 // ---------------------------------------------------------------------------
   173 // CAknDiscreetPopupControl::~CAknDiscreetPopupControl
   178 // CAknDiscreetPopupControl::~CAknDiscreetPopupControl
   174 // ---------------------------------------------------------------------------
   179 // ---------------------------------------------------------------------------
   175 //
   180 //
   176 CAknDiscreetPopupControl::~CAknDiscreetPopupControl()
   181 CAknDiscreetPopupControl::~CAknDiscreetPopupControl()
   177     {
   182     {
       
   183     _AKNTRACE_FUNC_ENTER;
   178     AKNTASHOOK_REMOVE();
   184     AKNTASHOOK_REMOVE();
   179     if ( IsVisible() )
   185     if ( IsVisible() )
   180         {
   186         {
   181         HidePopup();
   187         HidePopup();
   182         }
   188         }
   187         {
   193         {
   188         iWindowGroup.Close();
   194         iWindowGroup.Close();
   189         }
   195         }
   190     delete iTimer;	
   196     delete iTimer;	
   191     delete iDrawer;
   197     delete iDrawer;
       
   198     _AKNTRACE_FUNC_EXIT;
   192     }
   199     }
   193 
   200 
   194 
   201 
   195 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
   196 // CAknDiscreetPopupControl::HandleDiscreetPopupActionL
   203 // CAknDiscreetPopupControl::HandleDiscreetPopupActionL
   399 // CAknDiscreetPopupControl::DoTimeOut
   406 // CAknDiscreetPopupControl::DoTimeOut
   400 // ---------------------------------------------------------------------------
   407 // ---------------------------------------------------------------------------
   401 //
   408 //
   402 void CAknDiscreetPopupControl::DoTimeOut()
   409 void CAknDiscreetPopupControl::DoTimeOut()
   403     {
   410     {
       
   411 	_AKNTRACE_FUNC_ENTER;
   404     if ( !iInternalFlags.IsSet( EPressedDown ) )
   412     if ( !iInternalFlags.IsSet( EPressedDown ) )
   405         {
   413         {
   406         TRAP_IGNORE( RequestExitL() );
   414         TRAP_IGNORE( RequestExitL() );
   407         }
   415         }
   408     else
   416     else
   409         {
   417         {
   410         iTimer->Cancel();
   418         iTimer->Cancel();
   411         }
   419         }
       
   420 	_AKNTRACE_FUNC_EXIT;
   412     }
   421     }
   413 
   422 
   414 
   423 
   415 // ---------------------------------------------------------------------------
   424 // ---------------------------------------------------------------------------
   416 // CAknDiscreetPopupControl::RequestExitL
   425 // CAknDiscreetPopupControl::RequestExitL
   417 // Popup exit when popup is completely invisible.
   426 // Popup exit when popup is completely invisible.
   418 // ---------------------------------------------------------------------------
   427 // ---------------------------------------------------------------------------
   419 //
   428 //
   420 void CAknDiscreetPopupControl::RequestExitL()
   429 void CAknDiscreetPopupControl::RequestExitL()
   421     {
   430     {
       
   431     _AKNTRACE_FUNC_ENTER;
   422     if( iCommandObserver && !iInternalFlags.IsSet( EGlobal ) )
   432     if( iCommandObserver && !iInternalFlags.IsSet( EGlobal ) )
   423         {
   433         {
   424         iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose );
   434         iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose );
   425         }
   435         }
   426     HidePopup();
   436     HidePopup();
   427     ReportEventL( MCoeControlObserver::EEventRequestExit );
   437     ReportEventL( MCoeControlObserver::EEventRequestExit );
   428     iInternalFlags.Clear( EPressedDown );
   438     iInternalFlags.Clear( EPressedDown );
       
   439     _AKNTRACE_FUNC_EXIT;
   429     }
   440     }
   430 
   441 
   431 
   442 
   432 // ---------------------------------------------------------------------------
   443 // ---------------------------------------------------------------------------
   433 // CAknDiscreetPopupControl::NotifyObserverL
   444 // CAknDiscreetPopupControl::NotifyObserverL
   434 // ---------------------------------------------------------------------------
   445 // ---------------------------------------------------------------------------
   435 //
   446 //
   436 void CAknDiscreetPopupControl::NotifyObserverL()
   447 void CAknDiscreetPopupControl::NotifyObserverL()
   437     {
   448     {
       
   449     _AKNTRACE_FUNC_ENTER;
   438     if ( iCommand != 0 && iCommandObserver )
   450     if ( iCommand != 0 && iCommandObserver )
   439         {
   451         {
       
   452         _AKNTRACE( "CAknDiscreetPopupControl::NotifyObserverL(), tap event will be disposed." );
   440         // Play feedback if there is command associated with the popup
   453         // Play feedback if there is command associated with the popup
   441         ImmediateFeedback( ETouchFeedbackSensitive );
   454         ImmediateFeedback( ETouchFeedbackSensitive );
   442         iCommandObserver->ProcessCommandL( iCommand );
   455         iCommandObserver->ProcessCommandL( iCommand );
   443         }
   456         }
       
   457     _AKNTRACE_FUNC_EXIT;
   444     }
   458     }
   445 
   459 
   446 
   460 
   447 // -----------------------------------------------------------------------------
   461 // -----------------------------------------------------------------------------
   448 // CAknDiscreetPopupControl::ImmediateFeedback
   462 // CAknDiscreetPopupControl::ImmediateFeedback
   528 // CAknDiscreetPopupControl::ShowPopupL
   542 // CAknDiscreetPopupControl::ShowPopupL
   529 // ---------------------------------------------------------------------------
   543 // ---------------------------------------------------------------------------
   530 //
   544 //
   531 void CAknDiscreetPopupControl::ShowPopupL()
   545 void CAknDiscreetPopupControl::ShowPopupL()
   532     {
   546     {
       
   547     _AKNTRACE_FUNC_ENTER;
   533     AppUi()->AddToStackL( 
   548     AppUi()->AddToStackL( 
   534             this, 
   549             this, 
   535             ECoeStackPriorityDefault,
   550             ECoeStackPriorityDefault,
   536             ECoeStackFlagRefusesAllKeys |
   551             ECoeStackFlagRefusesAllKeys |
   537             ECoeStackFlagRefusesFocus );
   552             ECoeStackFlagRefusesFocus );
   561         }
   576         }
   562     
   577     
   563     iTimer->Start( timeout, 
   578     iTimer->Start( timeout, 
   564                    0, 
   579                    0, 
   565                    TCallBack( TimeOut, this ) );
   580                    TCallBack( TimeOut, this ) );
       
   581 				   
       
   582 	_AKNTRACE_FUNC_EXIT;
   566     }
   583     }
   567 
   584 
   568 
   585 
   569 // ---------------------------------------------------------------------------
   586 // ---------------------------------------------------------------------------
   570 // CAknDiscreetPopupControl::HidePopup
   587 // CAknDiscreetPopupControl::HidePopup
   693 // CAknDiscreetPopupControl::HandleResourceChange
   710 // CAknDiscreetPopupControl::HandleResourceChange
   694 // ---------------------------------------------------------------------------
   711 // ---------------------------------------------------------------------------
   695 //
   712 //
   696 void CAknDiscreetPopupControl::HandleResourceChange( TInt aType )
   713 void CAknDiscreetPopupControl::HandleResourceChange( TInt aType )
   697     {
   714     {
       
   715     _AKNTRACE_FUNC_ENTER;
   698     CAknControl::HandleResourceChange( aType );
   716     CAknControl::HandleResourceChange( aType );
   699     switch ( aType )
   717     switch ( aType )
   700         {
   718         {
   701         case KEikDynamicLayoutVariantSwitch:
   719         case KEikDynamicLayoutVariantSwitch:
   702             {
   720             {
   718         default:
   736         default:
   719             {
   737             {
   720             break;
   738             break;
   721             }
   739             }
   722         }
   740         }
       
   741     _AKNTRACE_FUNC_EXIT;
   723     }
   742     }
   724 
   743 
   725 
   744 
   726 // ---------------------------------------------------------------------------
   745 // ---------------------------------------------------------------------------
   727 // CAknDiscreetPopupControl::HandlePointerEventL
   746 // CAknDiscreetPopupControl::HandlePointerEventL
   738     // pressed-down)
   757     // pressed-down)
   739     if ( aPointerEvent.iType == TPointerEvent::EButton1Down
   758     if ( aPointerEvent.iType == TPointerEvent::EButton1Down
   740          && eventInRect
   759          && eventInRect
   741          && iInternalFlags.IsClear( EDismissed ) )
   760          && iInternalFlags.IsClear( EDismissed ) )
   742         {
   761         {
       
   762         _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Down" );
   743         SetPressedDownState( ETrue );
   763         SetPressedDownState( ETrue );
   744         ImmediateFeedback( ETouchFeedbackSensitive );
   764         ImmediateFeedback( ETouchFeedbackSensitive );
   745         }
   765         }
   746 
   766 
   747     // Pointer drag - reset pressed-down state if pointer out of popup area
   767     // Pointer drag - reset pressed-down state if pointer out of popup area
   748     else if ( aPointerEvent.iType == TPointerEvent::EDrag )
   768     else if ( aPointerEvent.iType == TPointerEvent::EDrag )
   749         {
   769         {
       
   770         _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EDrag" );
   750         iInternalFlags.Set( EDragged );
   771         iInternalFlags.Set( EDragged );
   751         if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) )
   772         if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) )
   752             {
   773             {
   753             iInternalFlags.Clear( EPressedDown );
   774             iInternalFlags.Clear( EPressedDown );
   754             }
   775             }
   759         }
   780         }
   760 
   781 
   761     // Pointer up - reset pressed-down state 
   782     // Pointer up - reset pressed-down state 
   762     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   783     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   763         {
   784         {
       
   785         _AKNTRACE( "CAknDiscreetPopupControl::HandlePointerEventL, TPointerEvent::EButton1Up" );
   764         if ( eventInRect )
   786         if ( eventInRect )
   765             {
   787             {
   766             NotifyObserverL();
   788             NotifyObserverL();
   767             }
   789             }
   768         
   790