sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Part of the MVS Application for TechView
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
#include "MVSBalanceDialog.h"
|
sl@0
|
18 |
#include "MVSApp.hrh"
|
sl@0
|
19 |
|
sl@0
|
20 |
const TInt KBalanceBarUpdateFactor = 10;//Increment factor for the balance bar every increment
|
sl@0
|
21 |
//would increase/decrease the bar by a factor of 10.
|
sl@0
|
22 |
|
sl@0
|
23 |
void CMVSBalanceDialog::SetupDialogLD(TInt aBalance,
|
sl@0
|
24 |
CMVSAppUi* aAppUi, TBool aPlayBack)
|
sl@0
|
25 |
{
|
sl@0
|
26 |
CMVSBalanceDialog* dialog = new (ELeave) CMVSBalanceDialog(aBalance, aAppUi, aPlayBack);
|
sl@0
|
27 |
dialog->ExecuteLD(R_MVS_DIALOG_SETBALANCE);
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
void CMVSBalanceDialog::PreLayoutDynInitL()
|
sl@0
|
32 |
{
|
sl@0
|
33 |
_LIT(KTitle1,"SetPlayBalance");
|
sl@0
|
34 |
_LIT(KTitle2,"SetRecordBalance");
|
sl@0
|
35 |
if(iPlayBack)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
SetTitleL(KTitle1);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
else
|
sl@0
|
40 |
{
|
sl@0
|
41 |
SetTitleL(KTitle2);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
// Get a downcasted pointer to the controls
|
sl@0
|
44 |
CCoeControl* myControlPtr = this->Control(EMVSSetBalance);
|
sl@0
|
45 |
iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);
|
sl@0
|
46 |
if(iProgInfo)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
iProgInfo->SetAndDraw((iBalance+100)/2);
|
sl@0
|
49 |
}
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
CMVSBalanceDialog::CMVSBalanceDialog(TInt aBalance, CMVSAppUi* aAppUi, TBool aPlayBack)
|
sl@0
|
54 |
: iBalance(aBalance), iPlayBack(aPlayBack), iAppUi(aAppUi)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
//Nothing to do here - all done in initialisation list
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
|
sl@0
|
60 |
TKeyResponse CMVSBalanceDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
sl@0
|
61 |
{
|
sl@0
|
62 |
if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
OkToExitL(EMVSButtonOk);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
TBool CMVSBalanceDialog::OkToExitL(TInt aButtonId)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
// Get a pointer to the progress bar control.
|
sl@0
|
73 |
// Downcast the returned CCoeControl* pointer to the correct type.
|
sl@0
|
74 |
switch(aButtonId)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
case(EMVSButtonLeft):
|
sl@0
|
77 |
iProgInfo->IncrementAndDraw(-(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor));
|
sl@0
|
78 |
break;
|
sl@0
|
79 |
|
sl@0
|
80 |
case(EMVSButtonRight):
|
sl@0
|
81 |
iProgInfo->IncrementAndDraw(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor);
|
sl@0
|
82 |
break;
|
sl@0
|
83 |
|
sl@0
|
84 |
case(EMVSButtonOk):
|
sl@0
|
85 |
//Get the value on the progress bar
|
sl@0
|
86 |
//to convert balance from a figure between 0 and 100
|
sl@0
|
87 |
//to a figure between -100 and 100
|
sl@0
|
88 |
iBalance = (iProgInfo->CurrentValue()*2)-100;
|
sl@0
|
89 |
iAppUi->SetBalanceL(iBalance);
|
sl@0
|
90 |
return ETrue;
|
sl@0
|
91 |
|
sl@0
|
92 |
default: //cancel
|
sl@0
|
93 |
return ETrue;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
return EFalse;
|
sl@0
|
96 |
}
|