1 #include <lib/components/listboxepg.h>
2 #include <lib/dvb/epgcache.h>
3 #include <lib/service/service.h>
5 void eListboxEPGContent::setRoot(const eServiceReference &root)
7 eEPGCache *epg=eEPGCache::getInstance();
14 if (!epg->startTimeQuery(root))
16 ePtr<eServiceEvent> ptr;
17 while( !epg->getNextTimeEntry(ptr) )
18 m_list.push_back(ptr);
21 eDebug("startTimeQuery failed %s", root.toString().c_str());
24 m_size = m_list.size();
28 m_listbox->entryReset();
32 RESULT eListboxEPGContent::getCurrent(ePtr<eServiceEvent> &evt)
44 void eListboxEPGContent::setElementPosition(int element, eRect where)
46 if ((element >= 0) && (element < celElements))
47 m_element_position[element] = where;
50 void eListboxEPGContent::setElementFont(int element, gFont *font)
52 if ((element >= 0) && (element < celElements))
53 m_element_font[element] = font;
56 void eListboxEPGContent::sort()
59 ePtr<iListableService> lst;
60 if (!m_service_center->list(m_root, lst))
62 m_list.sort(iListableServiceCompare(lst));
63 /* FIXME: is this really required or can we somehow keep the current entry? */
66 m_listbox->entryReset();
71 DEFINE_REF(eListboxEPGContent);
73 eListboxEPGContent::eListboxEPGContent()
79 void eListboxEPGContent::cursorHome()
81 m_cursor = m_list.begin();
85 void eListboxEPGContent::cursorEnd()
87 m_cursor = m_list.end();
88 m_cursor_number = m_size;
91 int eListboxEPGContent::cursorMove(int count)
93 list::iterator old = m_cursor;
97 while(count && (m_cursor != m_list.end()))
103 } else if (count < 0)
105 while (count && (m_cursor != m_list.begin()))
116 int eListboxEPGContent::cursorValid()
118 return m_cursor != m_list.end();
121 int eListboxEPGContent::cursorSet(int n)
129 int eListboxEPGContent::cursorGet()
131 return m_cursor_number;
134 void eListboxEPGContent::cursorSave()
136 m_saved_cursor = m_cursor;
137 m_saved_cursor_number = m_cursor_number;
140 void eListboxEPGContent::cursorRestore()
142 m_cursor = m_saved_cursor;
143 m_cursor_number = m_saved_cursor_number;
144 m_saved_cursor = m_list.end();
147 int eListboxEPGContent::size()
152 void eListboxEPGContent::setSize(const eSize &size)
155 eSize s = m_itemsize;
156 s.setWidth(size.width()/20*5);
157 m_element_position[celBeginTime] = eRect(ePoint(0, 0), s);
158 m_element_font[celBeginTime] = new gFont("Arial", 22);
159 s.setWidth(size.width()/20*15);
160 m_element_position[celTitle] = eRect(ePoint(size.width()/20*5, 0), s);
161 m_element_font[celTitle] = new gFont("Arial", 22);
164 void eListboxEPGContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
166 painter.clip(eRect(offset, m_itemsize));
167 style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
172 for (int e = 0; e < celElements; ++e)
174 if (!m_element_font[e])
177 painter.setFont(m_element_font[e]);
179 std::string text = "<n/a>";
185 text=(*m_cursor)->getBeginTimeString();
190 text = (*m_cursor)->m_event_name;
195 eRect area = m_element_position[e];
196 area.moveBy(offset.x(), offset.y());
198 painter.renderText(area, text);
202 style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);