⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indicatoricon.cpp

📁 图片解码程序
💻 CPP
字号:
/*
 * ============================================================================
 *  Name     : CIndicatorIcon from CCoeControl
 *  Part of  : IndicatorIconEx
 *  Created  : 01/11/2006 by Vinod Kumar K V
 *  Description:
 *     Some utility functions.
 *  Version  :
 *  Copyright: Copyright (c) 1999 - 2006 Vinsofts Inc.
 *			   (http://cc.1asphost.com/vinsofts/)
 * ============================================================================
 */

// INCLUDE FILES
#include <akncontext.h>
#include <fbs.h>
#include <eikenv.h>

#include <avkon.mbg>

#include "IndicatorIcon.h"

// CONSTANTS
const TInt KIndicatorPosX = 152;
const TInt KIndicatorPosY = 12;

_LIT(KSysIconFile, "z:\\system\\data\\avkon.mbm");

// ================= MEMBER FUNCTIONS =======================

// ----------------------------------------------------------------------------
// CIndicatorIcon::NewL()
// Two-phased constructor.
// ----------------------------------------------------------------------------
//
CIndicatorIcon* CIndicatorIcon::NewL()
	{
	CIndicatorIcon* self = CIndicatorIcon::NewLC();
	CleanupStack::Pop(self);
	return self;
	}

// ----------------------------------------------------------------------------
// CIndicatorIcon::NewLC()
// Two-phased constructor. 
// ----------------------------------------------------------------------------
//    
CIndicatorIcon* CIndicatorIcon::NewLC()
	{
	CIndicatorIcon* self = new (ELeave) CIndicatorIcon();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

// ----------------------------------------------------------
// CIndicatorIcon::CIndicatorIcon()
//
// C++ default constructor can NOT contain any code, that
// might leave.
// ----------------------------------------------------------
//
CIndicatorIcon::CIndicatorIcon()
	{
	}

// ----------------------------------------------------------
// CIndicatorIcon::ConstructL(const TRect& aRect)
//
// EPOC default constructor can leave.
// ----------------------------------------------------------
//
void CIndicatorIcon::ConstructL()
	{
	iMyWindowGroup = RWindowGroup(iCoeEnv->WsSession());
	User::LeaveIfError(iMyWindowGroup.Construct((TUint32)&iMyWindowGroup));

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

	CreateWindowL(&iMyWindowGroup);

	// by default setting the indicator icon to inactive
	SetIndicatorIconL(EIndicatorIconAppActive);

	ActivateL();
	}

// ----------------------------------------------------------
// CIndicatorIcon::~CIndicatorIcon()
//
// Destructor
// ----------------------------------------------------------
//
CIndicatorIcon::~CIndicatorIcon()
	{
	if (iIndicator)
		{
		delete iIndicator;
		iIndicator = NULL;
		} // if (iIndicator)

	if (iIndicatorMask)
		{
		delete iIndicatorMask;
		iIndicatorMask = NULL;
		} // if (iIndicatorMask)

	iMyWindowGroup.Close();
	}

// ---------------------------------------------------------
// CIndicatorIcon::SetIndicatorIconL(TInt aIconType)
//
// Set the indicator icon.
// ---------------------------------------------------------
//
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()));
	
	// if aRedraw == ETrue just draw the canvas again.
	if(aRedraw)
		{
		DrawNow();
		}
	}

// ---------------------------------------------------------
// CIndicatorIcon::Draw(const TRect& aRect) const
//
// Draw function.
// ---------------------------------------------------------
//
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);
	}

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -