add enq cancel
[enigma2.git] / lib / gui / elistbox.h
1 #ifndef __lib_listbox_h
2 #define __lib_listbox_h
3
4 #include <lib/gui/ewidget.h>
5 #include <connection.h>
6
7 class iListboxContent: public iObject
8 {
9 public:
10         virtual ~iListboxContent()=0;
11         
12                 /* indices go from 0 to size().
13                    the end is reached when the cursor is on size(), 
14                    i.e. one after the last entry (this mimics 
15                    stl behaviour)
16                    
17                    cursors never invalidate - they can become invalid
18                    when stuff is removed. Cursors will always try
19                    to stay on the same data, however when the current
20                    item is removed, this won't work. you'll be notified
21                    anyway. */
22 #ifndef SWIG    
23 protected:
24         iListboxContent();
25         friend class eListbox;
26         virtual void cursorHome()=0;
27         virtual void cursorEnd()=0;
28         virtual int cursorMove(int count=1)=0;
29         virtual int cursorValid()=0;
30         virtual int cursorSet(int n)=0;
31         virtual int cursorGet()=0;
32         
33         virtual void cursorSave()=0;
34         virtual void cursorRestore()=0;
35         
36         virtual int size()=0;
37         
38         void setListbox(eListbox *lb);
39         
40         // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
41         virtual void setSize(const eSize &size)=0;
42         
43                 /* the following functions always refer to the selected item */
44         virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
45         
46         eListbox *m_listbox;
47 #endif
48 };
49
50 class eListbox: public eWidget
51 {
52 public:
53         eListbox(eWidget *parent);
54         ~eListbox();
55         void setContent(iListboxContent *content);
56         
57 /*      enum Movement {
58                 moveUp,
59                 moveDown,
60                 moveTop,
61                 moveEnd,
62                 justCheck
63         }; */
64         
65         void moveSelection(int how);
66
67         enum ListboxActions {
68                 moveUp,
69                 moveDown,
70                 moveTop,
71                 moveEnd,
72                 pageUp,
73                 pageDown,
74                 justCheck
75         };
76         
77         void setItemHeight(int h);
78
79 #ifndef SWIG
80                 /* entryAdded: an entry was added *before* the given index. it's index is the given number. */
81         void entryAdded(int index);
82                 /* entryRemoved: an entry with the given index was removed. */
83         void entryRemoved(int index);
84                 /* entryChanged: the entry with the given index was changed and should be redrawn. */
85         void entryChanged(int index);
86                 /* the complete list changed. you should not attemp to keep the current index. */
87         void entryReset();
88
89 protected:
90         int event(int event, void *data=0, void *data2=0);
91         void recalcSize();
92         
93 private:
94         int m_top, m_selected;
95         int m_itemheight;
96         int m_items_per_page;
97         ePtr<iListboxContent> m_content;
98 #endif
99
100 };
101
102 #endif