diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-08-28 00:01:38 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-08-28 00:01:38 +0000 |
commit | 55786731e0517efdc123d4e8245b2aa94fa55cbe (patch) | |
tree | 17d64454f3daeb9f55241e8c9a95b5671f2da023 /src/gui/buy.cpp | |
parent | 76291862ce0e26040f251bc4764539d8ff6634a0 (diff) | |
download | mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.gz mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.bz2 mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.tar.xz mana-client-55786731e0517efdc123d4e8245b2aa94fa55cbe.zip |
Made buy dialog resizable and added a WindowListener class for listening for
window resize and move events.
Diffstat (limited to 'src/gui/buy.cpp')
-rw-r--r-- | src/gui/buy.cpp | 79 |
1 files changed, 55 insertions, 24 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index ea477e07..3c7cbd51 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -43,6 +43,11 @@ BuyDialog::BuyDialog(Network *network): Window("Buy"), mNetwork(network), mMoney(0), mAmountItems(0), mMaxItems(0) { + setResizable(true); + setMinWidth(260); + setMinHeight(230); + setDefaultSize(0, 0, 260, 230); + mShopItems = new ShopItems; mShopItemList = new ShopListBox(mShopItems, mShopItems); @@ -57,32 +62,15 @@ BuyDialog::BuyDialog(Network *network): mItemDescLabel = new gcn::Label("Description:"); mItemEffectLabel = new gcn::Label("Effect:"); - setContentSize(260, 210); - mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mScrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110)); - mShopItemList->setDimension(gcn::Rectangle(5, 5, 238, 110)); - - mSlider->setDimension(gcn::Rectangle(5, 120, 200, 10)); - mSlider->setEnabled(false); - - mQuantityLabel->setPosition(215, 120); - mMoneyLabel->setPosition(5, 130); - - mIncreaseButton->setPosition(40, 186); mIncreaseButton->setSize(20, 20); - mIncreaseButton->setEnabled(false); - - mDecreaseButton->setPosition(10, 186); mDecreaseButton->setSize(20, 20); - mDecreaseButton->setEnabled(false); + mQuantityLabel->setWidth(60); - mBuyButton->setPosition(180, 186); + mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mIncreaseButton->setEnabled(false); + mDecreaseButton->setEnabled(false); mBuyButton->setEnabled(false); - - mQuitButton->setPosition(212, 186); - - mItemEffectLabel->setDimension(gcn::Rectangle(5, 150, 240, 14)); - mItemDescLabel->setDimension(gcn::Rectangle(5, 169, 240, 14)); + mSlider->setEnabled(false); mShopItemList->setActionEventId("item"); mSlider->setActionEventId("slider"); @@ -101,6 +89,8 @@ BuyDialog::BuyDialog(Network *network): add(mItemDescLabel); add(mItemEffectLabel); + addWindowListener(this); + loadWindowState(); setLocationRelativeTo(getParent()); } @@ -207,6 +197,49 @@ 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() { @@ -247,8 +280,6 @@ BuyDialog::updateButtonsAndLabels() // Update quantity and money labels mQuantityLabel->setCaption( toString(mAmountItems) + " / " + toString(mMaxItems)); - mQuantityLabel->adjustSize(); mMoneyLabel->setCaption("Price: " + toString(price) + " GP / " + toString(mMoney - price) + " GP" ); - mMoneyLabel->adjustSize(); } |