1 #ifndef __lib_listbox_h
2 #define __lib_listbox_h
4 #include <lib/gui/ewidget.h>
5 #include <connection.h>
9 class iListboxContent: public iObject
12 virtual ~iListboxContent()=0;
14 /* indices go from 0 to size().
15 the end is reached when the cursor is on size(),
16 i.e. one after the last entry (this mimics
19 cursors never invalidate - they can become invalid
20 when stuff is removed. Cursors will always try
21 to stay on the same data, however when the current
22 item is removed, this won't work. you'll be notified
27 friend class eListbox;
28 virtual void cursorHome()=0;
29 virtual void cursorEnd()=0;
30 virtual int cursorMove(int count=1)=0;
31 virtual int cursorValid()=0;
32 virtual int cursorSet(int n)=0;
33 virtual int cursorGet()=0;
35 virtual void cursorSave()=0;
36 virtual void cursorRestore()=0;
40 void setListbox(eListbox *lb);
42 // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
43 virtual void setSize(const eSize &size)=0;
45 /* the following functions always refer to the selected item */
46 virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
52 class eListbox: public eWidget
54 void updateScrollBar();
56 eListbox(eWidget *parent);
64 void setScrollbarMode(int mode);
66 void setContent(iListboxContent *content);
76 int getCurrentIndex();
77 void moveSelection(int how);
78 void moveSelectionTo(int index);
90 void setItemHeight(int h);
91 void setSelectionEnable(int en);
94 /* entryAdded: an entry was added *before* the given index. it's index is the given number. */
95 void entryAdded(int index);
96 /* entryRemoved: an entry with the given index was removed. */
97 void entryRemoved(int index);
98 /* entryChanged: the entry with the given index was changed and should be redrawn. */
99 void entryChanged(int index);
100 /* the complete list changed. you should not attemp to keep the current index. */
101 void entryReset(bool cursorHome=true);
104 int event(int event, void *data=0, void *data2=0);
108 int m_scrollbar_mode, m_prev_scrollbar_page;
109 bool m_content_changed;
111 int m_top, m_selected;
113 int m_items_per_page;
114 int m_selection_enabled;
115 ePtr<iListboxContent> m_content;
116 eSlider *m_scrollbar;