📄 appframe.cpp
字号:
{
if (newType!=iStatusPaneType) //Requesting a type different from current type.
{
#pragma message("Need to sort out the status pane here too")
#if defined(__CRYSTAL__)
CEikStatusPane* statusPane = aOplAPI.EikonEnv().AppUiFactory()->StatusPane();
if (newType==EAfStatusPaneTypeNarrow)
{
// Make OPLR's status pane sit behind ours, this helps solve some
// drawing problems
if (statusPane)
statusPane->SwitchLayoutL(R_INDICATOR_LAYOUT_NARROW);
iStatusPane->SwitchLayoutL(R_INDICATOR_LAYOUT_NARROW);
}
else
{
// Make OPLR's status pane sit behind ours, this helps solve some
// drawing problems
if (statusPane)
statusPane->SwitchLayoutL(R_INDICATOR_LAYOUT_WIDE);
iStatusPane->SwitchLayoutL(R_INDICATOR_LAYOUT_WIDE);
}
#endif
iStatusPaneType=(TAfStatusPaneType)newType;
if (iStatusPane->IsVisible())
{
aOplAPI.Push(OpxUtil::OplBool16(ResizeTitleL(aOplAPI.EikonEnv())));
return;
}
}
}
aOplAPI.Push(OpxUtil::OplBool16(KNoRedraw));
}
/**
* Processes the OPL procedure
* AfSetStatusVisible%:(aVisibility%)
* Makes the Status pane visible/invisible, depending on the visibility flag passed in.
* Returns KTrue% if screen size needs changing, otherwise KFalse%
*/
void CAppFrameUser::SetStatusVisible(OplAPI& aOplAPI)
{
TBool newVisibility=OpxUtil::CppBool(aOplAPI.PopInt16()); //aVisibility%
InitStatusPane(aOplAPI);
CEikStatusPane* statusPane = aOplAPI.EikonEnv().AppUiFactory()->StatusPane();
if (statusPane)
statusPane->MakeVisible(newVisibility);
if (iStatusPane)
{
TBool currentVisibility=iStatusPane->IsVisible();
if (currentVisibility!=newVisibility) //change required.
{
// Make OPLR's status pane sit behind ours, this helps solve some
// drawing problems
if (statusPane)
statusPane->MakeVisible(newVisibility);
iStatusPane->MakeVisible(newVisibility);
aOplAPI.Push(OpxUtil::OplBool16(ResizeTitleL(aOplAPI.EikonEnv())));
return;
}
}
aOplAPI.Push(OpxUtil::OplBool16(KNoRedraw));
}
/**
* Processes the OPL procedure
* AfStatusVisible%:(BYREF aType%)
* Sets the referenced var to the type of the status pane.
* Returns KTrue% if the status pane is visible, KFalse% otherwise.
*/
void CAppFrameUser::StatusVisible(OplAPI& aOplAPI)
{
TInt16 *type=aOplAPI.PopPtrInt16();
InitStatusPane(aOplAPI);
aOplAPI.PutWord(type,(TInt16)iStatusPaneType);
if (iStatusPane)
aOplAPI.Push(OpxUtil::OplBool16(iStatusPane->IsVisible()));
else
aOplAPI.Push(OpxUtil::OplBool16(KNoRedraw));
}
/**
* Processes the OPL procedure
* AfSetTitle:(aTitle$,aTitleType%)
* Sets the title in the titlebar.
*/
void CAppFrameUser::SetTitle(OplAPI& aOplAPI)
{ // AfSetTitle:(aTitle$,aTitleType%)
#if defined(__CRYSTAL__)
TInt16 type=aOplAPI.PopInt16();
TPtrC titleString=aOplAPI.PopString();
CCknAppTitle::TAppTitleElement titleType=(CCknAppTitle::TAppTitleElement)(OpxUtil::CppIndex(type));
if (titleType!=CCknAppTitle::EMainTitle && titleType!=CCknAppTitle::ETitleExtension)
User::Leave(KOplErrInvalidArgs); // disallow ESubTitle, EAdditionalInfo and invalid values
if (iTitleBar)
{
iTitleBar->SetTextL(titleString,titleType);
iTitleBar->DrawNow();
}
#else // not crystal
aOplAPI.PopInt16();
aOplAPI.PopString();
User::Leave(KOplErrNotSupported);
#endif
aOplAPI.Push(0.0);
}
/**
* Processes the OPL procedure
* AfSetTitleAreaWidth:(aTitleType%,aWidth%)
* Sets the area width of the given title
*/
void CAppFrameUser::SetTitleAreaWidth(OplAPI& aOplAPI)
{
#if defined(__CRYSTAL__)
TInt width=aOplAPI.PopInt16();
TInt type=aOplAPI.PopInt16();
CCknAppTitle::TAppTitleElement titleType=(CCknAppTitle::TAppTitleElement)(OpxUtil::CppIndex(type));
if (titleType!=CCknAppTitle::EMainTitle && titleType!=CCknAppTitle::ETitleExtension)
User::Leave(KOplErrInvalidArgs); // disallow ESubTitle, EAdditionalInfo and invalid values
if (iTitleBar)
{
iTitleBar->SetAreaWidth(width,titleType);
iTitleBar->DrawNow();
}
#else
aOplAPI.PopInt16();
aOplAPI.PopInt16();
User::Leave(KOplErrNotSupported);
#endif
aOplAPI.Push(0.0);
}
/**
* Processes the OPL procedure
* AfSetTitleVisible%:(aVisibility%)
* Makes the title visible/invisible, depending on the visibility flag passed in.
* Returns KTrue% if screen size needs changing, otherwise KFalse%.
*/
void CAppFrameUser::SetTitleVisible(OplAPI& aOplAPI)
{
#if defined(__CRYSTAL__)
TBool newVisibility=OpxUtil::CppBool(aOplAPI.PopInt16()); //aVisibility%
TBool currentVisibility=iIsTitleBarVisible;
if (currentVisibility!=newVisibility) // change required.
{
iIsTitleBarVisible=newVisibility;
iTitleWindow.SetVisible(newVisibility);
// If other controls have changed state while title invisible.
iTitleBar->DrawNow();
aOplAPI.Push(OpxUtil::OplBool16(ResizeTitleL(aOplAPI.EikonEnv())));
return;
}
#else // not crystal
aOplAPI.PopInt16();
User::Leave(KOplErrNotSupported); // Not available on Series60
#endif
aOplAPI.Push(OpxUtil::OplBool16(KNoRedraw));
}
/**
* Processes the OPL procedure
* AfTitleVisible%:
* Returns KTrue% if the title is visible, else KFalse%
*/
void CAppFrameUser::TitleVisible(OplAPI& aOplAPI)
{
aOplAPI.Push(OpxUtil::OplBool16(iIsTitleBarVisible));
}
/**
* Processes the OPL procedure
* AfScreenInfo:(BYREF aXOrigin%, BYREF aYOrigin%, BYREF aWidth%, BYREF aHeight%)
* Populates the vars with the following info:
* x position of origin
* y position of origin
* width of visible screen in pixels
* height of visible screen in pixels
*/
void CAppFrameUser::ScreenInfo(OplAPI& aOplAPI)
{
TInt16 *visibleHeight=aOplAPI.PopPtrInt16();//aHeight%
TInt16 *visibleWidth=aOplAPI.PopPtrInt16();//aWidth%
TInt16 *yOrigin=aOplAPI.PopPtrInt16();//aYOrigin%
TInt16 *xOrigin=aOplAPI.PopPtrInt16();//aXOrigin%
TRect visibleRect=aOplAPI.EikonEnv().ScreenDevice()->SizeInPixels();
#if defined(__UIQ__)
visibleRect=CEikonEnv::Static()->EikAppUi()->ClientRect();
#else
if (iButtonGroupContainer)
if (iButtonGroupContainer->IsVisible())
iButtonGroupContainer->ReduceRect(visibleRect);
#endif
if (iStatusPane)
if (iStatusPane->IsVisible())
iStatusPane->ReduceRect(visibleRect);
if (iIsTitleBarVisible)
{
TSize titleSize=iTitleWindow.Size();
visibleRect.iTl.iY+=titleSize.iHeight;
}
aOplAPI.PutWord(xOrigin,(TInt16)visibleRect.iTl.iX);
aOplAPI.PutWord(yOrigin,(TInt16)visibleRect.iTl.iY);
aOplAPI.PutWord(visibleWidth,(TInt16)(visibleRect.iBr.iX-visibleRect.iTl.iX));
aOplAPI.PutWord(visibleHeight,(TInt16)(visibleRect.iBr.iY-visibleRect.iTl.iY));
aOplAPI.Push(0.0);
}
void CAppFrameUser::AddToDesk(OplAPI& aOplAPI)
{
#if defined(USE_ADDTODESK)
TPtrC linkDocName=aOplAPI.AppCurrentDocument();
if (linkDocName.CompareF(KNullDesC)==0) // No current document so add Application link
{
CLinkApplication* linkApp=CLinkApplication::NewL();
CleanupStack::PushL(linkApp);
linkApp->SetApplicationUidL(aOplAPI.AppUid());
LinkUtils::CreateLinkDocumentL(*linkApp);
}
else // Add a link to the current document
{
CLinkDocument* linkDoc=CLinkDocument::NewL();
CleanupStack::PushL(linkDoc);
linkDoc->SetDocumentL(linkDocName);
LinkUtils::CreateLinkDocumentL(*linkDoc);
}
CleanupStack::PopAndDestroy(); // linkApp or linkDoc
#else
User::Leave(KOplErrNotSupported); // Not available on Series60
#endif
aOplAPI.Push(0.0);
}
void CAppFrameUser::MenuPaneToStartOn(OplAPI& aOplAPI)
{
aOplAPI.Push(KMenuPaneToStartOn);
}
void CAppFrameUser::ViewSystemLog(OplAPI& aOplAPI)
{
_LIT(KLogAppFileName, "\\System\\Apps\\LogView\\LogView.app");
CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
cmdLine->SetCommandL(EApaCommandRun);
cmdLine->SetLibraryNameL(KLogAppFileName);
EikDll::StartAppL(*cmdLine);
CleanupStack::PopAndDestroy(); // cmdLine
aOplAPI.Push(0.0);
}
void CAppFrameUser::ToggleIrDA(OplAPI& aOplAPI)
{ //AfToggleIrDA:
#if defined(USE_IRLISTEN)
if (iIrListenAppUi)
iIrListenAppUi->ToggleListeningL();
else
User::Leave(KErrNotSupported);
#else
User::Leave(KOplErrNotSupported); // Not available on Series60
#endif
aOplAPI.Push(0.0);
}
void CAppFrameUser::ConfirmationDialog(OplAPI& aOplAPI)
{ //AfConfirmationDialog%:(aTitle$,aMessage$,aConfirmButtonTitle$)
#if defined(__SERIES60__)
aOplAPI.PopString();
aOplAPI.PopString();
aOplAPI.PopString();
User::Leave(KOplErrNotSupported); // Not available on Series60
aOplAPI.Push(OpxUtil::OplBool16(0));
#elif defined(__UIQ__)
aOplAPI.PopString();
TPtrC message=aOplAPI.PopString();
TPtrC title=aOplAPI.PopString();
aOplAPI.Push(OpxUtil::OplBool16( CEikonEnv::Static()->QueryWinL(title,message)));
#else
TPtrC confirmButtonTitle=aOplAPI.PopString();
TPtrC message=aOplAPI.PopString();
TPtrC title=aOplAPI.PopString();
aOplAPI.Push(OpxUtil::OplBool16( CCknConfirmationDialog::RunDlgLD(title,message,NULL,&confirmButtonTitle) ));
#endif
}
void CAppFrameUser::InfoDialog(OplAPI& aOplAPI)
{ //AfInformationDialog%:(aTitle$,aMessage$)
TPtrC aMessage=aOplAPI.PopString();
TPtrC aTitle=aOplAPI.PopString();
#if defined(__SERIES60__)
User::Leave(KOplErrNotSupported); // Not available on Series60
aOplAPI.Push(OpxUtil::OplBool16(0));
#elif defined(__UIQ__)
CEikonEnv::Static()->InfoWinL(aTitle,aMessage);
aOplAPI.Push(OpxUtil::OplBool16( ETrue ));
#else
aOplAPI.Push(OpxUtil::OplBool16( CCknInfoDialog::RunDlgLD(aTitle,aMessage,NULL) ));
#endif
}
//
// Private
//
/**
* Resize the title bar.
* Returns ETrue if an OPL redraw is required, EFalse otherwise.
*/
TBool CAppFrameUser::ResizeTitleL(const CEikonEnv& aEikonEnv)
{
if (!iIsTitleBarVisible)
{
if (iStatusPane || iButtonGroupContainer)
return ETrue;
else
return EFalse; //Invisible title and no other controls, so no redraw required.
}
// Recalc title bar size after status pane and/or CBA have changed.
TRect titleRect=aEikonEnv.ScreenDevice()->SizeInPixels();
if (iStatusPane)
if (iStatusPane->IsVisible())
iStatusPane->ReduceRect(titleRect);
if (iButtonGroupContainer)
if (iButtonGroupContainer->IsVisible())
iButtonGroupContainer->ReduceRect(titleRect);
#if defined(__SERIES60__)||defined(__UIQ__)
User::Leave(KOplErrNotSupported); // Not available on Series60
#else
TPoint topLeft(titleRect.iTl.iX,0);
TSize newSize(titleRect.iBr.iX-titleRect.iTl.iX,iTitleBar->Size().iHeight);
iTitleWindow.SetPosition(topLeft);
User::LeaveIfError(iTitleWindow.SetSizeErr(newSize));
iTitleBar->SetPosition(TPoint(0,0)); //top left of container window
iTitleBar->SetSize(iTitleWindow.Size());
iTitleContext->Clear();
iTitleBar->DrawNow();
#endif
return ETrue;
}
CAppFrameUser::~CAppFrameUser()
{
#if !defined(__SERIES60__)&&!defined(__UIQ__)
delete iTitleBar;
#endif
delete iTitleContext;
iTitleWindow.Close();
delete iStatusPane;
#if defined(__UIQ__)
delete iButtonGroupOwner;
#endif
delete iButtonGroupContainer;
delete iAppFrameObserver;
#if defined(USE_IRLISTEN)
delete iIrListenAppUi;
#endif
};
COpxAppFrame::COpxAppFrame(OplAPI& aOplAPI)
:COpxBase(aOplAPI)
{
}
COpxAppFrame* COpxAppFrame::NewLC(OplAPI& aOplAPI)
{
COpxAppFrame* This=new(ELeave) COpxAppFrame(aOplAPI);
CleanupStack::PushL(This);
This->ConstructL(aOplAPI);
return This;
}
void COpxAppFrame::ConstructL(OplAPI& aOplAPI)
{
iAppFrameUser=CAppFrameUser::NewL(aOplAPI);
}
COpxAppFrame::~COpxAppFrame()
{
delete iAppFrameUser;
Dll::FreeTls();
}
void COpxAppFrame::RunL(TInt aProcNum)
{
switch (aProcNum)
{
case EOfferEvent:
iAppFrameUser->OfferEvent(iOplAPI);
break;
case ESetCBAButton:
iAppFrameUser->SetCBAButton(iOplAPI);
break;
case ESetCBAButtonDefault:
iAppFrameUser->SetCBAButtonDefault(iOplAPI);
break;
case ESetCBAButtonDimmed:
iAppFrameUser->SetCBAButtonDimmed(iOplAPI);
break;
case ECBAButtonDimmed:
iAppFrameUser->CBAButtonDimmed(iOplAPI);
break;
case ESetCBAButtonVisible:
iAppFrameUser->SetCBAButtonVisible(iOplAPI);
break;
case ECBAButtonVisible:
iAppFrameUser->CBAButtonVisible(iOplAPI);
break;
case ESetCBAVisible:
iAppFrameUser->SetCBAVisible(iOplAPI);
break;
case ECBAVisible:
iAppFrameUser->CBAVisible(iOplAPI);
break;
case ECBAMaxButtons:
iAppFrameUser->CBAMaxButtons(iOplAPI);
break;
case ESetStatus:
iAppFrameUser->SetStatus(iOplAPI);
break;
case ESetStatusVisible:
iAppFrameUser->SetStatusVisible(iOplAPI);
break;
case EStatusVisible:
iAppFrameUser->StatusVisible(iOplAPI);
break;
case ESetTitle:
iAppFrameUser->SetTitle(iOplAPI);
break;
case ESetTitleAreaWidth:
iAppFrameUser->SetTitleAreaWidth(iOplAPI);
break;
case ESetTitleVisible:
iAppFrameUser->SetTitleVisible(iOplAPI);
break;
case ETitleVisible:
iAppFrameUser->TitleVisible(iOplAPI);
break;
case EScreenInfo:
iAppFrameUser->ScreenInfo(iOplAPI);
break;
case EAddToDesk:
iAppFrameUser->AddToDesk(iOplAPI);
break;
case EMenuPaneToStartOn:
iAppFrameUser->MenuPaneToStartOn(iOplAPI);
break;
case EViewSystemLog:
iAppFrameUser->ViewSystemLog(iOplAPI);
break;
case EToggleIrDA:
iAppFrameUser->ToggleIrDA(iOplAPI);
break;
case EConfirmationDialog:
iAppFrameUser->ConfirmationDialog(iOplAPI);
break;
case EInfoDialog:
iAppFrameUser->InfoDialog(iOplAPI);
break;
default:
User::Leave(KOplErrOpxProcNotFound);
}
}
TBool COpxAppFrame::CheckVersion(TInt aVersion)
{
if ((aVersion & 0xFF00) > (KOpxVersion & 0xFF00))
return EFalse;
else
return ETrue;
}
EXPORT_C COpxBase* NewOpxL(OplAPI& iOplAPI)
{
COpxAppFrame* tls=((COpxAppFrame*)Dll::Tls());
if (tls==NULL) // tls is NULL on loading an OPX DLL (also after unloading it)
{
tls=COpxAppFrame::NewLC(iOplAPI);
User::LeaveIfError(Dll::SetTls(tls));
CleanupStack::Pop(); // tls
}
return (COpxBase *)tls;
}
EXPORT_C TUint Version()
{
return KOpxVersion;
}
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
{
return(KErrNone);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -