diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-06 21:35:19 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-06 21:35:19 +0100 |
commit | 705d753cd7e762095ae53a428ed277449d064fed (patch) | |
tree | ac658992fd82080923518d8605747dcae17dd5a8 /src/gui/item_amount.cpp | |
parent | 9219f1ffd4b05886b66c9074c918850fc97c430c (diff) | |
download | mana-705d753cd7e762095ae53a428ed277449d064fed.tar.gz mana-705d753cd7e762095ae53a428ed277449d064fed.tar.bz2 mana-705d753cd7e762095ae53a428ed277449d064fed.tar.xz mana-705d753cd7e762095ae53a428ed277449d064fed.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 064c8f93..17c3243a 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -26,6 +26,8 @@ #include "slider.h" #include "trade.h" +#include "widgets/layout.h" + #include "../item.h" #include "../localplayer.h" @@ -35,38 +37,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(); @@ -83,7 +84,6 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): break; } - setContentSize(200, 80); setLocationRelativeTo(getParentWindow()); setVisible(true); } @@ -101,16 +101,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++; @@ -123,7 +113,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); } - |