From be33fea8ef32e3e689e9ce8744867b4a8ba01b5e Mon Sep 17 00:00:00 2001 From: "no@ma.il" Date: Tue, 24 Apr 2012 12:55:18 +0200 Subject: [PATCH] channellist.cpp : fix biggest chan number in list Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6cfd4da52ebcc394c73c40c9634f6f3cb7b96955 Author: no@ma.il Date: 2012-04-24 (Tue, 24 Apr 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/channellist.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index d71ebd795..689f15d33 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -32,6 +32,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include #include @@ -1899,10 +1900,19 @@ void CChannelList::paintHead() void CChannelList::paint() { - liststart = (selected/listmaxshow)*listmaxshow; - //FIXME do we need to find biggest chan number in list ? - numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("0000"); + 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()); + liststart = (selected/listmaxshow)*listmaxshow; updateEvents(this->historyMode ? 0:liststart, this->historyMode ? 0:(liststart + listmaxshow)); frameBuffer->paintBoxRel(x, y+theight, width, height-footerHeight-theight, COL_MENUCONTENT_PLUS_0, 0, CORNER_BOTTOM);