os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSBalanceDialog.cpp
First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Part of the MVS Application for TechView
17 #include "MVSBalanceDialog.h"
20 const TInt KBalanceBarUpdateFactor = 10;//Increment factor for the balance bar every increment
21 //would increase/decrease the bar by a factor of 10.
23 void CMVSBalanceDialog::SetupDialogLD(TInt aBalance,
24 CMVSAppUi* aAppUi, TBool aPlayBack)
26 CMVSBalanceDialog* dialog = new (ELeave) CMVSBalanceDialog(aBalance, aAppUi, aPlayBack);
27 dialog->ExecuteLD(R_MVS_DIALOG_SETBALANCE);
31 void CMVSBalanceDialog::PreLayoutDynInitL()
33 _LIT(KTitle1,"SetPlayBalance");
34 _LIT(KTitle2,"SetRecordBalance");
43 // Get a downcasted pointer to the controls
44 CCoeControl* myControlPtr = this->Control(EMVSSetBalance);
45 iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);
48 iProgInfo->SetAndDraw((iBalance+100)/2);
53 CMVSBalanceDialog::CMVSBalanceDialog(TInt aBalance, CMVSAppUi* aAppUi, TBool aPlayBack)
54 : iBalance(aBalance), iPlayBack(aPlayBack), iAppUi(aAppUi)
56 //Nothing to do here - all done in initialisation list
60 TKeyResponse CMVSBalanceDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
62 if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
64 OkToExitL(EMVSButtonOk);
66 return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
70 TBool CMVSBalanceDialog::OkToExitL(TInt aButtonId)
72 // Get a pointer to the progress bar control.
73 // Downcast the returned CCoeControl* pointer to the correct type.
77 iProgInfo->IncrementAndDraw(-(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor));
80 case(EMVSButtonRight):
81 iProgInfo->IncrementAndDraw(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor);
85 //Get the value on the progress bar
86 //to convert balance from a figure between 0 and 100
87 //to a figure between -100 and 100
88 iBalance = (iProgInfo->CurrentValue()*2)-100;
89 iAppUi->SetBalanceL(iBalance);