show current running event title in favourites service list
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 24 Nov 2005 19:27:32 +0000 (19:27 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 24 Nov 2005 19:27:32 +0000 (19:27 +0000)
lib/python/Components/ServiceList.py
lib/service/listboxservice.cpp
lib/service/listboxservice.h

index e0a3153410a851f9360a161d49ba39173a12f917..d39e74270b26546dddc8e226746a6a50d2891bdb 100644 (file)
@@ -93,8 +93,9 @@ class ServiceList(HTMLComponent, GUIComponent):
                        self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), 28))
                else:
                        self.instance.setItemHeight(28)
-                       self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
-                       self.l.setElementPosition(self.l.celServiceName, eRect(50, 0, self.instance.size().width(), 28))
                        self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20))
-                       self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 2, 50, 28))
+                       self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 40, 28))
+                       self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
+                       self.l.setElementPosition(self.l.celServiceName, eRect(50, 0, self.instance.size().width()-50, 28))
+                       self.l.setElementFont(self.l.celServiceInfo, gFont("Arial", 18))
                        self.l.setVisualMode(eListboxServiceContent.visModeComplex)
index fe6906080dd466d3babbbd084d214e820bdf146d..9eafc853cc1d212c47e1ef0a3380da8fdcd4c8ea 100644 (file)
@@ -1,5 +1,7 @@
 #include <lib/service/listboxservice.h>
 #include <lib/service/service.h>
+#include <lib/gdi/font.h>
+#include <lib/dvb/epgcache.h>
 
 void eListboxServiceContent::setRoot(const eServiceReference &root)
 {
@@ -136,7 +138,7 @@ void eListboxServiceContent::sort()
 DEFINE_REF(eListboxServiceContent);
 
 eListboxServiceContent::eListboxServiceContent()
-       :m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_numberoffset(0)
+       :epgcache(eEPGCache::getInstance()), m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_numberoffset(0)
 {
        cursorHome();
        eServiceCenter::getInstance(m_service_center);
@@ -324,38 +326,76 @@ void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const
                {
                        if (!m_element_font[e])
                                continue;
-                       painter.setFont(m_element_font[e]);
-                       
+                       int flags=gPainter::RT_VALIGN_CENTER;
+
+                       eRect area = m_element_position[e];
+
                        std::string text = "<n/a>";
-                       
+
                        switch (e)
                        {
-                       case celServiceName:
-                       {
-                               if (service_info)
-                                       service_info->getName(*m_cursor, text);
-                               break;
-                       }
+                       case celIcon:
+                               // render icon here...
+                               continue;
                        case celServiceNumber:
                        {
                                char bla[10];
                                sprintf(bla, "%d", m_numberoffset + m_cursor_number + 1);
                                text = bla;
+                               flags|=gPainter::RT_HALIGN_RIGHT;
+                               break;
+                       }
+                       case celServiceName:
+                       {
+                               if (service_info)
+                                       service_info->getName(*m_cursor, text);
                                break;
                        }
                        case celServiceInfo:
                        {
-                               text = "now&next";
+                               ePtr<eServiceEvent> evt;
+                               time_t t=-1;
+                               if ( !epgcache->lookupEventTime(*m_cursor, t, evt) )
+                                       text = '(' + evt->getEventName() + ')';
+                               else
+                                       continue;
                                break;
                        }
-                       case celIcon:
-                               continue;
                        }
-                       
-                       eRect area = m_element_position[e];
-                       area.moveBy(offset.x(), offset.y());
-                       
-                       painter.renderText(area, text);
+
+                       eTextPara *para = new eTextPara(area);
+
+                       para->setFont(m_element_font[e]);
+                       para->renderString(text);
+
+                       if (e == celServiceName)
+                       {
+                               eRect bbox = para->getBoundBox();
+                               int name_width = bbox.width()+10;
+                               m_element_position[celServiceInfo].setLeft(area.left()+name_width);
+                               m_element_position[celServiceInfo].setTop(area.top());
+                               m_element_position[celServiceInfo].setWidth(area.width()-name_width);
+                               m_element_position[celServiceInfo].setHeight(area.height());
+                       }
+
+                       if (flags & gPainter::RT_HALIGN_RIGHT)
+                               para->realign(eTextPara::dirRight);
+                       else if (flags & gPainter::RT_HALIGN_CENTER)
+                               para->realign(eTextPara::dirCenter);
+                       else if (flags & gPainter::RT_HALIGN_BLOCK)
+                               para->realign(eTextPara::dirBlock);
+
+                       ePoint offs = offset;
+
+                       if (flags & gPainter::RT_VALIGN_CENTER)
+                       {
+                               eRect bbox = para->getBoundBox();
+                               int vcentered_top = (area.height() - bbox.height()) / 2;
+                               int correction = vcentered_top - bbox.top();
+                               offs += ePoint(0, correction);
+                       }
+
+                       painter.renderPara(para, offs);
                }
                
                if (selected)
index dde08188f93a4a3f32fca1230751918b321fc977..1d5dc2a200b11e0b4bf6bbc643bd59866b36b105 100644 (file)
@@ -3,12 +3,14 @@
 
 #include <lib/gui/elistbox.h>
 #include <lib/service/iservice.h>
-
 #include <set>
 
+class eEPGCache;
+
 class eListboxServiceContent: public virtual iListboxContent
 {
        DECLARE_REF(eListboxServiceContent);
+       eEPGCache *epgcache;
 public:
        eListboxServiceContent();
        void setRoot(const eServiceReference &ref);
@@ -36,9 +38,9 @@ public:
        
                /* only in complex mode: */
        enum {
-               celServiceName,
-               celServiceNumber,
                celIcon,
+               celServiceNumber,
+               celServiceName,
                celServiceInfo, // "now" event
                celElements
        };