這是一種在Series 60表單上顯示標籤的方法。你可以在電量圖示或信號圖示旁邊顯示一個標籤,為此需要用程式實現。我使用了從CCoeControl繼承的CIndicatorIcon 這個類。你需要象這樣創建ConstructL():
void CIndicatorIcon::ConstructL()
{
iMyWindowGroup = RWindowGroup(iCoeEnv->WsSession());
User::LeaveIfError(iMyWindowGroup.Construct((TUint32)&iMyWindowGroup));

 

iMyWindowGroup.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iMyWindowGroup.EnableReceiptOfFocus(EFalse);

 

CreateWindowL(&iMyWindowGroup);

 

// 預設設置指示標籤靜止
SetIndicatorIconL(EIndicatorIconAppActive);

 

ActivateL();
}

在ConstructL()中,我調用了另一個函數 SetIndicatorIconL()設置標籤:
 
void CIndicatorIcon::SetIndicatorIconL(TIndicatorIcon aIndicatorIconType, TBool aRedraw)
{
switch(aIndicatorIconType)
{
case EIndicatorIconEmpty:
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_empty);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_empty_mask);
break;

 

case EIndicatorIconAppActive:
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_bt_connect_on);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_bt_connect_on_mask);
break;

 

case EIndicatorIconAppInactive:
iIndicator = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_bt_audio);
iIndicatorMask = CEikonEnv::Static()->CreateBitmapL(KSysIconFile, EMbmAvkonQgn_prop_bt_audio_mask);
break;

 

default:
break;
}

 

SetRect(TRect(TPoint(KIndicatorPosX, KIndicatorPosY),iIndicator->SizeInPixels()));

 

// 如果 aRedraw == ETrue 從新繪製畫布
if(aRedraw)
{
DrawNow();
}
}

 

你需要跳過CCoeControl的Draw()函數代碼如下 :

 

void CIndicatorIcon::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();

 

gc.Clear();
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
gc.BitBltMasked(TPoint(aRect.iTl.iX, aRect.iTl.iY),
iIndicator,
TRect(TPoint(0, 0), iIndicator->SizeInPixels()),
iIndicatorMask,
ETrue);
}

現在把這些行加入到程式AppUi類的ConstructL()中:

 

iIndicatorIcon = CIndicatorIcon::NewL();
// 下一行將畫標籤並繪製到螢幕上
iIndicatorIcon->SetIndicatorIconL(CIndicatorIcon::EIndicatorIconAppInactive, ETrue);



FROM:http://www.sf.org.cn/Article/lumen/200603/17280.html
創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()