// TimeLabel.h: interface for the CTimeLabel class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(__RV_TIMELABEL_H_INCLUDED_)
#define __RV_TIMELABEL_H_INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Label.h"

//time display format
#define TL_DF_MM_SS_CS   0//  "mm:ss:cs"
#define TL_DF_HH_MM      1 //"hh:mm"
#define TL_DF_MM_SS      2//"mm:ss"
#define TL_DF_HH_MM_SS   3//"hh:mm:ss"
#define TL_DF_FULL_TIME  4//"YY-MM-DD WK hh:mm:ss"
#define TL_DF_DATE_TIME  5//"YY-MM-DD hh:mm:ss"


class INDIX_API CTimeLabel : public CLabel  
{
public:
	enum TIME_TYPE{
		TT_WATCH =0,
		TT_COUNTER ,
		TT_ANTI_COUNTER, //倒计时
	};

	enum TIME_FORMAT{
		TF_MM_SS_CS  = 0,//  "mm:ss:cs"
		TF_HH_MM   ,//"hh:mm"
		TF_MM_SS   ,//"mm:ss"
		TF_HH_MM_SS  ,//"hh:mm:ss"
		TF_FULL_TIME ,//"YY-MM-DD WK hh:mm:ss"
		TF_DATE_TIME ,//"YY-MM-DD hh:mm:ss"
		TF_SS_MS     =58   ,//  "ss:ms"
		TF_MSEC,      //"ms"
		TF_SECONDS,   //"ss"
		TF_MINUTES,   //"mm"
		TF_HOURS,   //"hh"
	};


public:

	CTimeLabel();
	virtual ~CTimeLabel();
	
	virtual BOOL  Create(/*CDelegate* pDelegate=NULL,*/ const TCHAR* strName = NULL, UINT id =-1, int style = RV_UC_DEFAULT_STYLE ) ;
	virtual void  Destroy(/*BOOL bEraseStroke=FALSE*/) ;

	virtual BOOL Serialize(HANDLE device, BOOL bIn ) ;

	virtual CUCObj* Clone(  CUCObj* twin) ;

	//virtual void Beat();
	
	//virtual void  Activate();

	virtual void Show(CDelegate* pDelegate,int mode, BOOL bForce);	

	//void Start(BOOL bReset);
	//void Stop();

	void SetFormat(TIME_FORMAT format);
	void SetType(TIME_TYPE  type);

	TIME_FORMAT GetFormat(){ return m_nFormat; };
	TIME_TYPE   GetType( ) { return m_nType; };

	int GetInitVal() {return (int)m_nInitVal; };
	void SetInitVal(int seconds);
	void SetInitVal(int hours, int minutes, int seconds);
	BOOL IsAlarmOn(){ return m_bAlarmOn;};
	 
	virtual void EnableAnimation(BOOL flag, CDelegate* pDelegate );
	  
	//动态控件如滚动条，动画，时间显示的内容切换
	virtual void Beat(CDelegate* pDelegate );

	//BOOL   Start(int hours=0, int minutes=1, int seconds=0);
	//double Stop();

	double GetTime();

private:

	TIME_TYPE     m_nType;
	TIME_FORMAT   m_nFormat;

	__int64  m_nInitVal;//单位:秒
	BOOL     m_bAlarmOn;
	double   m_nTimeDiff;//秒
	//time_t m_previousTime;

	//__int64  m_nRunCounter;
	double  m_nStartTime;  //秒
	double  m_previousTime;//秒
	int      m_nBeatRate;  //每秒多少次
	

	//BOOL m_bStarted;

	void ReadCurTime(BOOL bInit);

	//CRITICAL_SECTION m_cs;

public:
	
};

#endif // !defined(__RV_TIMELABEL_H_INCLUDED_)
