📄 soundappui.cpp
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <eikenv.h>
#include <avkon.hrh>
#include <eikbtgpc.h>
#include <Sound.rsg>
#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 = iToneAdapter;
// 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -