from HTMLComponent import HTMLComponent
from GUIComponent import GUIComponent
+from skin import parseColor
from enigma import loadPNG, eListboxServiceContent, eListbox, eServiceCenter, eServiceReference, gFont, eRect
self.mode = self.MODE_NORMAL
self.onSelectionChanged = [ ]
+ def applySkin(self, desktop):
+ attribs = [ ]
+ if self.skinAttributes is not None:
+ attribs = [ ]
+ for (attrib, value) in self.skinAttributes:
+ if attrib == "foregroundColorMarked":
+ self.l.setColor(eListboxServiceContent.markedForeground, parseColor(value))
+ elif attrib == "foregroundColorMarkedSelected":
+ self.l.setColor(eListboxServiceContent.markedForegroundSelected, parseColor(value))
+ elif attrib == "backgroundColorMarked":
+ self.l.setColor(eListboxServiceContent.markedBackground, parseColor(value))
+ elif attrib == "backgroundColorMarkedSelected":
+ self.l.setColor(eListboxServiceContent.markedBackgroundSelected, parseColor(value))
+ elif attrib == "foregroundColorServiceNotAvail":
+ self.l.setColor(eListboxServiceContent.serviceNotAvail, parseColor(value))
+ else:
+ attribs.append((attrib, value))
+ self.skinAttributes = attribs
+ return GUIComponent.applySkin(self, desktop)
+
def connectSelChanged(self, fnc):
if not fnc in self.onSelectionChanged:
self.onSelectionChanged.append(fnc)
eListboxServiceContent::eListboxServiceContent()
:m_visual_mode(visModeSimple), m_size(0), m_current_marked(false), m_numberoffset(0), m_itemheight(25)
{
+ memset(m_color_set, 0, sizeof(m_color_set));
cursorHome();
eServiceCenter::getInstance(m_service_center);
}
+void eListboxServiceContent::setColor(int color, gRGB &col)
+{
+ if ((color >= 0) && (color < colorElements))
+ {
+ m_color_set[color] = true;
+ m_color[color] = col;
+ }
+}
+
void eListboxServiceContent::cursorHome()
{
if (m_current_marked && m_saved_cursor == m_list.end())
{
painter.clip(eRect(offset, m_itemsize));
- if (m_current_marked && selected)
- style.setStyle(painter, eWindowStyle::styleListboxMarked);
- else if (cursorValid() && isMarked(*m_cursor))
+ bool marked = m_current_marked || (cursorValid() && isMarked(*m_cursor));
+
+ if (marked)
style.setStyle(painter, selected ? eWindowStyle::styleListboxMarkedAndSelected : eWindowStyle::styleListboxMarked);
else
style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
+
+ eListboxStyle *local_style = 0;
+
+ /* get local listbox style, if present */
+ if (m_listbox)
+ local_style = m_listbox->getLocalStyle();
+
+ if (marked)
+ {
+ if (selected)
+ {
+ if (m_color_set[markedForegroundSelected])
+ painter.setForegroundColor(m_color[markedForegroundSelected]);
+ if (m_color_set[markedBackgroundSelected])
+ painter.setBackgroundColor(m_color[markedBackgroundSelected]);
+ }
+ else
+ {
+ if (m_color_set[markedForeground])
+ painter.setForegroundColor(m_color[markedForeground]);
+ if (m_color_set[markedBackground])
+ painter.setBackgroundColor(m_color[markedBackground]);
+ }
+ }
+ else if (local_style)
+ {
+ if (selected)
+ {
+ /* if we have a local background color set, use that. */
+ if (local_style->m_background_color_selected_set)
+ painter.setBackgroundColor(local_style->m_background_color_selected);
+ /* same for foreground */
+ if (local_style->m_foreground_color_selected_set)
+ painter.setForegroundColor(local_style->m_foreground_color_selected);
+ }
+ else
+ {
+ /* if we have a local background color set, use that. */
+ if (local_style->m_background_color_set)
+ painter.setBackgroundColor(local_style->m_background_color);
+ /* same for foreground */
+ if (local_style->m_foreground_color_set)
+ painter.setForegroundColor(local_style->m_foreground_color);
+ }
+ }
+
+ if (!local_style || !local_style->m_transparent_background)
+ /* if we have no transparent background */
+ {
+ /* blit background picture, if available (otherwise, clear only) */
+ if (local_style && local_style->m_background)
+ painter.blit(local_style->m_background, offset, eRect(), 0);
+ else
+ painter.clear();
+ } else
+ {
+ if (local_style->m_background)
+ painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST);
+ else if (selected && !local_style->m_selection)
+ painter.clear();
+ }
+
painter.clear();
if (cursorValid())
eServiceReference ref = *m_cursor;
bool isPlayable = !(ref.flags & eServiceReference::isDirectory || ref.flags & eServiceReference::isMarker);
- if (isPlayable && service_info && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
- painter.setForegroundColor(gRGB(0xbbbbbb));
+ if (!marked && isPlayable && service_info && !service_info->isPlayable(*m_cursor, m_is_playable_ignore))
+ {
+ if (m_color_set[serviceNotAvail])
+ painter.setForegroundColor(m_color[serviceNotAvail]);
+ else
+ painter.setForegroundColor(gRGB(0xbbbbbb));
+ }
+
+ if (selected && local_style && local_style->m_selection)
+ painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);
int xoffset=0; // used as offset when painting the folder/marker symbol
}
}
- if (selected)
+ if (selected && (!local_style || !local_style->m_selection))
style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
}
#ifndef __lib_service_listboxservice_h
#define __lib_service_listboxservice_h
+#include <lib/gdi/gpixmap.h>
#include <lib/gui/elistbox.h>
#include <lib/service/iservice.h>
#include <set>
int getItemHeight() { return m_itemheight; }
int setItemHeight(int height);
+
+ enum {
+ markedForeground,
+ markedForegroundSelected,
+ markedBackground,
+ markedBackgroundSelected,
+ serviceNotAvail,
+ colorElements
+ };
+ void setColor(int color, gRGB &col);
protected:
void cursorHome();
void cursorEnd();
eRect m_element_position[celElements];
ePtr<gFont> m_element_font[celElements];
ePtr<gPixmap> m_pixmaps[picElements];
+ gRGB m_color[colorElements];
+ bool m_color_set[colorElements];
private:
typedef std::list<eServiceReference> list;