mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSBalanceDialog.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 "MVSBalanceDialog.h"
       
    18 #include "MVSApp.hrh"
       
    19 
       
    20 const TInt KBalanceBarUpdateFactor = 10;//Increment factor for the balance bar every increment
       
    21 										//would increase/decrease the bar by a factor of 10.
       
    22 
       
    23 void CMVSBalanceDialog::SetupDialogLD(TInt aBalance,
       
    24                                    CMVSAppUi* aAppUi, TBool aPlayBack)
       
    25 	{
       
    26     CMVSBalanceDialog* dialog = new (ELeave) CMVSBalanceDialog(aBalance, aAppUi, aPlayBack);
       
    27     dialog->ExecuteLD(R_MVS_DIALOG_SETBALANCE);
       
    28     }
       
    29 
       
    30 
       
    31 void CMVSBalanceDialog::PreLayoutDynInitL()
       
    32     {
       
    33     _LIT(KTitle1,"SetPlayBalance");
       
    34     _LIT(KTitle2,"SetRecordBalance");
       
    35     if(iPlayBack)
       
    36     	{
       
    37      	SetTitleL(KTitle1);
       
    38      	}
       
    39     else
       
    40     	{
       
    41      	SetTitleL(KTitle2);
       
    42      	}
       
    43     // Get a downcasted pointer to the controls
       
    44     CCoeControl* myControlPtr = this->Control(EMVSSetBalance);
       
    45     iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);
       
    46     if(iProgInfo)
       
    47 	    {
       
    48 	    iProgInfo->SetAndDraw((iBalance+100)/2);	
       
    49 	    }  
       
    50     }
       
    51 
       
    52 
       
    53 CMVSBalanceDialog::CMVSBalanceDialog(TInt aBalance, CMVSAppUi* aAppUi, TBool aPlayBack)
       
    54 : iBalance(aBalance), iPlayBack(aPlayBack), iAppUi(aAppUi) 
       
    55     {
       
    56     //Nothing to do here - all done in initialisation list
       
    57     }
       
    58 
       
    59 
       
    60 TKeyResponse CMVSBalanceDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
    61 	{
       
    62 	if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
       
    63 		{
       
    64 		OkToExitL(EMVSButtonOk);
       
    65 		}
       
    66 	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
       
    67 	}
       
    68 
       
    69 
       
    70 TBool CMVSBalanceDialog::OkToExitL(TInt aButtonId)
       
    71     {
       
    72     // Get a pointer to the progress bar control.
       
    73     // Downcast the returned CCoeControl* pointer to the correct type.
       
    74     switch(aButtonId)
       
    75     	{
       
    76         case(EMVSButtonLeft):
       
    77         	iProgInfo->IncrementAndDraw(-(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor));
       
    78           	break;
       
    79 
       
    80         case(EMVSButtonRight):
       
    81             iProgInfo->IncrementAndDraw(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor);
       
    82           	break;
       
    83 
       
    84         case(EMVSButtonOk):
       
    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);
       
    90             return ETrue;
       
    91 		
       
    92         default: //cancel
       
    93         	return ETrue;
       
    94         }
       
    95     return EFalse;
       
    96     }