os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSBalanceDialog.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSBalanceDialog.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,96 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Part of the MVS Application for TechView
    1.18 +//
    1.19 +
    1.20 +#include "MVSBalanceDialog.h"
    1.21 +#include "MVSApp.hrh"
    1.22 +
    1.23 +const TInt KBalanceBarUpdateFactor = 10;//Increment factor for the balance bar every increment
    1.24 +										//would increase/decrease the bar by a factor of 10.
    1.25 +
    1.26 +void CMVSBalanceDialog::SetupDialogLD(TInt aBalance,
    1.27 +                                   CMVSAppUi* aAppUi, TBool aPlayBack)
    1.28 +	{
    1.29 +    CMVSBalanceDialog* dialog = new (ELeave) CMVSBalanceDialog(aBalance, aAppUi, aPlayBack);
    1.30 +    dialog->ExecuteLD(R_MVS_DIALOG_SETBALANCE);
    1.31 +    }
    1.32 +
    1.33 +
    1.34 +void CMVSBalanceDialog::PreLayoutDynInitL()
    1.35 +    {
    1.36 +    _LIT(KTitle1,"SetPlayBalance");
    1.37 +    _LIT(KTitle2,"SetRecordBalance");
    1.38 +    if(iPlayBack)
    1.39 +    	{
    1.40 +     	SetTitleL(KTitle1);
    1.41 +     	}
    1.42 +    else
    1.43 +    	{
    1.44 +     	SetTitleL(KTitle2);
    1.45 +     	}
    1.46 +    // Get a downcasted pointer to the controls
    1.47 +    CCoeControl* myControlPtr = this->Control(EMVSSetBalance);
    1.48 +    iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);
    1.49 +    if(iProgInfo)
    1.50 +	    {
    1.51 +	    iProgInfo->SetAndDraw((iBalance+100)/2);	
    1.52 +	    }  
    1.53 +    }
    1.54 +
    1.55 +
    1.56 +CMVSBalanceDialog::CMVSBalanceDialog(TInt aBalance, CMVSAppUi* aAppUi, TBool aPlayBack)
    1.57 +: iBalance(aBalance), iPlayBack(aPlayBack), iAppUi(aAppUi) 
    1.58 +    {
    1.59 +    //Nothing to do here - all done in initialisation list
    1.60 +    }
    1.61 +
    1.62 +
    1.63 +TKeyResponse CMVSBalanceDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    1.64 +	{
    1.65 +	if(aKeyEvent.iCode == EKeyEnter && aType == EEventKeyDown)
    1.66 +		{
    1.67 +		OkToExitL(EMVSButtonOk);
    1.68 +		}
    1.69 +	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
    1.70 +	}
    1.71 +
    1.72 +
    1.73 +TBool CMVSBalanceDialog::OkToExitL(TInt aButtonId)
    1.74 +    {
    1.75 +    // Get a pointer to the progress bar control.
    1.76 +    // Downcast the returned CCoeControl* pointer to the correct type.
    1.77 +    switch(aButtonId)
    1.78 +    	{
    1.79 +        case(EMVSButtonLeft):
    1.80 +        	iProgInfo->IncrementAndDraw(-(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor));
    1.81 +          	break;
    1.82 +
    1.83 +        case(EMVSButtonRight):
    1.84 +            iProgInfo->IncrementAndDraw(KMVSProgressLabelMaxValue/KBalanceBarUpdateFactor);
    1.85 +          	break;
    1.86 +
    1.87 +        case(EMVSButtonOk):
    1.88 +            //Get the value on the progress bar
    1.89 +            //to convert balance from a figure between 0 and 100
    1.90 +            //to a figure between -100 and 100
    1.91 +            iBalance = (iProgInfo->CurrentValue()*2)-100;
    1.92 +            iAppUi->SetBalanceL(iBalance);
    1.93 +            return ETrue;
    1.94 +		
    1.95 +        default: //cancel
    1.96 +        	return ETrue;
    1.97 +        }
    1.98 +    return EFalse;
    1.99 +    }