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/buy.cpp | |
parent | 6ee1046233bfa2218eff1ffa45e31821b3559ea0 (diff) | |
download | mana-ea50de0b56063f3e7c6436422d275ac6e71d0072.tar.gz mana-ea50de0b56063f3e7c6436422d275ac6e71d0072.tar.bz2 mana-ea50de0b56063f3e7c6436422d275ac6e71d0072.tar.xz mana-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/buy.cpp')
-rw-r--r-- | src/gui/buy.cpp | 77 |
1 files changed, 16 insertions, 61 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a3424ab6..0717efa6 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -28,6 +28,8 @@ #include "shoplistbox.h" #include "slider.h" +#include "widgets/layout.h" + #include "../npc.h" #include "../net/messageout.h" @@ -62,7 +64,6 @@ BuyDialog::BuyDialog(Network *network): mIncreaseButton->setSize(20, 20); mDecreaseButton->setSize(20, 20); - mQuantityLabel->setWidth(60); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mIncreaseButton->setEnabled(false); @@ -70,22 +71,22 @@ BuyDialog::BuyDialog(Network *network): mBuyButton->setEnabled(false); mSlider->setEnabled(false); - mShopItemList->setActionEventId("item"); mSlider->setActionEventId("slider"); - - mShopItemList->addSelectionListener(this); mSlider->addActionListener(this); + mShopItemList->addSelectionListener(this); - add(mScrollArea); - add(mSlider); - add(mQuantityLabel); - add(mBuyButton); - add(mQuitButton); - add(mIncreaseButton); - add(mDecreaseButton); - add(mMoneyLabel); - add(mItemDescLabel); - add(mItemEffectLabel); + place(0, 0, mScrollArea, 5).setPadding(3); + place(0, 1, mQuantityLabel, 2); + place(2, 1, mSlider, 3); + place(0, 2, mMoneyLabel, 5); + place(0, 3, mItemEffectLabel, 5); + place(0, 4, mItemDescLabel, 5); + place(0, 5, mDecreaseButton); + place(1, 5, mIncreaseButton); + place(3, 5, mBuyButton); + place(4, 5, mQuitButton); + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::AUTO_SET); loadWindowState(); setLocationRelativeTo(getParent()); @@ -191,53 +192,7 @@ void BuyDialog::valueChanged(const gcn::SelectionEvent &event) mSlider->gcn::Slider::setScale(1, mMaxItems); } -void BuyDialog::widgetResized(const gcn::Event &event) -{ - Window::widgetResized(event); - - const gcn::Rectangle &area = getChildrenArea(); - const int width = area.width; - const int height = area.height; - - mDecreaseButton->setPosition(8, height - 8 - mDecreaseButton->getHeight()); - mIncreaseButton->setPosition( - mDecreaseButton->getX() + mDecreaseButton->getWidth() + 5, - mDecreaseButton->getY()); - - mQuitButton->setPosition( - width - 8 - mQuitButton->getWidth(), - height - 8 - mQuitButton->getHeight()); - mBuyButton->setPosition( - mQuitButton->getX() - 5 - mBuyButton->getWidth(), - mQuitButton->getY()); - - mItemDescLabel->setDimension(gcn::Rectangle(8, - mBuyButton->getY() - 5 - mItemDescLabel->getHeight(), - width - 16, - mItemDescLabel->getHeight())); - mItemEffectLabel->setDimension(gcn::Rectangle(8, - mItemDescLabel->getY() - 5 - mItemEffectLabel->getHeight(), - width - 16, - mItemEffectLabel->getHeight())); - mMoneyLabel->setDimension(gcn::Rectangle(8, - mItemEffectLabel->getY() - 5 - mMoneyLabel->getHeight(), - width - 16, - mMoneyLabel->getHeight())); - - mQuantityLabel->setPosition( - width - mQuantityLabel->getWidth() - 8, - mMoneyLabel->getY() - 5 - mQuantityLabel->getHeight()); - mSlider->setDimension(gcn::Rectangle(8, - mQuantityLabel->getY(), - mQuantityLabel->getX() - 8 - 8, - 10)); - - mScrollArea->setDimension(gcn::Rectangle(8, 8, width - 16, - mSlider->getY() - 5 - 8)); -} - -void -BuyDialog::updateButtonsAndLabels() +void BuyDialog::updateButtonsAndLabels() { const int selectedItem = mShopItemList->getSelected(); int price = 0; |