mpxmusicplayer/mediakeyhandler/src/mpxnotifierdialog.cpp
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of media key handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <eikenv.h>
       
    22 #include <apgwgnam.h>
       
    23 #include <eikimage.h>
       
    24 #include <eikappui.h>
       
    25 #include <gulfont.h>
       
    26 #include <fontids.hrh>
       
    27 #include <AknUtils.h>
       
    28 #include <AknsBasicBackgroundControlContext.h>
       
    29 #include <AknsUtils.h>
       
    30 #include <AknsConstants.h>
       
    31 #include <AknsDrawUtils.h>
       
    32 #include <avkon.rsg>
       
    33 #include <eiklabel.h>
       
    34 #include <data_caging_path_literals.hrh>
       
    35 #include <aknlayoutscalable_apps.cdl.h>
       
    36 #include <skinlayout.cdl.h>
       
    37 #include <mpxmediakeyhandler.mbg>
       
    38 #include <mpxmediakeyhandler.rsg>
       
    39 #include <StringLoader.h>
       
    40 #include <mpxuser.h>
       
    41 #include <activeidle2domainpskeys.h>
       
    42 #include <mpxpskeywatcher.h>
       
    43 
       
    44 #include "mpxlog.h"
       
    45 #include "mpxnotifierdialog.h"
       
    46 
       
    47 using namespace AknLayoutScalable_Apps;
       
    48 
       
    49 
       
    50 // CONSTANTS
       
    51 const TInt KMPXComponentsCount = CMPXNotifierDialog::EMPXComponentsCount;
       
    52 
       
    53 const TInt KMPXOneSecInMicroSecs( 1000000 );
       
    54 const TInt KMPXOneHourInSeconds( 3600 );
       
    55 const TInt KMPXOneHundredHoursInSecs( 360000 );
       
    56 const TInt KMPXDurationDisplayResvLen( 10 );
       
    57 
       
    58 const TInt KMPXWindowPosition = 10;             // window group's priority
       
    59 const TInt KMPXInactivityTime = 4000000;        // 4 seconds - close window after this
       
    60 _LIT( KMPXInfoPopupWgName, "MPXInfoPopup" );    // window groups name
       
    61 
       
    62 _LIT( KMPXMediaKeyHandlerMbmFile, "mpxmediakeyhandler.mbm" );
       
    63 
       
    64 
       
    65 // ======== MEMBER FUNCTIONS ========
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // C++ default constructor can NOT contain any code, that
       
    69 // might leave.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CMPXNotifierDialog::CMPXNotifierDialog()
       
    73     {
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Symbian 2nd phase constructor can leave.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CMPXNotifierDialog::ConstructL()
       
    81     {
       
    82     // create a window group for popup
       
    83     // needed to prevent apps noticing this window
       
    84     RWsSession& wsSession = iCoeEnv->WsSession();
       
    85     iWindowGroup = RWindowGroup( wsSession );
       
    86     User::LeaveIfError( iWindowGroup.Construct( ( TUint32 )&iWindowGroup, EFalse ) );
       
    87     iWindowGroup.AutoForeground( EFalse );
       
    88     iEikonEnv->EikAppUi()->AddToStackL( this );
       
    89 
       
    90     CApaWindowGroupName* name = CApaWindowGroupName::NewLC(
       
    91         wsSession, ( TUint32 )&iWindowGroup );
       
    92     name->SetHidden( ETrue );
       
    93     name->SetCaptionL( KMPXInfoPopupWgName ); // Available to OOM watcher so this won't be closed
       
    94     User::LeaveIfError( name->SetWindowGroupName( iWindowGroup ) );
       
    95     CleanupStack::PopAndDestroy( name );
       
    96 
       
    97     iWindowGroup.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront );
       
    98 
       
    99     // create control's window to own window group
       
   100     CreateWindowL( &iWindowGroup );
       
   101 
       
   102     // create icon & label controls
       
   103     iSongLabel = new ( ELeave ) CEikLabel();
       
   104     iSongLabel->SetContainerWindowL( *this );
       
   105     iSongLabel->SetTextL( KNullDesC );
       
   106 
       
   107     iTimeLabel = new ( ELeave ) CEikLabel();
       
   108     iTimeLabel->SetContainerWindowL( *this );
       
   109     iTimeLabel->SetTextL( KNullDesC );
       
   110 
       
   111     CreateIconsL();
       
   112 
       
   113     // Timer
       
   114     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   115 
       
   116     // for watching when we go active idle
       
   117     iPSKeyWatcher = CMPXPSKeyWatcher::NewL( KPSUidAiInformation, KActiveIdleState, this );
       
   118 
       
   119     MakeVisible( EFalse );
       
   120     ResizeInfoPopup();
       
   121     ActivateL();
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // Two-phased constructor.
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 CMPXNotifierDialog* CMPXNotifierDialog::NewL()
       
   129     {
       
   130     CMPXNotifierDialog* self = new( ELeave ) CMPXNotifierDialog();
       
   131     CleanupStack::PushL( self );
       
   132     self->ConstructL();
       
   133     CleanupStack::Pop( self );
       
   134     return self;
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // Destructor
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 CMPXNotifierDialog::~CMPXNotifierDialog()
       
   142     {
       
   143     iEikonEnv->EikAppUi()->RemoveFromStack( this );
       
   144     delete iPSKeyWatcher;
       
   145     iWindowGroup.Close();
       
   146     if (iTimer)
       
   147         iTimer->Cancel();
       
   148     delete iTimer;
       
   149     delete iSongLabel;
       
   150     delete iTimeLabel;
       
   151     delete iPlayIcon;
       
   152     delete iPauseIcon;
       
   153     delete iFFIcon;
       
   154     delete iFRIcon;
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // Shows pop-up dialog.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CMPXNotifierDialog::ShowInfoPopupL(
       
   162     TMPXPlaybackPopupIcons aIcon,
       
   163     const TDesC& aTitle,
       
   164     TInt aTime,
       
   165     TMPXPlaybackPopupModes aMode )
       
   166     {
       
   167     MPX_DEBUG2( "CMPXNotifierDialog::ShowInfoPopupL aMode = %d", aMode );
       
   168     if ( ( EMPXPopupShowIfVisible == aMode && !IsVisible() ) ||
       
   169         ( EMPXPopupShowIfVisibleRestartTimer == aMode && !IsVisible() ) )
       
   170         {
       
   171         MPX_DEBUG1( "CMPXNotifierDialog::ShowInfoPopupL do nothing" );
       
   172         return;
       
   173         }
       
   174 
       
   175     UpdateInfoPopupL( aIcon, aTitle, aTime );
       
   176 
       
   177     if ( EMPXPopupTimeout == aMode ||
       
   178         EMPXPopupShowIfVisibleRestartTimer == aMode )
       
   179         {
       
   180         MPX_DEBUG1( "CMPXNotifierDialog::ShowInfoPopupL starting timer" );
       
   181         iTimer->Cancel();
       
   182         iTimer->Start(
       
   183             KMPXInactivityTime,
       
   184             KMPXInactivityTime,
       
   185             TCallBack( TimerCallback, this ) );
       
   186         }
       
   187     else if ( EMPXPopupNoTimeout == aMode )
       
   188         {
       
   189         MPX_DEBUG1( "CMPXNotifierDialog::ShowInfoPopupL canceling timer" );
       
   190         iTimer->Cancel();
       
   191         }
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // Removes pop-up from screen.
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 void CMPXNotifierDialog::CancelInfoPopup()
       
   199     {
       
   200     MPX_DEBUG1( "CMPXNotifierDialog::CancelInfoPopup" );
       
   201     iTimer->Cancel();
       
   202     if ( IsVisible() )
       
   203         {
       
   204         iWindowGroup.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront );
       
   205         MakeVisible( EFalse );
       
   206         }
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // Gets notified when display orientation hange is started
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CMPXNotifierDialog::NotifyOrientationChangeBegin()
       
   214 	{
       
   215 	// ::HandeResourceChange() will unhide the dialog as soon as the
       
   216 	// orientation change has been completed. KEikDynamicLayoutVariantSwitch comes
       
   217 	// too late so the layout is not correct from the beginning 
       
   218 	if( IsVisible() )
       
   219 		{
       
   220 		MakeVisible( EFalse );
       
   221 		iReopenDialog = ETrue;
       
   222 		}
       
   223 	}
       
   224 
       
   225 // Updates pop-up dialog contents.
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CMPXNotifierDialog::UpdateInfoPopupL(
       
   229     TMPXPlaybackPopupIcons aIcon,
       
   230     const TDesC& aTitle,
       
   231     TInt aTime )
       
   232     {
       
   233     ShowIcon( aIcon );
       
   234 
       
   235     // Set label text
       
   236     // magic: allocate 3 chars more (make sure "..." fits).
       
   237     HBufC* buf = HBufC::NewLC( aTitle.Length() + 3 );
       
   238     *buf = aTitle;
       
   239     TPtr ptr( buf->Des() );
       
   240     AknTextUtils::ClipToFit(
       
   241         ptr,
       
   242         *iSongLabel->Font(),
       
   243         iSongLabel->Rect().Width() );
       
   244     iSongLabel->SetTextL( *buf );
       
   245     CleanupStack::PopAndDestroy( buf );
       
   246 
       
   247     // Set duration label
       
   248     if ( aTime != KErrNotFound )
       
   249         {
       
   250         HBufC* duration = DisplayableDurationL( aTime );
       
   251         CleanupStack::PushL( duration );
       
   252         iTimeLabel->SetTextL( *duration );
       
   253         CleanupStack::PopAndDestroy( duration );
       
   254         }
       
   255     else
       
   256         {
       
   257         iTimeLabel->SetTextL( KNullDesC );
       
   258         }
       
   259 
       
   260     if ( !IsVisible() )
       
   261         {
       
   262         // make this window visible
       
   263         iWindowGroup.SetOrdinalPosition( 0, KMPXWindowPosition );
       
   264         MakeVisible( ETrue );
       
   265         }
       
   266     DrawDeferred();
       
   267     }
       
   268 
       
   269 // ---------------------------------------------------------------------------
       
   270 // Create icons.
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 void CMPXNotifierDialog::CreateIconsL()
       
   274     {
       
   275     delete iPlayIcon;
       
   276     iPlayIcon = NULL;
       
   277     iPlayIcon = new ( ELeave ) CEikImage();
       
   278     iPlayIcon->SetContainerWindowL( *this );
       
   279     ConstructImageL(
       
   280         iPlayIcon,
       
   281         AknsUtils::SkinInstance(),
       
   282         KAknsIIDQgnIndiMupPlay,
       
   283         KAknsIIDQsnIconColors,
       
   284         EAknsCIQsnIconColorsCG26,
       
   285         EMbmMpxmediakeyhandlerQgn_indi_mup_play,
       
   286         EMbmMpxmediakeyhandlerQgn_indi_mup_play_mask );
       
   287 
       
   288     delete iPauseIcon;
       
   289     iPauseIcon = NULL;
       
   290     iPauseIcon = new ( ELeave ) CEikImage();
       
   291     iPauseIcon->SetContainerWindowL( *this );
       
   292     ConstructImageL(
       
   293         iPauseIcon,
       
   294         AknsUtils::SkinInstance(),
       
   295         KAknsIIDQgnIndiMupPause,
       
   296         KAknsIIDQsnIconColors,
       
   297         EAknsCIQsnIconColorsCG26,
       
   298         EMbmMpxmediakeyhandlerQgn_indi_mup_pause,
       
   299         EMbmMpxmediakeyhandlerQgn_indi_mup_pause_mask );
       
   300     delete iFFIcon;
       
   301     iFFIcon = NULL;
       
   302     iFFIcon = new ( ELeave ) CEikImage();
       
   303     iFFIcon->SetContainerWindowL( *this );
       
   304     ConstructImageL(
       
   305         iFFIcon,
       
   306         AknsUtils::SkinInstance(),
       
   307         KAknsIIDQgnIndiMupForw,
       
   308         KAknsIIDQsnIconColors,
       
   309         EAknsCIQsnIconColorsCG26,
       
   310         EMbmMpxmediakeyhandlerQgn_indi_mup_forw,
       
   311         EMbmMpxmediakeyhandlerQgn_indi_mup_forw_mask );
       
   312 
       
   313     delete iFRIcon;
       
   314     iFRIcon = NULL;
       
   315     iFRIcon = new ( ELeave ) CEikImage();
       
   316     iFRIcon->SetContainerWindowL( *this );
       
   317     ConstructImageL(
       
   318         iFRIcon,
       
   319         AknsUtils::SkinInstance(),
       
   320         KAknsIIDQgnIndiMupRew,
       
   321         KAknsIIDQsnIconColors,
       
   322         EAknsCIQsnIconColorsCG26,
       
   323         EMbmMpxmediakeyhandlerQgn_indi_mup_rew,
       
   324         EMbmMpxmediakeyhandlerQgn_indi_mup_rew_mask );
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------------------------
       
   328 // Constructs skinnable icon.
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 void  CMPXNotifierDialog::ConstructImageL(
       
   332     CEikImage* aImage,
       
   333     MAknsSkinInstance* aSkin,
       
   334     const TAknsItemID& aId,
       
   335     const TAknsItemID& aColorId,
       
   336     TInt aColorIndex,
       
   337     TInt aBitmapId,
       
   338     TInt aMaskId )
       
   339     {
       
   340     CFbsBitmap* bitmap = NULL;
       
   341     CFbsBitmap* mask = NULL;
       
   342 
       
   343     TParse parse;
       
   344     parse.Set( KMPXMediaKeyHandlerMbmFile, &KDC_APP_RESOURCE_DIR, NULL );
       
   345     TFileName iconFile( parse.FullName() );
       
   346     User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) );
       
   347 
       
   348     AknsUtils::CreateColorIconL(
       
   349         aSkin,
       
   350         aId,
       
   351         aColorId,
       
   352         aColorIndex,
       
   353         bitmap,
       
   354         mask,
       
   355         iconFile,
       
   356         aBitmapId,
       
   357         aMaskId,
       
   358         KRgbBlack );
       
   359 
       
   360     aImage->SetPicture( bitmap, mask ); // Owership transferred to CEikImage
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------------------------
       
   364 // Resize info popup.
       
   365 // ---------------------------------------------------------------------------
       
   366 //
       
   367 void CMPXNotifierDialog::ResizeInfoPopup()
       
   368     {
       
   369     TRect appRect = iEikonEnv->EikAppUi()->ApplicationRect();
       
   370 
       
   371     // get parent rectangle (status pane)
       
   372     TAknWindowLineLayout statusPane = AknLayout::status_pane( appRect, 0 );
       
   373     TAknLayoutRect res;
       
   374     res.LayoutRect( appRect, statusPane );
       
   375     TRect parentRect = res.Rect();
       
   376 
       
   377     // set the rectangle
       
   378     TAknWindowComponentLayout l = popup_mup_playback_window();
       
   379     res.LayoutRect( parentRect, l.LayoutLine() );
       
   380     SetRect( res.Rect() );
       
   381     DrawNow();
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // Sets pop-up layouts.
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 void CMPXNotifierDialog::SetLayoutsL( TBool aLong )
       
   389     {
       
   390     TAknWindowComponentLayout l;
       
   391     // play icon
       
   392     l = popup_mup_playback_window_g1();
       
   393     AknLayoutUtils::LayoutImage( iPlayIcon, Rect(), l.LayoutLine() );
       
   394     // pause icon
       
   395     l = popup_mup_playback_window_g1();
       
   396     AknLayoutUtils::LayoutImage( iPauseIcon, Rect(), l.LayoutLine() );
       
   397     // FF icon
       
   398     l = popup_mup_playback_window_g1();
       
   399     AknLayoutUtils::LayoutImage( iFFIcon, Rect(), l.LayoutLine() );
       
   400     // FR icon
       
   401     l = popup_mup_playback_window_g1();
       
   402     AknLayoutUtils::LayoutImage( iFRIcon, Rect(), l.LayoutLine() );
       
   403     // song label
       
   404     TAknTextComponentLayout t = popup_mup_playback_window_t1();
       
   405     AknLayoutUtils::LayoutLabel( iSongLabel, Rect(), t.LayoutLine() );
       
   406     // time label
       
   407     if( aLong )
       
   408         {
       
   409         t = popup_mup_playback_window_t2( 1 );
       
   410         }
       
   411     else
       
   412         {
       
   413         t = popup_mup_playback_window_t2();
       
   414         }
       
   415 
       
   416     AknLayoutUtils::LayoutLabel( iTimeLabel, Rect(), t.LayoutLine() );
       
   417 
       
   418     // Set label color
       
   419     TRgb color;
       
   420     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   421     TInt error = AknsUtils::GetCachedColor(
       
   422         skin,
       
   423         color,
       
   424         KAknsIIDQsnTextColors,
       
   425         EAknsCIQsnTextColorsCG19 );
       
   426     if ( !error )
       
   427         {
       
   428         AknLayoutUtils::OverrideControlColorL(
       
   429             *iSongLabel,
       
   430             EColorLabelText,
       
   431             color );
       
   432 
       
   433         AknLayoutUtils::OverrideControlColorL(
       
   434             *iTimeLabel,
       
   435             EColorLabelText,
       
   436             color );
       
   437         }
       
   438     }
       
   439 
       
   440 // ---------------------------------------------------------------------------
       
   441 // Show playback icon.
       
   442 // ---------------------------------------------------------------------------
       
   443 //
       
   444 void CMPXNotifierDialog::ShowIcon(
       
   445     TMPXPlaybackPopupIcons aIcon )
       
   446     {
       
   447 
       
   448     switch ( aIcon )
       
   449         {
       
   450         case EMPXPopupPlayIcon:
       
   451             {
       
   452             iIconShown = EMPXPopupPlayIcon;
       
   453             iPlayIcon->MakeVisible( ETrue );
       
   454             iPauseIcon->MakeVisible( EFalse );
       
   455             iFFIcon->MakeVisible( EFalse );
       
   456             iFRIcon->MakeVisible( EFalse );
       
   457             break;
       
   458             }
       
   459         case EMPXPopupPauseIcon:
       
   460             {
       
   461             iIconShown = EMPXPopupPauseIcon;
       
   462             iPlayIcon->MakeVisible( EFalse );
       
   463             iPauseIcon->MakeVisible( ETrue );
       
   464             iFFIcon->MakeVisible( EFalse );
       
   465             iFRIcon->MakeVisible( EFalse );
       
   466             break;
       
   467             }
       
   468         case EMPXPopupFFIcon:
       
   469             {
       
   470             iIconShown = EMPXPopupFFIcon;
       
   471             iFFIcon->MakeVisible( ETrue );
       
   472             iPlayIcon->MakeVisible( EFalse );
       
   473             iPauseIcon->MakeVisible( EFalse );
       
   474             iFRIcon->MakeVisible( EFalse );
       
   475             break;
       
   476             }
       
   477         case EMPXPopupFRIcon:
       
   478             {
       
   479             iIconShown = EMPXPopupFFIcon;
       
   480             iPlayIcon->MakeVisible( EFalse );
       
   481             iPauseIcon->MakeVisible( EFalse );
       
   482             iFFIcon->MakeVisible( EFalse );
       
   483             iFRIcon->MakeVisible( ETrue );
       
   484             break;
       
   485             }
       
   486         default:
       
   487             {
       
   488             iIconShown = EMPXPopupNoneIcon;
       
   489             iPlayIcon->MakeVisible( EFalse );
       
   490             iPauseIcon->MakeVisible( EFalse );
       
   491             iFFIcon->MakeVisible( EFalse );
       
   492             iFRIcon->MakeVisible( EFalse );
       
   493             break;
       
   494             }
       
   495         }
       
   496     }
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // Callback for timer
       
   500 // ---------------------------------------------------------------------------
       
   501 //
       
   502 TInt CMPXNotifierDialog::TimerCallback( TAny* aPtr )
       
   503     {
       
   504     MPX_DEBUG1( "CMPXNotifierDialog::TimerCallback" );
       
   505     static_cast<CMPXNotifierDialog*>( aPtr )->CancelInfoPopup();
       
   506     return KErrNone;
       
   507     }
       
   508 
       
   509 // ---------------------------------------------------------------------------
       
   510 // Convert to displayable duration.
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 HBufC* CMPXNotifierDialog::DisplayableDurationL(
       
   514     TInt aDuration )
       
   515     {
       
   516     TInt resId;
       
   517     HBufC* format = NULL;
       
   518     if ( aDuration >= KMPXOneHundredHoursInSecs )
       
   519         {
       
   520         resId = R_MPX_TIME_DURAT_HHHMMSS_WITH_ZERO;
       
   521         format = StringLoader::LoadLC(
       
   522             resId, aDuration / KMPXOneHourInSeconds );
       
   523         }
       
   524     else
       
   525         {
       
   526         resId = R_QTN_TIME_DURAT_MIN_SEC_WITH_ZERO;
       
   527         if ( aDuration >= KMPXOneHourInSeconds )
       
   528             {
       
   529             resId = R_QTN_TIME_DURAT_LONG_WITH_ZERO;
       
   530             }
       
   531         format = StringLoader::LoadLC( resId );
       
   532         }
       
   533 
       
   534     SetLayoutsL( aDuration > KMPXOneHourInSeconds? ETrue: EFalse);
       
   535 
       
   536     // Convert total playing time to texts.
       
   537     TTime durTime( (TInt64)aDuration * KMPXOneSecInMicroSecs );
       
   538 
       
   539     HBufC* buf =
       
   540         HBufC::NewLC( format->Length() + KMPXDurationDisplayResvLen );
       
   541     TPtr bufTPtr( buf->Des() );
       
   542 
       
   543     durTime.FormatL( bufTPtr, *format );
       
   544     AknTextUtils::LanguageSpecificNumberConversion( bufTPtr );
       
   545     CleanupStack::Pop( buf );
       
   546     CleanupStack::PopAndDestroy( format );
       
   547 
       
   548     return buf;
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // From CCoeControl
       
   553 // Draws the control.
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 void CMPXNotifierDialog::Draw( const TRect& /* aRect */ ) const
       
   557     {
       
   558     CWindowGc& gc = SystemGc();
       
   559 
       
   560     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   561     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   562 
       
   563     // background
       
   564     AknsDrawUtils::Background( skin, cc, gc, Rect() );
       
   565 
       
   566     // skin stuff - find out size of the corner piece
       
   567     TAknLayoutRect cornerRect;
       
   568     // skinned draw uses submenu popup window skin (skinned border)
       
   569     cornerRect.LayoutRect(
       
   570         Rect(),
       
   571         SkinLayout::Submenu_skin_placing_Line_2() );
       
   572 
       
   573     TRect innerRect( Rect() );
       
   574     innerRect.Shrink( cornerRect.Rect().Width(), cornerRect.Rect().Height() );
       
   575 
       
   576     if ( !AknsDrawUtils::DrawFrame(
       
   577             skin,
       
   578             gc,
       
   579             Rect(),
       
   580             innerRect,
       
   581             KAknsIIDQsnFrPopupSub,
       
   582             KAknsIIDQsnFrPopupCenterSubmenu ) )
       
   583         {
       
   584         // skinned border failed -> black border
       
   585         gc.SetPenStyle( CGraphicsContext::ESolidPen );
       
   586         gc.SetBrushColor( KRgbBlack );
       
   587         gc.DrawRect( Rect() );
       
   588         }
       
   589     }
       
   590 
       
   591 // ---------------------------------------------------------------------------
       
   592 // From CCoeControl
       
   593 // Handles a change to the control's resources.
       
   594 // ---------------------------------------------------------------------------
       
   595 //
       
   596 void CMPXNotifierDialog::HandleResourceChange( TInt aType )
       
   597     {
       
   598     CCoeControl::HandleResourceChange( aType );
       
   599 
       
   600     if ( aType == KAknsMessageSkinChange )
       
   601         {
       
   602         // Reload icons & layout
       
   603         TRAP_IGNORE(
       
   604             {
       
   605             CreateIconsL();
       
   606             ShowIcon( iIconShown );
       
   607             SetLayoutsL();
       
   608             } );
       
   609         }
       
   610     else if ( aType == KEikDynamicLayoutVariantSwitch )
       
   611         {
       
   612         ResizeInfoPopup();
       
   613         if( iReopenDialog )
       
   614           {
       
   615           MakeVisible( ETrue );
       
   616           iReopenDialog = EFalse;
       
   617           }
       
   618         }
       
   619     else
       
   620         {
       
   621         // pass
       
   622         }
       
   623     }
       
   624 
       
   625 // ---------------------------------------------------------------------------
       
   626 // From CCoeControl
       
   627 // Responds to changes to the size and position of the contents of this
       
   628 // control.
       
   629 // ---------------------------------------------------------------------------
       
   630 //
       
   631 void CMPXNotifierDialog::SizeChanged()
       
   632     {
       
   633     TRAP_IGNORE( SetLayoutsL() );
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 // From CCoeControl
       
   638 // Gets the number of controls contained in a compound control.
       
   639 // ---------------------------------------------------------------------------
       
   640 //
       
   641 TInt CMPXNotifierDialog::CountComponentControls() const
       
   642     {
       
   643     return KMPXComponentsCount;
       
   644     }
       
   645 
       
   646 // ---------------------------------------------------------------------------
       
   647 // From CCoeControl
       
   648 // Gets an indexed component of a compound control.
       
   649 // ---------------------------------------------------------------------------
       
   650 //
       
   651 CCoeControl* CMPXNotifierDialog::ComponentControl( TInt aIndex ) const
       
   652     {
       
   653     CCoeControl* control = NULL;
       
   654 
       
   655     switch ( aIndex )
       
   656         {
       
   657         case EMPXTrackLabel:
       
   658             {
       
   659             control = iSongLabel;
       
   660             break;
       
   661             }
       
   662         case EMPXTimeLabel:
       
   663             {
       
   664             control = iTimeLabel;
       
   665             break;
       
   666             }
       
   667         case EMPXPlayIcon:
       
   668             {
       
   669             control = iPlayIcon;
       
   670             break;
       
   671             }
       
   672         case EMPXPauseIcon:
       
   673             {
       
   674             control = iPauseIcon;
       
   675             break;
       
   676             }
       
   677         case EMPXFFIcon:
       
   678             {
       
   679             control = iFFIcon;
       
   680             break;
       
   681             }
       
   682         case EMPXFRIcon:
       
   683             {
       
   684             control = iFRIcon;
       
   685             break;
       
   686             }
       
   687         default:
       
   688             {
       
   689             // Pass
       
   690             break;
       
   691             }
       
   692         }
       
   693 
       
   694     return control;
       
   695     }
       
   696 
       
   697 // ---------------------------------------------------------------------------
       
   698 // From MMPXPSKeyObserver
       
   699 // Handle PS event
       
   700 // ---------------------------------------------------------------------------
       
   701 //
       
   702 void CMPXNotifierDialog::HandlePSEvent( TUid aUid, TInt aKey )
       
   703     {
       
   704     if ( ( aUid == KPSUidAiInformation ) && ( aKey == KActiveIdleState ) )
       
   705         {
       
   706         //we want to cancel popup when going to active idle
       
   707         CancelInfoPopup();
       
   708         }
       
   709     }
       
   710 //  End of File