summaryrefslogtreecommitdiff
path: root/src/gui/trade.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-01 04:01:00 +0100
committerIra Rice <irarice@gmail.com>2009-01-05 20:51:29 -0700
commitd87d6368b23fe11e5217d674ed1a4bad05d9bf90 (patch)
treed82c7fc1f629fe4806c6d4ce8f8be5902ccc3b8a /src/gui/trade.cpp
parent4a4b1d993a1c230b0769630949187f299ec6072c (diff)
downloadmana-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.tar.gz
mana-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.tar.bz2
mana-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.tar.xz
mana-d87d6368b23fe11e5217d674ed1a4bad05d9bf90.zip
Made trade window resizable
Also fixed overlap between description label and the buttons and added the SDL_ttf library to the Code::Blocks project file.
Diffstat (limited to 'src/gui/trade.cpp')
-rw-r--r--src/gui/trade.cpp64
1 files changed, 40 insertions, 24 deletions
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 843c9663..bae8daa6 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -50,7 +50,11 @@ TradeWindow::TradeWindow(Network *network):
mPartnerInventory(new Inventory(INVENTORY_SIZE))
{
setWindowName("Trade");
- setDefaultSize(115, 227, 332, 209);
+ setDefaultSize(115, 227, 342, 209);
+ setResizable(true);
+
+ setMinWidth(342);
+ setMinHeight(209);
mAddButton = new Button("Add", "add", this);
mOkButton = new Button("Ok", "ok", this);
@@ -73,7 +77,8 @@ TradeWindow::TradeWindow(Network *network):
mMoneyLabel = new gcn::Label("You get: 0 GP");
mMoneyLabel2 = new gcn::Label("You give:");
- mMoneyField = new TextField();
+ mMoneyField = new TextField;
+ mMoneyField->setWidth(50);
mAddButton->adjustSize();
mOkButton->adjustSize();
@@ -98,38 +103,49 @@ TradeWindow::TradeWindow(Network *network):
add(mMoneyLabel);
loadWindowState();
+}
+
+TradeWindow::~TradeWindow()
+{
+}
- gcn::Rectangle area = getChildrenArea();
- int width = area.width;
- int height = area.height;
+void TradeWindow::widgetResized(const gcn::Event &event)
+{
+ Window::widgetResized(event);
- mMoneyField->setPosition(8 + 60, height - 20);
- mMoneyField->setWidth(50);
+ const gcn::Rectangle &area = getChildrenArea();
+ const int width = area.width;
+ const int height = area.height;
+
+ mMoneyLabel2->setPosition(8, height - 8 - mMoneyLabel2->getHeight());
+ mMoneyField->setPosition(
+ 8 + mMoneyLabel2->getWidth(),
+ height - 8 - mMoneyField->getHeight());
+ mMoneyLabel->setPosition(
+ mMoneyField->getX() + mMoneyField->getWidth() + 6,
+ mMoneyLabel2->getY());
- mMoneyLabel->setPosition(8 + 60 + 50 + 6, height - 20);
- mMoneyLabel2->setPosition(8, height - 20);
+ mCancelButton->setPosition(width - 54, height - 8 - mCancelButton->getHeight());
+ mTradeButton->setPosition(mCancelButton->getX() - 41, mCancelButton->getY());
+ mOkButton->setPosition(mTradeButton->getX() - 24, mCancelButton->getY());
+ mAddButton->setPosition(mOkButton->getX() - 31, mCancelButton->getY());
- mCancelButton->setPosition(width - 54, height - 49);
- mTradeButton->setPosition(mCancelButton->getX() - 41, height - 49);
- mOkButton->setPosition(mTradeButton->getX() - 24, height - 49);
- mAddButton->setPosition(mOkButton->getX() - 31, height - 49);
+ mItemDescriptionLabel->setPosition(8,
+ mOkButton->getY() - mItemDescriptionLabel->getHeight() - 4);
+ mItemNameLabel->setPosition(8,
+ mItemDescriptionLabel->getY() - mItemNameLabel->getHeight() - 4);
+
+ const int remaining = mItemNameLabel->getY() - 4 - 8 - 8;
+ const int itemContainerHeight = remaining / 2;
mMyItemContainer->setSize(width - 24 - 12 - 1,
(INVENTORY_SIZE * 24) / (width / 24) - 1);
- mMyScroll->setSize(width - 16, (height - 76) / 2);
+ mMyScroll->setSize(width - 16, itemContainerHeight);
mPartnerItemContainer->setSize(width - 24 - 12 - 1,
(INVENTORY_SIZE * 24) / (width / 24) - 1);
- mPartnerScroll->setSize(width - 16, (height - 76) / 2);
-
- mItemNameLabel->setPosition(8,
- mPartnerScroll->getY() + mPartnerScroll->getHeight() + 4);
- mItemDescriptionLabel->setPosition(8,
- mItemNameLabel->getY() + mItemNameLabel->getHeight() + 4);
-}
-
-TradeWindow::~TradeWindow()
-{
+ mPartnerScroll->setSize(width - 16, itemContainerHeight);
+ mPartnerScroll->setPosition(8, 8 + itemContainerHeight + 8);
}
void TradeWindow::addMoney(int amount)