×
Namespaces

Variants
Actions

如何利用资源文件在导航栏中显示图片

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
翻译:
hoolee
最后由 hamishwillee 在 14 Feb 2012 编辑
  • 详细描述

我们可以使用NAVI_IMAGE资源描述来指定导航栏的图片。这个资源有三个字段需要定义:

bmpfile 指定一个mbm文件

bmpid 指定mbm文件中某个图片的index值

bmpmask 可选,用来指定mbm文件中某个遮罩文件的index值


下列代码片段是rss文件中定义的:

#include <avkon.mbg>
 
RESOURCE NAVI_IMAGE r_yourapplication_navi_image
{
 
bmpfile = "\\system\data\avkon.mbm"; // or KAvkonBitmapFile define in avkon.rh
 
bmpid = EMbmAvkonQgn_stat_keyguard;
 
}

bmpfile字段指定了mbm文件的位置,然后可以使用指定具体图片的字段

TUid naviPaneUid;
naviPaneUid.iUid = EEikStatusPaneUidNavi;
CEikStatusPane* statusPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane = statusPane->PaneCapabilities(naviPaneUid);
 
// if we can access the navigation pane
 
if (subPane.IsPresent() && subPane.IsAppOwned())
{
CAknNavigationControlContainer* naviPane = (CAknNavigationControlContainer*)statusPane->ControlL
 
(naviPaneUid);
 
 
 
// read the navigation pane image resource
TResourceReader reader;
 
 
iCoeEnv->CreateResourceReaderLC(reader, R_YOURAPPLICATION_NAVI_IMAGE);
 
if (iNaviDecorator)
{
 
delete iNaviDecorator;
iNaviDecorator = NULL;
 
}
 
// set the navigation pane image
iNaviDecorator = naviPane->CreateNavigationImageL(reader);
// pushed by CreateResourceReaderLC
CleanupStack::PopAndDestroy();
naviPane->PushL(*iNaviDecorator);
}
This page was last modified on 14 February 2012, at 08:20.
31 page views in the last 30 days.