📄 progressbarctrl.cpp
字号:
/*
============================================================================
Name : ProgressBarCtrl.cpp
Author : Hou maoqing
Version : 1.0
Copyright : Copyright (c) Hou maoqing 2008
Description : CProgressBarCtrl implementation
============================================================================
*/
#include "ProgressBarCtrl.h"
CProgressBarCtrl::CProgressBarCtrl()
{
m_nTotalProgress=0;
m_nCurrentProgress=0;
}
CProgressBarCtrl::~CProgressBarCtrl()
{
}
void CProgressBarCtrl::ConstructL(const CCoeControl* aParent,const TRect& aRect)
{
SetContainerWindowL(*aParent);
SetRect(aRect);
ActivateL();
}
void CProgressBarCtrl::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
TRect drawRect(Rect());
gc.Clear(drawRect);
//画总进度
gc.SetPenStyle(CGraphicsContext::ESolidPen);
gc.DrawRect(drawRect);
//画当前进度
TRect curRect(drawRect);
if(m_nTotalProgress>0 && m_nCurrentProgress>=0)
curRect.iBr.iX=curRect.iTl.iX+curRect.Width()*m_nCurrentProgress/m_nTotalProgress;
else
curRect.iBr.iX=curRect.iTl.iX;
gc.SetBrushColor(KRgbRed);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(curRect);
}
void CProgressBarCtrl::SizeChanged()
{
this->DrawDeferred();
}
TKeyResponse CProgressBarCtrl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
TKeyResponse r = EKeyWasNotConsumed;
if(aType==EEventKey)
{
if(aKeyEvent.iCode==EKeyLeftArrow)
{
m_nCurrentProgress-=5;
if(m_nCurrentProgress<0)
m_nCurrentProgress=0;
this->DrawDeferred();
r = EKeyWasConsumed;
}
else if(aKeyEvent.iCode==EKeyRightArrow)
{
m_nCurrentProgress+=5;
if(m_nCurrentProgress>m_nTotalProgress)
m_nCurrentProgress=m_nTotalProgress;
this->DrawDeferred();
r = EKeyWasConsumed;
}
}
return r;
}
void CProgressBarCtrl::SetTotalProgress(TInt nTotalProgress)
{
m_nTotalProgress=nTotalProgress;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -