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