From 70a2f36b1b8abb3bdf5df019c3bef34189d728eb Mon Sep 17 00:00:00 2001 From: chriszero Date: Tue, 28 Apr 2015 19:17:08 +0200 Subject: Added watch tokens, updated description about availiable tokens in template --- browserGrid.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'browserGrid.cpp') diff --git a/browserGrid.cpp b/browserGrid.cpp index 81451f7..e181350 100644 --- a/browserGrid.cpp +++ b/browserGrid.cpp @@ -12,6 +12,8 @@ cBrowserGrid::cBrowserGrid(skindesignerapi::cOsdView* rootView) : cViewGridNavig m_pViewHeader = std::shared_ptr( new cViewHeader(rootView->GetViewElement(eViewElementsRoot::verHeader))); m_pfooter = std::shared_ptr(rootView->GetViewElement(eViewElementsRoot::verFooter)); m_pInfopane = std::shared_ptr(rootView->GetViewElement(eViewElementsRoot::verInfopane)); + m_pWatch = std::shared_ptr(rootView->GetViewElement(eViewElementsRoot::verWatch)); + m_lastsecond = 0; m_rows = Config::GetInstance().GridRows; m_columns = Config::GetInstance().GridColumns; @@ -248,6 +250,43 @@ void cBrowserGrid::PrevTab() SwitchGrid(m_pViewHeader->PrevTab()); } +bool cBrowserGrid::DrawTime() { + time_t t = time(0); // get time now + struct tm * now = localtime(&t); + int sec = now->tm_sec; + if (sec == m_lastsecond) + return false; + + int min = now->tm_min; + int hour = now->tm_hour; + int hourMinutes = hour%12 * 5 + min / 12; + + char monthname[20]; + char monthshort[10]; + strftime(monthshort, sizeof(monthshort), "%b", now); + strftime(monthname, sizeof(monthname), "%B", now); + + m_pWatch->Clear(); + m_pWatch->ClearTokens(); + m_pWatch->AddIntToken("sec", sec); + m_pWatch->AddIntToken("min", min); + m_pWatch->AddIntToken("hour", hour); + m_pWatch->AddIntToken("hmins", hourMinutes); + m_pWatch->AddIntToken("year", now->tm_year + 1900); + m_pWatch->AddIntToken("day", now->tm_mday); + m_pWatch->AddStringToken("time", *TimeString(t)); + m_pWatch->AddStringToken("monthname", monthname); + m_pWatch->AddStringToken("monthnameshort", monthshort); + m_pWatch->AddStringToken("month", *cString::sprintf("%02d", now->tm_mon + 1)); + m_pWatch->AddStringToken("dayleadingzero", *cString::sprintf("%02d", now->tm_mday)); + m_pWatch->AddStringToken("dayname", *WeekDayNameFull(now->tm_wday)); + m_pWatch->AddStringToken("daynameshort", *WeekDayName(now->tm_wday)); + m_pWatch->Display(); + + m_lastsecond = sec; + return true; +} + /* * cDummyElement */ -- cgit v1.2.3