diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-29 23:59:08 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-29 23:59:08 +0000 |
commit | e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3 (patch) | |
tree | e8dc775e12f6b4eb0a6d56448f05286c774bbb8a /src/gui/listbox.h | |
parent | 0e8c09433f3a193b5a94a1ad572d8237113cdfbf (diff) | |
download | mana-client-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.tar.gz mana-client-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.tar.bz2 mana-client-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.tar.xz mana-client-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.zip |
Merged trunk changes from revision 2618 to 2716 into the 0.1.0 branch.
Diffstat (limited to 'src/gui/listbox.h')
-rw-r--r-- | src/gui/listbox.h | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 5999f7a7..c1932f54 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -26,10 +26,12 @@ #include <guichan/widgets/listbox.hpp> +class SelectionListener; + /** * A list box, meant to be used inside a scroll area. Same as the Guichan list * box except this one doesn't have a background, instead completely relying - * on the scroll area. + * on the scroll area. It also adds selection listener functionality. * * \ingroup GUI */ @@ -45,6 +47,43 @@ class ListBox : public gcn::ListBox * Draws the list box. */ void draw(gcn::Graphics *graphics); + + void mousePress(int x, int y, int button); + void mouseRelease(int x, int y, int button); + void mouseMotion(int x, int y); + + /** + * Adds a listener to the list that's notified each time a change to + * the selection occurs. + */ + void addSelectionListener(SelectionListener *listener) + { + mListeners.push_back(listener); + } + + /** + * Removes a listener from the list that's notified each time a change + * to the selection occurs. + */ + void removeSelectionListener(SelectionListener *listener) + { + mListeners.remove(listener); + } + + /** + * Sets the index of the selected element. + */ + void setSelected(int selected); + + private: + /** + * Sends out selection events to the list of selection listeners. + */ + void fireSelectionChangedEvent(); + + bool mMousePressed; /**< Keeps track of mouse pressed status. */ + + std::list<SelectionListener*> mListeners; }; #endif |