mmserv/audioeffectsui/equalizer/src/EqualizerFreqBand.cpp
changeset 16 43d09473c595
parent 14 80975da52420
child 22 128eb6a32b84
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
     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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <eikdef.h>
       
    23 #include <e32math.h>
       
    24 #include <AknUtils.h>
       
    25 #include <AknsDrawUtils.h>
       
    26 #include <bautils.h>
       
    27 #include <data_caging_path_literals.hrh> 
       
    28 //LAF and Skin changes
       
    29 #include <AknIconUtils.h>
       
    30 #include <AknsUtils.h>
       
    31 #include <AknsConstants.h>
       
    32 #include <AknsDrawUtils.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 #if defined(RD_TACTILE_FEEDBACK)
       
    39 #include <touchfeedback.h>
       
    40 #endif
       
    41 
       
    42 #include <equalizer.mbg>
       
    43 #include "EqualizerPrivateConstants.h"
       
    44 #include "EqualizerEditingDialog.h"
       
    45 #include "EqualizerFreqBand.h"
       
    46 #include "Equalizer.hrh"
       
    47 
       
    48 // ============================ MEMBER FUNCTIONS =============================
       
    49 
       
    50 //============================================================================
       
    51 // -----> CEqualizerFreqBand (implementation)
       
    52 //============================================================================
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CEqualizerFreqBand* CEqualizerFreqBand::NewL(CEqualizerEditingDialog* aEqEditingDialog,
       
    56 //    CAudioEqualizerUtility*& aAudEqUtility, CAudioEqualizer& aAudEqualizer,
       
    57 //     const TInt aPresetIndex, const TBool aIsActivePreset,
       
    58 //    const TInt aBandIndex, TInt& aMoverPos, TRect& aRect)
       
    59 //
       
    60 // Two Phase construction
       
    61 // ----------------------------------------------------------------------------
       
    62 //
       
    63 CEqualizerFreqBand* CEqualizerFreqBand::NewL(CEqualizerEditingDialog* aEqEditingDialog,
       
    64     CAudioEqualizerUtility*& aAudEqUtility, const TInt aPresetIndex,
       
    65     const TBool aIsActivePreset, const TInt aBandIndex, 
       
    66     TRect& aRect)
       
    67     {
       
    68     CEqualizerFreqBand* self = CEqualizerFreqBand::NewLC(aEqEditingDialog, aAudEqUtility,
       
    69      aPresetIndex, aIsActivePreset, aBandIndex, 
       
    70      aRect);
       
    71     CleanupStack::Pop(self);
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // CEqualizerFreqBand* CEqualizerFreqBand::NewLC(CEqualizerEditingDialog* aEqEditingDialog,
       
    77 // CAudioEqualizerUtility*& aAudEqUtility, const TInt aPresetIndex,
       
    78 // const TBool aIsActivePreset,   const TInt aBandIndex, TInt& aMoverPos, 
       
    79 // TRect& aRect)
       
    80 // Two Phase construction
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 CEqualizerFreqBand* CEqualizerFreqBand::NewLC(CEqualizerEditingDialog* aEqEditingDialog,
       
    84     CAudioEqualizerUtility*& aAudEqUtility, const TInt aPresetIndex,
       
    85     const TBool aIsActivePreset, const TInt aBandIndex, 
       
    86     TRect& aRect)
       
    87     {
       
    88     CEqualizerFreqBand* self = new (ELeave) CEqualizerFreqBand(aEqEditingDialog, aAudEqUtility,
       
    89     aPresetIndex, aIsActivePreset, aBandIndex, 
       
    90     aRect);
       
    91     CleanupStack::PushL(self); 
       
    92     self->ConstructL();
       
    93     return self;
       
    94     }    
       
    95 // ----------------------------------------------------------------------------
       
    96 //CEqualizerFreqBand::CEqualizerFreqBand(CEqualizerEditingDialog* aEqEditingDialog,
       
    97 //    CAudioEqualizerUtility*& aAudEqUtility, 
       
    98 //     const TPresetName& aPresetName, const TBool aIsActivePreset,
       
    99 //    const TInt aBandIndex, TInt& aMoverPos, TRect& aRect) 
       
   100 //
       
   101 // First phase constructor
       
   102 // ----------------------------------------------------------------------------
       
   103 CEqualizerFreqBand::CEqualizerFreqBand(CEqualizerEditingDialog* aEqEditingDialog, 
       
   104     CAudioEqualizerUtility*& aAudEqUtility, const TInt aPresetIndex, 
       
   105     const TBool aIsActivePreset,
       
   106     const TInt aBandIndex,  TRect& aContainerRect) 
       
   107     : iEqEditingDialog(aEqEditingDialog), iAudEqUtility(aAudEqUtility), iPresetIndex(aPresetIndex), 
       
   108     iIsActivePreset(aIsActivePreset), iBandIndex(aBandIndex), 
       
   109     iContainerRect(aContainerRect)
       
   110     {
       
   111     }
       
   112 
       
   113 // -------------------------------------------------------------------
       
   114 // void CEqualizerFreqBand::ConstructL() 
       
   115 //
       
   116 // Second phase constructor
       
   117 // --------------------------------------------------------------------
       
   118 //
       
   119 void CEqualizerFreqBand::ConstructL() 
       
   120     {
       
   121     LoadBitmapsL();
       
   122     iPresetName = iAudEqUtility->GetPresetL(iPresetIndex);
       
   123     iAudioEqualizer = &iAudEqUtility->Equalizer();
       
   124     iAudioEqualizer->DbLevelLimits(iMinBandLevel, iMaxBandLevel);
       
   125     }
       
   126 
       
   127 // -------------------------------------------------------------------
       
   128 // CEqualizerFreqBand::~CEqualizerFreqBand()
       
   129 //
       
   130 // Destructor
       
   131 // --------------------------------------------------------------------
       
   132 //    
       
   133 CEqualizerFreqBand::~CEqualizerFreqBand()
       
   134     { 
       
   135     delete iBgBitmap;
       
   136     delete iBgBitmapMask;
       
   137     delete iSliderBitmap;
       
   138     delete iSliderBitmapMask;
       
   139 
       
   140 #if defined(RD_TACTILE_FEEDBACK)
       
   141    MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   142    if (feedback)
       
   143        {
       
   144    	   feedback->RemoveFeedbackForControl(this);
       
   145        }
       
   146 #endif
       
   147     }
       
   148 
       
   149 // -------------------------------------------------------------------
       
   150 // void CEqualizerFreqBand::Draw(const TRect& aRect) const
       
   151 //
       
   152 // Function to draw the control
       
   153 // --------------------------------------------------------------------
       
   154 //
       
   155 void CEqualizerFreqBand::Draw(const TRect& /*aRect*/) const
       
   156     {
       
   157     CWindowGc& gc=SystemGc();
       
   158     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   159     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   160     AknsDrawUtils::Background( skinInstance, cc, this, gc, iBackgroundRect );
       
   161     TRect innerRect = iBackgroundRect;
       
   162     innerRect.Shrink( TSize( 5, 5) );
       
   163 	if (IsFocused())
       
   164 		{
       
   165    			
       
   166    		AknsDrawUtils::DrawFrame( skinInstance, gc, iBackgroundRect, 
       
   167    						innerRect,KAknsIIDQsnFrGrid, KAknsIIDQsnFrGridCenter);		
       
   168 		}
       
   169     					
       
   170 	gc.BitBltMasked(iBackgroundRect.iTl,iBgBitmap, TRect(TPoint(), 
       
   171 					iBackgroundRect.Size()), iBgBitmapMask, ETrue);
       
   172 	
       
   173 	TInt halfSliderSize = iSliderRect.Height() / 2;
       
   174 	TInt sliderRectYCoord = iSliderRect.iTl.iY;
       
   175 	TInt yCoordOffset = ((iMoverPos - sliderRectYCoord) - halfSliderSize);
       
   176 	TRect tempSliderRect = iSliderRect;
       
   177 	tempSliderRect.Move(0,yCoordOffset);
       
   178 	
       
   179     gc.BitBltMasked(tempSliderRect.iTl,iSliderBitmap,TRect(TPoint(), 
       
   180     						tempSliderRect.Size()),iSliderBitmapMask,ETrue);
       
   181 	}
       
   182 // -------------------------------------------------------------------
       
   183 // void CEqualizerFreqBand::SizeChanged()
       
   184 //
       
   185 // This function is called by the framework whenever the control size 
       
   186 // is changed
       
   187 // --------------------------------------------------------------------
       
   188 void CEqualizerFreqBand::SizeChanged()
       
   189     {
       
   190 	TInt variety = EEqualizerVarietyOne;
       
   191 
       
   192     CAudioEqualizer& audioEqualizer = iAudEqUtility->Equalizer();
       
   193     TUint numberOfFreqBands = audioEqualizer.NumberOfBands();
       
   194         
       
   195 	if(numberOfFreqBands == KEqualizerFiveBands)
       
   196 	    {
       
   197 	    variety = EEqualizerVarietyTwo;
       
   198 	    }
       
   199    
       
   200 	iScaleRect = ComponentRect(Rect(),
       
   201 									variety,EEqualizerScale);
       
   202 	iBackgroundRect = ComponentRect(iScaleRect,
       
   203 								EEqualizerVarietyNotUsed,EEqualizerBackground);
       
   204  	iSliderRect = ComponentRect(iScaleRect,
       
   205  									EEqualizerVarietyNotUsed,EEqualizerSlider);
       
   206 
       
   207 #if defined(RD_TACTILE_FEEDBACK)
       
   208 	MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   209 	if (feedback)
       
   210 		{
       
   211 		feedback->SetFeedbackArea(this, 0, iBackgroundRect,
       
   212 			ETouchFeedbackBasic, ETouchEventStylusDown);
       
   213 		}
       
   214 #endif
       
   215 
       
   216 	AknIconUtils::SetSize(iBgBitmap,iBackgroundRect.Size(), EAspectRatioNotPreserved);
       
   217 	AknIconUtils::SetSize(iBgBitmapMask,iBackgroundRect.Size(), EAspectRatioNotPreserved);
       
   218 	
       
   219 	AknIconUtils::SetSize(iSliderBitmap,iSliderRect.Size(), EAspectRatioNotPreserved);
       
   220     AknIconUtils::SetSize(iSliderBitmapMask,iSliderRect.Size(), EAspectRatioNotPreserved);
       
   221     
       
   222     TInt scaleHeight = iBackgroundRect.Height();
       
   223     TInt zeroCoord = iBackgroundRect.iTl.iY + (scaleHeight / 2);
       
   224     iZeroPos = zeroCoord;  
       
   225     iMoverPos = iEqEditingDialog->GetMoverPosition(iBandIndex);
       
   226     
       
   227     TInt sliderInc = iBackgroundRect.Height() / KNumberOfSteps;
       
   228     TReal res,frac;
       
   229     frac = (TReal)(iMoverPos - iZeroPos) / sliderInc;
       
   230     Math::Round(res,frac,0);
       
   231     Math::Int(iStepCount,res);
       
   232     iStepCount += KNumberOfSteps / 2;
       
   233     if(iStepCount > KNumberOfSteps)
       
   234     	{
       
   235     	iStepCount = KNumberOfSteps;
       
   236     	}
       
   237     if(iStepCount < 0)
       
   238     	{
       
   239     	iStepCount = 0;
       
   240     	}
       
   241 
       
   242     }
       
   243 
       
   244 // -------------------------------------------------------------------
       
   245 // void CEqualizerFreqBand::FocusChanged(TDrawNow aDrawNow)
       
   246 //
       
   247 // This function is called by the framework whenever the control's 
       
   248 // focus is changed
       
   249 // --------------------------------------------------------------------
       
   250 //
       
   251 void CEqualizerFreqBand::FocusChanged(TDrawNow aDrawNow)
       
   252     {
       
   253     if (aDrawNow)
       
   254         {
       
   255         DrawNow();        
       
   256         }
       
   257     }
       
   258     
       
   259 // -------------------------------------------------------------------
       
   260 // void CEqualizerFreqBand::HandleResourceChange(TInt aType)
       
   261 //
       
   262 // This function is called by the framework whenever there is a 
       
   263 // change in skin
       
   264 // -------------------------------------------------------------------
       
   265 void CEqualizerFreqBand::HandleResourceChange(TInt aType)
       
   266     {
       
   267     if (aType == KAknsMessageSkinChange)
       
   268         {
       
   269         TInt tempMoverPos = iMoverPos;
       
   270         LoadBitmapsL();
       
   271         SizeChanged();
       
   272         iMoverPos = tempMoverPos;
       
   273         DrawNow();
       
   274         }
       
   275     }
       
   276 
       
   277 // -------------------------------------------------------------------
       
   278 // void CEqualizerFreqBand::LoadBitmapsL()
       
   279 // This function is called to load the bitmaps from the icons file
       
   280 // --------------------------------------------------------------------
       
   281 //     
       
   282 void CEqualizerFreqBand::LoadBitmapsL()
       
   283     {
       
   284     // Find which drive this DLL is installed.
       
   285     TFileName fileName;
       
   286     // Get the full resource file
       
   287     TParse fp;
       
   288     // Add the resource dir
       
   289     fp.Set( KIconsFilename, &KDC_APP_BITMAP_DIR, NULL);
       
   290     // Get the filename with full path
       
   291     fileName = fp.FullName(); 
       
   292 
       
   293     MAknsSkinInstance * skinInstance;
       
   294     skinInstance = AknsUtils::SkinInstance();
       
   295     
       
   296     //Destroying previously created background icons
       
   297     if (iBgBitmap)
       
   298     	{
       
   299     	delete iBgBitmap;
       
   300     	iBgBitmap = NULL;
       
   301     	}
       
   302     	
       
   303     if (iBgBitmapMask)
       
   304     	{
       
   305     	delete iBgBitmapMask;
       
   306     	iBgBitmapMask = NULL;
       
   307     	}
       
   308     
       
   309     //Destroying previously created slider icons
       
   310     if (iSliderBitmap)
       
   311     	{
       
   312     	delete iSliderBitmap;
       
   313     	iSliderBitmap = NULL;
       
   314     	}
       
   315     
       
   316     if (iSliderBitmapMask)
       
   317     	{
       
   318     	delete iSliderBitmapMask;
       
   319     	iSliderBitmapMask = NULL;
       
   320     	}
       
   321     
       
   322     //Creating the background icon
       
   323     AknsUtils::CreateIconL(skinInstance,KAknsIIDQgnIndiMupEqBg,
       
   324                            iBgBitmap,iBgBitmapMask,fileName,
       
   325                            EMbmEqualizerQgn_indi_mup2_eq_bg,
       
   326                            EMbmEqualizerQgn_indi_mup2_eq_bg_mask);
       
   327     
       
   328     //Creating the slider icon
       
   329     AknsUtils::CreateIconL(skinInstance,KAknsIIDQgnIndiMupEqSlider,
       
   330                            iSliderBitmap,iSliderBitmapMask,fileName,
       
   331                            EMbmEqualizerQgn_indi_mup_eq_slider,
       
   332                            EMbmEqualizerQgn_indi_mup_eq_slider_mask);
       
   333     }       
       
   334 
       
   335 // -------------------------------------------------------------------
       
   336 // void CEqualizerFreqBand::UpdateBandLevelInEngineL()
       
   337 // This function is called to update the engine with the new band level
       
   338 // --------------------------------------------------------------------
       
   339 // 
       
   340 void CEqualizerFreqBand::UpdateBandLevelInEngineL(TBool lastIncFlag)
       
   341     {
       
   342     //Update engine
       
   343 	TInt sliderInc = iBackgroundRect.Height() / KNumberOfSteps;
       
   344     TInt diffUIBandLevel = KNumberOfSteps / 2;
       
   345     TInt bandLevel;
       
   346     TReal frac;
       
   347     TInt sliderNoOfPix;
       
   348     TInt actualNoOfPix;
       
   349     TInt pixDiff;
       
   350     TReal fracDiff;
       
   351         
       
   352     if (iMoverPos > iZeroPos)
       
   353         {
       
   354         frac = (TReal)(iMoverPos - iZeroPos) / ((TReal)diffUIBandLevel * sliderInc);
       
   355 		if(lastIncFlag)
       
   356 			{
       
   357 			sliderNoOfPix = diffUIBandLevel * sliderInc;
       
   358 			actualNoOfPix = iMoverPos - iZeroPos;
       
   359 			if(sliderNoOfPix > actualNoOfPix)
       
   360 				{
       
   361 				pixDiff = sliderNoOfPix - actualNoOfPix;
       
   362 				fracDiff = (TReal)pixDiff / ((TReal)diffUIBandLevel * sliderInc);
       
   363 				frac += fracDiff;				
       
   364 				}
       
   365 			else
       
   366 				{
       
   367 				pixDiff = actualNoOfPix - sliderNoOfPix;
       
   368 				fracDiff = (TReal)pixDiff / ((TReal)diffUIBandLevel * sliderInc);
       
   369 				frac -= fracDiff;				
       
   370 				}
       
   371 			}
       
   372 		if (frac > 1)
       
   373 			{
       
   374 			frac = 1;
       
   375 			}
       
   376 		else
       
   377 		if (frac < -1)
       
   378 			{
       
   379 			frac = -1;
       
   380 			}
       
   381         bandLevel=(TInt)(frac * iMinBandLevel);        
       
   382         }
       
   383     else if (iMoverPos < iZeroPos)
       
   384         {
       
   385         frac = (TReal)(iZeroPos - iMoverPos) / ((TReal)diffUIBandLevel * sliderInc);
       
   386         if(lastIncFlag)						
       
   387 			{
       
   388 			sliderNoOfPix = diffUIBandLevel * sliderInc;
       
   389 			actualNoOfPix = iZeroPos - iMoverPos;
       
   390 			if(sliderNoOfPix > actualNoOfPix)
       
   391 				{
       
   392 				pixDiff = sliderNoOfPix - actualNoOfPix;
       
   393 				fracDiff = (TReal)pixDiff / ((TReal)diffUIBandLevel * sliderInc);
       
   394 				frac += fracDiff;				
       
   395 				}
       
   396 			else
       
   397 				{
       
   398 				pixDiff = actualNoOfPix - sliderNoOfPix;
       
   399 				fracDiff = (TReal)pixDiff / ((TReal)diffUIBandLevel * sliderInc);
       
   400 				frac -= fracDiff;				
       
   401 				}
       
   402 			}
       
   403 		if (frac > 1)
       
   404 			{
       
   405 			frac = 1;
       
   406 			}
       
   407 		else
       
   408 		if (frac < -1)
       
   409 			{
       
   410 			frac = -1;
       
   411 			}
       
   412         bandLevel=(TInt)(frac * iMaxBandLevel);   
       
   413         }
       
   414     else
       
   415         {
       
   416         bandLevel = 0;
       
   417         }   
       
   418        
       
   419 //RDebug::Printf("Todd1 ==> bnad index=%d, Level set = %d", iBandIndex+1, bandLevel);
       
   420     iAudioEqualizer->SetBandLevelL(iBandIndex+1, bandLevel);     
       
   421 
       
   422     if (iIsActivePreset) 
       
   423         {
       
   424         TInt err;
       
   425         TRAP(err, iAudioEqualizer->EnableL());	
       
   426         }
       
   427    }
       
   428 
       
   429 // -------------------------------------------------------------------
       
   430 // TKeyResponse CEqualizerFreqBand::OfferKeyEventL
       
   431 // (const TKeyEvent& aKeyEvent,TEventCode aType)
       
   432 // This function is called to handle key events
       
   433 // --------------------------------------------------------------------
       
   434 //
       
   435 TKeyResponse CEqualizerFreqBand::OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
   436 TEventCode aType)
       
   437     {
       
   438     TKeyResponse ret = EKeyWasNotConsumed;
       
   439     
       
   440     TInt halfSliderSize = iSliderRect.Height() / 2;
       
   441     TInt sliderInc = iBackgroundRect.Height() / KNumberOfSteps;
       
   442 	TInt nextInc;
       
   443 	TBool lastIncFlag = 0;
       
   444 	
       
   445     if (aType==EEventKey && (aKeyEvent.iScanCode==EStdKeyDownArrow ))
       
   446         {
       
   447         if (iMoverPos < (iBackgroundRect.iBr.iY - halfSliderSize))
       
   448          	{
       
   449             nextInc = sliderInc;
       
   450             iStepCount += 1;
       
   451             if(((iMoverPos + nextInc) <= 
       
   452             				(iBackgroundRect.iBr.iY - halfSliderSize))
       
   453             				&& (iStepCount != KNumberOfSteps))
       
   454             	{
       
   455             	TInt offset = Abs(iMoverPos - iZeroPos) % sliderInc;
       
   456             	if(offset==0)
       
   457             		iMoverPos += nextInc ;
       
   458             	else
       
   459             		{
       
   460             		//iStepCount--;
       
   461             		if(iMoverPos>iZeroPos)	
       
   462             	   		iMoverPos+= sliderInc - offset;
       
   463             	
       
   464             		if(iMoverPos<iZeroPos)
       
   465             	    	iMoverPos+= sliderInc + offset;
       
   466             		}
       
   467             	}
       
   468 		    else
       
   469 		    	{
       
   470 		    	nextInc = (iBackgroundRect.iBr.iY - halfSliderSize)
       
   471 		    								 - iMoverPos;
       
   472 		    	iMoverPos += nextInc;
       
   473 		    	
       
   474 		    	if(iStepCount > KNumberOfSteps )
       
   475 		    	    iStepCount = KNumberOfSteps;
       
   476 		    	}
       
   477             if(((iMoverPos) == (iBackgroundRect.iBr.iY - halfSliderSize)) ||
       
   478             			(iStepCount == KNumberOfSteps))
       
   479             	{
       
   480             	lastIncFlag = 1;
       
   481             	}
       
   482             //Update engine
       
   483             UpdateBandLevelInEngineL(lastIncFlag);
       
   484             }
       
   485         DrawNow();
       
   486         ret = EKeyWasConsumed;
       
   487         }
       
   488     else if (aType==EEventKey && (aKeyEvent.iScanCode==EStdKeyUpArrow))
       
   489         {
       
   490         if (iMoverPos > (iBackgroundRect.iTl.iY+halfSliderSize))
       
   491             {
       
   492             nextInc = sliderInc;
       
   493             iStepCount -= 1;
       
   494             if(((iMoverPos - nextInc) >= (iBackgroundRect.iTl.iY + halfSliderSize))
       
   495             			&& (iStepCount != 0))
       
   496             	{
       
   497             	TInt offset = Abs(iMoverPos - iZeroPos) % sliderInc;
       
   498             	if(offset==0)
       
   499                		iMoverPos -= nextInc;
       
   500             	else
       
   501             		{
       
   502             		//iStepCount++; 
       
   503             		if(iMoverPos>iZeroPos)	
       
   504             	   		iMoverPos-= nextInc + offset;
       
   505             	
       
   506             		if(iMoverPos<iZeroPos)
       
   507             	   		iMoverPos-= sliderInc - offset;
       
   508             		}
       
   509             	}
       
   510             else
       
   511             	{
       
   512             	nextInc = iMoverPos - (iBackgroundRect.iTl.iY + halfSliderSize);
       
   513             	iMoverPos -= nextInc;
       
   514             	
       
   515             	if(iStepCount < 0 )
       
   516 		    	    iStepCount = 0;
       
   517             	}
       
   518             if(((iMoverPos) == (iBackgroundRect.iTl.iY + halfSliderSize)) ||
       
   519             			(iStepCount == 0))
       
   520             	{
       
   521             	lastIncFlag = 1;
       
   522             	}
       
   523             //Update engine
       
   524             UpdateBandLevelInEngineL(lastIncFlag);
       
   525             }
       
   526         DrawNow();
       
   527         ret = EKeyWasConsumed;
       
   528         }
       
   529     else
       
   530         {
       
   531         ret = EKeyWasNotConsumed;
       
   532         }
       
   533     return ret;
       
   534     }
       
   535 
       
   536 // ----------------------------------------------------------------------------
       
   537 // TRect CEqualizerFreqBand::ComponentRect(const TRect& aRect, TInt aVariety, 
       
   538 //                                                    TInt aComponentNumber)
       
   539 // This function is called to return the rect of a control after reading the 
       
   540 // layout information from the CDL file. It returns the rect for the control 
       
   541 // based on the Enumerated member sent as a parameter
       
   542 // ----------------------------------------------------------------------------
       
   543 //
       
   544 TRect CEqualizerFreqBand::ComponentRect(const TRect& aRect, TInt aVariety, 
       
   545                                                     TInt aComponentNumber)
       
   546     {
       
   547     TAknWindowComponentLayout lLayout;
       
   548     
       
   549     switch(aComponentNumber)
       
   550         {
       
   551         case EEqualizerFreqBand1:    lLayout = AknLayoutScalable_Apps::
       
   552                                             mup_equalizer_pane(aVariety);
       
   553                                     break;
       
   554                                     
       
   555         case EEqualizerFreqBand2:    lLayout = AknLayoutScalable_Apps::
       
   556                                             mup_equalizer_pane_cp1(aVariety);
       
   557                                     break;
       
   558                                     
       
   559         case EEqualizerFreqBand3:    lLayout = AknLayoutScalable_Apps::
       
   560                                             mup_equalizer_pane_cp2(aVariety);
       
   561                                     break;
       
   562                                     
       
   563         case EEqualizerFreqBand4:    lLayout = AknLayoutScalable_Apps::
       
   564                                             mup_equalizer_pane_cp3(aVariety);
       
   565                                     break;
       
   566                                     
       
   567         case EEqualizerFreqBand5:    lLayout = AknLayoutScalable_Apps::
       
   568                                             mup_equalizer_pane_cp4(aVariety);
       
   569                                     break;
       
   570 
       
   571         case EEqualizerFreqBand6:    lLayout = AknLayoutScalable_Apps::
       
   572                                             mup_equalizer_pane_cp5(1);
       
   573                                     break;
       
   574 
       
   575         case EEqualizerFreqBand7:    lLayout = AknLayoutScalable_Apps::
       
   576                                             mup_equalizer_pane_cp6(1);
       
   577                                     break;
       
   578 
       
   579         case EEqualizerFreqBand8:    lLayout = AknLayoutScalable_Apps::
       
   580                                             mup_equalizer_pane_cp7(1);
       
   581                                     break;
       
   582                                     
       
   583         case EEqualizerMainPane:    lLayout = AknLayoutScalable_Apps::
       
   584                                             main_mup_eq_pane();
       
   585                                     break;
       
   586 
       
   587         case EEqualizerScale:         lLayout = AknLayoutScalable_Apps::
       
   588                                             mup_scale_pane(aVariety);
       
   589                                     break;
       
   590 
       
   591         case EEqualizerBackground:    lLayout = AknLayoutScalable_Apps::
       
   592                                             mup_scale_pane_g1();
       
   593                                     break;
       
   594 
       
   595         case EEqualizerSlider:        lLayout = AknLayoutScalable_Apps::
       
   596                                             mup_scale_pane_g2();
       
   597                                     break;
       
   598 
       
   599         default:                    break;
       
   600         }
       
   601     
       
   602     TAknLayoutRect lLayoutRect;
       
   603     lLayoutRect.LayoutRect(aRect,lLayout.LayoutLine());
       
   604     
       
   605     TRect rect = lLayoutRect.Rect();
       
   606     return (rect);
       
   607     }
       
   608 
       
   609 // ----------------------------------------------------------------------------
       
   610 // CEqualizerFreqBand::SetAudioEqualizerL(CAudioEqualizerUtility* 
       
   611 // aAudEqUtility)
       
   612 // This function is used to set a new CAudioEqualizerUtility* 
       
   613 // ----------------------------------------------------------------------------
       
   614 //    
       
   615 void CEqualizerFreqBand::SetAudioEqualizerL(
       
   616 CAudioEqualizerUtility* aAudEqUtility)
       
   617 	{
       
   618 	
       
   619 	// Save the user's settings
       
   620 	iAudEqUtility->ModifyPresetL(iPresetIndex, iPresetName, *iAudioEqualizer);
       
   621 	
       
   622 	// Set new value for CAudioEqualizerUtility
       
   623 	__ASSERT_DEBUG((iAudEqUtility != NULL), User::Invariant());
       
   624 	iAudEqUtility = aAudEqUtility;
       
   625 	iPresetName = iAudEqUtility->GetPresetL(iPresetIndex);
       
   626     iAudioEqualizer = &iAudEqUtility->Equalizer();
       
   627 	}
       
   628 
       
   629 #ifdef RD_SCALABLE_UI_V2
       
   630 // ----------------------------------------------------------------------------
       
   631 // CEqualizerFreqBand::HandlePointerEventL(const TPointerEvent&  
       
   632 // aPointerEvent)
       
   633 // This function is used handle pen input events 
       
   634 // ----------------------------------------------------------------------------
       
   635 //    
       
   636 void CEqualizerFreqBand::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   637 	{
       
   638     TInt pos;
       
   639 	TInt halfSliderSize = iSliderRect.Height() / 2;
       
   640     TInt sliderInc = iBackgroundRect.Height() / KNumberOfSteps;
       
   641     TInt offset;
       
   642 	TBool lastIncFlag = 0;
       
   643 #if defined(RD_TACTILE_FEEDBACK)
       
   644 	MTouchFeedback* feedback = NULL;
       
   645 #endif
       
   646 
       
   647 	if ( aPointerEvent.iPosition.iY < iBackgroundRect.iTl.iY )
       
   648 		{
       
   649 		pos = iBackgroundRect.iTl.iY;
       
   650 		}
       
   651 	else if ( aPointerEvent.iPosition.iY > iBackgroundRect.iBr.iY )
       
   652 		{
       
   653 		pos = iBackgroundRect.iBr.iY;
       
   654 		}
       
   655 	else
       
   656 		{
       
   657 		pos = aPointerEvent.iPosition.iY;
       
   658 		}
       
   659 
       
   660 	if (AknLayoutUtils::PenEnabled())
       
   661 		{
       
   662 		switch (aPointerEvent.iType)
       
   663             {
       
   664             case TPointerEvent::EButton1Down:
       
   665                 break;
       
   666 
       
   667             case TPointerEvent::EButton1Up:
       
   668             	offset = Abs(pos- iZeroPos) % sliderInc;
       
   669 
       
   670             	if(pos<= iZeroPos)
       
   671 	            	{
       
   672 	               	if(offset!=0)
       
   673             			{
       
   674 	            		if(offset <= (sliderInc/2))
       
   675 	            	   		pos+= offset;
       
   676 	            		else
       
   677 	            	    	pos+= offset - sliderInc;
       
   678 	            		}
       
   679 	            	}
       
   680 	            else
       
   681 	            	{
       
   682 	            	if(offset!=0)
       
   683 		            	{
       
   684 		            	if(offset <= (sliderInc/2))
       
   685 	            	   		pos-= offset;
       
   686 	            	    else
       
   687 	            	   		pos+= sliderInc - offset;
       
   688 		            	}
       
   689 	            	}
       
   690 
       
   691 	            iStepCount = (pos - iBackgroundRect.iTl.iY)/sliderInc;
       
   692 
       
   693 	            if(iStepCount == 0)
       
   694 		            {
       
   695 		            lastIncFlag = 1;
       
   696 		            pos = iBackgroundRect.iTl.iY + halfSliderSize;
       
   697 		            }
       
   698 
       
   699 	            if(iStepCount >= KNumberOfSteps)
       
   700 		            {
       
   701 		            lastIncFlag = 1;
       
   702 		            pos = iBackgroundRect.iBr.iY - halfSliderSize;
       
   703 		            }
       
   704 
       
   705                 iMoverPos = pos;
       
   706 	            UpdateBandLevelInEngineL(lastIncFlag);
       
   707 	            DrawNow();
       
   708                 break;
       
   709 
       
   710             case TPointerEvent::EDrag:
       
   711 #if defined(RD_TACTILE_FEEDBACK)
       
   712             	feedback = MTouchFeedback::Instance();
       
   713 				if (feedback)
       
   714 				    {
       
   715 					feedback->InstantFeedback(ETouchFeedbackSensitive);
       
   716 	                }
       
   717 #endif
       
   718                 if(pos< (iBackgroundRect.iTl.iY + halfSliderSize))
       
   719                     {
       
   720                 	pos = iBackgroundRect.iTl.iY + halfSliderSize;
       
   721                 	lastIncFlag = 1;
       
   722                     }
       
   723 
       
   724                 if(pos> (iBackgroundRect.iBr.iY - halfSliderSize))
       
   725                     {
       
   726                 	pos=iBackgroundRect.iBr.iY - halfSliderSize;
       
   727                 	lastIncFlag = 1;
       
   728                     }
       
   729 
       
   730                 iMoverPos = pos;
       
   731 	            UpdateBandLevelInEngineL(lastIncFlag);
       
   732 	            DrawNow();
       
   733                 break;
       
   734             default:
       
   735 //RDebug::Printf("Todd2 %d=", aPointerEvent.iType);
       
   736                 break;
       
   737             }
       
   738 		}
       
   739 	}
       
   740 #endif //RD_SCALABLE_UI_V2
       
   741 // End of File