diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-21 19:59:39 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-21 19:59:39 +0000 |
commit | 53800016443ed50a5b0ea27b65b39730586352d4 (patch) | |
tree | 2a73a6bc69c54b1397e02cada7fc72dac41afcb1 | |
parent | 7afe9d904f11fc65f02959798dfc6abb3660d660 (diff) | |
download | mana-53800016443ed50a5b0ea27b65b39730586352d4.tar.gz mana-53800016443ed50a5b0ea27b65b39730586352d4.tar.bz2 mana-53800016443ed50a5b0ea27b65b39730586352d4.tar.xz mana-53800016443ed50a5b0ea27b65b39730586352d4.zip |
Converted sell dialog box to layout handler. Removed some useless code from buy dialog box.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/gui/buy.cpp | 5 | ||||
-rw-r--r-- | src/gui/sell.cpp | 77 | ||||
-rw-r--r-- | src/gui/sell.h | 8 |
4 files changed, 21 insertions, 72 deletions
@@ -27,7 +27,8 @@ * src/gui/menuwindow.cpp: Fixed missing pixels at bottom and right. * src/gui/window.cpp, src/gui/window.h: Changed to use default values when restoring missing settings. - * src/gui/buy.cpp, src/gui/buy.h: Converted to layout handler. + * src/gui/buy.cpp, src/gui/buy.h, src/gui/sell.cpp, src/gui/sell.h: + Converted to layout handler. 2007-10-20 Guillaume Melquiond <guillaume.melquiond@gmail.com> diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a122783e..b95a8b25 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -64,7 +64,6 @@ BuyDialog::BuyDialog(): mIncreaseButton->setSize(20, 20); mDecreaseButton->setSize(20, 20); - mQuantityLabel->setWidth(60); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mIncreaseButton->setEnabled(false); @@ -72,11 +71,9 @@ BuyDialog::BuyDialog(): mBuyButton->setEnabled(false); mSlider->setEnabled(false); - mShopItemList->setActionEventId("item"); mSlider->setActionEventId("slider"); - - mShopItemList->addSelectionListener(this); mSlider->addActionListener(this); + mShopItemList->addSelectionListener(this); place(0, 0, mScrollArea, 5).setPadding(3); place(0, 1, mQuantityLabel, 2); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index ff6fa17f..8c442aad 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -33,6 +33,8 @@ #include "shop.h" #include "slider.h" +#include "widgets/layout.h" + #include "../item.h" #include "../npc.h" #include "../net/gameserver/player.h" @@ -66,7 +68,6 @@ SellDialog::SellDialog(): mIncreaseButton->setSize(20, 20); mDecreaseButton->setSize(20, 20); - mQuantityLabel->setWidth(60); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mIncreaseButton->setEnabled(false); @@ -75,25 +76,24 @@ SellDialog::SellDialog(): mSlider->setEnabled(false); mShopItemList->setPriceCheck(false); - mShopItemList->setActionEventId("item"); - mSlider->setActionEventId("slider"); - - mShopItemList->addActionListener(this); mShopItemList->addSelectionListener(this); + mSlider->setActionEventId("slider"); mSlider->addActionListener(this); - add(mScrollArea); - add(mSlider); - add(mQuantityLabel); - add(mMoneyLabel); - add(mItemEffectLabel); - add(mItemDescLabel); - add(mIncreaseButton); - add(mDecreaseButton); - add(mSellButton); - add(mQuitButton); - - addWindowListener(this); + 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, mSellButton); + place(4, 5, mQuitButton); + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::FILL); + layout.setColWidth(2, Layout::FILL); + loadWindowState("Sell"); setLocationRelativeTo(getParent()); } @@ -193,49 +193,6 @@ void SellDialog::selectionChanged(const SelectionEvent &event) mSlider->gcn::Slider::setScale(1, mMaxItems); } -void SellDialog::windowResized(const WindowEvent &event) -{ - gcn::Rectangle area = getChildrenArea(); - int width = area.width; - 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()); - mSellButton->setPosition( - mQuitButton->getX() - 5 - mSellButton->getWidth(), - mQuitButton->getY()); - - mItemDescLabel->setDimension(gcn::Rectangle(8, - mSellButton->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 SellDialog::setMoney(int amount) { mPlayerMoney = amount; diff --git a/src/gui/sell.h b/src/gui/sell.h index d1e2ddd2..cde862d5 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -41,8 +41,7 @@ class ShopListBox; * * \ingroup Interface */ -class SellDialog : public Window, gcn::ActionListener, SelectionListener, - WindowListener +class SellDialog : public Window, gcn::ActionListener, SelectionListener { public: /** @@ -80,11 +79,6 @@ class SellDialog : public Window, gcn::ActionListener, SelectionListener, void selectionChanged(const SelectionEvent &event); /** - * Called whenever the window is resized. - */ - void windowResized(const WindowEvent &event); - - /** * Gives Player's Money amount */ void setMoney(int amount); |