summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-14 14:54:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-14 14:54:39 +0000
commitf842e0b40d8382011f0bc46b1446945d99ac0425 (patch)
tree5ddbb7c146a8ece28a4260d788350b1c2cf0dbed /src/gui/itemcontainer.cpp
parentcbbcc5489e2f72a76b66ae849cbe8f1dc44246ca (diff)
downloadmana-f842e0b40d8382011f0bc46b1446945d99ac0425.tar.gz
mana-f842e0b40d8382011f0bc46b1446945d99ac0425.tar.bz2
mana-f842e0b40d8382011f0bc46b1446945d99ac0425.tar.xz
mana-f842e0b40d8382011f0bc46b1446945d99ac0425.zip
Upgraded to Guichan 0.6.0 (merge from guichan-0.6.0 branch).
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 5bcd000d..055a07cb 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -58,7 +58,8 @@ ItemContainer::~ItemContainer()
mSelImg->decRef();
}
-void ItemContainer::logic()
+void
+ItemContainer::logic()
{
gcn::Widget::logic();
@@ -70,7 +71,8 @@ void ItemContainer::logic()
}
}
-void ItemContainer::draw(gcn::Graphics* graphics)
+void
+ItemContainer::draw(gcn::Graphics *graphics)
{
int gridWidth = 36; //(item icon width + 4)
int gridHeight = 42; //(item icon height + 10)
@@ -128,7 +130,8 @@ void ItemContainer::draw(gcn::Graphics* graphics)
}
}
-void ItemContainer::setWidth(int width)
+void
+ItemContainer::setWidth(int width)
{
gcn::Widget::setWidth(width);
@@ -145,17 +148,20 @@ void ItemContainer::setWidth(int width)
(mMaxItems % columns > 0 ? 1 : 0)) * gridHeight);
}
-Item* ItemContainer::getItem()
+Item*
+ItemContainer::getItem()
{
return mSelectedItem;
}
-void ItemContainer::selectNone()
+void
+ItemContainer::selectNone()
{
setSelectedItem(NULL);
}
-void ItemContainer::setSelectedItem(Item *item)
+void
+ItemContainer::setSelectedItem(Item *item)
{
if (mSelectedItem != item)
{
@@ -164,7 +170,8 @@ void ItemContainer::setSelectedItem(Item *item)
}
}
-void ItemContainer::fireSelectionChangedEvent()
+void
+ItemContainer::fireSelectionChangedEvent()
{
SelectionEvent event(this);
SelectionListeners::iterator i_end = mListeners.end();
@@ -176,14 +183,18 @@ void ItemContainer::fireSelectionChangedEvent()
}
}
-void ItemContainer::mousePress(int mx, int my, int button)
+void
+ItemContainer::mousePressed(gcn::MouseEvent &event)
{
- int gridWidth = 36; //(item icon width + 4)
- int gridHeight = 42; //(item icon height + 10)
- int columns = getWidth() / gridWidth;
+ int button = event.getButton();
- if (button == gcn::MouseInput::LEFT || gcn::MouseInput::RIGHT)
+ if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT)
{
+ int gridWidth = 36; //(item icon width + 4)
+ int gridHeight = 42; //(item icon height + 10)
+ int columns = getWidth() / gridWidth;
+ int mx = event.getX();
+ int my = event.getY();
int index = mx / gridWidth + ((my / gridHeight) * columns) + 2;
if (index > INVENTORY_SIZE) {