summaryrefslogtreecommitdiff
path: root/src/gui/item_amount.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/item_amount.cpp')
-rw-r--r--src/gui/item_amount.cpp61
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);
}