summaryrefslogtreecommitdiff
path: root/src/gui/listbox.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-09-03 21:25:02 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-09-03 21:25:02 +0000
commit22aca668b53786dc00ff43764e61980e6499ec30 (patch)
tree9deb46fb98db77b556d579ce9eeaf4baa80a75e5 /src/gui/listbox.h
parentfe3ecae6936b41045b405fb5055a9ad754ddec3b (diff)
downloadmana-client-22aca668b53786dc00ff43764e61980e6499ec30.tar.gz
mana-client-22aca668b53786dc00ff43764e61980e6499ec30.tar.bz2
mana-client-22aca668b53786dc00ff43764e61980e6499ec30.tar.xz
mana-client-22aca668b53786dc00ff43764e61980e6499ec30.zip
Fixed updating of labels in buy and sell dialogs. Also made our listbox respond
to mouse dragging to change the selection.
Diffstat (limited to 'src/gui/listbox.h')
-rw-r--r--src/gui/listbox.h41
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