examples/SFExamples/Quick_Recipes_on_Symbian_OS_Multimedia_Example_Code/AudioTone/src/AudioToneAppUi.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 // INCLUDES
00018 #include <AudioTone.rsg>
00019 
00020 #include "AudioToneAppUi.h"
00021 #include "AudioToneMainView.h"
00022 #include "AudioTonePlayer.h"
00023 #include "AudioTone.hrh"
00024 
00025 // CONSTANTS
00026 const TInt KOneSecond = 1000 * 1000;
00027 
00028 const TInt KOctaveA = 440;
00029 
00030 const TInt KFrequencyOne1 = 1209;
00031 const TInt KFrequencyOne2 = 697;
00032 
00033 // MEMBER FUNCTIONS
00034 
00035 // --------------------------------------------------------------------------
00036 // Constructor
00037 // --------------------------------------------------------------------------
00038 void CAudioToneAppUi::ConstructL()
00039         {
00040 
00041 
00042         BaseConstructL(EAknEnableSkin);
00043         
00044         iMainView = CAudioToneMainView::NewL(ClientRect());
00045 
00046         
00047         iTonePlayer = CAudioTonePlayer::NewL();
00048         }
00049         
00050 // --------------------------------------------------------------------------
00051 // Destructor
00052 // --------------------------------------------------------------------------
00053 CAudioToneAppUi::~CAudioToneAppUi()
00054     {
00055     delete iTonePlayer;
00056     
00057 
00058     if (iMainView)
00059         {
00060         delete iMainView;
00061         iMainView = NULL;
00062         }
00063 
00064     }
00065 
00066 // --------------------------------------------------------------------------
00067 // Handles user command.
00068 // --------------------------------------------------------------------------
00069 void CAudioToneAppUi::HandleCommandL(TInt aCommand)
00070         {
00071         switch ( aCommand )
00072                 {
00073 
00074                 // For S60, we need to handle this event, which is normally
00075                 // an event from the right soft key.
00076                 case EAknSoftkeyExit:
00077 
00078                 case EEikCmdExit:
00079                         {
00080                         Exit();
00081                         break;
00082                         }
00083                 
00084                 case EAudioTonePlayTone:
00085                         {
00086                         iTonePlayer->PlayTone(KOctaveA,
00087                                         TTimeIntervalMicroSeconds(2 * KOneSecond));
00088                         break;
00089                         }
00090                 
00091                 case EAudioTonePlayDualTone:
00092                         {
00093                         iTonePlayer->PlayDualTone(KFrequencyOne1, KFrequencyOne2,
00094                                         TTimeIntervalMicroSeconds(KOneSecond));
00095                         break;
00096                         }
00097                         
00098                 case EAudioToneStopTone:
00099                         {
00100                         iTonePlayer->Stop();
00101                         break;
00102                         }
00103                 
00104                 default:
00105                         // Do nothing
00106                         break;
00107                 }
00108         }
00109 
00110         
00111 
00112 
00113 // --------------------------------------------------------------------------
00114 // Handles screen resolution/size changes.
00115 // --------------------------------------------------------------------------
00116 void CAudioToneAppUi::HandleResourceChangeL(TInt aType)
00117         {
00118         CAknAppUi::HandleResourceChangeL(aType);
00119         iMainView->SetRect(ClientRect());
00120         }
00121 
00122 
00123         
00124 // End of File

Generated by  doxygen 1.6.2