Merge branch 'bug_532_fixed_servicelist_contextmenu_crash'
[enigma2.git] / lib / service / listboxservice.h
1 #ifndef __lib_service_listboxservice_h
2 #define __lib_service_listboxservice_h
3
4 #include <lib/gdi/gpixmap.h>
5 #include <lib/gui/elistbox.h>
6 #include <lib/service/iservice.h>
7 #include <set>
8
9 class eListboxServiceContent: public virtual iListboxContent
10 {
11         DECLARE_REF(eListboxServiceContent);
12 public:
13         eListboxServiceContent();
14
15         void addService(const eServiceReference &ref, bool beforeCurrent=false);
16         void removeCurrent();
17         void FillFinished();
18
19         void setIgnoreService( const eServiceReference &service );
20         void setRoot(const eServiceReference &ref, bool justSet=false);
21         void getCurrent(eServiceReference &ref);
22         
23         int getNextBeginningWithChar(char c);
24         int getPrevMarkerPos();
25         int getNextMarkerPos();
26         
27                 /* support for marked services */
28         void initMarked();
29         void addMarked(const eServiceReference &ref);
30         void removeMarked(const eServiceReference &ref);
31         int isMarked(const eServiceReference &ref);
32
33                 /* this is NOT thread safe! */
34         void markedQueryStart();
35         int markedQueryNext(eServiceReference &ref);
36
37         int lookupService(const eServiceReference &ref);
38         void setCurrent(const eServiceReference &ref);
39
40         enum {
41                 visModeSimple,
42                 visModeComplex
43         };
44         
45         void setVisualMode(int mode);
46         
47                 /* only in complex mode: */
48         enum {
49                 celServiceNumber,
50                 celMarkerPixmap,
51                 celFolderPixmap,
52                 celServiceEventProgressbar,
53                 celServiceName,
54                 celServiceTypePixmap,
55                 celServiceInfo, // "now" event
56                 celElements
57         };
58
59         enum {
60                 picDVB_S,
61                 picDVB_T,
62                 picDVB_C,
63                 picServiceGroup,
64                 picFolder,
65                 picMarker,
66                 picServiceEventProgressbar,
67                 picElements
68         };
69
70         void setElementPosition(int element, eRect where);
71         void setElementFont(int element, gFont *font);
72         void setPixmap(int type, ePtr<gPixmap> &pic);
73         
74         void sort();
75
76         int setCurrentMarked(bool);
77
78         void setNumberOffset(int offset) { m_numberoffset = offset; }
79         
80         int getItemHeight() { return m_itemheight; }
81         void setItemHeight(int height);
82
83         enum {
84                 markedForeground,
85                 markedForegroundSelected,
86                 markedBackground,
87                 markedBackgroundSelected,
88                 serviceNotAvail,
89                 serviceEventProgressbarColor,
90                 serviceEventProgressbarColorSelected,
91                 serviceEventProgressbarBorderColor,
92                 serviceEventProgressbarBorderColorSelected,
93                 serviceDescriptionColor,
94                 serviceDescriptionColorSelected,
95                 colorElements
96         };
97         
98         void setColor(int color, gRGB &col);
99 protected:
100         void cursorHome();
101         void cursorEnd();
102         int cursorMove(int count=1);
103         int cursorValid();
104         int cursorSet(int n);
105         int cursorGet();
106
107         void cursorSave();
108         void cursorRestore();
109         int size();
110         
111         // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
112         void setSize(const eSize &size);
113         
114                 /* the following functions always refer to the selected item */
115         void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
116         
117         int m_visual_mode;
118                 /* for complex mode */
119         eRect m_element_position[celElements];
120         ePtr<gFont> m_element_font[celElements];
121         ePtr<gPixmap> m_pixmaps[picElements];
122         gRGB m_color[colorElements];
123         bool m_color_set[colorElements];
124 private:
125         typedef std::list<eServiceReference> list;
126         
127         list m_list;
128         list::iterator m_cursor, m_saved_cursor;
129         
130         int m_cursor_number, m_saved_cursor_number;
131         int m_size;
132         
133         eSize m_itemsize;
134         ePtr<iServiceHandler> m_service_center;
135         ePtr<iListableService> m_lst;
136         
137         eServiceReference m_root;
138
139                 /* support for marked services */
140         std::set<eServiceReference> m_marked;
141         std::set<eServiceReference>::const_iterator m_marked_iterator;
142
143                 /* support for movemode */
144         bool m_current_marked;
145
146         int m_numberoffset;
147
148         eServiceReference m_is_playable_ignore;
149
150         int m_itemheight;
151 };
152
153 #endif