summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.h
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-09-03 15:00:47 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-09-03 15:00:47 +0000
commit77efbb50066a030d1f44f8de8d06ace9f284e3a2 (patch)
tree22d737ac0058e4fa87e7767d41e02999bcbf84be /src/gui/itemcontainer.h
parent40ca3dc75197412594c5f6a78d68b265e235024b (diff)
downloadmana-client-77efbb50066a030d1f44f8de8d06ace9f284e3a2.tar.gz
mana-client-77efbb50066a030d1f44f8de8d06ace9f284e3a2.tar.bz2
mana-client-77efbb50066a030d1f44f8de8d06ace9f284e3a2.tar.xz
mana-client-77efbb50066a030d1f44f8de8d06ace9f284e3a2.zip
Introduced SelectionListener to fix updating problem in inventory window
(should also be used to fix similar problem in trade, buy and sell dialogs). Made the ItemInfo be passed around as a reference instead of a pointer, since it is never NULL.
Diffstat (limited to 'src/gui/itemcontainer.h')
-rw-r--r--src/gui/itemcontainer.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index f52f37ec..a2d5f0f7 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -27,9 +27,12 @@
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
+#include <list>
+
class Image;
class Inventory;
class Item;
+class SelectionListener;
/**
* An item container. Used to show items in inventory and trade dialog.
@@ -76,16 +79,46 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener
Item* getItem();
/**
- * Set selected item to -1.
+ * Sets selected item to NULL.
*/
void selectNone();
+ /**
+ * 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);
+ }
+
private:
+ /**
+ * Sets the currently selected item.
+ */
+ void setSelectedItem(Item *item);
+
+ /**
+ * Sends out selection events to the list of selection listeners.
+ */
+ void fireSelectionChangedEvent();
+
Inventory *mInventory;
Image *mSelImg;
Item *mSelectedItem;
int mMaxItems;
+
+ std::list<SelectionListener*> mListeners;
};
#endif