📄 recordercontainer.cpp
字号:
/*
* ============================================================================
* Name : RecorderContainer.cpp
* Part of : RecorderExample
* Created : 20.03.2005 by Forum Nokia
* Version : 1.0.0
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include <coemain.h>
#include <barsread.h>
#include <aknappui.h>
#include <eikprogi.h>
//label
#include <eiklabel.h>
#include "RecorderContainer.h"
#include <akntitle.h>
// CONSTANTS
const TInt KProgressBarResetValue = 0;
#define KDrawColorBlack TRgb(0xffffff)
#define PROGRESS_BAR_POSITION TPoint( 15, 45 )
#define TIME_POSITION TPoint( 15, 60 )
#define LABEL_POSITION TPoint( 15, 30 )
#define INFO_POSITION TPoint( 15, 85 )
#define INFO_TEXT_POSITION TPoint( 15, 100 )
const TInt KProgressBarHeight = 10;
const TInt KProgressBarSplitsInBlock = 0;
const TInt KProgressBarWidth = 120;
const TInt KProgressBarFinalValue = 15;
_LIT(KColon,":");
_LIT(KSpace," ");
_LIT(KSlash,"/");
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CREcorderContainer::CRecorderContainer()
// C++ default constructor
// ---------------------------------------------------------
CRecorderContainer::CRecorderContainer()
{
}
// ---------------------------------------------------------
// CRecorderContainer::ConstructL()
// EPOC default constructor can leave.
// ---------------------------------------------------------
void CRecorderContainer::ConstructL( const TRect& aRect )
{
CreateWindowL();
Window().SetShadowDisabled( EFalse );
CEikProgressInfo::SInfo info;
info.iHeight = KProgressBarHeight;
info.iSplitsInBlock = KProgressBarSplitsInBlock;
info.iTextType = EEikProgressTextNone;
info.iWidth = KProgressBarWidth;
info.iFinalValue = KProgressBarFinalValue;
iPBar = new( ELeave ) CEikProgressInfo( info );
iPBar ->ConstructL();
iPBar ->SetPosition( PROGRESS_BAR_POSITION );
iPBar ->SetContainerWindowL( *this );
TBuf<20> aMessage;
aMessage.Zero();
//filename label
iLabel = new (ELeave) CEikLabel;
iLabel ->SetContainerWindowL(*this);
iLabel ->SetPosition( LABEL_POSITION );
iLabel ->SetTextL(aMessage);
//timer label
iTime = new (ELeave) CEikLabel;
iTime ->SetContainerWindowL(*this);
iTime ->SetPosition( TIME_POSITION );
iTime ->SetTextL(aMessage);
//info label
iInfo = new (ELeave) CEikLabel;
iInfo ->SetContainerWindowL(*this);
iInfo ->SetPosition( INFO_POSITION );
iInfo ->SetTextL(_L("Automatic operation:"));
//info text label
iInfoText = new (ELeave) CEikLabel;
iInfoText ->SetContainerWindowL(*this);
iInfoText ->SetPosition( INFO_TEXT_POSITION );
SetInfo(ETrue);
CEikStatusPane *sp = ((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane();
iTitlePane = (CAknTitlePane *)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
SetRect( aRect );
ActivateL();
}
// ---------------------------------------------------------
// CRecorderContainer::~CREcorderContainer()
// Destructor
// ---------------------------------------------------------
CRecorderContainer::~CRecorderContainer()
{
delete( iLabel );
delete( iPBar );
delete( iTime );
delete( iInfo );
delete( iInfoText );
}
// ---------------------------------------------------------
// CRecorderContainer::SizeChanged()
// UI components' size are recalculated
// ---------------------------------------------------------
void CRecorderContainer::SizeChanged()
{
iLabel -> SetExtent( LABEL_POSITION, iLabel->MinimumSize() );
iPBar -> SetExtent( PROGRESS_BAR_POSITION, iPBar->MinimumSize() );
iTime -> SetExtent( TIME_POSITION, iTime->MinimumSize() );
iInfo -> SetExtent( INFO_POSITION, iInfo->MinimumSize() );
iInfoText -> SetExtent( INFO_TEXT_POSITION, iInfoText->MinimumSize() );
}
// ---------------------------------------------------------
// CRecorderContainer::IncrementBarsAndDraw( TInt aIncrement )
// Increase progress bar length
// ---------------------------------------------------------
//
void CRecorderContainer::IncrementBarsAndDraw( TInt aIncrement )
{
iPBar ->IncrementAndDraw( aIncrement );
}
// ---------------------------------------------------------
// CRecorderContainer::ResetAllValues()
// Reset progress bar length
// ---------------------------------------------------------
//
void CRecorderContainer::ResetAllValues(TInt CurrentValue, TInt FinalValue)
{
iPBar -> SetFinalValue(FinalValue);
iPBar -> SetAndDraw( CurrentValue );
iFinalValue = FinalValue;
}
// ---------------------------------------------------------
// CRecorderContainer::SetBarValue
// Set new value to progressbar and update timelabel's text
// ---------------------------------------------------------
//
void CRecorderContainer::SetBarValue(TInt CurrentValue)
{
TBuf <20> time;
time.AppendNum((CurrentValue - CurrentValue%60) / 60);
time.Append(KColon);
time.AppendNum(CurrentValue%60);
time.Append(KSpace);
time.Append(KSlash);
time.Append(KSpace);
time.AppendNum((iFinalValue - iFinalValue%60)/60);
time.Append(KColon);
time.AppendNum(iFinalValue%60);
iTime -> SetTextL(time);
SizeChanged();
this -> DrawNow();
iPBar -> SetAndDraw(CurrentValue);
}
// ---------------------------------------------------------
// CRecorderContainer::CountComponentControls() const
// amount of component controls
// ---------------------------------------------------------
//
TInt CRecorderContainer::CountComponentControls() const
{
return 5;
}
// ---------------------------------------------------------
// CRecorderContainer::ComponentControl( TInt aIndex ) const
// Ptr to each component controls
// ---------------------------------------------------------
//
CCoeControl* CRecorderContainer::ComponentControl( TInt aIndex ) const
{
switch (aIndex)
{
case 0:
{
return iPBar;
break;
}
case 1:
{
return iLabel;
break;
}
case 2:
{
return iTime;
break;
}
case 3:
{
return iInfo;
break;
}
case 4:
{
return iInfoText;
break;
}
default:
return NULL;
}
}
// ---------------------------------------------------------
// CRecorderContainer::Draw( const TRect& aRect ) const
// Draw function
// ---------------------------------------------------------
//
void CRecorderContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KDrawColorBlack );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
void CRecorderContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// ---------------------------------------------------------
// CRecorderContainer::SetText()
// Set text to errorlabel and draw screen
// ---------------------------------------------------------
//
void CRecorderContainer::SetText(TDesC& aText)
{
iLabel -> SetTextL(aText);
SizeChanged();
iLabel -> DrawNow();
}
// ---------------------------------------------------------
// CRecorderContainer::SetInfo()
// Set active or deactive text to InfoText label
// ---------------------------------------------------------
//
void CRecorderContainer::SetInfo(TBool active)
{
if (active)
{
iInfoText->SetTextL(_L("Active"));
}
else
{
iInfoText->SetTextL(_L("Deactive"));
}
SizeChanged();
this -> DrawNow();
iInfoText -> DrawNow();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -