www.pudn.com > nokie_soundplayer.rar > soundappui.cpp
/* Copyright (c) 2004, Nokia. All rights reserved */ // INCLUDE FILES #include#include #include #include #include "sound.pan" #include "Sound.hrh" #include "SoundAppUi.h" #include "SoundView.h" //#include "toneadapter.h" #include "playeradapter.h" //#include "recorderadapter.h" // ========================= MEMBER FUNCTIONS ================================== // ----------------------------------------------------------------------------- // CSoundAppUi::CSoundAppUi() // C++ default constructor can NOT contain any code, that might leave. // ----------------------------------------------------------------------------- // CSoundAppUi::CSoundAppUi() { // No implementation required } // ----------------------------------------------------------------------------- // CSoundAppUi::ConstructL() // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CSoundAppUi::ConstructL() { // Initialise app UI BaseConstructL(); // Constructs all services. // iToneAdapter = CToneAdapter::NewL( *this ); iPlayerAdapter = CPlayerAdapter::NewL( KSoundSampleFile, *this ); // iRecorderAdapter = CRecorderAdapter::NewL( *this ); // Set the Initialize mode for Tone iAudioAdapter = iPlayerAdapter; // Create view and ask to draw the indetifier to screen iAppView = CSoundView::NewL( ClientRect(), iAudioAdapter->Identify() ); // Set iAppView to controll Stack. AddToStackL( iAppView ); } // ----------------------------------------------------------------------------- // CSoundAppUi::~CSoundAppUi() // Destructor. // ----------------------------------------------------------------------------- // CSoundAppUi::~CSoundAppUi() { iEikonEnv->RemoveFromStack( iAppView ); delete iAppView; delete iToneAdapter; delete iPlayerAdapter; delete iRecorderAdapter; iAudioAdapter = NULL; } // ----------------------------------------------------------------------------- // CSoundAppUi::HandleCommandL() // Takes care of Command handling. // ----------------------------------------------------------------------------- // void CSoundAppUi::HandleCommandL( TInt aCommand ) { switch ( aCommand ) { case EEikCmdExit: case EAknSoftkeyExit: Exit(); break; // case ESoundCmdTone: // SetAdapterL( iToneAdapter ); // break; case ESoundCmdPlayer: SetAdapterL( iPlayerAdapter ); break; // case EESoundCmdRecorder: // SetAdapterL( iRecorderAdapter ); // break; case ESoundCmdPlay: iAudioAdapter->PlayL(); break; case ESoundCmdStop: iAudioAdapter->StopL(); break; // case ESoundCmdRecord: // iAudioAdapter->RecordL(); // break; default: User::Panic( KSound, KSoundPanicUnexpectedCommand ); break; } } // ----------------------------------------------------------------------------- // CSoundAppUi::SetAdapterL() // Sets audio adapter (tone,recorder, player) // ----------------------------------------------------------------------------- // void CSoundAppUi::SetAdapterL( MAudioAdapter* aAudioAdapter ) { iAudioAdapter = aAudioAdapter; UpdateViewL(); } // ----------------------------------------------------------------------------- // CSoundAppUi::UpdateViewL() // Update View. // ----------------------------------------------------------------------------- // void CSoundAppUi::UpdateViewL() { iAppView->NotifyStatusL( iAudioAdapter->Identify() ); iAppView->DrawNow(); } // ----------------------------------------------------------------------------- // CSoundAppUi::DynInitMenuPaneL() // This function is called by the EIKON framework just before it displays // a menu pane. Its default implementation is empty, and by overriding it, // the application can set the state of menu items dynamically according // to the state of application data. // ------------------------------------------------------------------------------ // void CSoundAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) { if ( aResourceId == R_SOUND_MENU ) { iAudioAdapter->UpdateMenuL( aMenuPane ); } } // End of File