mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSVolumeDialog.cpp
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Part of the MVS Application for TechView
       
    15 //
       
    16 
       
    17 #include "MVSVolumeDialog.h"
       
    18 #include "MVSApp.hrh"
       
    19 #include "MVSAppUI.h"
       
    20 
       
    21 
       
    22 void CMVSVolumeDialog::SetupDialogLD(TInt aVolume, TTimeIntervalMicroSeconds aRamp,
       
    23                                   TTimeIntervalMicroSeconds aClipLength, TBool aPlayback, CMVSAppUi* aAppUi)
       
    24 	{
       
    25     CMVSVolumeDialog* dialog = new (ELeave) CMVSVolumeDialog(aVolume, aRamp, aClipLength, aPlayback, aAppUi);
       
    26     dialog->ExecuteLD(R_MVS_DIALOG_SETVOLUME);
       
    27     }
       
    28 
       
    29 
       
    30 void CMVSVolumeDialog::PreLayoutDynInitL()
       
    31     {
       
    32     _LIT(KTitle1,"SetVolume");
       
    33     _LIT(KTitle2,"SetGain");
       
    34      if(iPlayback)
       
    35      	{
       
    36      	SetTitleL(KTitle1);
       
    37      	}
       
    38 	 else
       
    39 	 	{
       
    40 	 	SetTitleL(KTitle2);
       
    41 	 	}
       
    42     // Get a downcasted pointer to the controls
       
    43     CCoeControl* myControlPtr = this->Control(EMVSCmdSetVolume);
       
    44     iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);  
       
    45     //Initial Volume
       
    46     iProgInfo->SetAndDraw(iVolume);
       
    47     //Initial VolumeRamp
       
    48     InitControl((TInt)EMVSCmdSetVolumeRamp, I64INT(iRamp.Int64())/1000, 0, I64INT(iClipLength.Int64())/1000);
       
    49     }
       
    50 
       
    51 
       
    52 CMVSVolumeDialog::CMVSVolumeDialog(TInt aVolume, TTimeIntervalMicroSeconds aRamp,
       
    53                              TTimeIntervalMicroSeconds aClipLength, TBool aPlayback, CMVSAppUi* aAppUi)
       
    54 : iVolume(aVolume), iRamp(aRamp), iClipLength(aClipLength), iPlayback(aPlayback), iAppUi(aAppUi), iOldVolume(aVolume)
       
    55 	{
       
    56     }
       
    57 
       
    58 
       
    59 TKeyResponse CMVSVolumeDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
    60 	{
       
    61 	if(aKeyEvent.iCode == EKeyEscape && aType == EEventKeyDown)
       
    62 		{
       
    63 		OkToExitL(EMVSButtonCancel);
       
    64 		}
       
    65 	else if(aKeyEvent.iCode == EKeyRightArrow)
       
    66 		{
       
    67 		OkToExitL(EMVSButtonUp);
       
    68 		}
       
    69 	else if(aKeyEvent.iCode == EKeyLeftArrow)
       
    70 		{
       
    71 		OkToExitL(EMVSButtonDown);
       
    72 		}
       
    73 	
       
    74 	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
       
    75 	}
       
    76 
       
    77 
       
    78 TBool CMVSVolumeDialog::OkToExitL(TInt aButtonId)
       
    79 	{
       
    80     // Get a pointer to the progress bar control.
       
    81     // Downcast the returned CCoeControl* pointer to the correct type.
       
    82     CCoeControl* myControlPtr = this->Control(EMVSCmdSetVolume);
       
    83     iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);
       
    84     CEikNumberEditor* control = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVolumeRamp));
       
    85     switch(aButtonId)
       
    86     	{
       
    87     	case (EMVSButtonCancel):
       
    88     		iAppUi->SetVolumeL(iOldVolume, iRamp);
       
    89          	return ETrue;
       
    90          	
       
    91         case(EMVSButtonDown):
       
    92         	if(iProgInfo)
       
    93 	        	{
       
    94 	        	iProgInfo->IncrementAndDraw(-5);
       
    95 	        	iVolume = iProgInfo->CurrentValue();
       
    96 	          	iRamp = control->Number()*1000;
       
    97 	        	iAppUi->SetVolumeL(iVolume, iRamp);
       
    98 	        	}
       
    99         	break;
       
   100 
       
   101         case(EMVSButtonUp):
       
   102             if(iProgInfo)
       
   103 	            {
       
   104 	            iProgInfo->IncrementAndDraw(5);
       
   105 	        	iVolume = iProgInfo->CurrentValue();
       
   106 	          	iRamp = control->Number()*1000;
       
   107 	            iAppUi->SetVolumeL(iVolume, iRamp);
       
   108 	            }
       
   109            	break;
       
   110 
       
   111         case(EMVSButtonOk):
       
   112         default:
       
   113         	return ETrue;
       
   114         }
       
   115      
       
   116     return EFalse;
       
   117     }
       
   118 
       
   119 
       
   120 
       
   121 void CMVSVolumeDialog::InitControl( const TInt aId, const TInt aRamp, const TInt aStart, const TInt aFinish )
       
   122 	{
       
   123 	CEikNumberEditor* control = static_cast<CEikNumberEditor*> ( Control(aId) );        
       
   124 	if(control)
       
   125 		{
       
   126 		control->SetNumber(aRamp);
       
   127 		control->SetMinimumAndMaximum( aStart, aFinish );
       
   128 		}
       
   129 	
       
   130 	}