diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-06 21:35:19 +0100 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-06 15:03:22 -0700 |
commit | ea50de0b56063f3e7c6436422d275ac6e71d0072 (patch) | |
tree | 8b6a862e90a313d655e42f543e2a57bc7500a57e /src/gui/item_amount.cpp | |
parent | 6ee1046233bfa2218eff1ffa45e31821b3559ea0 (diff) | |
download | mana-client-ea50de0b56063f3e7c6436422d275ac6e71d0072.tar.gz mana-client-ea50de0b56063f3e7c6436422d275ac6e71d0072.tar.bz2 mana-client-ea50de0b56063f3e7c6436422d275ac6e71d0072.tar.xz mana-client-ea50de0b56063f3e7c6436422d275ac6e71d0072.zip |
Used layout for buy, sell and item amount dialogs
(changes by Guillaume Melquiond, merged from the mainline client)
Diffstat (limited to 'src/gui/item_amount.cpp')
-rw-r--r-- | src/gui/item_amount.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index 191c7b8b..48b0e601 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -25,6 +25,8 @@ #include "slider.h" #include "trade.h" +#include "widgets/layout.h" + #include "../item.h" #include "../localplayer.h" @@ -34,38 +36,37 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): Window("", true, parent), mItem(item) { + const int maxRange = mItem->getQuantity(); + // Integer field mItemAmountTextBox = new IntTextBox(1); - mItemAmountTextBox->setRange(1, mItem->getQuantity()); + mItemAmountTextBox->setRange(1, maxRange); + mItemAmountTextBox->setWidth(30); + mItemAmountTextBox->setActionEventId("Dummy"); + mItemAmountTextBox->addActionListener(this); // Slider - mItemAmountSlide = new Slider(1.0, mItem->getQuantity()); + mItemAmountSlide = new Slider(1.0, maxRange); + mItemAmountSlide->setHeight(10); mItemAmountSlide->setActionEventId("Slide"); mItemAmountSlide->addActionListener(this); // Buttons Button *minusButton = new Button("-", "Minus", this); + minusButton->setSize(20, 20); Button *plusButton = new Button("+", "Plus", this); + plusButton->setSize(20, 20); Button *okButton = new Button(_("Ok"), "Drop", this); Button *cancelButton = new Button(_("Cancel"), "Cancel", this); // Set positions - mItemAmountTextBox->setPosition(35, 10); - mItemAmountTextBox->setSize(24, 16); - plusButton->setPosition(60, 5); - minusButton->setPosition(10, 5); - mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10)); - mItemAmountSlide->setPosition(10, 35); - okButton->setPosition(10, 50); - cancelButton->setPosition(60, 50); - - // Assemble - add(mItemAmountTextBox); - add(plusButton); - add(minusButton); - add(mItemAmountSlide); - add(okButton); - add(cancelButton); + place(0, 0, minusButton); + place(1, 0, mItemAmountTextBox).setPadding(2); + place(2, 0, plusButton); + place(0, 1, mItemAmountSlide, 6); + place(4, 2, okButton); + place(5, 2, cancelButton); + reflowLayout(250, 0); resetAmount(); @@ -82,7 +83,6 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): break; } - setContentSize(200, 80); setLocationRelativeTo(getParentWindow()); setVisible(true); } @@ -100,16 +100,6 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) { scheduleDelete(); } - else if (event.getId() == "Drop") - { - player_node->dropItem(mItem, mItemAmountTextBox->getInt()); - scheduleDelete(); - } - else if (event.getId() == "AddTrade") - { - tradeWindow->tradeItem(mItem, mItemAmountTextBox->getInt()); - scheduleDelete(); - } else if (event.getId() == "Plus") { amount++; @@ -122,7 +112,16 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) { amount = static_cast<int>(mItemAmountSlide->getValue()); } + else if (event.getId() == "Drop") + { + player_node->dropItem(mItem, mItemAmountTextBox->getInt()); + scheduleDelete(); + } + else if (event.getId() == "AddTrade") + { + tradeWindow->tradeItem(mItem, mItemAmountTextBox->getInt()); + scheduleDelete(); + } mItemAmountTextBox->setInt(amount); mItemAmountSlide->setValue(amount); } - |