osd fix, tab for screening

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@837 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
satbaby
2010-10-13 14:47:27 +00:00
parent 4a4dbb7084
commit dcb785079e
4 changed files with 83 additions and 39 deletions

View File

@@ -87,11 +87,11 @@ void reformatExtendedEvents(std::string strItem, std::string strLabel, bool bUse
for (int nItem = 1; nItem < 11; nItem++) { for (int nItem = 1; nItem < 11; nItem++) {
sprintf(index, "%d", nItem); sprintf(index, "%d", nItem);
// Look for matching items // Look for matching items
int nPos = findItem(std::string(strItem) + std::string(index), vecDescriptions); int pos2 = findItem(std::string(strItem) + std::string(index), vecDescriptions);
if (-1 != nPos) { if (-1 != pos2) {
std::string item = std::string(vecItems[nPos]); std::string item = std::string(vecItems[pos2]);
vecDescriptions.erase(vecDescriptions.begin() + nPos); vecDescriptions.erase(vecDescriptions.begin() + pos2);
vecItems.erase(vecItems.begin() + nPos); vecItems.erase(vecItems.begin() + pos2);
if (false == bHasItems) { if (false == bHasItems) {
// First item added, so create new label item // First item added, so create new label item
vecDescriptions.push_back(strLabel); vecDescriptions.push_back(strLabel);
@@ -108,9 +108,9 @@ void reformatExtendedEvents(std::string strItem, std::string strLabel, bool bUse
} }
} else { // Single string event (e.g. Director) } else { // Single string event (e.g. Director)
// Look for matching items // Look for matching items
int nPos = findItem(strItem, vecDescriptions); int pos2 = findItem(strItem, vecDescriptions);
if (-1 != nPos) { if (-1 != pos2) {
vecDescriptions[nPos] = strLabel; vecDescriptions[pos2] = strLabel;
} }
} }
} }
@@ -152,7 +152,7 @@ void CEpgData::start()
toph = topboxheight; toph = topboxheight;
} }
void CEpgData::addTextToArray(const std::string & text) // UTF-8 void CEpgData::addTextToArray(const std::string & text, bool screening) // UTF-8
{ {
//printf("line: >%s<\n", text.c_str() ); //printf("line: >%s<\n", text.c_str() );
if (text==" ") if (text==" ")
@@ -160,17 +160,17 @@ void CEpgData::addTextToArray(const std::string & text) // UTF-8
emptyLineCount ++; emptyLineCount ++;
if (emptyLineCount<2) if (emptyLineCount<2)
{ {
epgText.push_back(text); epgText.push_back(epg_pair(text,screening));
} }
} }
else else
{ {
emptyLineCount = 0; emptyLineCount = 0;
epgText.push_back(text); epgText.push_back(epg_pair(text,screening));
} }
} }
void CEpgData::processTextToArray(std::string text) // UTF-8 void CEpgData::processTextToArray(std::string text, bool screening) // UTF-8
{ {
std::string aktLine = ""; std::string aktLine = "";
std::string aktWord = ""; std::string aktWord = "";
@@ -197,7 +197,7 @@ void CEpgData::processTextToArray(std::string text) // UTF-8
if (*text_=='\n') if (*text_=='\n')
{ //enter-handler { //enter-handler
addTextToArray( aktLine ); addTextToArray( aktLine, screening );
aktLine = ""; aktLine = "";
aktWidth= 0; aktWidth= 0;
} }
@@ -205,7 +205,7 @@ void CEpgData::processTextToArray(std::string text) // UTF-8
} }
else else
{//new line needed {//new line needed
addTextToArray( aktLine ); addTextToArray( aktLine, screening);
aktLine = aktWord; aktLine = aktWord;
aktWidth = aktWordWidth; aktWidth = aktWordWidth;
aktWord = ""; aktWord = "";
@@ -222,7 +222,7 @@ void CEpgData::processTextToArray(std::string text) // UTF-8
text_++; text_++;
} }
//add the rest //add the rest
addTextToArray( aktLine + aktWord ); addTextToArray( aktLine + aktWord, screening );
} }
void CEpgData::showText( int startPos, int ypos ) void CEpgData::showText( int startPos, int ypos )
@@ -233,15 +233,45 @@ void CEpgData::showText( int startPos, int ypos )
int textSize = epgText.size(); int textSize = epgText.size();
int y=ypos; int y=ypos;
const char tok = ' ';
int offset = 0, count = 0;
int max_mon_w = 0, max_wday_w = 0;
int digi = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getRenderWidth("29..");
for(int i = 0; i < 12;i++){
max_mon_w = std::max(max_mon_w ,g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getRenderWidth(g_Locale->getText(CLocaleManager::getMonth(i))));
if(i > 6)
continue;
max_wday_w = std::max(max_wday_w ,g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->getRenderWidth(g_Locale->getText(CLocaleManager::getWeekday(i))));
}
frameBuffer->paintBoxRel(sx, y, ox- 15, sb, COL_MENUCONTENT_PLUS_0); // background of the text box frameBuffer->paintBoxRel(sx, y, ox- 15, sb, COL_MENUCONTENT_PLUS_0); // background of the text box
for (int i = startPos; i < textSize && i < startPos + medlinecount; i++, y += medlineheight) for (int i = startPos; i < textSize && i < startPos + medlinecount; i++, y += medlineheight)
{ {
if ( i< info1_lines ) if(epgText[i].second){
g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO1]->RenderString(sx+10, y+medlineheight, ox- 15- 15, epgText[i], COL_MENUCONTENT, 0, true); // UTF-8 std::string::size_type pos1 = epgText[i].first.find_first_not_of(tok, 0);
std::string::size_type pos2 = epgText[i].first.find_first_of(tok, pos1);
while( pos2 != string::npos || pos1 != string::npos ){
switch(count){
case 1:
offset += max_wday_w;
break;
case 3:
offset += max_mon_w;
break;
default:
offset += digi;
break;
}
g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+10+offset, y+medlineheight, ox- 15- 15, epgText[i].first.substr(pos1, pos2 - pos1), COL_MENUCONTENT, 0, true); // UTF-8
count++;
pos1 = epgText[i].first.find_first_not_of(tok, pos2);
pos2 = epgText[i].first.find_first_of(tok, pos1);
}
offset = 0;
count = 0;
}
else else
g_Font[SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+10, y+medlineheight, ox- 15- 15, epgText[i], COL_MENUCONTENT, 0, true); // UTF-8 g_Font[( i< info1_lines ) ?SNeutrinoSettings::FONT_TYPE_EPG_INFO1:SNeutrinoSettings::FONT_TYPE_EPG_INFO2]->RenderString(sx+10, y+medlineheight, ox- 15- 15, epgText[i].first, COL_MENUCONTENT, 0, true); // UTF-8
} }
int sbc = ((textSize - 1)/ medlinecount) + 1; int sbc = ((textSize - 1)/ medlinecount) + 1;
@@ -500,17 +530,17 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
bool bHide = false; bool bHide = false;
if (false == epgData.info2.empty()) { if (false == epgData.info2.empty()) {
// Look for the first . in info1, usually this is the title of an episode. // Look for the first . in info1, usually this is the title of an episode.
std::string::size_type nPosDot = epgData.info1.find('.'); std::string::size_type pos2Dot = epgData.info1.find('.');
if (std::string::npos != nPosDot) { if (std::string::npos != pos2Dot) {
nPosDot += 2; // Skip dot and first blank pos2Dot += 2; // Skip dot and first blank
/* Houdini: changed for safty reason (crashes with some events at WDR regional) /* Houdini: changed for safty reason (crashes with some events at WDR regional)
if (nPosDot < epgData.info2.length()) { // Make sure we don't overrun the buffer if (pos2Dot < epgData.info2.length()) { // Make sure we don't overrun the buffer
*/ */
if (nPosDot < epgData.info2.length() && nPosDot < epgData.info1.length()) { // Make sure we don't overrun the buffer if (pos2Dot < epgData.info2.length() && pos2Dot < epgData.info1.length()) { // Make sure we don't overrun the buffer
// Check if the stuff after the dot equals the beginning of info2 // Check if the stuff after the dot equals the beginning of info2
if (0 == epgData.info2.find(epgData.info1.substr(nPosDot, epgData.info1.length() - nPosDot))) { if (0 == epgData.info2.find(epgData.info1.substr(pos2Dot, epgData.info1.length() - pos2Dot))) {
strEpisode = epgData.info1.substr(0, nPosDot) + "\n"; strEpisode = epgData.info1.substr(0, pos2Dot) + "\n";
bHide = true; bHide = true;
} }
} }
@@ -1048,11 +1078,9 @@ int CEpgData::FollowScreenings (const t_channel_id /*channel_id*/, const std::st
CChannelEventList::iterator e; CChannelEventList::iterator e;
struct tm *tmStartZeit; struct tm *tmStartZeit;
std::string screening_dates,screening_nodual; std::string screening_dates,screening_nodual;
int count; int count = 0;
char tmpstr[256]={0}; char tmpstr[256]={0};
count = 0;
screening_dates = screening_nodual = ""; screening_dates = screening_nodual = "";
// alredy read: evtlist = g_Sectionsd->getEventsServiceKey( channel_id&0xFFFFFFFFFFFFULL ); // alredy read: evtlist = g_Sectionsd->getEventsServiceKey( channel_id&0xFFFFFFFFFFFFULL );
@@ -1064,21 +1092,19 @@ int CEpgData::FollowScreenings (const t_channel_id /*channel_id*/, const std::st
count++; count++;
tmStartZeit = localtime(&(e->startTime)); tmStartZeit = localtime(&(e->startTime));
screening_dates = " "; screening_dates = g_Locale->getText(CLocaleManager::getWeekday(tmStartZeit));
screening_dates += g_Locale->getText(CLocaleManager::getWeekday(tmStartZeit));
screening_dates += '.'; screening_dates += '.';
strftime(tmpstr, sizeof(tmpstr), " %d.", tmStartZeit ); strftime(tmpstr, sizeof(tmpstr), " %d.", tmStartZeit );
screening_dates += tmpstr; screening_dates += tmpstr;
screening_dates += g_Locale->getText(CLocaleManager::getMonth(tmStartZeit)); screening_dates += g_Locale->getText(CLocaleManager::getMonth(tmStartZeit));
strftime(tmpstr, sizeof(tmpstr), ". %H:%M ", tmStartZeit ); strftime(tmpstr, sizeof(tmpstr), ". %H:%M", tmStartZeit );
screening_dates += tmpstr; screening_dates += tmpstr;
if (screening_dates != screening_nodual) { if (screening_dates != screening_nodual) {
screening_nodual=screening_dates; screening_nodual=screening_dates;
processTextToArray(screening_dates ); // UTF-8 processTextToArray(screening_dates, true ); // UTF-8
} }
} }
} }

View File

@@ -71,15 +71,16 @@ class CEpgData
int ox, oy, sx, sy, toph, sb; int ox, oy, sx, sy, toph, sb;
int emptyLineCount, info1_lines; int emptyLineCount, info1_lines;
int textCount; int textCount;
std::vector<std::string> epgText; typedef std::pair<std::string,bool> epg_pair;
std::vector<epg_pair> epgText;
int topheight,topboxheight; int topheight,topboxheight;
int buttonheight,botboxheight; int buttonheight,botboxheight;
int medlineheight,medlinecount; int medlineheight,medlinecount;
void GetEPGData(const t_channel_id channel_id, uint64_t id, time_t* startzeit, bool clear = true ); void GetEPGData(const t_channel_id channel_id, uint64_t id, time_t* startzeit, bool clear = true );
void GetPrevNextEPGData( uint64_t id, time_t* startzeit ); void GetPrevNextEPGData( uint64_t id, time_t* startzeit );
void addTextToArray( const std::string & text ); void addTextToArray( const std::string & text, bool screening );
void processTextToArray(std::string text); void processTextToArray(std::string text, bool screening = false);
void showText( int startPos, int ypos ); void showText( int startPos, int ypos );
bool hasFollowScreenings(const t_channel_id channel_id, const std::string & title); bool hasFollowScreenings(const t_channel_id channel_id, const std::string & title);
int FollowScreenings(const t_channel_id channel_id, const std::string & title); int FollowScreenings(const t_channel_id channel_id, const std::string & title);

View File

@@ -359,8 +359,23 @@ neutrino_locale_t CLocaleManager::getMonth(const struct tm * struct_tm_p)
return locale_month[struct_tm_p->tm_mon]; return locale_month[struct_tm_p->tm_mon];
} }
neutrino_locale_t CLocaleManager::getMonth(const int mon)
{
if(mon > -1 && mon < 12)
return locale_month[mon];
else
return LOCALE_MESSAGEBOX_ERROR;
}
neutrino_locale_t CLocaleManager::getWeekday(const struct tm * struct_tm_p) neutrino_locale_t CLocaleManager::getWeekday(const struct tm * struct_tm_p)
{ {
return locale_weekday[struct_tm_p->tm_wday]; return locale_weekday[struct_tm_p->tm_wday];
} }
neutrino_locale_t CLocaleManager::getWeekday(const int wday)
{
if(wday > -1 && wday < 7)
return locale_weekday[wday];
else
return LOCALE_MESSAGEBOX_ERROR;
}

View File

@@ -68,6 +68,8 @@ class CLocaleManager
const char * getText(const neutrino_locale_t keyName) const; const char * getText(const neutrino_locale_t keyName) const;
static neutrino_locale_t getMonth (const struct tm * struct_tm_p); static neutrino_locale_t getMonth (const struct tm * struct_tm_p);
static neutrino_locale_t getMonth (const int mon);
static neutrino_locale_t getWeekday(const struct tm * struct_tm_p); static neutrino_locale_t getWeekday(const struct tm * struct_tm_p);
static neutrino_locale_t getWeekday(const int wday);
}; };
#endif #endif