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

📄 bitmapdrawcontainer.cpp

📁 symbian S6O 3rd上传图片例题
💻 CPP
字号:
/**
 * 
 * @brief Definition of CBitmapDrawContainer
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDES

//  Class include
#include "BitmapDrawContainer.h"

// System includes
#include <fbs.h> //CFbsBitmap
#include <eikenv.h> // iEikonEnv
#include <aknutils.h>

// User include
#include <Bitmap.rsg> // resource file use
#include <Bitmap.mbg> // Bitmap enumeration

// CONSTANTS
_LIT(KDrawBitmapPath, "\\system\\apps\\Bitmap\\Bitmap.mbm");
const TInt KTopLeftX = 10;
const TInt KTopLeftY = 40;
const TInt KSizeWidth = 154;
const TInt KSizeHeight = 90;


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

/**
 * Symbian OS 2 phase constructor.
 * Constructs the CBitmapDrawContainer using the NewLC method, popping
 * the constructed object from the CleanupStack before returning it.
 * 
 * @param aRect The rectangle for this window
 * @return The newly constructed CBitmapDrawContainer
 */

CBitmapDrawContainer* CBitmapDrawContainer::NewL(const TRect& aRect)
	{
	CBitmapDrawContainer* self = CBitmapDrawContainer::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

/**
 * Symbian OS 2 phase constructor.
 * Constructs the CBitmapDrawContainer using the constructor and ConstructL 
 * method, leaving the constructed object on the CleanupStack before returning it.
 * 
 * @param aRect The rectangle for this window
 * @return The newly constructed CBitmapDrawContainer
 */

CBitmapDrawContainer* CBitmapDrawContainer::NewLC(const TRect& aRect)
	{
	CBitmapDrawContainer* self = new (ELeave) CBitmapDrawContainer;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

/**
 * Symbian OS 2nd phase constructor.  Creates a Window for the control to draw to.
 * Creates bitmap to be displayed. Illustrates use of the CFbsBitmap::Load() function
 *
 * @param aRect The rectangle for this window
 */ 

void CBitmapDrawContainer::ConstructL(const TRect& aRect)
	{
	CreateWindowL();	
	SetRect(aRect);
	TFileName bitmapFile (KDrawBitmapPath);
	User::LeaveIfError (CompleteWithAppPath (bitmapFile));

	iBitmap = new (ELeave) CFbsBitmap();
	User::LeaveIfError(iBitmap->Load(bitmapFile, EMbmBitmapDrawbitmap));
	ActivateL();
	}

/** 
 * Destructor.  
 */

CBitmapDrawContainer::~CBitmapDrawContainer()
	{
	delete iBitmap;
	}

/**
 * Called by the framework to draw this control.  Clears the area of 
 * aRect. Sets the top left hand point of where the image will be drawn from.
 * As DrawBitmap also requires the size of the image to be passed in, a TSize object
 * is also constructed with the desired width and height of the image.
 * @param aRect in which to draw
 */

void CBitmapDrawContainer::Draw(const TRect& aRect) const
	{
	CWindowGc& gc = SystemGc();
	gc.Clear(aRect);
	TPoint topLeft(KTopLeftX, KTopLeftY);
	TSize bitmapSize(KSizeWidth, KSizeHeight);
	gc.DrawBitmap(TRect(topLeft, bitmapSize), iBitmap);	
	}

// End of File

⌨️ 快捷键说明

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