📄 splashview.cpp
字号:
/*
* ============================================================================
* Name : CSplashView from CSplashView.h
* Part of : Splash
* Created : 17/02/2003 by Eric@NewLC
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright:
* ============================================================================
*/
// INCLUDE FILES
#include <eikdef.h>
#include "SplashView.h"
#include "SplashDocument.h"
#include "SplashAppUi.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CSplashView::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CSplashView::ConstructL(const TRect& aRect)
{
//
// Create and activate the main window
//
CreateWindowL();
SetRect(aRect);
ActivateL();
//
// Create the SplashScreen
// Set the refresh rate of the screen to 1000 micro-seconds
//
CSplashContainer::ConstructL(aRect);
SetTimerTick(1000);
//
// Configure some internal counters that are used for displaying
// the splash screen (app specific) - not par or the CSplashContainer
//
// iPreCount is the duration (in Ticks, 1 ticks = 1000 micro-sec according to
// previous initialisation) of the "black screen" before the text
// starts to appear
// iColorCount is the value that shall be used for each R,G and B component of
// displayed text color
// iPostCount is the duration (in Ticks) of display of the splash screen after
// the animation
iPreCount =10;
iColorCount=0;
iPostCount =20;
//
// Activate the splashscreen animation
//
StartTimer();
}
// Destructor
CSplashView::~CSplashView()
{
}
// ---------------------------------------------------------
// CSplashView::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CSplashView::SizeChanged()
{
}
// ---------------------------------------------------------
// CSplashView::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CSplashView::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CSplashView::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CSplashView::ComponentControl(TInt /*aIndex*/) const
{
return NULL;
}
// ---------------------------------------------------------
// CSplashView::DrawSplash(const TRect& aRect) const
// Equivalent of the CCoeControl Draw function while in Splash
// mode (i.e. until a call to SetState(<new mode>))
// ---------------------------------------------------------
//
void CSplashView::DrawSplash(const TRect& /*aRect*/) const
{
CWindowGc& gc = SystemGc();
TRect rect = Rect();
//
// Draw Black background
//
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.SetBrushColor(KRgbBlack);
gc.DrawRect(rect);
//
// Select default font for title
// The color will change from black -> white with the increase of iColorCount
//
const CFont* font = iEikonEnv->TitleFont();
gc.UseFont(font);
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.SetPenColor(TRgb(iColorCount,iColorCount,iColorCount));
//
// Draw the text, horizontally centered and vertically slightly below center
//
TSize aSize(rect.Width(),font->HeightInPixels()+5);
rect.SetRect(TPoint(0,(rect.Height()/2)-font->HeightInPixels()-5),aSize);
gc.DrawText(_L("My"),rect,font->AscentInPixels(),CGraphicsContext::ECenter);
rect.Move(0,font->HeightInPixels()+2);
gc.DrawText(_L("Splash"),rect,font->AscentInPixels(),CGraphicsContext::ECenter);
rect.Move(0,font->HeightInPixels()+2);
gc.DrawText(_L("Screen"),rect,font->AscentInPixels(),CGraphicsContext::ECenter);
gc.DiscardFont();
}
// ---------------------------------------------------------
// CSplashView::DrawMain(const TRect& aRect) const
// Equivalent of the CCoeControl Draw function while in main
// mode (i.e. after splash). Normally during the lifetime
// of your app.
// ---------------------------------------------------------
//
void CSplashView::DrawMain(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// TODO: Add your drawing code here
// example code...
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbWhite);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CSplashView::DrawExiting(const TRect& aRect) const
// Equivalent of the CCoeControl Draw function before exiting
// the App (not used in this app)
// ---------------------------------------------------------
//
void CSplashView::DrawExiting(const TRect& /*aRect*/) const
{
}
// ---------------------------------------------------------
// CSplashView::Tick()
// This function is called periodically each <tick> microsecond.
// The tick value has been initialised in the CSplashView::ConstructL
// function.
// If the function return ETrue, then a screen redraw will be
// requested by the base class.
// ---------------------------------------------------------
//
TBool CSplashView::Tick()
{
//
// Start by precount
// (during precount iColorCount is zero, so splash text will be displayed
// in black and then not visible)
if(iPreCount>0)
{
iPreCount--;
}
//
// After PreCount, fade the text to white with a 15 increment.
//
else if(iColorCount<255)
{
iColorCount+=15;
}
//
// When the text is white, wait for iPostCount Tick before switching
// to main state
//
else if(iPostCount>0)
{
iPostCount--;
}
else
{
SetState(CSplashContainer::EMain);
StopTimer();
}
return ETrue;
}
// ---------------------------------------------------------
// CSplashView::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CSplashView::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -