sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Part of the MVS Application for TechView sl@0: // sl@0: sl@0: #include "MVSVolumeDialog.h" sl@0: #include "MVSApp.hrh" sl@0: #include "MVSAppUI.h" sl@0: sl@0: sl@0: void CMVSVolumeDialog::SetupDialogLD(TInt aVolume, TTimeIntervalMicroSeconds aRamp, sl@0: TTimeIntervalMicroSeconds aClipLength, TBool aPlayback, CMVSAppUi* aAppUi) sl@0: { sl@0: CMVSVolumeDialog* dialog = new (ELeave) CMVSVolumeDialog(aVolume, aRamp, aClipLength, aPlayback, aAppUi); sl@0: dialog->ExecuteLD(R_MVS_DIALOG_SETVOLUME); sl@0: } sl@0: sl@0: sl@0: void CMVSVolumeDialog::PreLayoutDynInitL() sl@0: { sl@0: _LIT(KTitle1,"SetVolume"); sl@0: _LIT(KTitle2,"SetGain"); sl@0: if(iPlayback) sl@0: { sl@0: SetTitleL(KTitle1); sl@0: } sl@0: else sl@0: { sl@0: SetTitleL(KTitle2); sl@0: } sl@0: // Get a downcasted pointer to the controls sl@0: CCoeControl* myControlPtr = this->Control(EMVSCmdSetVolume); sl@0: iProgInfo = static_cast(myControlPtr); sl@0: //Initial Volume sl@0: iProgInfo->SetAndDraw(iVolume); sl@0: //Initial VolumeRamp sl@0: InitControl((TInt)EMVSCmdSetVolumeRamp, I64INT(iRamp.Int64())/1000, 0, I64INT(iClipLength.Int64())/1000); sl@0: } sl@0: sl@0: sl@0: CMVSVolumeDialog::CMVSVolumeDialog(TInt aVolume, TTimeIntervalMicroSeconds aRamp, sl@0: TTimeIntervalMicroSeconds aClipLength, TBool aPlayback, CMVSAppUi* aAppUi) sl@0: : iVolume(aVolume), iRamp(aRamp), iClipLength(aClipLength), iPlayback(aPlayback), iAppUi(aAppUi), iOldVolume(aVolume) sl@0: { sl@0: } sl@0: sl@0: sl@0: TKeyResponse CMVSVolumeDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) sl@0: { sl@0: if(aKeyEvent.iCode == EKeyEscape && aType == EEventKeyDown) sl@0: { sl@0: OkToExitL(EMVSButtonCancel); sl@0: } sl@0: else if(aKeyEvent.iCode == EKeyRightArrow) sl@0: { sl@0: OkToExitL(EMVSButtonUp); sl@0: } sl@0: else if(aKeyEvent.iCode == EKeyLeftArrow) sl@0: { sl@0: OkToExitL(EMVSButtonDown); sl@0: } sl@0: sl@0: return CEikDialog::OfferKeyEventL(aKeyEvent,aType); sl@0: } sl@0: sl@0: sl@0: TBool CMVSVolumeDialog::OkToExitL(TInt aButtonId) sl@0: { sl@0: // Get a pointer to the progress bar control. sl@0: // Downcast the returned CCoeControl* pointer to the correct type. sl@0: CCoeControl* myControlPtr = this->Control(EMVSCmdSetVolume); sl@0: iProgInfo = static_cast(myControlPtr); sl@0: CEikNumberEditor* control = static_cast(Control(EMVSCmdSetVolumeRamp)); sl@0: switch(aButtonId) sl@0: { sl@0: case (EMVSButtonCancel): sl@0: iAppUi->SetVolumeL(iOldVolume, iRamp); sl@0: return ETrue; sl@0: sl@0: case(EMVSButtonDown): sl@0: if(iProgInfo) sl@0: { sl@0: iProgInfo->IncrementAndDraw(-5); sl@0: iVolume = iProgInfo->CurrentValue(); sl@0: iRamp = control->Number()*1000; sl@0: iAppUi->SetVolumeL(iVolume, iRamp); sl@0: } sl@0: break; sl@0: sl@0: case(EMVSButtonUp): sl@0: if(iProgInfo) sl@0: { sl@0: iProgInfo->IncrementAndDraw(5); sl@0: iVolume = iProgInfo->CurrentValue(); sl@0: iRamp = control->Number()*1000; sl@0: iAppUi->SetVolumeL(iVolume, iRamp); sl@0: } sl@0: break; sl@0: sl@0: case(EMVSButtonOk): sl@0: default: sl@0: return ETrue; sl@0: } sl@0: sl@0: return EFalse; sl@0: } sl@0: sl@0: sl@0: sl@0: void CMVSVolumeDialog::InitControl( const TInt aId, const TInt aRamp, const TInt aStart, const TInt aFinish ) sl@0: { sl@0: CEikNumberEditor* control = static_cast ( Control(aId) ); sl@0: if(control) sl@0: { sl@0: control->SetNumber(aRamp); sl@0: control->SetMinimumAndMaximum( aStart, aFinish ); sl@0: } sl@0: sl@0: }