os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSVolumeDialog.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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 "MVSVolumeDialog.h"
sl@0
    18
#include "MVSApp.hrh"
sl@0
    19
#include "MVSAppUI.h"
sl@0
    20
sl@0
    21
sl@0
    22
void CMVSVolumeDialog::SetupDialogLD(TInt aVolume, TTimeIntervalMicroSeconds aRamp,
sl@0
    23
                                  TTimeIntervalMicroSeconds aClipLength, TBool aPlayback, CMVSAppUi* aAppUi)
sl@0
    24
	{
sl@0
    25
    CMVSVolumeDialog* dialog = new (ELeave) CMVSVolumeDialog(aVolume, aRamp, aClipLength, aPlayback, aAppUi);
sl@0
    26
    dialog->ExecuteLD(R_MVS_DIALOG_SETVOLUME);
sl@0
    27
    }
sl@0
    28
sl@0
    29
sl@0
    30
void CMVSVolumeDialog::PreLayoutDynInitL()
sl@0
    31
    {
sl@0
    32
    _LIT(KTitle1,"SetVolume");
sl@0
    33
    _LIT(KTitle2,"SetGain");
sl@0
    34
     if(iPlayback)
sl@0
    35
     	{
sl@0
    36
     	SetTitleL(KTitle1);
sl@0
    37
     	}
sl@0
    38
	 else
sl@0
    39
	 	{
sl@0
    40
	 	SetTitleL(KTitle2);
sl@0
    41
	 	}
sl@0
    42
    // Get a downcasted pointer to the controls
sl@0
    43
    CCoeControl* myControlPtr = this->Control(EMVSCmdSetVolume);
sl@0
    44
    iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);  
sl@0
    45
    //Initial Volume
sl@0
    46
    iProgInfo->SetAndDraw(iVolume);
sl@0
    47
    //Initial VolumeRamp
sl@0
    48
    InitControl((TInt)EMVSCmdSetVolumeRamp, I64INT(iRamp.Int64())/1000, 0, I64INT(iClipLength.Int64())/1000);
sl@0
    49
    }
sl@0
    50
sl@0
    51
sl@0
    52
CMVSVolumeDialog::CMVSVolumeDialog(TInt aVolume, TTimeIntervalMicroSeconds aRamp,
sl@0
    53
                             TTimeIntervalMicroSeconds aClipLength, TBool aPlayback, CMVSAppUi* aAppUi)
sl@0
    54
: iVolume(aVolume), iRamp(aRamp), iClipLength(aClipLength), iPlayback(aPlayback), iAppUi(aAppUi), iOldVolume(aVolume)
sl@0
    55
	{
sl@0
    56
    }
sl@0
    57
sl@0
    58
sl@0
    59
TKeyResponse CMVSVolumeDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
sl@0
    60
	{
sl@0
    61
	if(aKeyEvent.iCode == EKeyEscape && aType == EEventKeyDown)
sl@0
    62
		{
sl@0
    63
		OkToExitL(EMVSButtonCancel);
sl@0
    64
		}
sl@0
    65
	else if(aKeyEvent.iCode == EKeyRightArrow)
sl@0
    66
		{
sl@0
    67
		OkToExitL(EMVSButtonUp);
sl@0
    68
		}
sl@0
    69
	else if(aKeyEvent.iCode == EKeyLeftArrow)
sl@0
    70
		{
sl@0
    71
		OkToExitL(EMVSButtonDown);
sl@0
    72
		}
sl@0
    73
	
sl@0
    74
	return CEikDialog::OfferKeyEventL(aKeyEvent,aType);
sl@0
    75
	}
sl@0
    76
sl@0
    77
sl@0
    78
TBool CMVSVolumeDialog::OkToExitL(TInt aButtonId)
sl@0
    79
	{
sl@0
    80
    // Get a pointer to the progress bar control.
sl@0
    81
    // Downcast the returned CCoeControl* pointer to the correct type.
sl@0
    82
    CCoeControl* myControlPtr = this->Control(EMVSCmdSetVolume);
sl@0
    83
    iProgInfo = static_cast<CEikProgressInfo*>(myControlPtr);
sl@0
    84
    CEikNumberEditor* control = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVolumeRamp));
sl@0
    85
    switch(aButtonId)
sl@0
    86
    	{
sl@0
    87
    	case (EMVSButtonCancel):
sl@0
    88
    		iAppUi->SetVolumeL(iOldVolume, iRamp);
sl@0
    89
         	return ETrue;
sl@0
    90
         	
sl@0
    91
        case(EMVSButtonDown):
sl@0
    92
        	if(iProgInfo)
sl@0
    93
	        	{
sl@0
    94
	        	iProgInfo->IncrementAndDraw(-5);
sl@0
    95
	        	iVolume = iProgInfo->CurrentValue();
sl@0
    96
	          	iRamp = control->Number()*1000;
sl@0
    97
	        	iAppUi->SetVolumeL(iVolume, iRamp);
sl@0
    98
	        	}
sl@0
    99
        	break;
sl@0
   100
sl@0
   101
        case(EMVSButtonUp):
sl@0
   102
            if(iProgInfo)
sl@0
   103
	            {
sl@0
   104
	            iProgInfo->IncrementAndDraw(5);
sl@0
   105
	        	iVolume = iProgInfo->CurrentValue();
sl@0
   106
	          	iRamp = control->Number()*1000;
sl@0
   107
	            iAppUi->SetVolumeL(iVolume, iRamp);
sl@0
   108
	            }
sl@0
   109
           	break;
sl@0
   110
sl@0
   111
        case(EMVSButtonOk):
sl@0
   112
        default:
sl@0
   113
        	return ETrue;
sl@0
   114
        }
sl@0
   115
     
sl@0
   116
    return EFalse;
sl@0
   117
    }
sl@0
   118
sl@0
   119
sl@0
   120
sl@0
   121
void CMVSVolumeDialog::InitControl( const TInt aId, const TInt aRamp, const TInt aStart, const TInt aFinish )
sl@0
   122
	{
sl@0
   123
	CEikNumberEditor* control = static_cast<CEikNumberEditor*> ( Control(aId) );        
sl@0
   124
	if(control)
sl@0
   125
		{
sl@0
   126
		control->SetNumber(aRamp);
sl@0
   127
		control->SetMinimumAndMaximum( aStart, aFinish );
sl@0
   128
		}
sl@0
   129
	
sl@0
   130
	}