📄 oggplayappview.cpp
字号:
c= new(ELeave) COggIcon();
iPaused[aCanvas]= (COggIcon*)c;
iPaused[aCanvas]->Hide();
}
else if (p.iToken==_L("AlarmIcon")) {
_LIT(KAL,"Adding AlarmIcon");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggIcon();
iAlarmIcon[aCanvas]= (COggIcon*)c;
iAlarmIcon[aCanvas]->MakeVisible(iApp->iSettings.iAlarmActive);
}
else if (p.iToken==_L("RepeatIcon")) {
_LIT(KAL,"Adding RepeadIcon");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggIcon();
iRepeatIcon[aCanvas]= (COggIcon*)c;
iRepeatIcon[aCanvas]->MakeVisible(iApp->iSettings.iRepeat);
}
else if (p.iToken==_L("RandomIcon")) {
_LIT(KAL,"Adding RandomIcon");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggIcon();
iRandomIcon[aCanvas]= (COggIcon*)c;
iRandomIcon[aCanvas]->MakeVisible(iApp->iSettings.iRandom);
}
else if (p.iToken==_L("RepeatButton")) {
_LIT(KAL,"Adding RepeatButton");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new (ELeave) COggButton();
iRepeatButton[aCanvas]= (COggButton*)c;
iRepeatButton[aCanvas]->SetStyle(1);
}
else if (p.iToken==_L("RandomButton")) {
_LIT(KAL,"Adding RandomButton");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new (ELeave) COggButton();
iRandomButton[aCanvas]= (COggButton*)c;
iRandomButton[aCanvas]->SetStyle(1);
}
else if (p.iToken==_L("Analyzer")) {
_LIT(KAL,"Adding Analyzer");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggAnalyzer();
iAnalyzer[aCanvas]= (COggAnalyzer*)c;
if (iAnalyzer[aCanvas]) iAnalyzer[aCanvas]->SetStyle(iApp->iAnalyzerState);
}
else if (p.iToken==_L("Position")) {
_LIT(KAL,"Adding Position");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggSlider();
iPosition[aCanvas]= (COggSlider*)c;
}
else if (p.iToken==_L("Volume")) {
_LIT(KAL,"Adding Volume");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggSlider();
iVolume[aCanvas]= (COggSlider*)c;
}
else if (p.iToken==_L("ScrollBar")) {
_LIT(KAL,"Adding ScrollBar");
// RDebug::Print(KAL);
p.Debug(KAL);
c= new(ELeave) COggScrollBar();
iScrollBar[aCanvas]= (COggScrollBar*)c;
if (iListBox[aCanvas]) {
iListBox[aCanvas]->SetVertScrollBar(iScrollBar[aCanvas]);
iScrollBar[aCanvas]->SetAssociatedControl(iListBox[aCanvas]);
}
}
else if (p.iToken==_L("ListBox")) {
c= new(ELeave) COggListBox();
// _LIT(KAL,"Adding Listbox at 0x%x");
// RDebug::Print(KAL,c);
//OGGLOG.WriteFormat(KAL,c);
iListBox[aCanvas]= (COggListBox*)c;
SetupListBox(iListBox[aCanvas], p.iScaleFactor);
if (iScrollBar[aCanvas]) {
iScrollBar[aCanvas]->SetAssociatedControl(iListBox[aCanvas]);
iListBox[aCanvas]->SetVertScrollBar(iScrollBar[aCanvas]);
}
}
else if (p.iToken==_L("Animation")) {
c= new(ELeave) COggAnimation();
iAnimation[aCanvas]= (COggAnimation*)c;
}
else if (p.iToken==_L("Logo")) {
c= new(ELeave) COggAnimation();
iLogo[aCanvas]= (COggAnimation*)c;
}
else if(p.iToken==_L("HotKeys")||p.iToken==_L("Hotkeys")) {
SetHotkeysFromSkin(p);
}
if (c) {
c->SetObserver(this);
c->SetBitmapFile(iIconFileName);
c->Read(p);
iCanvas[aCanvas]->AddControl(c);
}
}
p.Debug(_L("Canvas read."));
}
TBool COggPlayAppView::SetHotkeysFromSkin(TOggParser& p) {
p.ReadToken();
if (p.iToken!=KBeginToken) {
p.iState= TOggParser::EBeginExpected;
return EFalse;
}
while (p.ReadToken() && p.iToken!=KEndToken && p.iState==TOggParser::ESuccess) {
ReadHotkeyArgument(p);
}
if (p.iState==TOggParser::ESuccess && p.iToken!=KEndToken)
p.iState= TOggParser::EEndExpected;
return p.iState==TOggParser::ESuccess;
}
TBool COggPlayAppView::ReadHotkeyArgument(TOggParser& p) {
TInt numkey;
if (p.iToken==_L("FastForward")) {
p.Debug(_L("Setting FastForward."));
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EFastForward]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EFastForward]=ETrue;
}
} else if(p.iToken==_L("Rewind")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::ERewind]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::ERewind]=ETrue;
}
} else if(p.iToken==_L("PageUp")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EPageUp]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EPageUp]=ETrue;
}
} else if(p.iToken==_L("PageDown")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EPageDown]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EPageDown]=ETrue;
}
} else if(p.iToken==_L("NextSong")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::ENextSong]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::ENextSong]=ETrue;
}
} else if(p.iToken==_L("PreviousSong")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EPreviousSong]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EPreviousSong]=ETrue;
}
}
#if !defined(SERIES80)
else if(p.iToken==_L("PauseResume"))
{
if (p.ReadToken(numkey))
{
iApp->iSettings.iUserHotkeys[TOggplaySettings::EPauseResume]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EPauseResume]=ETrue;
}
}
#endif
else if(p.iToken==_L("Play")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EPlay]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EPlay]=ETrue;
}
} else if(p.iToken==_L("Pause")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EPause]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EPause]=ETrue;
}
} else if(p.iToken==_L("Stop")) {
if (p.ReadToken(numkey)) {
iApp->iSettings.iUserHotkeys[TOggplaySettings::EStop]='0'+numkey;
iApp->iSettings.iLockedHotkeys[TOggplaySettings::EStop]=ETrue;
}
}
return ETrue;
}
void COggPlayAppView::SetupListBox(COggListBox* aListBox, TInt aScaleFactor)
{
// set up the layout of the listbox:
CColumnListBoxData* cd= aListBox->GetColumnListBoxData();
TInt w = Size().iWidth;
TInt graphicsWidth = 18;
if ((w == 352) && (aScaleFactor == 1))
graphicsWidth*= 2;
cd->SetColumnWidthPixelL(0, graphicsWidth);
cd->SetGraphicsColumnL(0, ETrue);
cd->SetColumnAlignmentL(0, CGraphicsContext::ECenter);
cd->SetColumnWidthPixelL(1, w-graphicsWidth);
cd->SetColumnAlignmentL(1, CGraphicsContext::ELeft);
cd->SetColumnWidthPixelL(2, w);
cd->SetColumnAlignmentL(2, CGraphicsContext::ELeft);
CFont* iFont= const_cast<CFont*>(iCoeEnv->NormalFont());
aListBox->SetFont(iFont);
aListBox->SetText(GetTextArray());
aListBox->SetObserver(this);
CGulIcon* titleIcon = iEikonEnv->CreateIconL(iIconFileName,0,1);
CGulIcon* albumIcon = iEikonEnv->CreateIconL(iIconFileName,2,3);
CGulIcon* artistIcon= iEikonEnv->CreateIconL(iIconFileName,4,5);
CGulIcon* genreIcon = iEikonEnv->CreateIconL(iIconFileName,6,7);
CGulIcon* folderIcon= iEikonEnv->CreateIconL(iIconFileName,8,9);
CGulIcon* fileIcon = iEikonEnv->CreateIconL(iIconFileName,10,11);
CGulIcon* backIcon = iEikonEnv->CreateIconL(iIconFileName,12,13);
CGulIcon* playIcon = iEikonEnv->CreateIconL(iIconFileName,34,35);
CGulIcon* pausedIcon= iEikonEnv->CreateIconL(iIconFileName,16,17);
//CColumnListBoxData* cd= aListBox->GetColumnListBoxData();
CArrayPtr<CGulIcon>* icons= cd->IconArray();
if (!icons) {
icons = new CArrayPtrFlat<CGulIcon>(3);
cd->SetIconArray(icons);
}
icons->Reset();
icons->AppendL(titleIcon);
icons->AppendL(albumIcon);
icons->AppendL(artistIcon);
icons->AppendL(genreIcon);
icons->AppendL(folderIcon);
icons->AppendL(fileIcon);
icons->AppendL(backIcon);
icons->AppendL(playIcon);
icons->AppendL(pausedIcon);
}
void COggPlayAppView::SetNextFocus() {
COggControl* c;
c=iFocusControlsIter;
//RDebug::Print(_L("SetNextFocus from 0x%x"),c);
//__ASSERT_DEBUG(c,OGGLOG.Write(_L("Assert: SetNextFocus - iterator has no control !?")));
//__ASSERT_DEBUG(c->Focus(),OGGLOG.Write(_L("Assert: SetNextFocus - control did not have focus")));
c->SetFocus(EFalse);
do {
iFocusControlsIter++;
if(!iFocusControlsIter) iFocusControlsIter.SetToFirst();
c=iFocusControlsIter;
} while (!c->IsVisible() || c->IsDimmed());
//RDebug::Print(_L("SetNextFocus to 0x%x"),c);
//__ASSERT_DEBUG(c,OGGPANIC(_L("no control in focus iterator !"),1318));
c->SetFocus(ETrue);
Update();
}
void COggPlayAppView::SetPrevFocus() {
COggControl* c;
c=iFocusControlsIter;
//RDebug::Print(_L("SetNextFocus from 0x%x"),c);
//__ASSERT_ALWAYS(c,OGGLOG.Write(_L("Assert: SetNextFocus - iterator has no control !?")));
//__ASSERT_ALWAYS(c->Focus(),OGGLOG.Write(_L("Assert: SetNextFocus - control did not have focus")));
c->SetFocus(EFalse);
do {
iFocusControlsIter--;
if(!iFocusControlsIter) iFocusControlsIter.SetToLast();
c=iFocusControlsIter;
} while (!c->IsVisible() || c->IsDimmed());
//RDebug::Print(_L("SetNextFocus to 0x%x"),c);
//__ASSERT_DEBUG(c,OGGPANIC(_L("no control in focus iterator !"),1318));
c->SetFocus(ETrue);
Update();
}
void
COggPlayAppView::GotoFlipClosed()
{
// modify controls for flip-closed mode display
if (iListBox[1]) iListBox[1]->SetCurrentItemIndex(iSelected);
}
void
COggPlayAppView::GotoFlipOpen()
{
// modify controls for flip-open mode display
if (iListBox[0]) iListBox[0]->SetCurrentItemIndex(iSelected);
}
TBool
COggPlayAppView::IsFlipOpen()
{
#if defined(SERIES60) || defined(MOTOROLA)
return 1;
#else
return iCoeEnv->ScreenDevice()->CurrentScreenMode() == 0;
#endif
}
void COggPlayAppView::Activated()
{
if (iActivateCount == 0)
MakeVisible(ETrue);
iActivateCount++;
}
void COggPlayAppView::Deactivated()
{
iActivateCount--;
if (iActivateCount == 0)
MakeVisible(EFalse);
}
void COggPlayAppView::ChangeLayout(TBool aSmall)
{
TRect rect(CEikonEnv::Static()->ScreenDevice()->SizeInPixels());
if (!aSmall)
rect = static_cast<CEikAppUi*>(iEikonEnv->AppUi())->ClientRect();
SetRect(rect);
if (aSmall)
{
iMode=1;
GotoFlipClosed();
Update();
iCanvas[1]->DrawControl();
iCanvas[1]->MakeVisible(ETrue);
iCanvas[0]->MakeVisible(EFalse);
} else
{
iMode= 0;
GotoFlipOpen();
Update();
iCanvas[0]->DrawControl();
iCanvas[0]->MakeVisible(ETrue);
#if defined(UIQ)
iCanvas[1]->MakeVisible(EFalse);
#endif
}
}
void
COggPlayAppView::AppToForeground(const TBool aForeground) const
{
RWsSession& ws=iEikonEnv->WsSession();
RWindowGroup& rw = iEikonEnv->RootWin();
TInt winId = rw.Identifier();
TApaTask tApatsk(ws);
tApatsk.SetWgId(winId);
if (aForeground) {
tApatsk.BringToForeground();
iApp->ActivateOggViewL();
}
else
tApatsk.SendToBackground();
}
_LIT(KEmpty,"");
const TInt
COggPlayAppView::GetValueFromTextLine(TInt idx)
{
// Fetch the numeric value from the line (the 2nd "argument")
CDesCArray* arr= GetTextArray();
__ASSERT_ALWAYS ( arr,
User::Panic(_L("COggPlayAppView::GetValue Array Not found"),0 ) );
TPtrC sel,msel;
if(idx >= 0 && idx < arr->Count())
{
sel.Set((*arr)[idx]);
TextUtils::ColumnText(msel, 2, &sel );
}
TLex parse(msel);
TInt previousViewId;
parse.Val(previousViewId);
return (previousViewId);
}
TBool
COggPlayAppView::HasAFileName(TInt idx)
{
// Returns true if a filename is associated with this item
COggListBox::TItemTypes type = GetItemType(idx) ;
if ((type == COggListBox::ETitle) || (type == COggListBox::EFileName) || (type == COggListBox::EPlayList))
return(ETrue);
return(EFalse);
}
const TDesC &
COggPlayAppView::GetFileName(TInt idx)
{
return *(GetFile(idx)->iFileName);
}
TOggFile* COggPlayAppView::GetFile(TInt idx)
{
COggListBox::TItemTypes type = GetItemType(idx);
__ASSERT_ALWAYS(((type == COggListBox::ETitle) || (type == COggListBox::EFileName) || (type == COggListBox::EPlayList)),
User::Panic(_L("GetFile called with wrong argument"),0 ) );
TBuf<128> filter;
GetFilterData(idx, filter);
TInt fileInt(0);
TLex parse(filter);
parse.Val(fileInt);
return (TOggFile*) fileInt;
}
const COggPlayAppUi::TViews
COggPlayAppView::GetViewName(TInt idx)
{
COggListBox::TItemTypes type = GetItemType(idx);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -