biggest chan number in list (revised)

This commit is contained in:
satbaby
2012-07-07 21:10:10 +02:00
parent 060c1c45b2
commit 441cba7d4a
3 changed files with 24 additions and 18 deletions

View File

@@ -1209,8 +1209,9 @@ int CChannelList::numericZap(int key)
}
return res;
}
int sx = 4 * g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number) + 14;
size_t maxchansize = MaxChanNr().size();
int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number);
int sx = maxchansize * fw + (fw/2);
int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6;
int ox = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - sx)/2;
@@ -1225,14 +1226,14 @@ int CChannelList::numericZap(int key)
while(1) {
if (lastchan != chn) {
snprintf((char*) &valstr, sizeof(valstr), "%d", chn);
while(strlen(valstr) < 4)
strcat(valstr,"-"); //"_"
while(strlen(valstr) < maxchansize)
strcat(valstr,"-"); //"_"
frameBuffer->paintBoxRel(ox, oy, sx, sy, COL_INFOBAR_PLUS_0);
for (int i = 3; i >= 0; i--) {
for (int i = maxchansize-1; i >= 0; i--) {
valstr[i+ 1] = 0;
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(ox+7+ i*((sx-14)>>2), oy+sy-3, sx, &valstr[i], COL_INFOBAR);
g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(ox+fw/3+ i*fw, oy+sy-3, sx, &valstr[i], COL_INFOBAR);
}
showInfo(chn);
@@ -1955,17 +1956,7 @@ void CChannelList::paintHead()
void CChannelList::paint()
{
zapit_list_it_t chan_it;
std::stringstream ss;
std::string chan_width;
int chan_nr_max = 1;
unsigned int nr = 0;
for (chan_it=chanlist.begin(); chan_it!=chanlist.end(); ++chan_it) {
chan_nr_max = std::max(chan_nr_max, chanlist[nr++]->number);
}
ss << chan_nr_max;
ss >> chan_width;
numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(chan_width.c_str());
numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(MaxChanNr().c_str());
liststart = (selected/listmaxshow)*listmaxshow;
updateEvents(this->historyMode ? 0:liststart, this->historyMode ? 0:(liststart + listmaxshow));
@@ -2029,3 +2020,17 @@ bool CChannelList::SameTP(CZapitChannel * channel)
}
return iscurrent;
}
std::string CChannelList::MaxChanNr()
{
zapit_list_it_t chan_it;
std::stringstream ss;
std::string maxchansize;
int chan_nr_max = 1;
unsigned int nr = 0;
for (chan_it=chanlist.begin(); chan_it!=chanlist.end(); ++chan_it) {
chan_nr_max = std::max(chan_nr_max, chanlist[nr++]->number);
}
ss << chan_nr_max;
ss >> maxchansize;
return maxchansize;
}