/*
============================================================================
Name : TestMaskAppView.h
Author :
Copyright : Your copyright notice
Description : Declares view class for application.
============================================================================
*/
#ifndef __TESTMASKAPPVIEW_h__
#define __TESTMASKAPPVIEW_h__
// INCLUDES
#include <coecntrl.h>
// CLASS DECLARATION
class CTestMaskAppView : public CCoeControl
{
public:
static CTestMaskAppView* NewL(const TRect& aRect);
static CTestMaskAppView* NewLC(const TRect& aRect);
virtual ~CTestMaskAppView();
public:
void Draw(const TRect& aRect) const;
virtual void SizeChanged();
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
void LoadBitmap();
private:
void ConstructL(const TRect& aRect);
CTestMaskAppView();
private:
CFbsBitmap* iBitmapBack;
CFbsBitmap* iBitmap;
CFbsBitmap* iMaskBitmap;
TRect iRect;
CFbsBitmap* iBitmap1;
CFbsBitmap* iMaskBitmap1;
TRect iRect1;
};
#endif // __TESTMASKAPPVIEW_h__
// End of File
/*
============================================================================
Name : TestMaskAppView.cpp
Author :
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/
// INCLUDE FILES
#include <coemain.h>
#include "TestMaskAppView.h"
// ============================ MEMBER FUNCTIONS ===============================
CTestMaskAppView* CTestMaskAppView::NewL(const TRect& aRect)
{
CTestMaskAppView* self = CTestMaskAppView::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
CTestMaskAppView* CTestMaskAppView::NewLC(const TRect& aRect)
{
CTestMaskAppView* self = new (ELeave) CTestMaskAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
void CTestMaskAppView::ConstructL(const TRect& aRect)
{
CreateWindowL();
LoadBitmap();
SetRect(aRect);
ActivateL();
}
CTestMaskAppView::CTestMaskAppView()
{
// No implementation required
}
CTestMaskAppView::~CTestMaskAppView()
{
delete iBitmapBack;
delete iBitmap;
delete iMaskBitmap;
delete iBitmap1;
delete iMaskBitmap1;
}
void CTestMaskAppView::Draw(const TRect& /*aRect*/) const
{
CWindowGc& gc = SystemGc();
TRect drawRect(Rect());
gc.Clear(drawRect);
gc.BitBlt(Position(),iBitmapBack);
gc.BitBltMasked(TPoint(5,305),iBitmap,iRect,iMaskBitmap,ETrue); //掩码图——白底黑图 ,关键之一
gc.BitBltMasked(TPoint(225,305),iBitmap1,iRect1,iMaskBitmap1,EFalse); //掩码图——黑底白图
}
void CTestMaskAppView::SizeChanged()
{
DrawNow();
}
void CTestMaskAppView::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
CCoeControl::HandlePointerEventL(aPointerEvent);
}
void CTestMaskAppView::LoadBitmap()
{
_LIT(multiBitmapFile,"c://Data//mbm//TestMask.mbm");
iBitmapBack = new (ELeave) CFbsBitmap();
iBitmap = new (ELeave) CFbsBitmap();
iMaskBitmap = new (ELeave) CFbsBitmap();
iBitmap1 = new (ELeave) CFbsBitmap();
iMaskBitmap1 = new (ELeave) CFbsBitmap();
User::LeaveIfError(iBitmapBack->Load(multiBitmapFile,0,ETrue));
User::LeaveIfError(iBitmap->Load(multiBitmapFile,1,ETrue));
User::LeaveIfError(iMaskBitmap->Load(multiBitmapFile,2,ETrue));
User::LeaveIfError(iBitmap1->Load(multiBitmapFile,3,ETrue));
User::LeaveIfError(iMaskBitmap1->Load(multiBitmapFile,4,ETrue));
iRect = TRect (TPoint(0,0),iBitmap->SizeInPixels()); //关键之2:
iRect1 = TRect (TPoint(0,0),iBitmap1->SizeInPixels());
}
// End of File