summaryrefslogtreecommitdiff
path: root/src/gui/itempopup.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-28 18:03:14 -0700
committerIra Rice <irarice@gmail.com>2009-01-28 18:03:14 -0700
commit129245a8063f09775930b0ffff11f043c219c277 (patch)
treee7a1486251f149cfd14c3eb290f4113107427bee /src/gui/itempopup.cpp
parent4418d3678337276070e6d46d8011ce052be388a5 (diff)
downloadmana-client-129245a8063f09775930b0ffff11f043c219c277.tar.gz
mana-client-129245a8063f09775930b0ffff11f043c219c277.tar.bz2
mana-client-129245a8063f09775930b0ffff11f043c219c277.tar.xz
mana-client-129245a8063f09775930b0ffff11f043c219c277.zip
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 <irarice@gmail.com>
Diffstat (limited to 'src/gui/itempopup.cpp')
-rw-r--r--src/gui/itempopup.cpp41
1 files changed, 20 insertions, 21 deletions
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()));