mmsharing/mmshui/src/musuistatuspanehandler.cpp
branchRCL_3
changeset 33 bc78a40cd63c
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
       
     1 /*
       
     2 * Copyright (c) 2005 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "musuistatuspanehandler.h"
       
    21 #include "musuidefinitions.h"
       
    22 #include "muslogger.h" // debug logging
       
    23 #include <musui.mbg>
       
    24 
       
    25 #include <eikspane.h>
       
    26 #include <barsread.h>
       
    27 #include <StringLoader.h>
       
    28 #include <akntitle.h>
       
    29 #include <aknenv.h>
       
    30 #include <akncontext.h>
       
    31 #include <AknIndicatorContainer.h>
       
    32 #include <aknnavi.h> // Navi pane container ( CAknNavigationControlContainer )
       
    33 #include <AknVolumePopup.h>
       
    34 #include <eikapp.h>
       
    35 #include <eikenv.h>
       
    36 #include <eikappui.h>
       
    37 
       
    38 
       
    39 // constants
       
    40 #define KMUSMBMFILENAME iEikonEnvironment.EikAppUi()->Application()->BitmapStoreName()
       
    41 
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CMusUiStatusPaneHandler* CMusUiStatusPaneHandler::NewL( CEikonEnv& aEikonEnv )
       
    48     {
       
    49     CMusUiStatusPaneHandler* self = 
       
    50                         new ( ELeave ) CMusUiStatusPaneHandler( aEikonEnv );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CMusUiStatusPaneHandler::~CMusUiStatusPaneHandler()
       
    63     {
       
    64     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::~CMusUiStatusPaneHandler" );
       
    65     
       
    66     delete iNaviPaneText;
       
    67     delete iMediaControl;
       
    68     delete iVolumePopup;
       
    69     
       
    70     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::~CMusUiStatusPaneHandler" );
       
    71     }
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CMusUiStatusPaneHandler::CMusUiStatusPaneHandler( CEikonEnv& aEikonEnv )
       
    79     :iEikonEnvironment( aEikonEnv )
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CMusUiStatusPaneHandler::ConstructL()
       
    89     {
       
    90     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::ConstructL" );
       
    91     
       
    92     CEikStatusPane* statusPane = iEikonEnvironment.AppUiFactory()->StatusPane();
       
    93     
       
    94     iNaviPane = STATIC_CAST(
       
    95                 CAknNavigationControlContainer*,
       
    96                 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
    97     iTitlePane = STATIC_CAST(
       
    98                 CAknTitlePane*,
       
    99                 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   100     iContextPane = STATIC_CAST(
       
   101                 CAknContextPane*,
       
   102                 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) );
       
   103 
       
   104     iVolumePopup = CAknVolumePopup::ConstructFromResourceL( 
       
   105                                         R_AVKON_NAVI_PANE_VOLUME_INDICATOR );
       
   106 
       
   107     iMediaControl = CreateMediaNaviL();
       
   108     
       
   109     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::ConstructL" );
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // Updates statuspane icons
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CMusUiStatusPaneHandler::SetStatusPaneIconsL( TInt32 aIconId,
       
   118                                                    TInt32 aIconMaskId )
       
   119     {
       
   120     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::SetStatusPaneIconsL" )
       
   121 
       
   122 	iContextPane->SetPictureFromFileL( KMUSMBMFILENAME, aIconId, aIconMaskId );
       
   123 													 
       
   124     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetStatusPaneIconsL" )
       
   125     }
       
   126 
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // Updates statuspane icons
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CMusUiStatusPaneHandler::SetStatusPaneIconsL( CFbsBitmap* aBitmap )
       
   133     {
       
   134     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::SetStatusPaneIconsL" );
       
   135     CEikImage* image = new (ELeave) CEikImage();
       
   136     image->SetBitmap( aBitmap );
       
   137     CEikImage* oldImage = iContextPane->SwapPicture( image );
       
   138     delete oldImage;
       
   139     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetStatusPaneIconsL" );
       
   140     }
       
   141 
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // Hides navi-pane decorators and clears text
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CMusUiStatusPaneHandler::ClearNaviPaneL()
       
   148     {
       
   149     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::ClearNaviPaneL" );
       
   150     delete iNaviPaneText;
       
   151     iNaviPaneText = NULL;
       
   152 
       
   153     // Pushes default decorator object (empty one) to top of the stack
       
   154     // and draws it
       
   155     iNaviPane->PushDefaultL();
       
   156 
       
   157     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::ClearNaviPaneL" );
       
   158     }
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // Sets title-pane text
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CMusUiStatusPaneHandler::SetTitleL( const TDesC& aTitle )
       
   166     {
       
   167     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::SetTitleL" );
       
   168     iTitlePane->SetTextL( aTitle );
       
   169     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetTitleL" );
       
   170     }
       
   171 
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 void CMusUiStatusPaneHandler::SetTitleFromResourceL( TInt aResourceId )
       
   178     {
       
   179     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::SetTitleFromResourceL" );
       
   180     HBufC* titlePaneTitle =  StringLoader::LoadLC( aResourceId );
       
   181     iTitlePane->SetTextL( *titlePaneTitle );
       
   182     CleanupStack::PopAndDestroy( titlePaneTitle );
       
   183     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetTitleFromResourceL" );
       
   184     }
       
   185     
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // Get the current volume setting.
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 TInt CMusUiStatusPaneHandler::GetVolumeControlValue() const
       
   192     {
       
   193     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::GetVolumeControlValue" );
       
   194              
       
   195     TInt volume = iVolumePopup->Value();
       
   196     
       
   197     MUS_LOG1( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::GetVolumeControlValue: [%d]",
       
   198                             volume );                        
       
   199     return volume;
       
   200     }
       
   201 
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // Activates volume control.
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 void CMusUiStatusPaneHandler::ActivateVolumeControlL( TInt aVolume, TBool aOnlyIfVisible )
       
   208     {
       
   209     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::ActivateVolumeControlL" );
       
   210 
       
   211     if ( aVolume < KMusVolumeMuted || aVolume > KMusVolumeMaximum )
       
   212         {
       
   213         MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetVolumeControlValue: returning" );
       
   214         return;
       
   215         }
       
   216 
       
   217     if ( !aOnlyIfVisible || (aOnlyIfVisible && iVolumePopup->IsVisible()) )
       
   218         {
       
   219         iVolumePopup->SetValue( aVolume );
       
   220         iVolumePopup->ShowVolumePopupL();
       
   221         }
       
   222     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::ActivateVolumeControlL" );
       
   223     }
       
   224     
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // Activate media navi pane.
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 void CMusUiStatusPaneHandler::ActivateNaviPaneMediaL()
       
   231     {
       
   232     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::ActivateNaviPaneMediaL" );
       
   233     iNaviPane->PushL( *iMediaControl );
       
   234     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::ActivateNaviPaneMediaL" );
       
   235     }
       
   236   
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 void CMusUiStatusPaneHandler::ShowNaviPaneIconL(
       
   243                         TMusUiNaviMediaDecorator aIcon )
       
   244     {
       
   245     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::ShowNaviPaneIconL" );
       
   246     CMusUiNaviMediaDecorator* mediaNavi =
       
   247                             static_cast<CMusUiNaviMediaDecorator*>(
       
   248                                             iMediaControl->DecoratedControl() );
       
   249     mediaNavi->ShowIcon( aIcon );
       
   250     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::ShowNaviPaneIconL" );
       
   251     }
       
   252 
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // Sets navi-pane label for left side
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 void CMusUiStatusPaneHandler::SetLeftLabelL( const TDesC& aLabel )
       
   259     {
       
   260     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::SetLeftLabelL" );
       
   261 
       
   262     static_cast<CMusUiNaviMediaDecorator*>
       
   263                     ( iMediaControl->DecoratedControl() )->SetLeftLabelL( aLabel );
       
   264     iNaviPane->DrawNow();
       
   265     
       
   266     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetLeftLabelL" );
       
   267     }
       
   268 
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // Sets navi-pane label for right side
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 void CMusUiStatusPaneHandler::SetRightLabelL( const TDesC& aLabel )
       
   275     {
       
   276     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::SetRightLabelL" );
       
   277 
       
   278     static_cast<CMusUiNaviMediaDecorator*>
       
   279                     ( iMediaControl->DecoratedControl() )->SetRightLabelL( aLabel );
       
   280     iNaviPane->DrawNow();
       
   281     
       
   282     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::SetRightLabelL" );
       
   283     }
       
   284 
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // Create media navi pane.
       
   288 // -----------------------------------------------------------------------------
       
   289 //
       
   290 CAknNavigationDecorator* CMusUiStatusPaneHandler::CreateMediaNaviL()
       
   291     {
       
   292     MUS_LOG( "mus: [MUSUI ]  -> CMusUiStatusPaneHandler::CreateMediaNaviL" );
       
   293     CMusUiNaviMediaDecorator* naviDecorator = CMusUiNaviMediaDecorator::NewL();
       
   294     CleanupStack::PushL( naviDecorator );
       
   295 
       
   296     CAknNavigationDecorator* decoratedFolder =
       
   297                             CAknNavigationDecorator::NewL(
       
   298                                     iNaviPane,
       
   299                                     naviDecorator,
       
   300                                     CAknNavigationDecorator::ENotSpecified );
       
   301     CleanupStack::Pop( naviDecorator );// decoratedFolder owns naviDecorator now
       
   302 
       
   303     CleanupStack::PushL( decoratedFolder );
       
   304     decoratedFolder->SetContainerWindowL( *iNaviPane );
       
   305     naviDecorator->SetContainerWindowL( *decoratedFolder );
       
   306     CleanupStack::Pop( decoratedFolder );
       
   307 
       
   308     decoratedFolder->MakeScrollButtonVisible( EFalse );
       
   309 
       
   310     MUS_LOG( "mus: [MUSUI ]  <- CMusUiStatusPaneHandler::CreateMediaNaviL" );
       
   311     return decoratedFolder;
       
   312     }
       
   313 
       
   314 
       
   315 // -----------------------------------------------------------------------------
       
   316 // Get Volump Popup control pointer
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 CAknVolumePopup* CMusUiStatusPaneHandler::GetVolumePopup() const
       
   320     {
       
   321     return iVolumePopup;
       
   322     }
       
   323 
       
   324 
       
   325 // end of file