Screens/LocationBox.py: Get rid of "from Directories import *"
[openblackhole/openblackhole-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 <lib/python/python.h>
8 #include <set>
9
10 class eListboxServiceContent: public virtual iListboxContent
11 {
12         DECLARE_REF(eListboxServiceContent);
13         static ePyObject m_GetPiconNameFunc;
14 public:
15         eListboxServiceContent();
16
17         void addService(const eServiceReference &ref, bool beforeCurrent=false);
18         void removeCurrent();
19         void FillFinished();
20
21         void setIgnoreService( const eServiceReference &service );
22         void setRoot(const eServiceReference &ref, bool justSet=false);
23         void getCurrent(eServiceReference &ref);
24
25         int getNextBeginningWithChar(char c);
26         int getPrevMarkerPos();
27         int getNextMarkerPos();
28
29                 /* support for marked services */
30         void initMarked();
31         void addMarked(const eServiceReference &ref);
32         void removeMarked(const eServiceReference &ref);
33         int isMarked(const eServiceReference &ref);
34
35                 /* this is NOT thread safe! */
36         void markedQueryStart();
37         int markedQueryNext(eServiceReference &ref);
38
39         int lookupService(const eServiceReference &ref);
40         bool setCurrent(const eServiceReference &ref);
41
42         enum {
43                 visModeSimple,
44                 visModeComplex
45         };
46
47         void setVisualMode(int mode);
48
49                 /* only in complex mode: */
50         enum {
51                 celServiceNumber,
52                 celMarkerPixmap,
53                 celFolderPixmap,
54                 celServiceEventProgressbar,
55                 celServiceName,
56                 celServiceInfo, // "now" event
57                 celServiceTypePixmap,
58                 celElements
59         };
60
61         enum {
62                 picDVB_S,
63                 picDVB_T,
64                 picDVB_C,
65                 picStream,
66                 picServiceGroup,
67                 picFolder,
68                 picMarker,
69                 picServiceEventProgressbar,
70                 picCrypto,
71                 picRecord,
72                 picElements
73         };
74
75         void setElementPosition(int element, eRect where);
76         void setElementFont(int element, gFont *font);
77         void setPixmap(int type, ePtr<gPixmap> &pic);
78
79         void sort();
80
81         int setCurrentMarked(bool);
82
83         int getItemHeight() { return m_itemheight; }
84         void setItemHeight(int height);
85         void setHideNumberMarker(bool doHide) { m_hide_number_marker = doHide; }
86         void setServiceTypeIconMode(int mode) { m_servicetype_icon_mode = mode; }
87         void setCryptoIconMode(int mode) { m_crypto_icon_mode = mode; }
88         void setRecordIndicatorMode(int mode) { m_record_indicator_mode = mode; }
89         void setColumnWidth(int value) { m_column_width = value; }
90         void setProgressbarHeight(int value) {  m_progressbar_height = value; }
91         void setProgressbarBorderWidth(int value) { m_progressbar_border_width = value; }
92         void setNonplayableMargins(int value) { m_nonplayable_margins = value; }
93         void setItemsDistances(int value) { m_items_distances = value; }
94
95         static void setGetPiconNameFunc(SWIG_PYOBJECT(ePyObject) func);
96
97         enum {
98                 markedForeground,
99                 markedForegroundSelected,
100                 markedBackground,
101                 markedBackgroundSelected,
102                 serviceNotAvail,
103                 eventForeground,
104                 eventForegroundSelected,
105                 eventborderForeground,
106                 eventborderForegroundSelected,
107                 eventForegroundFallback,
108                 eventForegroundSelectedFallback,
109                 serviceItemFallback,
110                 serviceSelectedFallback,
111                 serviceEventProgressbarColor,
112                 serviceEventProgressbarColorSelected,
113                 serviceEventProgressbarBorderColor,
114                 serviceEventProgressbarBorderColorSelected,
115                 serviceRecorded,
116                 colorElements
117         };
118
119         void setColor(int color, gRGB &col);
120         bool checkServiceIsRecorded(eServiceReference ref);
121 protected:
122         void cursorHome();
123         void cursorEnd();
124         int cursorMove(int count=1);
125         int cursorValid();
126         int cursorSet(int n);
127         int cursorResolve(int);
128         int cursorGet();
129         int currentCursorSelectable();
130
131         void cursorSave();
132         void cursorRestore();
133         int size();
134
135         // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
136         void setSize(const eSize &size);
137
138                 /* the following functions always refer to the selected item */
139         void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
140
141         int m_visual_mode;
142                 /* for complex mode */
143         eRect m_element_position[celElements];
144         ePtr<gFont> m_element_font[celElements];
145         ePtr<gPixmap> m_pixmaps[picElements];
146         gRGB m_color[colorElements];
147         bool m_color_set[colorElements];
148 private:
149         typedef std::list<eServiceReference> list;
150
151         list m_list;
152         list::iterator m_cursor, m_saved_cursor;
153
154         int m_cursor_number, m_saved_cursor_number;
155         int m_size;
156
157         eSize m_itemsize;
158         ePtr<iServiceHandler> m_service_center;
159         ePtr<iListableService> m_lst;
160
161         eServiceReference m_root;
162
163                 /* support for marked services */
164         std::set<eServiceReference> m_marked;
165         std::set<eServiceReference>::const_iterator m_marked_iterator;
166
167                 /* support for movemode */
168         bool m_current_marked;
169         void swapServices(list::iterator, list::iterator);
170
171         eServiceReference m_is_playable_ignore;
172
173         int m_itemheight;
174         bool m_hide_number_marker;
175         int m_servicetype_icon_mode;
176         int m_crypto_icon_mode;
177         int m_record_indicator_mode;
178         int m_column_width;
179         int m_progressbar_height;
180         int m_progressbar_border_width;
181         int m_nonplayable_margins;
182         int m_items_distances;
183 };
184
185 #endif