diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index efc190194..26afa3ea7 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -60,12 +60,11 @@ CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, cons col_body = color_body; col_shadow = color_shadow; + cl_format_str = format_str; paintClock = false; activeClock = activ; if (activeClock) startThread(); - - cl_format_str = format_str; } void CComponentsFrmClock::initVarClock() diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 9ea868ce9..621c9f9cc 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -1,41 +1,45 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Info Clock Window + based up CComponentsFrmClock + Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013, Michael Liebmann 'micha-bbg' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + #ifdef HAVE_CONFIG_H #include #endif #include #include -#include -#include - -#include -#include -#include -#include -#include +// #include #include #include -#define YOFF 0 -CInfoClock::CInfoClock() -{ - frameBuffer = CFrameBuffer::getInstance(); - x = y = clock_x = 0; - time_height = time_width = thrTimer = 0; - Init(); -} -CInfoClock::~CInfoClock() +CInfoClock::CInfoClock():CComponentsFrmClock( 0, 0, 0, 50, "%H:%M:%S", true, CC_SHADOW_OFF, COL_LIGHT_GRAY, COL_MENUCONTENT_PLUS_0,COL_MENUCONTENTDARK_PLUS_0) { - if(thrTimer) - pthread_cancel(thrTimer); - thrTimer = 0; -} - -void CInfoClock::Init() -{ - CVolumeHelper::getInstance()->refresh(); - CVolumeHelper::getInstance()->getInfoClockDimensions(&clock_x, &y, &time_width, &time_height, &digit_h, &digit_offset); + initVarInfoClock(); } CInfoClock* CInfoClock::getInstance() @@ -46,64 +50,35 @@ CInfoClock* CInfoClock::getInstance() return InfoClock; } -void CInfoClock::paintTime( bool show_dot) +void CInfoClock::initVarInfoClock() { - char timestr[20]; - int dummy, mute_dx, h_spacer; - time_t tm = time(0); - strftime((char*) ×tr, sizeof(timestr), "%H:%M:%S", localtime(&tm)); - timestr[2] = show_dot ? ':':'.'; - - CVolumeHelper *cvh = CVolumeHelper::getInstance(); - cvh->getInfoClockDimensions(&clock_x, &y, &time_width, &time_height, &digit_h, &digit_offset); - cvh->getMuteIconDimensions(&dummy, &dummy, &mute_dx, &dummy); - cvh->getSpacer(&h_spacer, &dummy); - if (CNeutrinoApp::getInstance()->isMuted()) - clock_x -= (mute_dx + h_spacer); - - int x_diff = (time_width - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->getRenderWidth(timestr)) / 2; - frameBuffer->paintBoxRel(clock_x, y, time_width, time_height, COL_MENUCONTENT_PLUS_0, RADIUS_SMALL); - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_CHANNAME]->RenderString(clock_x + x_diff, y + digit_h + digit_offset + ((time_height - digit_h) / 2), time_width, timestr, COL_MENUCONTENT_TEXT); + cl_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; + Init(); } -void* CInfoClock::TimerProc(void *arg) +void CInfoClock::Init() { - - bool show_dot = false; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0); - pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS,0); - - CInfoClock *InfoClock = static_cast(arg); - InfoClock->paintTime(show_dot); - while(1) { - sleep(1); - show_dot = !show_dot; - InfoClock->paintTime(show_dot); - } - return 0; + CVolumeHelper::getInstance()->refresh(); + CVolumeHelper::getInstance()->getInfoClockDimensions(&x, &y, &width, &height); + initCCLockItems(); } void CInfoClock::ClearDisplay() { - frameBuffer->paintBackgroundBoxRel(clock_x, y, time_width, time_height); + kill(); Init(); } -void CInfoClock::StartClock() +bool CInfoClock::StartClock() { Init(); - - if(!thrTimer) { - pthread_create (&thrTimer, NULL, TimerProc, (void*) this) ; - pthread_detach(thrTimer); - } + return Start(); } -void CInfoClock::StopClock() +bool CInfoClock::StopClock() { - if(thrTimer) { - pthread_cancel(thrTimer); - thrTimer = 0; - frameBuffer->paintBackgroundBoxRel(clock_x, y, time_width, time_height); - } + bool ret = Stop(); + kill(); + + return ret; } diff --git a/src/gui/infoclock.h b/src/gui/infoclock.h index 8d578181d..18899e2b4 100644 --- a/src/gui/infoclock.h +++ b/src/gui/infoclock.h @@ -1,39 +1,51 @@ -#ifndef __infoclock__ -#define __infoclock__ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Info Clock Window + based up CComponentsFrmClock + Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013, Michael Liebmann 'micha-bbg' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __INFOCLOCK__ +#define __INFOCLOCK__ -#include -#include -#include - -#include - -#include +#include -class CInfoClock +class CInfoClock : public CComponentsFrmClock { - private: - CFrameBuffer * frameBuffer; + protected: + void initVarInfoClock(); + private: + void Init(); + public: + CInfoClock(); + // ~CInfoClock(); // inherited from CComponentsFrmClock + static CInfoClock* getInstance(); - pthread_t thrTimer; - void paintTime( bool show_dot); - int time_offset, digit_offset, digit_h; - int x, y, clock_x; - void Init(); - static void CleanUpProc(void* arg); - static void* TimerProc(void *arg); - - public: - CInfoClock(); - ~CInfoClock(); - static CInfoClock* getInstance(); - - void StartClock(); - void StopClock(); - void ClearDisplay(); - - int time_width, time_height; + bool StartClock(); + bool StopClock(); + void ClearDisplay(); }; #endif diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index f2c1ade75..3b8445fe7 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -101,7 +101,7 @@ void CVolumeBar::initVolumeBarSize() cvh->getMuteIconDimensions(&mute_ax, &mute_ay, &mute_dx, &mute_dy); // info clock int dummy; - cvh->getInfoClockDimensions(&dummy, &clock_y, &clock_width, &clock_height, &dummy, &dummy); + cvh->getInfoClockDimensions(&dummy, &clock_y, &clock_width, &clock_height); int mute_corrY = 0; if (mute_dy < height) mute_corrY = (height - mute_dy) / 2; @@ -111,6 +111,7 @@ void CVolumeBar::initVolumeBarSize() CInfoClock::getInstance()->ClearDisplay(); vb_pbh = height-8; + vb_pby = height/2-vb_pbh/2; } diff --git a/src/gui/volumebar.h b/src/gui/volumebar.h index c19b04424..d6a43b4e8 100644 --- a/src/gui/volumebar.h +++ b/src/gui/volumebar.h @@ -123,7 +123,7 @@ class CVolumeHelper int getVolIconHeight() {return icon_height;} void getDimensions(int *_x, int *_y, int *_sw, int *_sh, int *_iw, int *_dw) { *_x = x; *_y = y; *_sw = sw; *_sh = sh; *_iw = icon_width; *_dw = digit_width; } void getMuteIconDimensions(int *_x, int *_y, int *w, int *h) { *_x = mute_ax; *_y = mute_ay+mute_corrY; *w = mute_dx; *h = mute_dy; } - void getInfoClockDimensions(int *_x, int *_y, int *w, int *h, int *d_h, int *d_o) { *_x = clock_ax; *_y = clock_ay; *w = clock_dx; *h = clock_dy, *d_h = digit_h, *d_o = digit_offset; } + void getInfoClockDimensions(int *_x, int *_y, int *w, int *h/*, int *d_h, int *d_o*/) { *_x = clock_ax; *_y = clock_ay; *w = clock_dx; *h = clock_dy/*, *d_h = digit_h, *d_o = digit_offset*/; } void getVolBarDimensions(int *_y, int *_dy) { *_y = vol_ay; *_dy = vol_height; } void setMuteIconCorrY(int corr) { mute_corrY = corr; } void refresh(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 559ea61fa..2fcb1463e 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2028,7 +2028,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) InfoClock = CInfoClock::getInstance(); if(g_settings.mode_clock) - InfoClock->StartClock(); + g_settings.mode_clock = InfoClock->StartClock(); //cCA::GetInstance()->Ready(true);