From 129245a8063f09775930b0ffff11f043c219c277 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 18:03:14 -0700 Subject: Consolidated setMinWidth into textWrap, since all lines are dependant upon knowing what dimension they have to wrap to or beat in order for text wrapping to work. By adding this to be initiated at the same time as the text wrapping is done, this should decrease visual artifacts caused by not initializing it properly to begin with. Also made the item popups compact to the minimum dimension. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'src/gui/itempopup.cpp') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 8235d640..1256275d 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -55,8 +55,6 @@ ItemPopup::ItemPopup(): // Item Description mItemDesc = new TextBox(); mItemDesc->setEditable(false); - mItemDesc->setMinWidth(186); - mItemDesc->setTextWrapped(""); mItemDescScroll = new ScrollArea(mItemDesc); mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -68,8 +66,6 @@ ItemPopup::ItemPopup(): // Item Effect mItemEffect = new TextBox(); mItemEffect->setEditable(false); - mItemEffect->setMinWidth(186); - mItemEffect->setTextWrapped(""); mItemEffectScroll = new ScrollArea(mItemEffect); mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -81,8 +77,6 @@ ItemPopup::ItemPopup(): // Item Weight mItemWeight = new TextBox(); mItemWeight->setEditable(false); - mItemWeight->setMinWidth(186); - mItemWeight->setTextWrapped(""); mItemWeightScroll = new ScrollArea(mItemWeight); mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -104,35 +98,40 @@ ItemPopup::ItemPopup(): void ItemPopup::setItem(const ItemInfo &item) { - const gcn::Rectangle &area = getChildrenArea(); - const int width = area.width; - - mItemDesc->setMinWidth(width - 10); - mItemEffect->setMinWidth(width - 10); - mItemWeight->setMinWidth(width - 10); - mItemName->setCaption(item.getName()); - mItemDesc->setTextWrapped(item.getDescription()); - mItemEffect->setTextWrapped(item.getEffect()); + mItemDesc->setTextWrapped(item.getDescription(), 196); + mItemEffect->setTextWrapped(item.getEffect(), 196); mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) + - _(" grams")); + _(" grams"), 196); + + int minWidth = mItemName->getWidth(); + + if (mItemDesc->getMinWidth() > minWidth) + minWidth = mItemDesc->getMinWidth(); + if (mItemEffect->getMinWidth() > minWidth) + minWidth = mItemEffect->getMinWidth(); + if (mItemWeight->getMinWidth() > minWidth) + minWidth = mItemWeight->getMinWidth(); + + minWidth += 8; + setWidth(minWidth); int numRowsDesc = mItemDesc->getNumberOfRows(); int numRowsEffect = mItemEffect->getNumberOfRows(); int numRowsWeight = mItemWeight->getNumberOfRows(); - mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196, + mItemDescScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsDesc * getFont()->getHeight())); - mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196, + mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsEffect * getFont()->getHeight())); - mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196, + mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, minWidth, numRowsWeight * getFont()->getHeight())); if(item.getEffect() == "") { - setContentSize(200, (numRowsDesc * getFont()->getHeight() + + setContentSize(minWidth, (numRowsDesc * getFont()->getHeight() + (3 * getFont()->getHeight()))); mItemWeightScroll->setPosition(2, @@ -141,7 +140,7 @@ void ItemPopup::setItem(const ItemInfo &item) } else { - setContentSize(200, (numRowsDesc * getFont()->getHeight()) + + setContentSize(minWidth, (numRowsDesc * getFont()->getHeight()) + (numRowsEffect * getFont()->getHeight()) + (3 * getFont()->getHeight())); -- cgit v1.2.3-70-g09d2