📄 progressbarcontainer.cpp
字号:
/*
* ============================================================================
* Name : CProgressBarContainer from ProgressBarContainer.h
* Part of : ProgressBar
* Created : 26.02.2006 by ToBeReplacedByAuthor
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include "ProgressBarContainer.h"
#include <eikprogi.h> // CEikProgressInfo
#include <ProgressBar.rsg> // for resource definition
#include <coemain.h> //iCoeEnv
#include <barsread.h> //for TResourceReader
#include "ProgressBar.hrh"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CProgressBarContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CProgressBarContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC( reader, R_PROGRESS_BAR );
iPBar = new( ELeave ) CEikProgressInfo();
iPBar->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy();
iPBar->SetPosition( TPoint( 10, 40 ) ) ;
iPBar->SetContainerWindowL( *this );
iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
StartTimer();
SetRect(aRect);
ActivateL();
}
// Destructor
CProgressBarContainer::~CProgressBarContainer()
{
delete iPBar;
if (iPeriodicTimer)
{
iPeriodicTimer->Cancel();
}
delete iPeriodicTimer;
}
void CProgressBarContainer::StartTimer()
{
//If the timer is not already running, start it
if (iPeriodicTimer->IsActive())
{
iPeriodicTimer->Cancel();
}
iPeriodicTimer->Start( 500000, 200000,TCallBack(CProgressBarContainer::Period,this));
}
// ---------------------------------------------------------
// CProgressBarContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CProgressBarContainer::SizeChanged()
{
// TODO: Add here control resize code etc.
}
// ---------------------------------------------------------
// CProgressBarContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CProgressBarContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CProgressBarContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CProgressBarContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iPBar;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CProgressBarContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CProgressBarContainer::Draw(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 );
}
// ---------------------------------------------------------
// CProgressBarContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CProgressBarContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
void CProgressBarContainer::DoStep()
{
iPBar->IncrementAndDraw( 1 );
}
TInt CProgressBarContainer::Period(TAny * aPtr)
{
((CProgressBarContainer*)aPtr)->DoStep();
//returning a value of TRUE indicates the callback should be done again
return TRUE;
}
void CProgressBarContainer::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EProgressBarCmdAppTest:
{
iPBar->SetAndDraw( 0 );
break;
}
default:
break;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -