📄 ddbouncingball_appview.cpp
字号:
// DDBouncingBall_AppView.cpp
// ---------------------------
//
// Copyright (c) 2002 Symbian Ltd. All rights reserved.
//
#include "DDBouncingBall_AppView.h"
#include "DDBouncingBall_Engine.h"
#include <eikenv.h>
// Local Constants
_LIT (KBitmapFilename,"\\System\\Apps\\DDBouncingBall\\DDBouncingBall.mbm");
const TInt KInitialXVelocity = 2;
const TInt KInitialYVelocity = 2;
CDDBouncingBallAppView* CDDBouncingBallAppView::NewL(const TRect& aRect)
{
CDDBouncingBallAppView* self = CDDBouncingBallAppView::NewLC(aRect);
CleanupStack::Pop();
return self;
}
CDDBouncingBallAppView* CDDBouncingBallAppView::NewLC(const TRect& aRect)
{
CDDBouncingBallAppView* self = new (ELeave) CDDBouncingBallAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
void CDDBouncingBallAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
// Create our Direct Screen Access object. With Bitmaps which we will
// create here. However the Engine will be responsible for the bitmap
// destruction.
CFbsBitmap* bitmap = iEikonEnv->CreateBitmapL(KBitmapFilename, 0);
CFbsBitmap* bitmapMask = iEikonEnv->CreateBitmapL(KBitmapFilename, 1);
// Set up the BouncingBall
iBouncingBall = new (ELeave) CDDBouncingBallEngine
(
iEikonEnv->WsSession(),
*(CCoeEnv::Static()->ScreenDevice()),
Window(),
bitmap,
bitmapMask,
KInitialXVelocity,
KInitialYVelocity
);
iBouncingBall->ConstructL();
// Activate the window, which makes it ready to be drawn
ActivateL();
}
CDDBouncingBallAppView::CDDBouncingBallAppView()
{
}
CDDBouncingBallAppView::~CDDBouncingBallAppView()
{
if (iBouncingBall->Bouncing())
iBouncingBall->StopBouncing();
delete iBouncingBall;
}
void CDDBouncingBallAppView::Draw(const TRect& /*aRect*/) const
{
// Clear the screen
CWindowGc& gc = SystemGc();
gc.Clear(Rect());
}
void CDDBouncingBallAppView::StartBouncingBallL()
{
iBouncingBall->StartBouncingL();
}
void CDDBouncingBallAppView::StopBouncingBall()
{
iBouncingBall->StopBouncing();
}
TBool CDDBouncingBallAppView::IsBouncing()
{
return iBouncingBall->Bouncing();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -