00001
00002
00003
00004 #ifndef UNIXTIMELINE_H
00005
00006 #include "OglGui/WindowTimeLine.h"
00007
00008 namespace Impala { namespace Application { namespace MediaTable {
00009
00010 class UnixTimeLine : public OglGui::WindowTimeLine
00011 {
00012 public:
00013 UnixTimeLine(int x, int y, int w, int h,
00014 long startTime=0, long timeSpan=60000) :
00015 OglGui::WindowTimeLine(x,y,w,h,startTime,timeSpan)
00016 {
00017 }
00018 UnixTimeLine(Window* parent, int w, int h,
00019 long startTime=0, long timeSpan=60000) :
00020 OglGui::WindowTimeLine(parent,w,h,startTime,timeSpan)
00021 {
00022 }
00023
00024 UnixTimeLine(Window* parent, int x, int y, int w, int h,
00025 long startTime=0, long timeSpan=60000) :
00026 OglGui::WindowTimeLine(parent,x,y,w,h,startTime,timeSpan)
00027 {
00028 }
00029
00030 protected:
00031 void DrawTick(long time,int x,int y,long tickSpan,int tickLen=5)
00032 {
00033 DrawLine(x, y-tickLen, x, y);
00034
00035 std::string months[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
00036 time_t span = tickSpan;
00037 time_t timet = time;
00038 tm dateSpan = *localtime(&span);
00039 tm* dateTm = localtime(&timet);
00040 std::string txt;
00041 if(dateSpan.tm_year > 70 || dateSpan.tm_mon > 6)
00042 txt = MakeString(dateTm->tm_year+1900);
00043 else if(dateSpan.tm_yday > 20)
00044 txt = months[dateTm->tm_mon] + " "
00045 + MakeString(dateTm->tm_year+1900);
00046 else if(dateSpan.tm_yday > 0 || dateSpan.tm_hour > 3 ||
00047 (dateTm->tm_hour < dateSpan.tm_hour))
00048 txt = months[dateTm->tm_mon] + " "
00049 + MakeString(dateTm->tm_mday);
00050 else
00051 txt = MakeString(dateTm->tm_hour) + ":"
00052 + ((dateTm->tm_min < 10) ? "0" : "")
00053 + MakeString(dateTm->tm_min);
00054
00055 int txtY = y - tickLen - 10;
00056 int txtX = x - ((x<15) ? 2 : 15);
00057
00058 if (!mTextShaded)
00059 oglSys.PosColPrintf(mOglWnd, txtX, txtY, mTextColor, txt.c_str());
00060 else
00061 oglSys.ShadowPrintf(mOglWnd, txtX, txtY, mTextShadowBg,
00062 mTextShadowFg, txt.c_str());
00063 }
00064 };
00065
00066 } } }
00067 #endif