diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index af884de5d..c62f045e2 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -84,6 +84,8 @@ void CComponentsFrmClock::initVarClock() cl_thread = 0; cl_interval = 1; + + cl_blink_str = ""; } CComponentsFrmClock::~CComponentsFrmClock() @@ -97,7 +99,7 @@ void CComponentsFrmClock::initTimeString() struct tm t; time_t ltime; ltime=time(<ime); - strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format_str, localtime_r(<ime, &t)); + strftime((char*) &cl_timestr, sizeof(cl_timestr), cl_format_str.c_str(), localtime_r(<ime, &t)); } // How does it works? @@ -262,9 +264,19 @@ void* CComponentsFrmClock::initClockThread(void *arg) CComponentsFrmClock *clock = static_cast(arg); time_t count = time(0); + std::string format_str_save = clock->cl_format_str; //start loop for paint while(1) { if (clock->paintClock) { + // Blinking depending on the blink format string + if (!clock->cl_blink_str.empty() && (clock->cl_format_str.length() == clock->cl_blink_str.length())) { + if (clock->cl_format_str == clock->cl_blink_str.c_str()) + clock->cl_format_str = format_str_save; + else { + format_str_save = clock->cl_format_str; + clock->cl_format_str = clock->cl_blink_str; + } + } //paint segements, but wihtout saved backgrounds clock->paint(CC_SAVE_SCREEN_NO); count = time(0); diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 860126edc..5d15c49b5 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -70,7 +70,9 @@ class CComponentsFrmClock : public CComponentsForm ///text color int cl_col_text; ///time format - const char* cl_format_str; + std::string cl_format_str; + ///time format for blink + std::string cl_blink_str; ///time string align, default allign is ver and hor centered int cl_align; @@ -107,6 +109,9 @@ class CComponentsFrmClock : public CComponentsForm ///use string expession: "%H:%M" = 12:22, "%H:%M:%S" = 12:22:12 virtual void setClockFormat(const char* format_str){cl_format_str = format_str;}; + ///time format for blink ("%H %M", "%H:%M %S" etc.) + virtual void setClockBlink(const char* format_str){cl_blink_str = format_str;}; + ///start ticking clock thread, returns true on success, if false causes log output virtual bool startThread(); ///stop ticking clock thread, returns true on success, if false causes log output