- add listbox
[vuplus_dvbapp] / 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                 /* indices go from 0 to size().
11                    the end is reached when the cursor is on size(), 
12                    i.e. one after the last entry (this mimics 
13                    stl behaviour)
14                    
15                    cursors never invalidate - they can become invalid
16                    when stuff is removed. Cursors will always try
17                    to stay on the same data, however when the current
18                    item is removed, this won't work. you'll be notified
19                    anyway. */
20                   
21         virtual void cursorHome()=0;
22         virtual void cursorEnd()=0;
23         virtual int cursorMove(int count=1)=0;
24         virtual int cursorValid()=0;
25         virtual int cursorSet(int n)=0;
26         virtual int cursorGet()=0;
27         
28         virtual void cursorSave()=0;
29         virtual void cursorRestore()=0;
30         
31         virtual int size()=0;
32         
33         virtual RESULT connectItemChanged(const Slot0<void> &itemChanged, ePtr<eConnection> &connection)=0;
34         
35         // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
36         virtual void setSize(const eSize &size)=0;
37         
38                 /* the following functions always refer to the selected item */
39         virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
40 };
41
42 class eListbox: public eWidget
43 {
44 public:
45         eListbox(eWidget *parent);
46         void setContent(iListboxContent *content);
47         
48         void moveSelection(int how);
49         enum {
50                 moveUp,
51                 moveDown,
52                 moveTop,
53                 moveEnd
54         };
55 protected:
56         int event(int event, void *data=0, void *data2=0);
57         void recalcSize();
58 private:
59         int m_top, m_selected;
60         int m_itemheight;
61         int m_items_per_page;
62         ePtr<iListboxContent> m_content;
63 };
64
65
66 #endif