From 7afe9d904f11fc65f02959798dfc6abb3660d660 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 21 Oct 2007 19:06:57 +0000 Subject: Converted dialog box to layout handler. --- ChangeLog | 1 + src/gui/buy.cpp | 71 +++++++++++++-------------------------------------------- src/gui/buy.h | 8 +------ 3 files changed, 18 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bd9bdd3..b3f31c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,7 @@ * 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. 2007-10-20 Guillaume Melquiond diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 7912bf13..a122783e 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -31,6 +31,8 @@ #include "shoplistbox.h" #include "slider.h" +#include "widgets/layout.h" + #include "../npc.h" #include "../net/gameserver/player.h" #include "../resources/itemdb.h" @@ -76,18 +78,20 @@ BuyDialog::BuyDialog(): mShopItemList->addSelectionListener(this); mSlider->addActionListener(this); - add(mScrollArea); - add(mSlider); - add(mQuantityLabel); - add(mBuyButton); - add(mQuitButton); - add(mIncreaseButton); - add(mDecreaseButton); - add(mMoneyLabel); - add(mItemDescLabel); - add(mItemEffectLabel); - - 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, mBuyButton); + place(4, 5, mQuitButton); + Layout &layout = getLayout(); + layout.setRowHeight(0, Layout::FILL); + layout.setColWidth(2, Layout::FILL); + loadWindowState("Buy"); setLocationRelativeTo(getParent()); } @@ -189,49 +193,6 @@ void BuyDialog::selectionChanged(const SelectionEvent &event) mSlider->gcn::Slider::setScale(1, mMaxItems); } -void BuyDialog::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()); - 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() { diff --git a/src/gui/buy.h b/src/gui/buy.h index 63d25583..4e129611 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -40,8 +40,7 @@ class ListBox; * * \ingroup Interface */ -class BuyDialog : public Window, public gcn::ActionListener, SelectionListener, - WindowListener +class BuyDialog : public Window, public gcn::ActionListener, SelectionListener { public: /** @@ -99,11 +98,6 @@ class BuyDialog : public Window, public gcn::ActionListener, SelectionListener, void updateButtonsAndLabels(); - /** - * Called whenever the window is resized. - */ - void windowResized(const WindowEvent &event); - private: gcn::Button *mBuyButton; gcn::Button *mQuitButton; -- cgit v1.2.3-70-g09d2