📄 wavegen_view.cpp
字号:
//
// wavegen_view.cpp
//
// Copyright (C) 2005 Nokia Corporation. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
// INCLUDE FILES
#include <avkon.hrh>
#include <avkon.rsg>
#include <akntitle.h>
#include <aknviewappui.h>
#include <wavegen.rsg>
#include "wavegen_view.h"
#include "wavegen_listbox.h"
#include "wavegen_engine.h"
// CONSTANTS
// Possible UIDs of view.
const TUid KViewId1 = { EGenerator };
const TUid KViewId2 = { EFilePlayer };
// max length of a status pane title text
const TInt KWaveGenTitleBufLength = 32;
//
// CWaveGenView class
//
/*
-------------------------------------------------------------------------------
NewL
Description: Standard Symbian NewL constructor
Return Value: Pointer to a newly-created CWaveGenView object.
-------------------------------------------------------------------------------
*/
CWaveGenView* CWaveGenView::NewL(CStreamAudioEngine* aEng, TPlaybackMode aMode)
{
CWaveGenView* self = NewLC(aEng, aMode);
CleanupStack::Pop(); // self
return self;
}
/*
-------------------------------------------------------------------------------
NewLC
Description: Standard Symbian NewLC constructor
Return Value: Pointer to a newly-created CWaveGenView object, which is also
left in the cleanup stack
-------------------------------------------------------------------------------
*/
CWaveGenView* CWaveGenView::NewLC(CStreamAudioEngine* aEng, TPlaybackMode aMode)
{
CWaveGenView* self = new (ELeave) CWaveGenView(aEng, aMode);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
/*
-------------------------------------------------------------------------------
ConstructL
Description: Standard 2nd phase constructor (called by NewLC)
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::ConstructL()
{
BaseConstructL();
}
/*
-------------------------------------------------------------------------------
CWaveGenView
Description: Constructor
-------------------------------------------------------------------------------
*/
CWaveGenView::CWaveGenView(CStreamAudioEngine* aEng, TPlaybackMode aMode)
: iEng(aEng),
iListBox(NULL),
iMode(aMode)
{
}
/*
-------------------------------------------------------------------------------
~CWaveGenView
Description: Destructor
-------------------------------------------------------------------------------
*/
CWaveGenView::~CWaveGenView()
{
if (iListBox)
{
AppUi()->RemoveFromStack(iListBox);
}
delete iListBox;
}
/*
-------------------------------------------------------------------------------
Id
Description: Returns ID of this view
Return Value: TUid
-------------------------------------------------------------------------------
*/
TUid CWaveGenView::Id() const
{
return (iMode == EGenerator) ? KViewId1 : KViewId2;
}
/*
-------------------------------------------------------------------------------
HandleCommandL
Description: Menu command handler
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EWaveGenCmdPlay:
iEng->PlayL();
break;
case EWaveGenCmdStop:
iEng->StopL();
break;
default:
break;
}
}
/*
-------------------------------------------------------------------------------
CreateListBoxL
Description: constructs and activates a new listbox from a specified
resource
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::CreateListBoxL(TInt aResourceId)
{
DeleteListBox();
iListBox = new (ELeave) CWaveGenListbox(iEng);
iListBox->SetMopParent(this);
iListBox->ConstructFromResourceL(aResourceId);
AppUi()->AddToStackL(*this, iListBox);
iListBox->MakeVisible(ETrue);
iListBox->SetRect(ClientRect());
iListBox->ActivateL();
iListBox->DrawNow();
}
/*
-------------------------------------------------------------------------------
DeleteListBoxL
Description: deletes and the listbox and removes it from control stack
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::DeleteListBox()
{
if (iListBox)
{
AppUi()->RemoveFromStack(iListBox);
}
delete iListBox;
iListBox = 0;
}
/*
-------------------------------------------------------------------------------
SetTitlePaneTextL
Description: Sets the title pane text from resource
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::SetTitlePaneTextL(const TInt aResourceId)
{
CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
(StatusPane()->ControlL(TUid::Uid(EEikStatusPaneUidTitle)));
TBuf<KWaveGenTitleBufLength> titleText(NULL);
iEikonEnv->ReadResource(titleText, aResourceId);
titlePane->SetTextL(titleText);
titlePane->DrawNow();
}
/*
-------------------------------------------------------------------------------
ActivateGeneratorViewL
Description: Creates the setting listbox for generator view and sets the
correct text for title pane
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::ActivateGeneratorViewL()
{
// stop the audio engine and switch to the generator buffer
iEng->StopL();
iEng->SwitchBuffer(EFalse);
CreateListBoxL(R_WAVEGEN_SETTING_LIST_SETTING_GENERATOR);
SetTitlePaneTextL(R_WAVEGEN_TITLE_TEXT_GENERATOR);
}
/*
-------------------------------------------------------------------------------
ActivatePlayerViewL
Description: Creates the setting listbox for player view and sets the
correct text for title pane
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::ActivatePlayerViewL()
{
// stop the audio engine and switch to the player buffer
iEng->StopL();
if(iEng->SwitchBuffer(ETrue))
{
CreateListBoxL(R_WAVEGEN_SETTING_LIST_SETTING_PCMPLAYER);
SetTitlePaneTextL(R_WAVEGEN_TITLE_TEXT_PCMPLAYER);
}
else
{
// display error message in the title pane if it fails
SetTitlePaneTextL(R_WAVEGEN_ERROR_PCM_FILE);
}
}
/*
-------------------------------------------------------------------------------
DoActivateL
Description: Activates this view by creating the correct listbox
according to view type (generator/file player)
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/ )
{
if(iMode == EGenerator)
ActivateGeneratorViewL();
else
ActivatePlayerViewL();
}
/*
-------------------------------------------------------------------------------
DoDeactivate
Description: Deactivates this view by deleting the listbox object
Return Value: N/A
-------------------------------------------------------------------------------
*/
void CWaveGenView::DoDeactivate()
{
DeleteListBox();
}
// eof
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -