1 #ifndef __lib_listbox_h
2 #define __lib_listbox_h
4 #include <lib/gui/ewidget.h>
5 #include <connection.h>
10 class iListboxContent: public iObject
13 virtual ~iListboxContent()=0;
15 /* indices go from 0 to size().
16 the end is reached when the cursor is on size(),
17 i.e. one after the last entry (this mimics
20 cursors never invalidate - they can become invalid
21 when stuff is removed. Cursors will always try
22 to stay on the same data, however when the current
23 item is removed, this won't work. you'll be notified
28 friend class eListbox;
29 virtual void cursorHome()=0;
30 virtual void cursorEnd()=0;
31 virtual int cursorMove(int count=1)=0;
32 virtual int cursorValid()=0;
33 virtual int cursorSet(int n)=0;
34 virtual int cursorGet()=0;
36 virtual void cursorSave()=0;
37 virtual void cursorRestore()=0;
41 void setListbox(eListbox *lb);
43 // void setOutputDevice ? (for allocating colors, ...) .. requires some work, though
44 virtual void setSize(const eSize &size)=0;
46 /* the following functions always refer to the selected item */
47 virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)=0;
53 class eListbox: public eWidget
55 void updateScrollBar();
57 eListbox(eWidget *parent);
60 PSignal0<void> selectionChanged;
67 void setScrollbarMode(int mode);
69 void setContent(iListboxContent *content);
79 int getCurrentIndex();
80 void moveSelection(int how);
81 void moveSelectionTo(int index);
93 void setItemHeight(int h);
94 void setSelectionEnable(int en);
96 /* entryAdded: an entry was added *before* the given index. it's index is the given number. */
97 void entryAdded(int index);
98 /* entryRemoved: an entry with the given index was removed. */
99 void entryRemoved(int index);
100 /* entryChanged: the entry with the given index was changed and should be redrawn. */
101 void entryChanged(int index);
102 /* the complete list changed. you should not attemp to keep the current index. */
103 void entryReset(bool cursorHome=true);
106 int event(int event, void *data=0, void *data2=0);
110 int m_scrollbar_mode, m_prev_scrollbar_page;
111 bool m_content_changed;
113 int m_top, m_selected;
115 int m_items_per_page;
116 int m_selection_enabled;
117 ePtr<iListboxContent> m_content;
118 eSlider *m_scrollbar;