1 #ifndef __lib_listbox_h
2 #define __lib_listbox_h
4 #include <lib/gui/ewidget.h>
5 #include <connection.h>
7 class iListboxContent: public iObject
10 virtual ~iListboxContent()=0;
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
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
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;
33 virtual void cursorSave()=0;
34 virtual void cursorRestore()=0;
38 void setListbox(eListbox *lb);
40 // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
41 virtual void setSize(const eSize &size)=0;
43 /* the following functions always refer to the selected item */
44 virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
50 class eListbox: public eWidget
53 eListbox(eWidget *parent);
55 void setContent(iListboxContent *content);
65 void moveSelection(int how);
77 void setItemHeight(int h);
78 void setSelectionEnable(int en);
81 /* entryAdded: an entry was added *before* the given index. it's index is the given number. */
82 void entryAdded(int index);
83 /* entryRemoved: an entry with the given index was removed. */
84 void entryRemoved(int index);
85 /* entryChanged: the entry with the given index was changed and should be redrawn. */
86 void entryChanged(int index);
87 /* the complete list changed. you should not attemp to keep the current index. */
91 int event(int event, void *data=0, void *data2=0);
95 int m_top, m_selected;
98 int m_selection_enabled;
99 ePtr<iListboxContent> m_content;