uifw/AvKon/src/akndiscreetpopupcontrol.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Discreet popup control
       
    15 *
       
    16 */
       
    17 
       
    18 #include <aknappui.h>
       
    19 #include <aknenv.h>
       
    20 #include <AknPriv.hrh>
       
    21 #include <aknsoundsystem.h>
       
    22 #include <AknsUtils.h>
       
    23 #include <AknTasHook.h>
       
    24 #include <AknUtils.h>
       
    25 #include <apgwgnam.h>
       
    26 #include <bautils.h>
       
    27 #include <barsread.h>
       
    28 #include <gulicon.h>
       
    29 #include <gfxtranseffect/gfxtranseffect.h>
       
    30 #include <akntransitionutils.h>
       
    31 #include <avkon.hrh>
       
    32 #include "akndiscreetpopupcontrol.h"
       
    33 #include "akndiscreetpopupdrawer.h"
       
    34 
       
    35 _LIT( KDiscreetPopupWindowGroupName, "Discreet pop-up" );
       
    36 
       
    37 const TInt KShortTimeout( 1500000 );
       
    38 const TInt KLongTimeout( 3000000 );
       
    39 const TInt KGlobalShowOrdinalPriority( ECoeWinPriorityAlwaysAtFront * 4 );
       
    40 const TInt KLocalShowOrdinalPriority( ECoeWinPriorityNormal + 1 );
       
    41 const TInt KLocalHideOrdinalPosition( -10 );
       
    42 
       
    43 /**
       
    44  * Internal discreet popup control flags.
       
    45  */
       
    46 enum TAknDiscreetPopupControlFlags
       
    47     {
       
    48     EPressedDown,     // Pointer down is received in popup area
       
    49     EDismissed,       // Popup is dismissed (pointer up is received in popup area)
       
    50     EGlobal,          // Popup is global
       
    51     EDragged          // Pointer is dragged while popup open
       
    52     };
       
    53 
       
    54 
       
    55 // ======== MEMBER FUNCTIONS ========
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CAknDiscreetPopupControl::NewL
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 EXPORT_C CAknDiscreetPopupControl* CAknDiscreetPopupControl::NewL( 
       
    62     const TBool aGlobal,
       
    63     const TDesC& aTitle, 
       
    64     const TDesC& aText, 
       
    65     CGulIcon* aIcon, 
       
    66     const TAknsItemID& aSkinId,
       
    67     const TDesC& aBitmapFile,
       
    68     const TInt& aBitmapId,
       
    69     const TInt& aMaskId,
       
    70     const TInt& aFlags, 
       
    71     const TInt& aCommand,
       
    72     const TInt& aPopupId,
       
    73     MEikCommandObserver* aCommandObserver )
       
    74     {
       
    75     CAknDiscreetPopupControl* self = 
       
    76         CAknDiscreetPopupControl::NewLC( aGlobal,
       
    77                                          aTitle,
       
    78                                          aText,
       
    79                                          aIcon,
       
    80                                          aSkinId,
       
    81                                          aBitmapFile,
       
    82                                          aBitmapId,
       
    83                                          aMaskId,
       
    84                                          aFlags,
       
    85                                          aCommand,
       
    86                                          aPopupId,
       
    87                                          aCommandObserver );
       
    88     CleanupStack::Pop( self );
       
    89     return self;
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CAknDiscreetPopupControl::NewL
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 EXPORT_C CAknDiscreetPopupControl* CAknDiscreetPopupControl::NewL(
       
    98     const TBool aGlobal,		
       
    99     const TInt& aResourceId,
       
   100     const TDesC& aResourceFile,
       
   101     const TInt& aCommand,
       
   102     const TInt& aPopupId,
       
   103     MEikCommandObserver* aCommandObserver )
       
   104     {
       
   105     CAknDiscreetPopupControl* self = 
       
   106         CAknDiscreetPopupControl::NewLC( aGlobal, 
       
   107                                          aCommand, 
       
   108                                          aPopupId, 
       
   109                                          aCommandObserver );
       
   110                                          
       
   111     self->ConstructFromResourceL( aResourceId, aResourceFile );
       
   112     CleanupStack::Pop( self );
       
   113     return self;
       
   114     }
       
   115 
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CAknDiscreetPopupControl::NewLC
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 CAknDiscreetPopupControl* CAknDiscreetPopupControl::NewLC(
       
   122     const TBool aGlobal,
       
   123     const TDesC& aTitle, 
       
   124     const TDesC& aText,
       
   125     CGulIcon* aIcon, 
       
   126     const TAknsItemID& aSkinId,
       
   127     const TDesC& aBitmapFile,
       
   128     const TInt& aBitmapId,
       
   129     const TInt& aMaskId,
       
   130     const TInt& aFlags, 
       
   131     const TInt& aCommand,
       
   132     const TInt& aPopupId,
       
   133     MEikCommandObserver* aCommandObserver )
       
   134     {
       
   135     CAknDiscreetPopupControl* self = 
       
   136         new ( ELeave ) CAknDiscreetPopupControl( aGlobal, 
       
   137                                                  aFlags, 
       
   138                                                  aCommand,
       
   139                                                  aPopupId, 
       
   140                                                  aCommandObserver );
       
   141     CleanupStack::PushL( self );
       
   142     self->ConstructL();
       
   143     self->ConstructDrawerL( aTitle, 
       
   144                             aText, 
       
   145                             aIcon,
       
   146                             aSkinId,
       
   147                             aBitmapFile,
       
   148                             aBitmapId,
       
   149                             aMaskId );
       
   150     return self;
       
   151     }
       
   152 
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // CAknDiscreetPopupControl::NewLC
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 CAknDiscreetPopupControl* CAknDiscreetPopupControl::NewLC(
       
   159     const TBool aGlobal,
       
   160     const TInt& aCommand,
       
   161     const TInt& aPopupId,
       
   162     MEikCommandObserver* aCommandObserver )
       
   163     {
       
   164     CAknDiscreetPopupControl* self = new ( ELeave ) CAknDiscreetPopupControl(
       
   165         aGlobal, 0, aCommand, aPopupId, aCommandObserver );
       
   166     CleanupStack::PushL( self );
       
   167     self->ConstructL();
       
   168     return self;
       
   169     }
       
   170 
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CAknDiscreetPopupControl::~CAknDiscreetPopupControl
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 CAknDiscreetPopupControl::~CAknDiscreetPopupControl()
       
   177     {
       
   178     AKNTASHOOK_REMOVE();
       
   179     if ( IsVisible() )
       
   180         {
       
   181         HidePopup();
       
   182         }
       
   183 
       
   184     GfxTransEffect::Deregister( this );
       
   185 
       
   186     if ( iInternalFlags.IsSet( EGlobal ) )
       
   187         {
       
   188         iWindowGroup.Close();
       
   189         }
       
   190     delete iTimer;	
       
   191     delete iDrawer;
       
   192     }
       
   193 
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // CAknDiscreetPopupControl::HandleDiscreetPopupActionL
       
   197 // ---------------------------------------------------------------------------
       
   198 
       
   199 EXPORT_C void CAknDiscreetPopupControl::HandleDiscreetPopupActionL(
       
   200         const TInt& aType )
       
   201     {
       
   202     switch ( aType )
       
   203         {
       
   204         case EAknDiscreetPopupShow:
       
   205             {
       
   206             ShowPopupL();
       
   207             break;
       
   208             }
       
   209         case EAknDiscreetPopupHide:
       
   210             {
       
   211             break;
       
   212             }
       
   213         case EAknDiscreetPopupAnotherLaunched:
       
   214             {
       
   215             SetPressedDownState( EFalse );
       
   216             break;
       
   217             }
       
   218         default:
       
   219             {
       
   220             break;
       
   221             }
       
   222         }
       
   223     }
       
   224 
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 // CAknDiscreetPopupControl::PopupId
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 EXPORT_C TInt CAknDiscreetPopupControl::PopupId()
       
   231     {
       
   232     return iPopupId;
       
   233     }    
       
   234 
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CAknDiscreetPopupControl::TimeOut
       
   238 // ---------------------------------------------------------------------------
       
   239 //
       
   240 TInt CAknDiscreetPopupControl::TimeOut( TAny* aObject )
       
   241     {
       
   242     static_cast<CAknDiscreetPopupControl*>( aObject )->DoTimeOut();
       
   243     return 1;
       
   244     }
       
   245 
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 // CAknDiscreetPopupControl::MakeVisible
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 void CAknDiscreetPopupControl::MakeVisible( TBool aVisible )
       
   252     {
       
   253     CCoeControl::MakeVisible( aVisible );
       
   254  
       
   255     if( iInternalFlags.IsSet( EGlobal ) )
       
   256         {
       
   257         iWindowGroup.SetOrdinalPosition( 0, KGlobalShowOrdinalPriority );
       
   258         }
       
   259     else
       
   260         {
       
   261         Window().SetOrdinalPosition( 0, KLocalShowOrdinalPriority );
       
   262         }    
       
   263 
       
   264     UpdateNonFadingStatus();
       
   265     }
       
   266 
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CAknDiscreetPopupControl::CAknDiscreetPopupControl
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 CAknDiscreetPopupControl::CAknDiscreetPopupControl( 
       
   273     const TBool& aGlobal, 
       
   274     const TInt& aFlags,
       
   275     const TInt& aCommand,
       
   276     const TInt& aPopupId,  
       
   277     MEikCommandObserver* aCommandObserver )
       
   278     : 
       
   279     iFlags( aFlags ),
       
   280     iCommand( 0 ),
       
   281     iPopupId ( aPopupId ),
       
   282     iCommandObserver( NULL ),
       
   283     iDrawer( NULL ),
       
   284     iFeedBack( MTouchFeedback::Instance() )
       
   285     {
       
   286     RThread thread;
       
   287     
       
   288     if ( aGlobal || thread.Name() == EIKAPPUI_SERVER_THREAD_NAME )
       
   289         {
       
   290         iInternalFlags.Set( EGlobal );
       
   291         }
       
   292 
       
   293     iInternalFlags.Set( EDismissed );
       
   294     iCommand = aCommand;
       
   295     iCommandObserver = aCommandObserver;
       
   296 
       
   297     GfxTransEffect::Register( this, KGfxDiscreetPopupControlUid );
       
   298     
       
   299     AKNTASHOOK_ADD( this, "CAknDiscreetPopupControl" );
       
   300     }
       
   301 
       
   302 
       
   303 // ---------------------------------------------------------------------------
       
   304 // CAknDiscreetPopupControl::ConstructL
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 void CAknDiscreetPopupControl::ConstructL()
       
   308     {
       
   309     if( iInternalFlags.IsSet( EGlobal ) )
       
   310         {
       
   311         RWsSession& wsSession = iCoeEnv->WsSession();
       
   312         iWindowGroup = RWindowGroup( wsSession );
       
   313         User::LeaveIfError( iWindowGroup.Construct( 
       
   314                                     ( TUint32 ) &iWindowGroup, EFalse ) );
       
   315         iWindowGroup.AutoForeground( EFalse );
       
   316 
       
   317         CApaWindowGroupName* name = 
       
   318                 CApaWindowGroupName::NewLC( wsSession, (TUint32) &iWindowGroup );
       
   319         name->SetHidden( ETrue );
       
   320         name->SetCaptionL( KDiscreetPopupWindowGroupName );
       
   321         User::LeaveIfError( name->SetWindowGroupName( iWindowGroup ));
       
   322         CleanupStack::PopAndDestroy( name );
       
   323 
       
   324         iWindowGroup.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront );
       
   325         
       
   326         // create control's window to own window group
       
   327         CreateWindowL( &iWindowGroup );	
       
   328         }
       
   329     else
       
   330         {
       
   331         CreateWindowL();
       
   332         Window().SetOrdinalPosition( KLocalHideOrdinalPosition );
       
   333         }
       
   334         
       
   335     iTimer = CPeriodic::NewL( 0 );
       
   336     
       
   337     EnableWindowTransparency();
       
   338 
       
   339     Window().SetPointerGrab( ETrue );
       
   340     EnableDragEvents();
       
   341     MakeVisible( EFalse );
       
   342     }
       
   343 
       
   344 
       
   345 // ---------------------------------------------------------------------------
       
   346 // CAknDiscreetPopupControl::ConstructDrawerL
       
   347 // ---------------------------------------------------------------------------
       
   348 //
       
   349 void CAknDiscreetPopupControl::ConstructDrawerL( 
       
   350     const TDesC& aTitleText, const TDesC& aBodyText, CGulIcon* aIcon,
       
   351     const TAknsItemID& aSkinId, const TDesC& aBitmapFile, 
       
   352     const TInt& aBitmapId, const TInt& aMaskId )
       
   353     {
       
   354     if ( !iDrawer )
       
   355         {
       
   356         iDrawer = CAknDiscreetPopupDrawer::NewL( this, 
       
   357                                                  aTitleText, 
       
   358                                                  aBodyText, 
       
   359                                                  aIcon, 
       
   360                                                  aSkinId, 
       
   361                                                  aBitmapFile, 
       
   362                                                  aBitmapId, 
       
   363                                                  aMaskId,
       
   364                                                  iCommand != 0 );
       
   365         SetRect( iDrawer->LayoutPopup() );
       
   366         ActivateL();
       
   367         }
       
   368     }
       
   369 
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // CAknDiscreetPopupControl::ConstructFromResourceL
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CAknDiscreetPopupControl::ConstructFromResourceL( 
       
   376     const TInt& aResourceId, const TDesC& aResourceFile )
       
   377     {
       
   378     // Add resource file if needed
       
   379     if ( aResourceFile != KNullDesC )
       
   380         {
       
   381         TFileName resourceFile;
       
   382         resourceFile.Append( aResourceFile );
       
   383         BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resourceFile );
       
   384         iEikonEnv->AddResourceFileL( resourceFile );
       
   385         }
       
   386 
       
   387     // Construct according to resource id
       
   388     if ( aResourceId )
       
   389         {
       
   390         TResourceReader reader;
       
   391         iCoeEnv->CreateResourceReaderLC( reader, aResourceId );
       
   392         ConstructFromResourceL( reader );
       
   393         CleanupStack::PopAndDestroy(); // reader
       
   394         }
       
   395     }
       
   396 
       
   397 
       
   398 // ---------------------------------------------------------------------------
       
   399 // CAknDiscreetPopupControl::DoTimeOut
       
   400 // ---------------------------------------------------------------------------
       
   401 //
       
   402 void CAknDiscreetPopupControl::DoTimeOut()
       
   403     {
       
   404     if ( !iInternalFlags.IsSet( EPressedDown ) )
       
   405         {
       
   406         TRAP_IGNORE( RequestExitL() );
       
   407         }
       
   408     else
       
   409         {
       
   410         iTimer->Cancel();
       
   411         }
       
   412     }
       
   413 
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // CAknDiscreetPopupControl::RequestExitL
       
   417 // Popup exit when popup is completely invisible.
       
   418 // ---------------------------------------------------------------------------
       
   419 //
       
   420 void CAknDiscreetPopupControl::RequestExitL()
       
   421     {
       
   422     if( iCommandObserver && !iInternalFlags.IsSet( EGlobal ) )
       
   423         {
       
   424         iCommandObserver->ProcessCommandL( EAknDiscreetPopupCmdClose );
       
   425         }
       
   426     HidePopup();
       
   427     ReportEventL( MCoeControlObserver::EEventRequestExit );
       
   428     iInternalFlags.Clear( EPressedDown );
       
   429     }
       
   430 
       
   431 
       
   432 // ---------------------------------------------------------------------------
       
   433 // CAknDiscreetPopupControl::NotifyObserverL
       
   434 // ---------------------------------------------------------------------------
       
   435 //
       
   436 void CAknDiscreetPopupControl::NotifyObserverL()
       
   437     {
       
   438     if ( iCommand != 0 && iCommandObserver )
       
   439         {
       
   440         // Play feedback if there is command associated with the popup
       
   441         ImmediateFeedback( ETouchFeedbackSensitive );
       
   442         iCommandObserver->ProcessCommandL( iCommand );
       
   443         }
       
   444     }
       
   445 
       
   446 
       
   447 // -----------------------------------------------------------------------------
       
   448 // CAknDiscreetPopupControl::ImmediateFeedback
       
   449 // -----------------------------------------------------------------------------
       
   450 //
       
   451 void CAknDiscreetPopupControl::ImmediateFeedback( TTouchLogicalFeedback aType )
       
   452     {
       
   453     if ( iFeedBack )
       
   454         {
       
   455         iFeedBack->InstantFeedback( aType );
       
   456         }
       
   457     }
       
   458 
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CAknDiscreetPopupControl::UpdateNonFadingStatus
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 void CAknDiscreetPopupControl::UpdateNonFadingStatus()
       
   465     {
       
   466     // Local popups are nonfading when application in foreground
       
   467     // Global popups are always nonfading
       
   468     TBool newStatus( IsVisible() );
       
   469     TBool changeStatus( 
       
   470             !Window().IsNonFading() && newStatus 
       
   471             || Window().IsNonFading() && !newStatus );
       
   472     TBool changeFadeState( EFalse );
       
   473     TBool newFadeState( EFalse );
       
   474 
       
   475     if ( !iInternalFlags.IsSet( EGlobal ) && newStatus )
       
   476         {
       
   477         CAknAppUi* appUi = AppUi();
       
   478         if ( appUi && !appUi->IsForeground() )
       
   479             {
       
   480             newStatus = EFalse;
       
   481             changeStatus = ETrue;
       
   482             if ( changeStatus )
       
   483                 {
       
   484                 Window().SetNonFading( newStatus );
       
   485                 }
       
   486             if ( appUi->IsFaded() )
       
   487                 {
       
   488                 changeFadeState = ETrue;
       
   489                 newFadeState = ETrue;
       
   490                 }
       
   491             }
       
   492         }
       
   493 
       
   494     if ( changeStatus )
       
   495         {
       
   496         Window().SetNonFading( newStatus );
       
   497         }
       
   498     if ( changeFadeState )
       
   499         {
       
   500         Window().SetFaded( newFadeState, RWindowTreeNode::EFadeWindowOnly );
       
   501         }
       
   502     }
       
   503 
       
   504 
       
   505 // ---------------------------------------------------------------------------
       
   506 // CAknDiscreetPopupControl::SetPressedDownState
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 void CAknDiscreetPopupControl::SetPressedDownState( const TBool& aPressedDown )
       
   510     {
       
   511     // Reset pressed-down state
       
   512     if ( !aPressedDown 
       
   513         && ( iInternalFlags.IsSet( EPressedDown ) 
       
   514         || iInternalFlags.IsSet( EDragged ) ) )
       
   515         {
       
   516         iInternalFlags.Clear( EDragged );
       
   517         iInternalFlags.Clear( EPressedDown );
       
   518         }
       
   519     // Set pressed-down state
       
   520     else if ( aPressedDown && !iInternalFlags.IsSet( EPressedDown ) )
       
   521         {
       
   522         iInternalFlags.Set( EPressedDown );
       
   523         }
       
   524     }
       
   525 
       
   526 
       
   527 // ---------------------------------------------------------------------------
       
   528 // CAknDiscreetPopupControl::ShowPopupL
       
   529 // ---------------------------------------------------------------------------
       
   530 //
       
   531 void CAknDiscreetPopupControl::ShowPopupL()
       
   532     {
       
   533     AppUi()->AddToStackL( 
       
   534             this, 
       
   535             ECoeStackPriorityDefault,
       
   536             ECoeStackFlagRefusesAllKeys |
       
   537             ECoeStackFlagRefusesFocus );
       
   538 
       
   539     User::ResetInactivityTime();
       
   540 
       
   541     PlayTone();
       
   542     
       
   543     if ( GfxTransEffect::IsRegistered( this ) )
       
   544         {
       
   545         iInternalFlags.Clear( EDismissed );
       
   546         GfxTransEffect::Begin( this, KGfxControlAppearAction );
       
   547         MakeVisible( ETrue );
       
   548         GfxTransEffect::SetDemarcation( this, iPosition );
       
   549         GfxTransEffect::End( this );
       
   550         }
       
   551     else
       
   552         {
       
   553         MakeVisible( ETrue );
       
   554         }
       
   555 
       
   556     TTimeIntervalMicroSeconds32 timeout( KShortTimeout );
       
   557     
       
   558     if ( iFlags & KAknDiscreetPopupDurationLong )
       
   559         {
       
   560         timeout = KLongTimeout;
       
   561         }
       
   562     
       
   563     iTimer->Start( timeout, 
       
   564                    0, 
       
   565                    TCallBack( TimeOut, this ) );
       
   566     }
       
   567 
       
   568 
       
   569 // ---------------------------------------------------------------------------
       
   570 // CAknDiscreetPopupControl::HidePopup
       
   571 // ---------------------------------------------------------------------------
       
   572 //
       
   573 void CAknDiscreetPopupControl::HidePopup()
       
   574     {
       
   575     if ( GfxTransEffect::IsRegistered( this ) )
       
   576         {
       
   577         GfxTransEffect::Begin( this, KGfxControlDisappearAction );
       
   578         MakeVisible( EFalse );
       
   579         GfxTransEffect::End( this );
       
   580         }
       
   581     else
       
   582         {
       
   583         MakeVisible( EFalse );
       
   584         }
       
   585 
       
   586     AppUi()->RemoveFromStack( this );
       
   587     }
       
   588 
       
   589 
       
   590 // ---------------------------------------------------------------------------
       
   591 // CAknDiscreetPopupControl::AppUi
       
   592 // ---------------------------------------------------------------------------
       
   593 //
       
   594 CAknAppUi* CAknDiscreetPopupControl::AppUi()
       
   595     {
       
   596     return static_cast<CAknAppUi*>( iCoeEnv->AppUi() );
       
   597     }
       
   598 
       
   599 
       
   600 // ---------------------------------------------------------------------------
       
   601 // CAknDiscreetPopupControl::PlayTone
       
   602 // ---------------------------------------------------------------------------
       
   603 //
       
   604 void CAknDiscreetPopupControl::PlayTone()
       
   605     {
       
   606     // Play popup tone if one is defined with flags
       
   607     TInt toneId( 0 );
       
   608     if ( iFlags & KAknDiscreetPopupConfirmationTone )
       
   609         {
       
   610         toneId = EAvkonSIDConfirmationTone;
       
   611         }
       
   612     else if ( iFlags & KAknDiscreetPopupWarningTone )
       
   613         {
       
   614         toneId = EAvkonSIDWarningTone;
       
   615         }
       
   616     else if ( iFlags & KAknDiscreetPopupErrorTone )
       
   617         {
       
   618         toneId = EAvkonSIDErrorTone;
       
   619         }
       
   620     if ( toneId )
       
   621         {
       
   622         CAknKeySoundSystem* soundSystem = AppUi()->KeySounds();
       
   623         if ( soundSystem )
       
   624             {
       
   625             soundSystem->PlaySound( toneId );
       
   626             }
       
   627         }
       
   628     }
       
   629 
       
   630 
       
   631 // ---------------------------------------------------------------------------
       
   632 // CAknDiscreetPopupControl::Draw
       
   633 // ---------------------------------------------------------------------------
       
   634 //
       
   635 void CAknDiscreetPopupControl::Draw( const TRect& /*aRect*/ ) const
       
   636     {
       
   637     if ( !iDrawer )
       
   638         {
       
   639         return;
       
   640         }
       
   641 
       
   642     iDrawer->Draw( SystemGc(), Rect() );
       
   643     }
       
   644 
       
   645 
       
   646 // ---------------------------------------------------------------------------
       
   647 // CAknDiscreetPopupControl::ConstructFromResourceL
       
   648 // ---------------------------------------------------------------------------
       
   649 //
       
   650 void CAknDiscreetPopupControl::ConstructFromResourceL( 
       
   651     TResourceReader &aReader )
       
   652     {
       
   653     // Flags
       
   654     iFlags = aReader.ReadInt16();
       
   655 
       
   656     // Texts
       
   657     TPtrC titleText( aReader.ReadTPtrC() );
       
   658     TPtrC bodyText( aReader.ReadTPtrC() );
       
   659     
       
   660     // Bitmap info
       
   661     TPtrC bitmapFile( aReader.ReadTPtrC() );
       
   662     TInt bitmapId( aReader.ReadInt16() );
       
   663     TInt maskId( aReader.ReadInt16() );
       
   664     
       
   665     // Skin id info
       
   666     
       
   667     TAknsItemID skinId;     
       
   668     TInt major = aReader.ReadInt32();
       
   669     TInt minor = aReader.ReadInt32();
       
   670     if ( major > 0 && minor > 0 )
       
   671         {
       
   672         skinId.Set( major, minor ); 
       
   673         }
       
   674     else
       
   675         {
       
   676         skinId = KAknsIIDNone;
       
   677         }        
       
   678    
       
   679     // Extension, not used currently
       
   680     aReader.ReadInt32();
       
   681     
       
   682     ConstructDrawerL( titleText, 
       
   683                       bodyText, 
       
   684                       NULL, 
       
   685                       skinId, 
       
   686                       bitmapFile, 
       
   687                       bitmapId, 
       
   688                       maskId );
       
   689     }
       
   690 
       
   691 
       
   692 // ---------------------------------------------------------------------------
       
   693 // CAknDiscreetPopupControl::HandleResourceChange
       
   694 // ---------------------------------------------------------------------------
       
   695 //
       
   696 void CAknDiscreetPopupControl::HandleResourceChange( TInt aType )
       
   697     {
       
   698     CAknControl::HandleResourceChange( aType );
       
   699     switch ( aType )
       
   700         {
       
   701         case KEikDynamicLayoutVariantSwitch:
       
   702             {
       
   703             SetRect( iDrawer->LayoutPopup() );
       
   704             break;
       
   705             }
       
   706         case KAknMessageFocusLost:
       
   707         case KEikMessageUnfadeWindows:
       
   708             {
       
   709             SetPressedDownState( EFalse );
       
   710             UpdateNonFadingStatus();
       
   711             break;
       
   712             }
       
   713         case KEikMessageFadeAllWindows:
       
   714             {
       
   715             SetPressedDownState( EFalse );
       
   716             break;
       
   717             }
       
   718         default:
       
   719             {
       
   720             break;
       
   721             }
       
   722         }
       
   723     }
       
   724 
       
   725 
       
   726 // ---------------------------------------------------------------------------
       
   727 // CAknDiscreetPopupControl::HandlePointerEventL
       
   728 // Pointer up launches the popup-specific action. 
       
   729 // Popup is not dismissed when pointer is down on the popup.
       
   730 // ---------------------------------------------------------------------------
       
   731 //
       
   732 void CAknDiscreetPopupControl::HandlePointerEventL( 
       
   733     const TPointerEvent& aPointerEvent )
       
   734     {
       
   735     TBool eventInRect( Rect().Contains( aPointerEvent.iPosition ) );
       
   736 
       
   737     // Pointer down - set pressed-down state (popup completely visible while
       
   738     // pressed-down)
       
   739     if ( aPointerEvent.iType == TPointerEvent::EButton1Down
       
   740          && eventInRect
       
   741          && iInternalFlags.IsClear( EDismissed ) )
       
   742         {
       
   743         SetPressedDownState( ETrue );
       
   744         ImmediateFeedback( ETouchFeedbackSensitive );
       
   745         }
       
   746 
       
   747     // Pointer drag - reset pressed-down state if pointer out of popup area
       
   748     else if ( aPointerEvent.iType == TPointerEvent::EDrag )
       
   749         {
       
   750         iInternalFlags.Set( EDragged );
       
   751         if ( !eventInRect && iInternalFlags.IsSet( EPressedDown ) )
       
   752             {
       
   753             iInternalFlags.Clear( EPressedDown );
       
   754             }
       
   755         else if ( eventInRect && !iInternalFlags.IsSet( EPressedDown ) )
       
   756             {
       
   757             iInternalFlags.Set( EPressedDown );
       
   758             }
       
   759         }
       
   760 
       
   761     // Pointer up - reset pressed-down state 
       
   762     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   763         {
       
   764         if ( eventInRect )
       
   765             {
       
   766             NotifyObserverL();
       
   767             }
       
   768         
       
   769         // Start fading away
       
   770         if ( iInternalFlags.IsClear( EDismissed ) )
       
   771             {
       
   772             iInternalFlags.Set( EDismissed );
       
   773             RequestExitL();
       
   774             }
       
   775 
       
   776         SetPressedDownState( EFalse );
       
   777         }
       
   778     }
       
   779