The following article will tell you how to make a timeline control step by step in S60.
Author Website: http://www.symbianer.com
The keywords of artile: window, custom control, time, periodic.

Frist, you need reffer to tow articles
I.Symbian OS: Creating Custom Controls
you can download here>>
II.Periodic timer active object.
Developer Library >> API Reference >> C++ API reference >> Timers and Timing Services >> CPeriodic
1. Class Declaration:
Code:
class CMyTimerContainer : public CCoeControl
{
public:
void ConstructL(TInt aSecond ,TPoint aPoint, TSize aSize); // Initialize Seconds, Position, Size Of Timeline Control
~CMyTimerContainer();
void Draw(const TRect& aRect) const;
static TInt Start__(TAny* aObject);
void Start_();
private: //data
CPeriodic* iPeriodic;
TInt iLeft; //Left times
TInt iTotal;//Total times
TPoint iPoint; //control position,
TSize iSize; //Control size
}
2. Periodic Functions:{
public:
void ConstructL(TInt aSecond ,TPoint aPoint, TSize aSize); // Initialize Seconds, Position, Size Of Timeline Control
~CMyTimerContainer();
void Draw(const TRect& aRect) const;
static TInt Start__(TAny* aObject);
void Start_();
private: //data
CPeriodic* iPeriodic;
TInt iLeft; //Left times
TInt iTotal;//Total times
TPoint iPoint; //control position,
TSize iSize; //Control size
}
Code:
TInt CMyTimerContainer::Start__(TAny* aObject)
{
((CMyTimerContainer*)aObject)->Start_(); // cast, and call non-static function
return 1;
}
void CMyTimerContainer::Start_()
{
iLeft--;
if(iLeft==0)
{
DrawNow();
iPeriodic->Cancel();
return;
}
DrawNow();
}
3. Draw Funciton{
((CMyTimerContainer*)aObject)->Start_(); // cast, and call non-static function
return 1;
}
void CMyTimerContainer::Start_()
{
iLeft--;
if(iLeft==0)
{
DrawNow();
iPeriodic->Cancel();
return;
}
DrawNow();
}
Code:
void CMyTimerContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
/*Draw BackGround*************************/
gc.SetBrushColor( KRgbBlack );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect(aRect);
/*Drar Timeline*************************/
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.SetBrushColor( KRgbRed );
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.DrawRect( TRect(TSize(iLeft*Size().iWidth/iTotal,iSize.iHeight)) );
}
{
CWindowGc& gc = SystemGc();
/*Draw BackGround*************************/
gc.SetBrushColor( KRgbBlack );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect(aRect);
/*Drar Timeline*************************/
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.SetBrushColor( KRgbRed );
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.DrawRect( TRect(TSize(iLeft*Size().iWidth/iTotal,iSize.iHeight)) );
}
4. Construct Function
Code:
void CMyTimerContainer::ConstructL(TInt aSecond ,TPoint aPoint, TSize aSize)
{
CreateWindowL();
iTotal = aSecond;
iLeft = iTotal;
iPoint = aPoint;
iSize = aSize;
iPeriodic = CPeriodic::NewL(CActive::EPriorityIdle);
iPeriodic->Start(0/*8000000*/, 1000000/*35714*/, TCallBack(Start__, this));
SetExtent(aPoint,aSize);
ActivateL();
}
{
CreateWindowL();
iTotal = aSecond;
iLeft = iTotal;
iPoint = aPoint;
iSize = aSize;
iPeriodic = CPeriodic::NewL(CActive::EPriorityIdle);
iPeriodic->Start(0/*8000000*/, 1000000/*35714*/, TCallBack(Start__, this));
SetExtent(aPoint,aSize);
ActivateL();
}
5. How To Use The Timeline Custom Control
Code:
a.Add Custom Control in XXXContainer.h
private: //data
CMyTimerContainer* iTimer;
b,Initialize Seconds, Position, Size Of Timeline Control
void CXXXXContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iTimer = new (ELeave) CMyTimerContainer;
iTimer->ConstructL( 60/*init seconds*/,TPoint(0,100),TSize(176,15),this);
SetRect(aRect);
ActivateL();
}
You can reffer to the codes of article to modify your codes. Welcome to comment here.private: //data
CMyTimerContainer* iTimer;
b,Initialize Seconds, Position, Size Of Timeline Control
void CXXXXContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iTimer = new (ELeave) CMyTimerContainer;
iTimer->ConstructL( 60/*init seconds*/,TPoint(0,100),TSize(176,15),this);
SetRect(aRect);
ActivateL();
}
Download Source Codes>>
English Version: http://www.symbianer.com/post/custom-control-timeline-en.html
Chinese Version: http://www.symbianer.com/post/custom-control-timeline.html
Mail: N-office@163.com
Website: http://www.symbianer.com



Comments (1) |
Trackbacks (0)
Re: Making TimeLine Control
نوكيا | 03/11/2009, 23:52
Nice app
احدث نوكيا | كسر حماية نوكيا | تحميل كتب | برامج عمل شهادة | مشاكل نوكيا | نوكيا N97 5800 5530 | برامج نوكيا N97 5800 5530 i8910 | العاب نوكيا N97 5800 5530 i8910 | برامج نوكيا N97 5800 5530 i8910 معربه | ثيمات نوكيا N97 5800 5530 i8910 | نوكيا n73 n96 n85 8gb n95 e66 e90 e71 e63 e51 n82 n81 6290 6120 5700 N86 | برامج نوكيا n73 n96 n85 8gb n95 e66 e90 e71 e63 e51 n82 n81 6290 6120 5700 N86 | العاب نوكيا n73 n96 n85 8gb n95 e66 e90 e71 e63 e51 n82 n81 6290 6120 5700 N86 | برامج نوكيا n73 n96 n85 8gb n95 e66 e90 e71 e63 e51 n82 n81 6290 6120 5700 N86 معربه | ثيمات نوكيا n73 n96 n85 8gb n95 e66 e90 e71 e63 e51 n82 n81 6290 6120 5700 N86 | نوكيا N90 6680 3230 7610 6260 6630 6670 6600 | برامج نوكيا N90 6680 3230 7610 6260 6630 6670 6600 | العاب نوكيا N90 6680 3230 7610 6260 6630 6670 6600 | برامج نوكيا N90 6680 3230 7610 6260 6630 6670 6600 معربه | ثيمات نوكيا N90 6680 3230 7610 6260 6630 6670 6600 | العاب نوكيا مميزه | ثيمات خلفيات مميزه | برامج نوكيا مميزة | Nokia N-Gage N-Gage QD العاب انجيج برامج