diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-14 10:07:55 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-14 10:07:55 +0000 |
commit | 69c147510bce9aa24be5ddcb3d050a5d52e3abe7 (patch) | |
tree | 99e7ae22cf75ed210e26e77137bf37d67353839e /src/gui/item_amount.cpp | |
parent | cb04d148c9aed572fe6e66313100e2cd9b66f5d5 (diff) | |
download | mana-client-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.tar.gz mana-client-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.tar.bz2 mana-client-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.tar.xz mana-client-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.zip |
Improved item amount dialog box.
Diffstat (limited to 'src/gui/item_amount.cpp')
-rw-r--r-- | src/gui/item_amount.cpp | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index 33a45fe7..6f1c8ae6 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -28,6 +28,8 @@ #include "slider.h" #include "trade.h" +#include "widgets/layout.h" + #include "../item.h" #include "../localplayer.h" @@ -38,47 +40,45 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item, Window("", true, parent), mItem(item) { - // New labels - mItemAmountTextBox = new IntTextBox(1); - - // New buttons - Button *minusButton = new Button("-", "Minus", this); - Button *plusButton = new Button("+", "Plus", this); - Button *okButton = new Button(_("Ok"), "Drop", this); - Button *cancelButton = new Button(_("Cancel"), "Cancel", this); - if (!maxRange) { + if (!maxRange) + { maxRange = mItem->getQuantity(); } - mItemAmountSlide = new Slider(1.0, maxRange); + // Integer field + mItemAmountTextBox = new IntTextBox(1); mItemAmountTextBox->setRange(1, maxRange); - mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10)); + mItemAmountTextBox->setWidth(30); + mItemAmountTextBox->setActionEventId("Dummy"); + mItemAmountTextBox->addActionListener(this); - // Set button events Id + // Slider + mItemAmountSlide = new Slider(1.0, maxRange); + mItemAmountSlide->setHeight(10); mItemAmountSlide->setActionEventId("Slide"); + mItemAmountSlide->addActionListener(this); - // Set position - mItemAmountTextBox->setPosition(35, 10); - mItemAmountTextBox->setSize(24, 16); - plusButton->setPosition(60, 5); - minusButton->setPosition(10, 5); - 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); + // 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); - mItemAmountSlide->addActionListener(this); + // Set positions + 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(); - switch (usage) { + switch (usage) + { case AMOUNT_TRADE_ADD: setCaption(_("Select amount of items to trade.")); okButton->setActionEventId("AddTrade"); @@ -95,7 +95,6 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item, break; } - setContentSize(200, 80); setLocationRelativeTo(getParentWindow()); setVisible(true); } |