aboutsummaryrefslogtreecommitdiff
path: root/lib/service/listboxservice.cpp
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-02-07 09:14:02 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-02-07 09:14:02 +0000
commitd9ee52e4f0fbe9a1ae00d0e66f9e6f0a07fa319f (patch)
treef1084b85919b5590615e281331cfe535c3a160c8 /lib/service/listboxservice.cpp
parent4bc08995411e21f3564f09e136809be68ddf96a8 (diff)
downloadenigma2-d9ee52e4f0fbe9a1ae00d0e66f9e6f0a07fa319f.tar.gz
enigma2-d9ee52e4f0fbe9a1ae00d0e66f9e6f0a07fa319f.zip
- added iStaticServiceInformation
- added service list interface for dvb - started work on queries (currently only "instr" on servicename) - started work on infobar - added listbox with service - fixed dvbdb - remove some debug output
Diffstat (limited to 'lib/service/listboxservice.cpp')
-rw-r--r--lib/service/listboxservice.cpp134
1 files changed, 134 insertions, 0 deletions
diff --git a/lib/service/listboxservice.cpp b/lib/service/listboxservice.cpp
new file mode 100644
index 00000000..011c96ca
--- /dev/null
+++ b/lib/service/listboxservice.cpp
@@ -0,0 +1,134 @@
+#include <lib/service/listboxservice.h>
+#include <lib/service/service.h>
+
+void eListboxServiceContent::setRoot(const eServiceReference &root)
+{
+ m_root = root;
+
+ assert(m_service_center);
+
+ ePtr<iListableService> lst;
+ if (m_service_center->list(m_root, lst))
+ eDebug("no list available!");
+ else
+ if (lst->getContent(m_list))
+ eDebug("getContent failed");
+
+ m_size = m_list.size();
+ cursorHome();
+}
+
+DEFINE_REF(eListboxServiceContent);
+
+eListboxServiceContent::eListboxServiceContent()
+{
+ m_size = 0;
+ cursorHome();
+ eServiceCenter::getInstance(m_service_center);
+}
+
+void eListboxServiceContent::cursorHome()
+{
+ m_cursor = m_list.begin();
+ m_cursor_number = 0;
+}
+
+void eListboxServiceContent::cursorEnd()
+{
+ m_cursor = m_list.end();
+ m_cursor_number = m_size;
+}
+
+int eListboxServiceContent::cursorMove(int count)
+{
+ if (count > 0)
+ {
+ while (count && (m_cursor != m_list.end()))
+ {
+ ++m_cursor;
+ ++m_cursor_number;
+ --count;
+ }
+ } else if (count < 0)
+ {
+ while (count && (m_cursor != m_list.begin()))
+ {
+ --m_cursor;
+ --m_cursor_number;
+ ++count;
+ }
+ }
+
+ return 0;
+}
+
+int eListboxServiceContent::cursorValid()
+{
+ return m_cursor != m_list.end();
+}
+
+int eListboxServiceContent::cursorSet(int n)
+{
+ cursorHome();
+ cursorMove(n);
+
+ return 0;
+}
+
+int eListboxServiceContent::cursorGet()
+{
+ return m_cursor_number;
+}
+
+void eListboxServiceContent::cursorSave()
+{
+ m_saved_cursor = m_cursor;
+ m_saved_cursor_number = m_cursor_number;
+}
+
+void eListboxServiceContent::cursorRestore()
+{
+ m_cursor = m_saved_cursor;
+ m_cursor_number = m_saved_cursor_number;
+}
+
+int eListboxServiceContent::size()
+{
+ return m_size;
+}
+
+void eListboxServiceContent::setSize(const eSize &size)
+{
+ m_itemsize = size;
+}
+
+void eListboxServiceContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
+{
+ ePtr<gFont> fnt = new gFont("Arial", 14);
+ painter.clip(eRect(offset, m_itemsize));
+ style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
+ painter.clear();
+
+ if (cursorValid())
+ {
+ painter.setFont(fnt);
+
+ ePoint text_offset = offset + (selected ? ePoint(2, 2) : ePoint(1, 1));
+
+ /* get name of service */
+ ePtr<iStaticServiceInformation> service_info;
+ m_service_center->info(*m_cursor, service_info);
+ std::string name = "<n/a>";
+
+ if (service_info)
+ service_info->getName(*m_cursor, name);
+
+ painter.renderText(eRect(text_offset, m_itemsize), name);
+
+ if (selected)
+ style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
+ }
+
+ painter.clippop();
+}
+