📄 audio2ui.cpp
字号:
/* Copyright (c) 2004, Symbian Software Ltd. All rights reserved */
#include <avkon.hrh>
#include "Audio2.pan"
#include "Audio2ui.h"
#include "Audio2view.h"
#include <gdi.h>
#include "Audio2.hrh"
#include <Audio2.rsg>
#include "Audio2eng.h"
//number editor
#include <eikmfne.h>
#include <aknquerydialog.h>
#include <akncommondialogs.h>
//#include <AknCommonDialogs.h> // For single function
#include <CAknMemorySelectionDialog.h>
#include <CAknMemorySelectionSettingPage.h>
#include <eikmenup.h>
_LIT(KNoFileLoaded, "No file loaded");
void CAudio2Ui::ConstructL()
{
BaseConstructL();
iAppView = CAudio2View::NewL(ClientRect());
iAppView->UpdateLabelL(KNoFileLoaded);
AddToStackL(iAppView);
iEngine=CAudio2Engine::NewL(*this);
iEngine->SetArrays(&iDataTypes, &iSampleRates, &iChannels);
}
CAudio2Ui::CAudio2Ui()
{
}
CAudio2Ui::~CAudio2Ui()
{
if (iAppView)
RemoveFromStack(iAppView);
delete iAppView;
iAppView = NULL;
delete iEngine;
iEngine=NULL;
iSampleRates.Close();
iChannels.Close();
iDataTypes.Close();
delete iFileTypeArray;
iFileTypeArray=NULL;
}
TKeyResponse CAudio2Ui::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
_LIT(KFileName,"rec.wav");
void CAudio2Ui::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case ECmdRecord:
iEngine->StartRecordingL();
break;
case ECmdPlay:
{
iEngine->PlayL();
break;
}
case ECmdConversionFormats:
FormatsDialogL();
break;
case ECmdConversionTypes:
TypesDialogL();
break;
case ECmdConvert:
iEngine->ConvertL(iFileTypeArray->MdcaPoint(iFormatIndex), iCodecIndex, iSampleRatesIndex, iChannelsIndex);
break;
case ECmdStop:
iEngine->StopL();
break;
case EAknSoftkeyExit:
Exit();
break;
default:
User::Invariant();
break;
}
}
void CAudio2Ui::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
{
if (aMenuId == R_AUDIO2_MENU)
iEngine->UpdateMenu(aMenuPane);
}
void CAudio2Ui::UpdateViewL()
{
iAppView->UpdateLabelL(KFileName);
iAppView->DrawNow();
}
void CAudio2Ui::FormatsDialogL()
{
TInt index=0;
CAknListQueryDialog* dialog=new (ELeave)CAknListQueryDialog(&index);
delete iFileTypeArray;
iFileTypeArray=NULL;
iFileTypeArray = new (ELeave) CDesCArrayFlat(4);
iEngine->RecordTypesL(*iFileTypeArray);
dialog->PrepareLC(R_TYPE_DIALOG);
dialog->SetItemTextArray(iFileTypeArray);
dialog->SetOwnershipType(/*TListBoxModelItemArrayOwnership::*/ELbmDoesNotOwnItemArray);
dialog->RunLD();
iEngine->GetFormatsL(iFileTypeArray->MdcaPoint(index));
iFormatIndex=index;
iCodecIndex=-1; //flag that we haven't set any data types yet
}
void CAudio2Ui::TypesDialogL()
{
// Codecs
CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(4);
CleanupStack::PushL(array);
HBufC8* buf8 = HBufC8::NewLC(10);
TPtr8 ptr = buf8->Des();
TBuf<5> buf;
for (TInt i=0; i<iDataTypes.Count(); i++)
{
iDataTypes[i].FourCC(&ptr);
buf.Copy(ptr);
array->AppendL(buf);
}
TInt index=0;
CAknListQueryDialog* dialog=new (ELeave)CAknListQueryDialog(&index);
dialog->PrepareLC(R_TYPE_DIALOG);
dialog->SetItemTextArray(array);
dialog->SetOwnershipType(ELbmDoesNotOwnItemArray);
dialog->RunLD();
CleanupStack::PopAndDestroy(); //buf8
CleanupStack::PopAndDestroy(); //array
iCodecIndex=index;
//sample rates
array = new (ELeave) CDesCArrayFlat(4);
CleanupStack::PushL(array);
for (TInt j=0;j<iSampleRates.Count();j++)
{
TBuf<12> number;
number.Num(iSampleRates[j]);
array->AppendL(number);
}
dialog=new (ELeave)CAknListQueryDialog(&index);
dialog->PrepareLC(R_TYPE_DIALOG);
dialog->SetItemTextArray(array);
dialog->SetOwnershipType(ELbmDoesNotOwnItemArray);
dialog->RunLD();
CleanupStack::PopAndDestroy(); //array
iSampleRatesIndex=index;
//channels
array = new (ELeave) CDesCArrayFlat(4);
CleanupStack::PushL(array);
for (TInt k=0;k<iChannels.Count();k++)
{
TBuf<12> number;
number.Num(iChannels[k]);
array->AppendL(number);
}
dialog=new (ELeave)CAknListQueryDialog(&index);
dialog->PrepareLC(R_TYPE_DIALOG);
dialog->SetItemTextArray(array);
dialog->SetOwnershipType(ELbmDoesNotOwnItemArray);
dialog->RunLD();
CleanupStack::PopAndDestroy();
iChannelsIndex=index;
//array
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -