bitmapbitbltcontainer.cpp

来自「series60 应用程序开发的源代码 series60 应用程序开发的源代码」· C++ 代码 · 共 106 行

CPP
106
字号
/**
 * 
 * @brief Definition of CBitmapBitBltContainer
 *
 * Copyright (c) EMCC Software Ltd 2003
 * @version 1.0
 */

// INCLUDES

//  Class include
#include "BitmapBitBltContainer.h"

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

// User include
#include <Bitmap.mbg> // Bitmap enumeration

_LIT(KBitBltBitmapPath, "\\system\\apps\\Bitmap\\Bitmap.mbm");
const TInt KTopLeftX = 10;
const TInt KTopLeftY = 40;


// CONSTANTS

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

/**
 * Symbian OS 2 phase constructor.
 * Constructs the CBitmapBitBltContainer 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 CBitmapBitBltContainer
 */

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

/**
 * Symbian OS 2 phase constructor.
 * Constructs the CBitmapBitBltContainer 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 CBitmapBitBltContainer
 */

CBitmapBitBltContainer* CBitmapBitBltContainer::NewLC(const TRect& aRect)
{
    CBitmapBitBltContainer* self = new (ELeave) CBitmapBitBltContainer;
    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 CBitmapBitBltContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();    
    SetRect(aRect);
    iBitmap = new (ELeave) CFbsBitmap();
    TFileName bitmapFile (KBitBltBitmapPath);
    User::LeaveIfError (CompleteWithAppPath (bitmapFile));
    User::LeaveIfError(iBitmap->Load(bitmapFile, EMbmBitmapBitbltbitmap));
    ActivateL();
}

/** 
 * Destructor. 
 */

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

/**
 * Called by the framework to draw this control.  Clears the area in specified
 * by aRect, creates a TPoint object for the top left of the image, draws bitmap using
 * Blitting.
 * @param aRect in which to draw
 */

void CBitmapBitBltContainer::Draw(const TRect& aRect) const
{
    CWindowGc& gc = SystemGc(); // obtain graphics context
    gc.Clear(aRect); // clear the graphics context
    TPoint topLeft(KTopLeftX, KTopLeftY); // create TPoint object for top left of bitmap
    gc.BitBlt(topLeft, iBitmap); // Blit bitmap using graphics context
}

// End of File

⌨️ 快捷键说明

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