mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 08:21:07 +02:00
CComponentsFrmClock: Add blinking function
Origin commit data
------------------
Commit: 4f93850708
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2013-12-10 (Tue, 10 Dec 2013)
This commit is contained in:
@@ -84,6 +84,8 @@ void CComponentsFrmClock::initVarClock()
|
|||||||
|
|
||||||
cl_thread = 0;
|
cl_thread = 0;
|
||||||
cl_interval = 1;
|
cl_interval = 1;
|
||||||
|
|
||||||
|
cl_blink_str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponentsFrmClock::~CComponentsFrmClock()
|
CComponentsFrmClock::~CComponentsFrmClock()
|
||||||
@@ -97,7 +99,7 @@ void CComponentsFrmClock::initTimeString()
|
|||||||
struct tm t;
|
struct tm t;
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
ltime=time(<ime);
|
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?
|
// How does it works?
|
||||||
@@ -262,9 +264,19 @@ void* CComponentsFrmClock::initClockThread(void *arg)
|
|||||||
|
|
||||||
CComponentsFrmClock *clock = static_cast<CComponentsFrmClock*>(arg);
|
CComponentsFrmClock *clock = static_cast<CComponentsFrmClock*>(arg);
|
||||||
time_t count = time(0);
|
time_t count = time(0);
|
||||||
|
std::string format_str_save = clock->cl_format_str;
|
||||||
//start loop for paint
|
//start loop for paint
|
||||||
while(1) {
|
while(1) {
|
||||||
if (clock->paintClock) {
|
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
|
//paint segements, but wihtout saved backgrounds
|
||||||
clock->paint(CC_SAVE_SCREEN_NO);
|
clock->paint(CC_SAVE_SCREEN_NO);
|
||||||
count = time(0);
|
count = time(0);
|
||||||
|
@@ -70,7 +70,9 @@ class CComponentsFrmClock : public CComponentsForm
|
|||||||
///text color
|
///text color
|
||||||
int cl_col_text;
|
int cl_col_text;
|
||||||
///time format
|
///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
|
///time string align, default allign is ver and hor centered
|
||||||
int cl_align;
|
int cl_align;
|
||||||
|
|
||||||
@@ -107,6 +109,9 @@ class CComponentsFrmClock : public CComponentsForm
|
|||||||
///use string expession: "%H:%M" = 12:22, "%H:%M:%S" = 12:22:12
|
///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;};
|
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
|
///start ticking clock thread, returns true on success, if false causes log output
|
||||||
virtual bool startThread();
|
virtual bool startThread();
|
||||||
///stop ticking clock thread, returns true on success, if false causes log output
|
///stop ticking clock thread, returns true on success, if false causes log output
|
||||||
|
Reference in New Issue
Block a user