uifw/AvKon/src/AknNoteDialog.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
    44 #include <avkondomainpskeys.h>
    44 #include <avkondomainpskeys.h>
    45 #include <aknglobalpopupprioritycontroller.h>
    45 #include <aknglobalpopupprioritycontroller.h>
    46 #endif
    46 #endif
    47 
    47 
    48 #include <AknTasHook.h> // for testability hooks
    48 #include <AknTasHook.h> // for testability hooks
       
    49 #include "akntrace.h"
    49 const TInt EEikDialogFlagSleeping   =0x20000;
    50 const TInt EEikDialogFlagSleeping   =0x20000;
       
    51 
       
    52 
    50 
    53 
    51 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
    52 // Finds out if this control belongs to the window group that is in focus.
    55 // Finds out if this control belongs to the window group that is in focus.
    53 // This information can be used to skip effects when the window group is
    56 // This information can be used to skip effects when the window group is not visible.
    54 // not visible.
       
    55 //
    57 //
    56 // @param aThis The control in question.
    58 // @param aControl The control in question.
    57 //
    59 //
    58 // @return ETrue if the window group is in focus, otherwise EFalse
    60 // @return ETrue if the window group is in focus, otherwise EFalse
    59 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    60 //
    62 //
    61 TBool IsFocusedWindowGroup( CAknNoteDialog* aThis )
    63 TBool IsFocusedWindowGroup( const CCoeControl* aControl )
    62     {
    64     {
    63     RWindowTreeNode* node = aThis->DrawableWindow();
    65     if( !aControl )
       
    66     	{
       
    67     	return EFalse;	
       
    68     	}
       
    69 
       
    70     RWindowTreeNode* node = aControl->DrawableWindow();
       
    71 
    64     // this code finds out if this control belongs to window group
    72     // this code finds out if this control belongs to window group
    65     // that is in focus, there are some rare cases when the latest opened
    73     // that is in focus, there are some rare cases when the latest opened
    66     // popup goes behind another one (e.g. system lock query -> power key menu)
    74     // popup goes behind another one (e.g. system lock query -> power key menu)
    67     // we don't want transition in that case
    75     // we don't want transition in that case
    68     RWsSession& wsSession = CEikonEnv::Static()->WsSession();
    76     RWsSession& wsSession = CEikonEnv::Static()->WsSession();
    69 
    77 
    70     if ( !node )
    78     if ( !node )
    71         {
    79         {
    72         return EFalse;
    80         return EFalse;
    73         }
    81         }
       
    82         
    74     TInt nodeWindowGroupId = node->WindowGroupId();
    83     TInt nodeWindowGroupId = node->WindowGroupId();
    75     TInt focusedWindowGroupId = wsSession.GetFocusWindowGroup();
    84     TInt focusedWindowGroupId = wsSession.GetFocusWindowGroup();
    76     
    85     
    77     if ( nodeWindowGroupId == focusedWindowGroupId )
    86     if ( nodeWindowGroupId == focusedWindowGroupId )
    78         {
    87         {
    79         return ETrue;
    88         return aControl->IsFocused();
    80         }
    89         }
    81 
    90 
    82     TInt count = wsSession.NumWindowGroups( 0 );
    91     TInt count = wsSession.NumWindowGroups( 0 );
    83 
    92 
    84     // because there is not leave here,so no need to use CleanupStack.
    93     // because there is not leave here,so no need to use CleanupStack.
    98             {
   107             {
    99             return ETrue;
   108             return ETrue;
   100             }
   109             }
   101         }
   110         }
   102     return EFalse;
   111     return EFalse;
   103     }
   112     }  
       
   113     
   104 
   114 
   105 //////////////////////////////////////////////////////////////////////
   115 //////////////////////////////////////////////////////////////////////
   106 // CAknNoteDialogExtension
   116 // CAknNoteDialogExtension
   107 //////////////////////////////////////////////////////////////////////
   117 //////////////////////////////////////////////////////////////////////
   108 NONSHARABLE_CLASS(CAknNoteDialogExtension) : public CBase
   118 NONSHARABLE_CLASS(CAknNoteDialogExtension) : public CBase
   179 //////////////////////////////////////////////////////////////////////
   189 //////////////////////////////////////////////////////////////////////
   180 
   190 
   181 EXPORT_C CAknNoteDialog::CAknNoteDialog() : CEikDialog(),
   191 EXPORT_C CAknNoteDialog::CAknNoteDialog() : CEikDialog(),
   182     iTimeoutInMicroseconds(ENoTimeout), iTone(ENoTone)
   192     iTimeoutInMicroseconds(ENoTimeout), iTone(ENoTone)
   183     {
   193     {
       
   194     _AKNTRACE_FUNC_ENTER;
   184     AKNTASHOOK_ADD( this, "CAknNoteDialog" );
   195     AKNTASHOOK_ADD( this, "CAknNoteDialog" );
       
   196     _AKNTRACE_FUNC_EXIT;
   185     }
   197     }
   186 
   198 
   187 EXPORT_C CAknNoteDialog::CAknNoteDialog(const TTone& aTone, const TTimeout& aTimeout) :
   199 EXPORT_C CAknNoteDialog::CAknNoteDialog(const TTone& aTone, const TTimeout& aTimeout) :
   188     CEikDialog(), iTimeoutInMicroseconds(aTimeout), iTone(aTone)
   200     CEikDialog(), iTimeoutInMicroseconds(aTimeout), iTone(aTone)
   189     {
   201     {
       
   202     _AKNTRACE_FUNC_ENTER;
       
   203     _AKNTRACE("iTimeoutInMicroseconds = %d", aTimeout);
   190     AKNTASHOOK_ADD( this, "CAknNoteDialog" );
   204     AKNTASHOOK_ADD( this, "CAknNoteDialog" );
       
   205     _AKNTRACE_FUNC_EXIT;
   191     }
   206     }
   192 
   207 
   193 EXPORT_C CAknNoteDialog::CAknNoteDialog(CEikDialog** aSelfPtr,const TTone& aTone, const TTimeout& aTimeout) :
   208 EXPORT_C CAknNoteDialog::CAknNoteDialog(CEikDialog** aSelfPtr,const TTone& aTone, const TTimeout& aTimeout) :
   194     CEikDialog(), iTimeoutInMicroseconds(aTimeout), iSelfPtr(aSelfPtr), iTone(aTone)
   209     CEikDialog(), iTimeoutInMicroseconds(aTimeout), iSelfPtr(aSelfPtr), iTone(aTone)
   195      {
   210      {
       
   211      _AKNTRACE_FUNC_ENTER;
       
   212      _AKNTRACE("iTimeoutInMicroseconds = %d", aTimeout);
   196      AKNTASHOOK_ADD( this, "CAknNoteDialog" );
   213      AKNTASHOOK_ADD( this, "CAknNoteDialog" );
       
   214      _AKNTRACE_FUNC_EXIT;
   197      }
   215      }
   198 
   216 
   199 EXPORT_C CAknNoteDialog::~CAknNoteDialog()
   217 EXPORT_C CAknNoteDialog::~CAknNoteDialog()
   200     {
   218     {
       
   219     _AKNTRACE_FUNC_ENTER;
   201     AKNTASHOOK_REMOVE();
   220     AKNTASHOOK_REMOVE();
   202 // FIXME: Experimental heuristics for determining popup type
   221 // FIXME: Experimental heuristics for determining popup type
   203 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
   222 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
   204 
   223 
   205     if ( GfxTransEffect::IsRegistered( this ) )
   224     if ( GfxTransEffect::IsRegistered( this ) )
   223         iSelfPtr = NULL;
   242         iSelfPtr = NULL;
   224         }
   243         }
   225 
   244 
   226     delete iControlAttributes;
   245     delete iControlAttributes;
   227     delete iNoteExtension;
   246     delete iNoteExtension;
       
   247     _AKNTRACE_FUNC_EXIT;
   228     }
   248     }
   229 
   249 
   230 EXPORT_C void CAknNoteDialog::SetTimeout(const TTimeout& aTimeout)
   250 EXPORT_C void CAknNoteDialog::SetTimeout(const TTimeout& aTimeout)
   231     {
   251     {
   232     iTimeoutInMicroseconds = aTimeout;
   252     iTimeoutInMicroseconds = aTimeout;
   380     return EKeyWasConsumed;
   400     return EKeyWasConsumed;
   381     }
   401     }
   382 
   402 
   383 EXPORT_C void CAknNoteDialog::LayoutAndDraw()
   403 EXPORT_C void CAknNoteDialog::LayoutAndDraw()
   384     {
   404     {
       
   405     _AKNTRACE_FUNC_ENTER;
   385     if (IsActivated())
   406     if (IsActivated())
   386         {
   407         {
   387         TRect screenRect = iAvkonAppUi->ApplicationRect();
   408         TRect screenRect = iAvkonAppUi->ApplicationRect();
   388         SetSizeAndPosition(PreferredSize( screenRect.Size()/*TSize(AKN_LAYOUT_WINDOW_screen.iW,AKN_LAYOUT_WINDOW_screen.iH)*/));
   409         SetSizeAndPosition(PreferredSize( screenRect.Size()/*TSize(AKN_LAYOUT_WINDOW_screen.iW,AKN_LAYOUT_WINDOW_screen.iH)*/));
   389         DrawNow();
   410         DrawNow();
   391         // Tell the attributes that the note has been fully drawn.
   412         // Tell the attributes that the note has been fully drawn.
   392         // Optimized text drawing is allowed only after this.
   413         // Optimized text drawing is allowed only after this.
   393         CAknNoteAttributes* attr = ControlAttributes();
   414         CAknNoteAttributes* attr = ControlAttributes();
   394         if ( attr )
   415         if ( attr )
   395             {
   416             {
   396             RDebug::Print(_L("CAknNoteDialog allowing opt. draw, %d"), (TUint)this );            
   417             _AKNTRACE( "[%s][%s] allowing opt. draw,0x%x", "CAknNoteDialog", "LayoutAndDraw", this );
   397             attr->AllowOptimizedDrawing();
   418             attr->AllowOptimizedDrawing();
   398             }
   419             }
   399         }
   420         }
       
   421     _AKNTRACE_FUNC_EXIT;
   400     }
   422     }
   401 
   423 
   402 EXPORT_C TInt CAknNoteDialog::RunLD()
   424 EXPORT_C TInt CAknNoteDialog::RunLD()
   403     {
   425     {
       
   426     _AKNTRACE_FUNC_ENTER;
   404     PlayTone();
   427     PlayTone();
   405     ReportUserActivity();
   428     ReportUserActivity();
   406 
   429 
   407 // FIXME: Experimental heuristics for finding out popup context from image/animation
   430 // FIXME: Experimental heuristics for finding out popup context from image/animation
   408 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS    
   431 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS    
   412         {
   435         {
   413         GfxTransEffect::Register( this, TUid::Uid( uid ) );
   436         GfxTransEffect::Register( this, TUid::Uid( uid ) );
   414         CAknTransitionUtils::RemoveData( ( TInt )NoteControl() );
   437         CAknTransitionUtils::RemoveData( ( TInt )NoteControl() );
   415         }
   438         }
   416 #endif
   439 #endif
   417         
   440 
       
   441     _AKNTRACE_FUNC_EXIT;    
   418     return CEikDialog::RunLD();
   442     return CEikDialog::RunLD();
   419     }
   443     }
   420 
   444 
   421 EXPORT_C TInt CAknNoteDialog::StaticDeleteL(TAny *aThis)
   445 EXPORT_C TInt CAknNoteDialog::StaticDeleteL(TAny *aThis)
   422     {
   446     {
       
   447     _AKNTRACE_FUNC_ENTER;
   423     CAknNoteDialog* self = REINTERPRET_CAST(CAknNoteDialog*,aThis);
   448     CAknNoteDialog* self = REINTERPRET_CAST(CAknNoteDialog*,aThis);
   424         
   449         
   425 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS           
   450 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS           
   426     if ( self->IsVisible() && GfxTransEffect::IsRegistered( self ) &&
   451     if ( self->IsVisible() && GfxTransEffect::IsRegistered( self ) &&
   427         IsFocusedWindowGroup( self ) )
   452          IsFocusedWindowGroup( self ) )
   428 		{
   453 		{
   429         TBool rsWasEnabled( EFalse );
   454         TBool rsWasEnabled( EFalse );
   430         if( !CAknEnv::Static()->TransparencyEnabled() && self->DrawableWindow() && self->Window().IsRedrawStoreEnabled() )
   455         if( !CAknEnv::Static()->TransparencyEnabled() && self->DrawableWindow() && self->Window().IsRedrawStoreEnabled() )
   431             {
   456             {
   432             rsWasEnabled = ETrue;
   457             rsWasEnabled = ETrue;
   476             self->iTimer->Cancel();
   501             self->iTimer->Cancel();
   477         self->OkToExitL(KErrCancel);
   502         self->OkToExitL(KErrCancel);
   478         self->ExitSleepingDialog();
   503         self->ExitSleepingDialog();
   479         self->NoteControl()->Reset();
   504         self->NoteControl()->Reset();
   480         }
   505         }
       
   506     _AKNTRACE_FUNC_EXIT;
   481     return EFalse;
   507     return EFalse;
   482     }
   508     }
   483 
   509 
   484 
   510 
   485 EXPORT_C void CAknNoteDialog::SetSizeAndPosition( const TSize& aSize )
   511 EXPORT_C void CAknNoteDialog::SetSizeAndPosition( const TSize& aSize )
   486     {
   512     {
       
   513     _AKNTRACE_FUNC_ENTER;
   487     SetBorder( TGulBorder::ENone );
   514     SetBorder( TGulBorder::ENone );
   488     CAknNoteControl* note = NoteControl();
   515     CAknNoteControl* note = NoteControl();
   489     if (note)
   516     if (note)
   490         {
   517         {
   491         if (!ControlAttributes()->IsLayoutNeeded()) // if we have a note control, there must be attributes also
   518         if (!ControlAttributes()->IsLayoutNeeded()) // if we have a note control, there must be attributes also
   507             AknLayoutUtils::LayoutControl(this, mainPane, dialogLay);
   534             AknLayoutUtils::LayoutControl(this, mainPane, dialogLay);
   508             }
   535             }
   509    
   536    
   510         ControlAttributes()->SetLayoutDone();                
   537         ControlAttributes()->SetLayoutDone();                
   511         }
   538         }
       
   539     _AKNTRACE_FUNC_EXIT;
   512     }
   540     }
   513 
   541 
   514 EXPORT_C void CAknNoteDialog::PreLayoutDynInitL()
   542 EXPORT_C void CAknNoteDialog::PreLayoutDynInitL()
   515     {
   543     {
   516     TransferControlAttributes();
   544     TransferControlAttributes();
   659 #endif
   687 #endif
   660 
   688 
   661 
   689 
   662 EXPORT_C void CAknNoteDialog::HandleResourceChange(TInt aType)
   690 EXPORT_C void CAknNoteDialog::HandleResourceChange(TInt aType)
   663     {
   691     {
       
   692     _AKNTRACE_FUNC_ENTER;
   664     if(aType==KEikDynamicLayoutVariantSwitch)
   693     if(aType==KEikDynamicLayoutVariantSwitch)
   665         {
   694         {
   666         if (!IsVisible())
   695         if (!IsVisible())
   667         	{
   696         	{
   668         	// a invisible note dialog is assumed to be a sleeping dialog
   697         	// a invisible note dialog is assumed to be a sleeping dialog
   695             NoteControl()->Layout();
   724             NoteControl()->Layout();
   696             }
   725             }
   697         }
   726         }
   698 
   727 
   699     CEikDialog::HandleResourceChange(aType);
   728     CEikDialog::HandleResourceChange(aType);
       
   729     _AKNTRACE_FUNC_EXIT;
   700     }
   730     }
   701 
   731 
   702 /**
   732 /**
   703  * Deprecated methods
   733  * Deprecated methods
   704  */
   734  */
   829 //------------------------------------------------------------------------------
   859 //------------------------------------------------------------------------------
   830 //
   860 //
   831 
   861 
   832 EXPORT_C void CAknNoteDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   862 EXPORT_C void CAknNoteDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   833     {
   863     {
       
   864     _AKNTRACE_FUNC_ENTER;
   834     if ( AknLayoutUtils::PenEnabled() )
   865     if ( AknLayoutUtils::PenEnabled() )
   835         {
   866         {
   836         CCoeControl* ctrl = GrabbingComponent();
   867         CCoeControl* ctrl = GrabbingComponent();
   837         CCoeControl::HandlePointerEventL(aPointerEvent);
   868         CCoeControl::HandlePointerEventL(aPointerEvent);
   838         
   869         // Add tactile feedbacup when tap can close note.
   839         if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   870         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   840             {
   871             {
   841             if ( DialogFlags()&EEikDialogFlagCloseDialogWhenTapped )
   872             if ( DialogFlags() & EEikDialogFlagCloseDialogWhenTapped )
   842                 {
   873                 {
   843                 //Touch release gives pop-up effect if note can be dismissed.
   874                 if( Rect().Contains( aPointerEvent.iPosition ) )
       
   875                     {
       
   876                     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   877                     if ( feedback )
       
   878                         {
       
   879                         feedback->InstantFeedback( ETouchFeedbackPopUp );
       
   880                         }
       
   881                     }
       
   882                 }
       
   883             }
       
   884         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   885             {
       
   886             if ( DialogFlags() & EEikDialogFlagCloseDialogWhenTapped )
       
   887                 {
   844                 if ( ctrl )
   888                 if ( ctrl )
   845                     {
   889                     {
   846                     // if grabbingComponent and dialog has 'close dialog when 
   890                     // if grabbingComponent and dialog has 'close dialog when 
   847                     // tapped flag', then close dialog here because tapping happened. 
   891                     // tapped flag', then close dialog here because tapping happened. 
   848                     if ( !IsBeingDestroyed() )
   892                     if ( !IsBeingDestroyed() )
   849                         {
   893                         {
   850                         StaticDeleteL( this );
   894                         StaticDeleteL( this );
   851                         }
   895                         }
   852                     
   896                     
   853                     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   854                     if ( feedback )
       
   855                         {
       
   856                         feedback->InstantFeedback( ETouchFeedbackPopUp );
       
   857                         }
       
   858                     }
   897                     }
   859                 }
   898                 }
   860             }
   899             }
   861         }
   900         }
       
   901     _AKNTRACE_FUNC_EXIT;
   862     }
   902     }
   863 
   903 
   864 
   904 
   865 EXPORT_C void* CAknNoteDialog::ExtensionInterface( TUid /*aInterface*/ ) 
   905 EXPORT_C void* CAknNoteDialog::ExtensionInterface( TUid /*aInterface*/ ) 
   866     { 
   906     {