mmserv/audioeffectsui/equalizer/src/EqualizerFreqBandContainer.cpp
changeset 33 5e8b14bae8c3
parent 28 ebf79c79991a
child 36 73253677b50a
equal deleted inserted replaced
28:ebf79c79991a 33:5e8b14bae8c3
     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:    Defines functionality related to Equalizer Frequency Band 
       
    15 *                Container
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <AknUtils.h>
       
    24 #include <AknsDrawUtils.h>
       
    25 #include <bautils.h>
       
    26 #include <AknsBasicBackgroundControlContext.h> 
       
    27 #include <data_caging_path_literals.hrh>
       
    28 
       
    29 //LAF and Skin changes
       
    30 #include <AknIconUtils.h>
       
    31 #include <AknsUtils.h>
       
    32 #include <AknsConstants.h>
       
    33 #include <aknlayout.cdl.h>
       
    34 #include <aknlayoutscalable_apps.cdl.h>
       
    35 #include <AknLayout2ScalableDef.h>
       
    36 #include <AknLayout2Def.h>
       
    37 #include <AudioEqualizerUtility.h>
       
    38 #include <eiklabel.h>
       
    39 #include <StringLoader.h>
       
    40 #include <Equalizer.rsg>
       
    41 #include <layoutmetadata.cdl.h>
       
    42 #include <e32math.h>
       
    43 
       
    44 #include "EqualizerPrivateConstants.h"
       
    45 #include "EqualizerEditingDialog.h"
       
    46 #include "EqualizerFreqBand.h"
       
    47 #include "EqualizerFreqBandContainer.h"
       
    48 #include "Equalizer.hrh"
       
    49 
       
    50 _LIT(KLabelFormatInt,"%d");
       
    51 _LIT(KLabelFormatFloat,"%.1f");
       
    52 
       
    53 // ============================ MEMBER FUNCTIONS =============================
       
    54 
       
    55 //////////////////////////////////////////////////////////////////////////////
       
    56 //
       
    57 // -----> CEqualizerFreqBandContainer (implementation)
       
    58 //
       
    59 //////////////////////////////////////////////////////////////////////////////
       
    60 
       
    61 // -------------------------------------------------------------------
       
    62 // CEqualizerFreqBandContainer::CEqualizerFreqBandContainer
       
    63 //(CAudioEqualizerUtility* aAudEqUtility,  TInt aPresetIndex,
       
    64 // TRect& aRect)
       
    65 //
       
    66 // First phase constructor
       
    67 // --------------------------------------------------------------------
       
    68 // 
       
    69 CEqualizerFreqBandContainer::CEqualizerFreqBandContainer(
       
    70 	CEqualizerEditingDialog* aEqEditingDialog,
       
    71     CAudioEqualizerUtility* aAudEqUtility, TInt aPresetIndex, 
       
    72     const TBool aIsActivePreset, TRect& aRect,
       
    73     MEqualizerPresetActivationObserver& aObserver,
       
    74     TInt aPresetKey, TPresetName& aPresetName )
       
    75      :iEqEditingDialog(aEqEditingDialog), iAudEqUtility(aAudEqUtility), iPresetIndex(aPresetIndex), 
       
    76      iIsActivePreset(aIsActivePreset), iRect(aRect), iObserver( aObserver ), iPresetKey( aPresetKey ),
       
    77      iBandSelected(EFalse), iPresetName( aPresetName )
       
    78     {
       
    79     }
       
    80 
       
    81 // -------------------------------------------------------------------
       
    82 // CEqualizerFreqBandContainer::~CEqualizerFreqBandContainer()
       
    83 //
       
    84 // Destructor
       
    85 // --------------------------------------------------------------------
       
    86 //     
       
    87 CEqualizerFreqBandContainer::~CEqualizerFreqBandContainer()
       
    88     {
       
    89     delete iBackGround; 
       
    90     if (iFreqBand)
       
    91         {
       
    92         iFreqBand->ResetAndDestroy(); //delete items
       
    93         delete (iFreqBand);
       
    94         }
       
    95     if (iFreqLabels)
       
    96         {
       
    97         iFreqLabels->ResetAndDestroy(); //delete items
       
    98         delete (iFreqLabels);
       
    99         }
       
   100     }
       
   101 
       
   102 // -------------------------------------------------------------------
       
   103 // void CEqualizerFreqBandContainer::ConstructL(TRect& aRect)
       
   104 //
       
   105 // Because CEqualizerFreqBandContainer is a compound control, it needs a
       
   106 // ConstructL() for when it's created outside a dialog, and a
       
   107 // ConstructFromResourceL() for when it's created inside a dialog.
       
   108 // --------------------------------------------------------------------
       
   109 //     
       
   110 void CEqualizerFreqBandContainer::ConstructL(TRect& aRect)
       
   111     {
       
   112     iBackGround = CAknsBasicBackgroundControlContext::NewL
       
   113     	( KAknsIIDQsnBgAreaMain, Rect(), EFalse );
       
   114     iAudEqUtility->GetPresetL(iPresetIndex);
       
   115     CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer();
       
   116     iNumberOfFreqBands = audioEqualizer.NumberOfBands();
       
   117     iFreqBand = new(ELeave) CArrayPtrFlat<CEqualizerFreqBand>
       
   118                  (KEqualizerArrayGranularity);
       
   119     iFreqLabels = new(ELeave) CArrayPtrFlat<CEikLabel>
       
   120                  (KEqualizerArrayGranularity);
       
   121     
       
   122     for (int i=0; i<iNumberOfFreqBands; i++)
       
   123         {
       
   124         // Create the CEqualizerFreqBands. Their size and position is 
       
   125         // set in CEqualizerFreqBandContainer::SizeChangedL().
       
   126         
       
   127         CEqualizerFreqBand* band = CEqualizerFreqBand::NewL(iEqEditingDialog, iAudEqUtility, 
       
   128          iPresetIndex, iIsActivePreset, i, aRect);
       
   129          
       
   130         CleanupStack::PushL(band);
       
   131         iFreqBand->AppendL(band);
       
   132         CleanupStack::Pop(band);
       
   133         (*iFreqBand)[i]->SetContainerWindowL(*this);
       
   134         }
       
   135 
       
   136     (*iFreqBand)[0]->SetFocus(ETrue);
       
   137     iIndexOfFocussedFreqBand = 0;
       
   138         
       
   139 #ifdef RD_SCALABLE_UI_V2
       
   140     EnableDragEvents();
       
   141 #endif //RD_SCALABLE_UI_V2
       
   142     ConstructLabelsL();
       
   143     // Set the bounding rectangle of this control (this will result in 
       
   144     // a call to SizeChangedL(). The component controls must be 
       
   145     // created before calling this, because SizeChangedL() sets their
       
   146     // sizes.
       
   147     SetRect(aRect);
       
   148     ActivateL();
       
   149     }
       
   150 
       
   151 // ----------------------------------------------------------------------
       
   152 // void CEqualizerFreqBandContainer::ConstructFromResourceL
       
   153 // (TResourceReader& /*aReader*/)
       
   154 //
       
   155 // This function is used when the CEqualizerFreqBandContainer is created
       
   156 // inside a dialog.
       
   157 // ----------------------------------------------------------------------
       
   158 // 
       
   159 void CEqualizerFreqBandContainer::ConstructFromResourceL(TResourceReader& 
       
   160 /*aReader*/)
       
   161     {
       
   162     ConstructL(iRect);
       
   163     }
       
   164 
       
   165 // -------------------------------------------------------------------
       
   166 // TInt CEqualizerFreqBandContainer::CountComponentControls() const
       
   167 //
       
   168 // Returns the number of controls in a compound control.
       
   169 // -------------------------------------------------------------------
       
   170 // 
       
   171 TInt CEqualizerFreqBandContainer::CountComponentControls() const
       
   172     {
       
   173     return iNumberOfFreqBands + iFreqLabels->Count();
       
   174     }
       
   175 
       
   176 // -------------------------------------------------------------------
       
   177 // CCoeControl* CEqualizerFreqBandContainer::ComponentControl
       
   178 // (TInt aIndex) const
       
   179 //
       
   180 // Returns the control given by the index in a compind control.
       
   181 // -------------------------------------------------------------------
       
   182 //
       
   183 CCoeControl* CEqualizerFreqBandContainer::ComponentControl(TInt aIndex) const
       
   184     {
       
   185     if(aIndex<iNumberOfFreqBands)
       
   186     return (*iFreqBand)[aIndex];
       
   187     else 
       
   188     return (*iFreqLabels)[aIndex - iNumberOfFreqBands];
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------
       
   192 // void CEqualizerFreqBandContainer::SizeChanged()
       
   193 //
       
   194 // This function gets called whenever one of the size-setting functions 
       
   195 // is called. As this is a compound control, this function calculates 
       
   196 // and sets the size and position for its components, based on its own 
       
   197 // size.
       
   198 // ---------------------------------------------------------------------
       
   199 //
       
   200 void CEqualizerFreqBandContainer::SizeChanged()
       
   201     {
       
   202     TInt equalizerVariety = EEqualizerVarietyOne; //By defualt use variety one
       
   203     
       
   204     TRect myRect = Rect();
       
   205     TRect rect = CEqualizerFreqBand::ComponentRect(iRect,
       
   206                                 EEqualizerVarietyNotUsed,EEqualizerMainPane);
       
   207     iRect = rect;
       
   208     /**
       
   209      *Equalizer variety based on the number of bands
       
   210      * Number of bands = 8 ==> Variety = 0
       
   211      * Number of bands = 5 ==> Variety = 1
       
   212      */
       
   213     if(iNumberOfFreqBands == KEqualizerEightBands)
       
   214         {
       
   215         equalizerVariety = EEqualizerVarietyOne;
       
   216         }
       
   217         
       
   218     if(iNumberOfFreqBands == KEqualizerFiveBands)
       
   219         {
       
   220         equalizerVariety = EEqualizerVarietyTwo;
       
   221         }
       
   222         
       
   223     //Setting the position and size for the frequency bands from the layout 
       
   224     //obtained
       
   225     for(TInt count = 0;count < iNumberOfFreqBands; count++)
       
   226         {
       
   227         TRect freqBandRect = CEqualizerFreqBand::ComponentRect(iRect,
       
   228                                                      equalizerVariety+2,count);
       
   229         (*iFreqBand)[count]->SetRect(freqBandRect);
       
   230         }
       
   231         
       
   232     TInt variety=0;
       
   233     if(Layout_Meta_Data::IsLandscapeOrientation())
       
   234     	variety=4;
       
   235     TRect temp;
       
   236     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, temp );
       
   237     TAknLayoutRect mainPaneLayout;
       
   238     mainPaneLayout.LayoutRect( temp,AknLayoutScalable_Apps::main_pane(variety).LayoutLine() );
       
   239     myRect = mainPaneLayout.Rect();
       
   240     myRect.iBr.iY = myRect.iBr.iY - myRect.iTl.iY;
       
   241     myRect.iTl.iY = 0;
       
   242     
       
   243     TAknTextLineLayout tLayout;
       
   244     
       
   245     tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t9(equalizerVariety);
       
   246    	AknLayoutUtils::LayoutLabel((*iFreqLabels)[0], myRect, tLayout);
       
   247 	
       
   248 	tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t10(equalizerVariety);
       
   249 	AknLayoutUtils::LayoutLabel((*iFreqLabels)[1], myRect, tLayout);
       
   250 	
       
   251 	tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t1(equalizerVariety);
       
   252 	AknLayoutUtils::LayoutLabel((*iFreqLabels)[2], iRect, tLayout);
       
   253 	
       
   254 	tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t2(equalizerVariety);
       
   255 	AknLayoutUtils::LayoutLabel((*iFreqLabels)[3], iRect, tLayout);
       
   256 	
       
   257 	tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t3(equalizerVariety);
       
   258 	AknLayoutUtils::LayoutLabel((*iFreqLabels)[4], iRect, tLayout);
       
   259 	
       
   260 	tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t4(equalizerVariety);
       
   261 	AknLayoutUtils::LayoutLabel((*iFreqLabels)[5], iRect, tLayout);
       
   262 	
       
   263 	tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t5(equalizerVariety);
       
   264 	AknLayoutUtils::LayoutLabel((*iFreqLabels)[6], iRect, tLayout);
       
   265 	
       
   266 	if(equalizerVariety == 0)
       
   267 		{
       
   268 		tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t6(equalizerVariety);
       
   269 		AknLayoutUtils::LayoutLabel((*iFreqLabels)[7], iRect, tLayout);
       
   270 		
       
   271 		tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t7(equalizerVariety);
       
   272 		AknLayoutUtils::LayoutLabel((*iFreqLabels)[8], iRect, tLayout);
       
   273 		
       
   274 		tLayout = AknLayoutScalable_Apps::main_mup_eq_pane_t8(equalizerVariety);
       
   275 		AknLayoutUtils::LayoutLabel((*iFreqLabels)[9], iRect, tLayout);
       
   276 		}
       
   277 	
       
   278 	if (iBackGround)
       
   279 	    {
       
   280 	    iBackGround->SetRect(iRect);
       
   281 	    }
       
   282     TRgb color;
       
   283     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   284         
       
   285     for(TInt i=0; i<iFreqLabels->Count(); i++)
       
   286         {
       
   287         CCoeControl* label( ComponentControl( i+iNumberOfFreqBands ));
       
   288         TInt error = AknsUtils::GetCachedColor( skin, color,
       
   289                                                 KAknsIIDQsnTextColors,
       
   290                                                 EAknsCIQsnTextColorsCG6 );
       
   291         if ( !error )
       
   292            	AknLayoutUtils::OverrideControlColorL( *label,
       
   293                                                   EColorLabelText,
       
   294                                                   color);
       
   295         }
       
   296     }
       
   297 
       
   298 // -------------------------------------------------------------------
       
   299 // void CEqualizerFreqBandContainer::Draw(const TRect& aRect) const
       
   300 //
       
   301 // This function gets called to draw a control
       
   302 // -------------------------------------------------------------------
       
   303 //         
       
   304 void CEqualizerFreqBandContainer::Draw(const TRect& aRect) const
       
   305     {
       
   306     CWindowGc& gc=SystemGc();
       
   307     gc.Clear(iRect);
       
   308     // Drawing skin
       
   309     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   310     if (iBackGround)
       
   311         {
       
   312         AknsDrawUtils::Background(skin, iBackGround, this, gc, iRect);
       
   313         }
       
   314     
       
   315     for(TInt i=0; i<iFreqLabels->Count(); i++)
       
   316     	{
       
   317     	if( (*iFreqLabels)[i] )
       
   318     		{
       
   319     		(*iFreqLabels)[i]->Draw(aRect);
       
   320     		}
       
   321         }
       
   322     }
       
   323 
       
   324 // ---------------------------------------------------------------------
       
   325 // void CEqualizerFreqBandContainer::FocusChanged(TDrawNow aDrawNow)
       
   326 //
       
   327 // This function gets called whenever the application calls SetFocus().
       
   328 // It redraws the CEqualizerFreqBandContainer, so that they are updated
       
   329 // to show which one now has focus.
       
   330 // ---------------------------------------------------------------------
       
   331 //
       
   332 void CEqualizerFreqBandContainer::FocusChanged(TDrawNow aDrawNow)
       
   333     {
       
   334     if (IsFocused())
       
   335         {
       
   336         (*iFreqBand)[0]->SetFocus(ETrue, EDrawNow);
       
   337         iFocussedFreqBand = (*iFreqBand)[0];
       
   338         iIndexOfFocussedFreqBand = 0;
       
   339         }
       
   340     else
       
   341         {
       
   342         if (iFocussedFreqBand && iFocussedFreqBand->IsFocused())
       
   343             {
       
   344             iFocussedFreqBand->SetFocus(EFalse, EDrawNow);             
       
   345             }
       
   346         }
       
   347     if (aDrawNow)
       
   348         {
       
   349         DrawNow();        
       
   350         } 
       
   351     }
       
   352 
       
   353 // ----------------------------------------------------------------------
       
   354 // void CEqualizerFreqBandContainer::SwapFocus(CCoeControl* aPrevControl,
       
   355 //  CCoeControl* aNewControl)
       
   356 //
       
   357 // This function is called from OfferKeyEventL() whenever the user 
       
   358 // presses left/right arrow keys to change to the previous/next band
       
   359 // ----------------------------------------------------------------------
       
   360 //
       
   361 void CEqualizerFreqBandContainer::SwapFocus(CCoeControl* aPrevControl, 
       
   362 CCoeControl* aNewControl)
       
   363     {
       
   364     aPrevControl->SetFocus(EFalse, EDrawNow);
       
   365     aNewControl->SetFocus(ETrue, EDrawNow);
       
   366     iFocussedFreqBand =  aNewControl;
       
   367     }
       
   368 
       
   369 // -------------------------------------------------------------------------
       
   370 // CEqualizerFreqBandContainer::OfferKeyEventL 
       
   371 // Function for handling key events.
       
   372 // -------------------------------------------------------------------------
       
   373 //
       
   374 TKeyResponse CEqualizerFreqBandContainer::OfferKeyEventL(const TKeyEvent& 
       
   375 aKeyEvent,TEventCode aType)
       
   376     {
       
   377     TKeyResponse ret = EKeyWasNotConsumed;
       
   378     TInt indexOfLastFocussedBand = -1;
       
   379     if( aType == EEventKey )
       
   380         {
       
   381           // Use the arrow keys to move focus between the two CEqualizerFreqBands.
       
   382         switch (aKeyEvent.iCode)
       
   383             {
       
   384             case EKeyUpArrow:
       
   385             case EKeyDownArrow:
       
   386                 {
       
   387                 ret = (*iFreqBand)[iIndexOfFocussedFreqBand]->OfferKeyEventL(
       
   388                 aKeyEvent, aType);
       
   389                 
       
   390                 // In MPX the band dialog presets need to be saved 
       
   391                 // and called back to the observer
       
   392                 //
       
   393                 if( iIsActivePreset )
       
   394                     {
       
   395                     CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer();
       
   396                     iAudEqUtility->ModifyPresetL(iPresetIndex, iPresetName, audioEqualizer);
       
   397                     
       
   398                     iObserver.HandlePresetActivation( iPresetKey );
       
   399                     }
       
   400                 }
       
   401                 break;
       
   402             
       
   403             case EKeyRightArrow:
       
   404                 if (AknLayoutUtils::LayoutMirrored())
       
   405                     {
       
   406                     // For Series60 Arabic Hebrew LAF                
       
   407                     // Bugfix for Id: TCON-6HKGAB            
       
   408                     indexOfLastFocussedBand = iIndexOfFocussedFreqBand;
       
   409                     iIndexOfFocussedFreqBand = 
       
   410                     (indexOfLastFocussedBand+iNumberOfFreqBands-1)
       
   411                                     %iNumberOfFreqBands;
       
   412                     SwapFocus((*iFreqBand)[indexOfLastFocussedBand], 
       
   413                     (*iFreqBand)[iIndexOfFocussedFreqBand]);
       
   414                     ret = EKeyWasConsumed;                     
       
   415                     }
       
   416                 else
       
   417                     {
       
   418                     indexOfLastFocussedBand = iIndexOfFocussedFreqBand;
       
   419                     iIndexOfFocussedFreqBand = 
       
   420                     (indexOfLastFocussedBand+1)%iNumberOfFreqBands;
       
   421                     SwapFocus((*iFreqBand)[indexOfLastFocussedBand], 
       
   422                     (*iFreqBand)[iIndexOfFocussedFreqBand]);
       
   423                     ret = EKeyWasConsumed;                   
       
   424                     }
       
   425                 break;
       
   426             case EKeyLeftArrow:
       
   427                 if (AknLayoutUtils::LayoutMirrored())
       
   428                     {
       
   429                     // For Series60 Arabic Hebrew LAF                
       
   430                     // Bugfix for Id: TCON-6HKGAB
       
   431                     indexOfLastFocussedBand = iIndexOfFocussedFreqBand;
       
   432                     iIndexOfFocussedFreqBand = (indexOfLastFocussedBand + 1)% 
       
   433                                                 iNumberOfFreqBands;
       
   434                     SwapFocus((*iFreqBand)[indexOfLastFocussedBand], 
       
   435                     (*iFreqBand)[iIndexOfFocussedFreqBand]);
       
   436                     ret = EKeyWasConsumed;                     
       
   437                     }
       
   438                 else
       
   439                     {
       
   440                     indexOfLastFocussedBand = iIndexOfFocussedFreqBand;
       
   441                     iIndexOfFocussedFreqBand = (indexOfLastFocussedBand + 
       
   442                     iNumberOfFreqBands -1)% iNumberOfFreqBands;
       
   443                     SwapFocus((*iFreqBand)[indexOfLastFocussedBand], 
       
   444                     (*iFreqBand)[iIndexOfFocussedFreqBand]);
       
   445                     ret = EKeyWasConsumed;                   
       
   446                     }
       
   447                 break;
       
   448 
       
   449             default:
       
   450                 break;
       
   451             }         
       
   452         }
       
   453 
       
   454     // If the CEqualizerFreqBandContainer didn't use the key event, it
       
   455     // must return EKeyWasNotConsumed,
       
   456     // so that the key event is passed to other controls on the stack.
       
   457     return ret;
       
   458     }
       
   459 
       
   460 // ----------------------------------------------------------------------------
       
   461 // CEqualizerFreqBandContainer::SetAudioEqualizerL(CAudioEqualizerUtility* 
       
   462 // aAudEqUtility)
       
   463 // This function is used to set a new CAudioEqualizerUtility* 
       
   464 // ----------------------------------------------------------------------------
       
   465 //    
       
   466 void CEqualizerFreqBandContainer::SetAudioEqualizerL(
       
   467 CAudioEqualizerUtility* aAudEqUtility)
       
   468 	{
       
   469 	iAudEqUtility=aAudEqUtility;
       
   470 	for (int i=0; i<iNumberOfFreqBands; i++)
       
   471 	    {
       
   472 	    (*iFreqBand)[i]->SetAudioEqualizerL(aAudEqUtility);
       
   473 	    }
       
   474 	}
       
   475 
       
   476 // ---------------------------------------------------------
       
   477 // CEqualizerFreqBandContainer::MopSupplyObject
       
   478 // Pass skin information if need.
       
   479 // (other items were commented in a header).
       
   480 // ---------------------------------------------------------
       
   481 //
       
   482 TTypeUid::Ptr CEqualizerFreqBandContainer::MopSupplyObject(TTypeUid aId)
       
   483 	{
       
   484 	if ( aId.iUid == MAknsControlContext::ETypeId )
       
   485 		{
       
   486 		// Return the control context for the childs
       
   487 		return MAknsControlContext::SupplyMopObject( aId, iBackGround );
       
   488 		}
       
   489 	return CCoeControl::MopSupplyObject( aId );
       
   490 	}
       
   491 	
       
   492 // ---------------------------------------------------------
       
   493 // CEqualizerFreqBandContainer::ConstructLabelsL
       
   494 // Contruct the frequency value labels.
       
   495 // (other items were commented in a header).
       
   496 // ---------------------------------------------------------
       
   497 //
       
   498 void CEqualizerFreqBandContainer::ConstructLabelsL()
       
   499 	{
       
   500 	
       
   501 	CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer();
       
   502 	CEikLabel* tempLabel;
       
   503 	TBuf<15> tempStr;
       
   504 	TReal x,y;
       
   505 	
       
   506 	tempLabel = new (ELeave) CEikLabel;
       
   507 	tempLabel->SetContainerWindowL( *this );
       
   508   HBufC* hzText = StringLoader::LoadLC(R_QTN_EQ_PRESET_FREQUENCY_HZ);
       
   509 	tempLabel->SetTextL(hzText->Des());
       
   510 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   511 	CleanupStack::PushL(tempLabel);
       
   512 	iFreqLabels->AppendL(tempLabel); 
       
   513 	CleanupStack::Pop(tempLabel);
       
   514 	CleanupStack::PopAndDestroy(); // hzText
       
   515 	
       
   516 	tempLabel = new (ELeave) CEikLabel;
       
   517 	tempLabel->SetContainerWindowL( *this );
       
   518   HBufC* mhzText = StringLoader::LoadLC(R_QTN_EQ_PRESET_FREQUENCY_KHZ);
       
   519 	tempLabel->SetTextL(mhzText->Des());
       
   520 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   521 	CleanupStack::PushL(tempLabel);
       
   522 	iFreqLabels->AppendL(tempLabel); 
       
   523 	CleanupStack::Pop(tempLabel);
       
   524 	CleanupStack::PopAndDestroy(); // MhzText
       
   525 
       
   526 	tempLabel = new (ELeave) CEikLabel;
       
   527 	tempLabel->SetContainerWindowL( *this );
       
   528 	tempStr.Format(KLabelFormatInt,audioEqualizer.CenterFrequency(1));
       
   529 	AknTextUtils::LanguageSpecificNumberConversion( tempStr );
       
   530 	tempLabel->SetTextL(tempStr);
       
   531 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   532 	CleanupStack::PushL(tempLabel);
       
   533 	iFreqLabels->AppendL(tempLabel); 
       
   534 	CleanupStack::Pop(tempLabel);
       
   535 	
       
   536 	tempLabel = new (ELeave) CEikLabel;
       
   537 	tempLabel->SetContainerWindowL( *this );
       
   538     tempStr.Format(KLabelFormatInt, audioEqualizer.CenterFrequency(2));
       
   539     AknTextUtils::LanguageSpecificNumberConversion( tempStr );
       
   540 	tempLabel->SetTextL(tempStr);
       
   541 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   542 	CleanupStack::PushL(tempLabel);
       
   543 	iFreqLabels->AppendL(tempLabel); 
       
   544 	CleanupStack::Pop(tempLabel);
       
   545 	
       
   546 	tempLabel = new (ELeave) CEikLabel;
       
   547 	tempLabel->SetContainerWindowL( *this );
       
   548     tempStr.Format(KLabelFormatInt, audioEqualizer.CenterFrequency(3));
       
   549     AknTextUtils::LanguageSpecificNumberConversion( tempStr );
       
   550 	tempLabel->SetTextL(tempStr);
       
   551 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   552 	CleanupStack::PushL(tempLabel);
       
   553 	iFreqLabels->AppendL(tempLabel); 
       
   554 	CleanupStack::Pop(tempLabel);
       
   555 	
       
   556 	Math::Round(y,(TReal)audioEqualizer.CenterFrequency(4)/1000,1);
       
   557 	tempLabel = new (ELeave) CEikLabel;
       
   558 	tempLabel->SetContainerWindowL( *this );
       
   559 	Math::Mod(x,y*10,10);
       
   560 	if(x==0)
       
   561 	    tempStr.Format(KLabelFormatInt,(TInt)y);
       
   562 	else
       
   563 	    tempStr.Format(KLabelFormatFloat,y);
       
   564 	AknTextUtils::LanguageSpecificNumberConversion( tempStr );
       
   565 	tempLabel->SetTextL(tempStr);
       
   566 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   567 	CleanupStack::PushL(tempLabel);
       
   568 	iFreqLabels->AppendL(tempLabel); 
       
   569 	CleanupStack::Pop(tempLabel);
       
   570 	
       
   571 	Math::Round(y,(TReal)audioEqualizer.CenterFrequency(5)/1000,1);
       
   572 	tempLabel = new (ELeave) CEikLabel;
       
   573 	tempLabel->SetContainerWindowL( *this );
       
   574 	Math::Mod(x,y*10,10);
       
   575 	if(x==0)
       
   576 	    tempStr.Format(KLabelFormatInt,(TInt)y);
       
   577 	else
       
   578 	    tempStr.Format(KLabelFormatFloat,y);
       
   579 	AknTextUtils::LanguageSpecificNumberConversion( tempStr );
       
   580 	tempLabel->SetTextL(tempStr);
       
   581 	tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   582 	CleanupStack::PushL(tempLabel);
       
   583 	iFreqLabels->AppendL(tempLabel); 
       
   584 	CleanupStack::Pop(tempLabel);
       
   585 	
       
   586 	if(iNumberOfFreqBands ==KEqualizerEightBands)
       
   587 		{
       
   588 		Math::Round(y,(TReal)audioEqualizer.CenterFrequency(6)/1000,1);
       
   589 		tempLabel = new (ELeave) CEikLabel;
       
   590 		tempLabel->SetContainerWindowL( *this );
       
   591 		Math::Mod(x,y*10,10);
       
   592 		if(x==0)
       
   593 	        tempStr.Format(KLabelFormatInt,(TInt)y);
       
   594 	    else
       
   595 	        tempStr.Format(KLabelFormatFloat,y);
       
   596 	    AknTextUtils::LanguageSpecificNumberConversion( tempStr );
       
   597 		tempLabel->SetTextL(tempStr);
       
   598 		tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   599 		CleanupStack::PushL(tempLabel);
       
   600 		iFreqLabels->AppendL(tempLabel); 
       
   601 		CleanupStack::Pop(tempLabel);
       
   602 		
       
   603 		Math::Round(y,(TReal)audioEqualizer.CenterFrequency(7)/1000,1);
       
   604 		tempLabel = new (ELeave) CEikLabel;
       
   605 		tempLabel->SetContainerWindowL( *this );
       
   606 		Math::Mod(x,y*10,10);
       
   607 		if(x==0)
       
   608 	        tempStr.Format(KLabelFormatInt,(TInt)y);
       
   609 	    else
       
   610 	        tempStr.Format(KLabelFormatFloat,y);
       
   611 	    AknTextUtils::LanguageSpecificNumberConversion(tempStr);
       
   612 		tempLabel->SetTextL(tempStr);
       
   613 		tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   614 		CleanupStack::PushL(tempLabel);
       
   615 		iFreqLabels->AppendL(tempLabel); 
       
   616 		CleanupStack::Pop(tempLabel);
       
   617 		
       
   618 		Math::Round(y,(TReal)audioEqualizer.CenterFrequency(8)/1000,1);
       
   619 		tempLabel = new (ELeave) CEikLabel;
       
   620 		tempLabel->SetContainerWindowL( *this );
       
   621 		Math::Mod(x,y*10,10);
       
   622 		if(x==0)
       
   623 	        tempStr.Format(KLabelFormatInt,(TInt)y);
       
   624     	else
       
   625 	        tempStr.Format(KLabelFormatFloat,y);
       
   626     	AknTextUtils::LanguageSpecificNumberConversion(tempStr);
       
   627 		tempLabel->SetTextL(tempStr);
       
   628 		tempLabel->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   629 		CleanupStack::PushL(tempLabel);
       
   630 		iFreqLabels->AppendL(tempLabel); 
       
   631 		CleanupStack::Pop(tempLabel);
       
   632 		}
       
   633 		
       
   634 	TRgb color;
       
   635   MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   636     
       
   637   for(TInt i=0; i<iFreqLabels->Count(); i++)
       
   638    	{
       
   639    	CCoeControl* label( ComponentControl( i+iNumberOfFreqBands ));
       
   640    	TInt error = AknsUtils::GetCachedColor( skin, color,
       
   641                                             KAknsIIDQsnTextColors,
       
   642                                             EAknsCIQsnTextColorsCG6 );
       
   643    	if ( !error )
       
   644        	AknLayoutUtils::OverrideControlColorL( *label,
       
   645                                               EColorLabelText,
       
   646                                               color);
       
   647    	}
       
   648 	
       
   649 	}
       
   650 	
       
   651 #ifdef RD_SCALABLE_UI_V2
       
   652 // ---------------------------------------------------------
       
   653 // CEqualizerFreqBandContainer::HandlePointerEventL
       
   654 // This function is used to handle pen input events.
       
   655 // ---------------------------------------------------------
       
   656 //
       
   657 void CEqualizerFreqBandContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   658     {
       
   659     if (AknLayoutUtils::PenEnabled())
       
   660         {
       
   661         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   662             {
       
   663 	        for ( TInt i = 0; i < iNumberOfFreqBands; i++ )
       
   664 	            {
       
   665 	            TRect x = (*iFreqBand)[i]->Rect();
       
   666 	            if (x.Contains(aPointerEvent.iPosition))
       
   667 	                {
       
   668 	                if ( iIndexOfFocussedFreqBand != i )
       
   669 	                    {
       
   670 	                    TInt indexOfLastFocussedBand = iIndexOfFocussedFreqBand;
       
   671 	                    iIndexOfFocussedFreqBand = i;
       
   672 	                    SwapFocus((*iFreqBand)[indexOfLastFocussedBand],
       
   673 	                        (*iFreqBand)[iIndexOfFocussedFreqBand]);
       
   674 	                    }
       
   675 	                iBandSelected = ETrue;
       
   676 	                break;
       
   677 	                }
       
   678 				}
       
   679 			}
       
   680 
       
   681 		if ( iBandSelected )
       
   682 		    {
       
   683 			(*iFreqBand)[iIndexOfFocussedFreqBand]->HandlePointerEventL(aPointerEvent);
       
   684 		    }
       
   685 
       
   686 		// In MPX the band dialog presets need to be saved
       
   687 		// and called back to the observer
       
   688 		//
       
   689 		if ( iBandSelected &&
       
   690             ( (aPointerEvent.iType == TPointerEvent::EButton1Up) ||
       
   691 		      (aPointerEvent.iType == TPointerEvent::EDrag) ) )
       
   692 			{
       
   693 			if ( iIsActivePreset )
       
   694                 {
       
   695 				CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer();
       
   696 				iAudEqUtility->ModifyPresetL(iPresetIndex, iPresetName, audioEqualizer);
       
   697 				iObserver.HandlePresetActivation( iPresetKey );
       
   698 				}
       
   699 			if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   700                 {
       
   701                 iBandSelected = EFalse;
       
   702 			    }
       
   703 			}
       
   704 	    }
       
   705     }
       
   706 #endif //RD_SCALABLE_UI_V2
       
   707 
       
   708 // End of File
       
   709