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 "MVSBalanceDialog.h" sl@0: #include "MVSApp.hrh" sl@0: sl@0: const TInt KBalanceBarUpdateFactor = 10;//Increment factor for the balance bar every increment sl@0: //would increase/decrease the bar by a factor of 10. sl@0: sl@0: void CMVSBalanceDialog::SetupDialogLD(TInt aBalance, sl@0: CMVSAppUi* aAppUi, TBool aPlayBack) sl@0: { sl@0: CMVSBalanceDialog* dialog = new (ELeave) CMVSBalanceDialog(aBalance, aAppUi, aPlayBack); sl@0: dialog->ExecuteLD(R_MVS_DIALOG_SETBALANCE); sl@0: } sl@0: sl@0: sl@0: void CMVSBalanceDialog::PreLayoutDynInitL() sl@0: { sl@0: _LIT(KTitle1,"SetPlayBalance"); sl@0: _LIT(KTitle2,"SetRecordBalance"); 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(EMVSSetBalance); sl@0: iProgInfo = static_cast(myControlPtr); sl@0: if(iProgInfo) sl@0: { sl@0: iProgInfo->SetAndDraw((iBalance+100)/2); sl@0: } sl@0: } sl@0: sl@0: sl@0: CMVSBalanceDialog::CMVSBalanceDialog(TInt aBalance, CMVSAppUi* aAppUi, TBool aPlayBack) sl@0: : iBalance(aBalance), iPlayBack(aPlayBack), iAppUi(aAppUi) sl@0: { sl@0: //Nothing to do here - all done in initialisation list sl@0: } sl@0: sl@0: sl@0: TKeyResponse CMVSBalanceDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) sl@0: { sl@0: if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown) sl@0: { sl@0: OkToExitL(EMVSButtonOk); sl@0: } sl@0: return CEikDialog::OfferKeyEventL(aKeyEvent,aType); sl@0: } sl@0: sl@0: sl@0: TBool CMVSBalanceDialog::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: switch(aButtonId) sl@0: { sl@0: case(EMVSButtonLeft): sl@0: iProgInfo->IncrementAndDraw(-(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor)); sl@0: break; sl@0: sl@0: case(EMVSButtonRight): sl@0: iProgInfo->IncrementAndDraw(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor); sl@0: break; sl@0: sl@0: case(EMVSButtonOk): sl@0: //Get the value on the progress bar sl@0: //to convert balance from a figure between 0 and 100 sl@0: //to a figure between -100 and 100 sl@0: iBalance = (iProgInfo->CurrentValue()*2)-100; sl@0: iAppUi->SetBalanceL(iBalance); sl@0: return ETrue; sl@0: sl@0: default: //cancel sl@0: return ETrue; sl@0: } sl@0: return EFalse; sl@0: }